]> xenbits.xensource.com Git - xtf.git/log
xtf.git
8 years agorunner: Introduce TestInfo to wrap the raw test json
Andrew Cooper [Fri, 29 Jul 2016 15:31:26 +0000 (15:31 +0000)]
runner: Introduce TestInfo to wrap the raw test json

The constructor now performs appropriate verification on the json
configuration, rather than open-coding it in get_all_test_info().  Users of
the dictionary-like json are altered to use attributes.

An all_instances() method is added to return test instances for all suitable
environments, optionally with a subset filter.  This is used in preference to
three open-coded loops, generating instance names.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agorunner: Cache the combined test json
Andrew Cooper [Thu, 28 Jul 2016 11:54:26 +0000 (11:54 +0000)]
runner: Cache the combined test json

To avoid rereading the same data from the disk.  Later it will be needed on
several paths.  Additionally, rename 'test_info' to 'info_file' to make its
use more clear.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agorunner: Switch --host to being a real parameter
Andrew Cooper [Thu, 28 Jul 2016 11:47:00 +0000 (11:47 +0000)]
runner: Switch --host to being a real parameter

This avoids having extra magic parameters in the mix of categories,
environments and test names

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce .gitattributes
Andrew Cooper [Fri, 29 Jul 2016 13:02:42 +0000 (13:02 +0000)]
Introduce .gitattributes

This allows `git diff` and friends to be slightly more clever about generating
hunks for specific files.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agobuild: Generate xl configurations with a python script rather than by hand
Andrew Cooper [Tue, 26 Jul 2016 18:55:26 +0000 (19:55 +0100)]
build: Generate xl configurations with a python script rather than by hand

It is about to get more complicated.  Additionally, specify a dependency on
$(TEST-EXTRA-CFG) if specified by a test.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agomkinfo: Assign names to command line parameters
Andrew Cooper [Tue, 26 Jul 2016 18:53:18 +0000 (19:53 +0100)]
mkinfo: Assign names to command line parameters

This is easier to read, and has a side effect of bailing with a hard error if
the wrong number of parameters are passed.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoRename test-info.json to just info.json
Andrew Cooper [Mon, 25 Jul 2016 16:37:09 +0000 (17:37 +0100)]
Rename test-info.json to just info.json

There are enough files starting with test.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agobuild: Add move-if-changed helper
Andrew Cooper [Tue, 26 Jul 2016 15:33:43 +0000 (15:33 +0000)]
build: Add move-if-changed helper

And use it in preference to repeated opencoding

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoCorrect the usage of $(DESTDIR) and $(PREFIX)
Andrew Cooper [Wed, 20 Jul 2016 17:43:13 +0000 (18:43 +0100)]
Correct the usage of $(DESTDIR) and $(PREFIX)

The GNU coding standards expect $(DESTDIR) to be the root of everything
installed, and for $(PREFIX) to then be added to the path.  This is not how
XTF previously behaved.

XTF is not a typical package, and doesn't meet the usual semantics; it expects
to arrange all files under a single directory.  Drop the use of $(PREFIX)
entirely (to avoid the expectation that it behaves as $(prefix) usually
behaves) and introduce $(xtfdir) instead.

$(DESTDIR) now works as intended for staged installes, and $(xtfdir) is the
single selected directy containing all installed content.

The intended way to install XTF now:

  $ make install DESTDIR=/path/to/staging/area xtfdir=/local/scratch/xtf

Reported-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
8 years agoIntroduce $(INSTALL_DIR) and use it in preference to mkdir
Andrew Cooper [Thu, 21 Jul 2016 11:37:15 +0000 (12:37 +0100)]
Introduce $(INSTALL_DIR) and use it in preference to mkdir

Include the -p parameters by default for $(INSTALL*) variables rather than
opencoding them everywhere.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce zeroptr[] for accessing virtual address 0
Andrew Cooper [Mon, 25 Jul 2016 15:29:03 +0000 (16:29 +0100)]
Introduce zeroptr[] for accessing virtual address 0

There are some times when access to 0 is really needed.  Use the linker to
work around NULL pointer logic in the compiler.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoxtf-runner: regularise runner exit code
Wei Liu [Mon, 13 Jun 2016 14:06:48 +0000 (15:06 +0100)]
xtf-runner: regularise runner exit code

The script now returns the most severe result. Document the exit code in
help string.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoxtf-runner: provide a set of exit codes for different results
Wei Liu [Thu, 21 Jul 2016 15:06:19 +0000 (16:06 +0100)]
xtf-runner: provide a set of exit codes for different results

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoxtf-runner: sync all test results
Wei Liu [Mon, 13 Jun 2016 14:30:10 +0000 (15:30 +0100)]
xtf-runner: sync all test results

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agogitignore: ignore vim swp file
Wei Liu [Fri, 22 Jul 2016 09:17:29 +0000 (10:17 +0100)]
gitignore: ignore vim swp file

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoExport ROOT, DESTDIR and PREFIX to all makefiles
Andrew Cooper [Wed, 20 Jul 2016 17:05:45 +0000 (18:05 +0100)]
Export ROOT, DESTDIR and PREFIX to all makefiles

Rather than regenerating them from defaults each time.  Drop the MAKEFLAGS
lines, as MAKEFLAGS are automatically inherited by sub-makes.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce makefile variable for commands in use per the GNU coding standards
Andrew Cooper [Wed, 20 Jul 2016 15:26:33 +0000 (16:26 +0100)]
Introduce makefile variable for commands in use per the GNU coding standards

Use the suggested defaults, and replace all open-coded examples.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoFix the handling of errors in the all/build targets
Andrew Cooper [Wed, 20 Jul 2016 15:26:33 +0000 (16:26 +0100)]
Fix the handling of errors in the all/build targets

Currently a build error will be eaten by the shell for loop, causing the
makefile not to stop.  Use `set -e;` to prevent this behaviour

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agopv32pae: Probe for leaked SMEP/SMAP before switching to user mappings
Andrew Cooper [Sun, 17 Jul 2016 16:45:33 +0000 (17:45 +0100)]
pv32pae: Probe for leaked SMEP/SMAP before switching to user mappings

This allows XTF to panic() with a useful error message, rather than crashing
with an obscure error on the hypervisor console because of Xen failing to
create a bounce frame on the (now-user) stack.

Update the documentation, as Xen 4.7 no longer leaks SMEP/SMAP into guests.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce more pagetable helpers
Andrew Cooper [Tue, 19 Jul 2016 15:05:23 +0000 (16:05 +0100)]
Introduce more pagetable helpers

Symbolic constants for expressing pte flags in a short way, and helpers to
construct a pagetable entry from a frame and flags.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agohvm: Honour test_wants_user_mappings
Andrew Cooper [Tue, 19 Jul 2016 13:51:30 +0000 (14:51 +0100)]
hvm: Honour test_wants_user_mappings

Fewer tests overall need user mappings, so construct the identity pagetables
without _PAGE_USER set in leaf entries by default.

Before loading paging settings, check whether a test has opted-in to user
mappings, and re-add _PAGE_USER to the l1 and l2 pagetable entries.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoProvide PTE_SIZE and PTE_ORDER appropriate for the in-use paging mode
Andrew Cooper [Tue, 19 Jul 2016 12:38:01 +0000 (13:38 +0100)]
Provide PTE_SIZE and PTE_ORDER appropriate for the in-use paging mode

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agopv: Honour test_wants_user_mappings
Andrew Cooper [Tue, 19 Jul 2016 13:58:46 +0000 (14:58 +0100)]
pv: Honour test_wants_user_mappings

32bit PV guests start on supervisor mappings, and previously unilaterally
switched to user mappings.  Now, only switch to user mappings if a test has
opted in.

64bit PV guests run at cpl3, must use user mappings and architecturally have
no choice in the matter.

This change is best reviewed with `git show --ignore-all-space`

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce a per-test opt-in for using user mappings
Andrew Cooper [Tue, 19 Jul 2016 13:51:04 +0000 (14:51 +0100)]
Introduce a per-test opt-in for using user mappings

The choice of user or supervisor mappings is currently chosen for the
test, and is inflexible for a test needing to run in situations where
Xen leaks SMEP/SMAP into the guest, or where the test specifically wants
to use SMEP/SMAP itself.

As it turns out, fewer tests require user mappings than not.  For the
tests which don't require user mappings, allowing them to run on
supervisor mappings is quicker to set up, and allows the test to run
even if Xen leaks paging state.

Introduce test_wants_user_mappings and default it to false.  Tests which
want user mappings can opt-in by overriding the weak reference to true.
Explicit set the opt-in for the three tests which currently require
them.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce more memory management helpers
Andrew Cooper [Tue, 19 Jul 2016 12:36:27 +0000 (13:36 +0100)]
Introduce more memory management helpers

These are still simply, relying on identity mappings and state provided by the
domain builder for PV guests.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoAdd Xen ABI for update_va_mapping flags, and replace opencoded constants
Andrew Cooper [Fri, 15 Jul 2016 09:02:29 +0000 (10:02 +0100)]
Add Xen ABI for update_va_mapping flags, and replace opencoded constants

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoReplace @sa with @see in all documentation
Andrew Cooper [Fri, 15 Jul 2016 13:02:37 +0000 (14:02 +0100)]
Replace @sa with @see in all documentation

They are identical as far as Doxygen is concerned, but more intuitive when
reading the raw text.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce invlpg() helper
Andrew Cooper [Wed, 1 Jun 2016 13:40:21 +0000 (14:40 +0100)]
Introduce invlpg() helper

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoHelpers to pack and unpack a frame in a PSE36 superpage
Andrew Cooper [Wed, 1 Jun 2016 13:34:41 +0000 (14:34 +0100)]
Helpers to pack and unpack a frame in a PSE36 superpage

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoCreate aliases of the live L1 and L2 pagetables
Andrew Cooper [Sun, 5 Jun 2016 17:18:35 +0000 (18:18 +0100)]
Create aliases of the live L1 and L2 pagetables

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce paddr_t
Andrew Cooper [Sun, 5 Jun 2016 12:42:08 +0000 (13:42 +0100)]
Introduce paddr_t

rather than just using uint64_t.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce PRI helper definitions for PTEs
Andrew Cooper [Sun, 5 Jun 2016 12:28:00 +0000 (13:28 +0100)]
Introduce PRI helper definitions for PTEs

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoMore pagetable order and entries information
Andrew Cooper [Sun, 5 Jun 2016 11:22:57 +0000 (12:22 +0100)]
More pagetable order and entries information

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoMore space for static inline pagetable helpers
Andrew Cooper [Sun, 5 Jun 2016 11:18:35 +0000 (12:18 +0100)]
More space for static inline pagetable helpers

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce typesafe min()/max() helpers
Andrew Cooper [Fri, 27 May 2016 09:42:53 +0000 (10:42 +0100)]
Introduce typesafe min()/max() helpers

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce mmu_update() hypercall infrastructure
Andrew Cooper [Mon, 11 Jul 2016 12:46:53 +0000 (13:46 +0100)]
Introduce mmu_update() hypercall infrastructure

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoCollect CPU family/model/stepping information on boot
Andrew Cooper [Fri, 27 May 2016 13:34:41 +0000 (14:34 +0100)]
Collect CPU family/model/stepping information on boot

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoAdd FEP utility
Wei Liu [Mon, 20 Jun 2016 14:44:38 +0000 (15:44 +0100)]
Add FEP utility

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoHelpers to retrieve %ss and %esp from cpu_regs
Andrew Cooper [Fri, 27 May 2016 07:53:53 +0000 (08:53 +0100)]
Helpers to retrieve %ss and %esp from cpu_regs

In 32bit, if not stack switch occurs, this information isn't present in an
exception frame.  As a result, regs->sp and regs->ss may actually alias the
interrupted stack frame.  To avoid accidental incorrect use, prefix the names
in cpu_regs with an underscore.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce ASSERT() and BUILD_BUG_ON()
Andrew Cooper [Thu, 16 Jun 2016 12:05:01 +0000 (12:05 +0000)]
Introduce ASSERT() and BUILD_BUG_ON()

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoxtf-runner: Extend test selection to run multiple tests at once
Andrew Cooper [Tue, 7 Jun 2016 17:08:10 +0000 (18:08 +0100)]
xtf-runner: Extend test selection to run multiple tests at once

A caller may now specify a test name (in which case all environments will be
run), an environment (in which case every test supporting that environment
will be run), or a category (in which case all tests in that category will be
run).

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoxtf-runner: Support listing tests
Andrew Cooper [Tue, 7 Jun 2016 13:25:38 +0000 (14:25 +0100)]
xtf-runner: Support listing tests

Without parameters, all tests will be returned.

Alternatively, specific environments or categories can be specified, to filter
the results.  A special input of "host" will query Xen for the available
environments, and filter accordingly.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoxtf-runner: Basic test runner
Andrew Cooper [Mon, 22 Feb 2016 12:43:54 +0000 (12:43 +0000)]
xtf-runner: Basic test runner

Currently just accepts a list of full test-$ENV-$NAME, runs them in order, and
provides a results summary at the end.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce a pylint configuration file
Andrew Cooper [Mon, 22 Feb 2016 12:43:52 +0000 (12:43 +0000)]
Introduce a pylint configuration file

Also ignore python intermediate files.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoConstants for all EFER bits
Andrew Cooper [Sun, 29 May 2016 14:58:04 +0000 (15:58 +0100)]
Constants for all EFER bits

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoFix _ASM_EXTABLE_HANDLER() to expand preprocessor tokens in its parameters
Andrew Cooper [Mon, 6 Jun 2016 11:54:40 +0000 (11:54 +0000)]
Fix _ASM_EXTABLE_HANDLER() to expand preprocessor tokens in its parameters

Currently it stringises the literal parameter, which can result in a
non-expanded token ending up in at the assembler, causing a build failure.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce _PAGE_* constants for all pagetable entry bits
Andrew Cooper [Tue, 31 May 2016 17:20:39 +0000 (17:20 +0000)]
Introduce _PAGE_* constants for all pagetable entry bits

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoProvide cpu_has_* helper predicates for common features
Andrew Cooper [Tue, 31 May 2016 17:17:14 +0000 (17:17 +0000)]
Provide cpu_has_* helper predicates for common features

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoCollect the CPU vendor on boot, and make it available for tests
Andrew Cooper [Mon, 23 May 2016 18:21:06 +0000 (19:21 +0100)]
Collect the CPU vendor on boot, and make it available for tests

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoProvide {BITS,BYTES}_PER_LONG
Andrew Cooper [Mon, 23 May 2016 13:39:26 +0000 (13:39 +0000)]
Provide {BITS,BYTES}_PER_LONG

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoAdd cpuid_e[abcd]x() helper wrappers
Andrew Cooper [Fri, 20 May 2016 10:22:49 +0000 (11:22 +0100)]
Add cpuid_e[abcd]x() helper wrappers

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoHelper script to create new tests, and high level tests documentation
Andrew Cooper [Thu, 19 May 2016 18:22:24 +0000 (19:22 +0100)]
Helper script to create new tests, and high level tests documentation

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoDisable implicit makefile rules
Andrew Cooper [Thu, 19 May 2016 17:09:27 +0000 (18:09 +0100)]
Disable implicit makefile rules

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoRemove setting ROOT path in common.mk
Roger Pau Monne [Thu, 19 May 2016 13:43:30 +0000 (15:43 +0200)]
Remove setting ROOT path in common.mk

Since it might be included from different paths that have different levels
of nestedness. Also all makefiles that include common.mk already define ROOT
on their own.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoProvide _PAGE_AD as shorthand, and simplify the invlpg test
Andrew Cooper [Tue, 17 May 2016 18:37:54 +0000 (19:37 +0100)]
Provide _PAGE_AD as shorthand, and simplify the invlpg test

Pass _PAGE_AD as parameter to the asm block, to reduce the use of magic
constants.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoCollect feature information from cpuid
Andrew Cooper [Wed, 11 May 2016 13:57:58 +0000 (14:57 +0100)]
Collect feature information from cpuid

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoUse IS_DEFINED() in preference to #ifdef
Andrew Cooper [Wed, 11 May 2016 12:56:33 +0000 (13:56 +0100)]
Use IS_DEFINED() in preference to #ifdef

By exposing more code and having the compiler optimise it out, there is less
chance of bitrot.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroduce IS_DEFINED() for use in C code
Andrew Cooper [Wed, 9 Mar 2016 19:41:59 +0000 (19:41 +0000)]
Introduce IS_DEFINED() for use in C code

Alter CONFIG_{PV,HVM} to be explicitly defined as 1.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoProvide function pointer abstractions for cpuid() and cpuid_count()
Andrew Cooper [Wed, 11 May 2016 12:38:14 +0000 (13:38 +0100)]
Provide function pointer abstractions for cpuid() and cpuid_count()

Code common between PV and HVM using cpuid() needs to use different cpuid()
implementations, as PV guests need to use the Xen forced emulation prefix.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroduce an architecture specific convenience header
Andrew Cooper [Wed, 11 May 2016 11:43:03 +0000 (12:43 +0100)]
Introduce an architecture specific convenience header

Avoid introducing arch/x86/lib.h implicitly via xtf/lib.h

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoXSA-173 PoC
Andrew Cooper [Fri, 18 Mar 2016 21:18:49 +0000 (21:18 +0000)]
XSA-173 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoMake the tables from hvm/pagetables.S available to C code
Andrew Cooper [Tue, 10 May 2016 16:09:55 +0000 (17:09 +0100)]
Make the tables from hvm/pagetables.S available to C code

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAllow selecting objcopy binary to use
Roger Pau Monne [Tue, 10 May 2016 12:00:27 +0000 (14:00 +0200)]
Allow selecting objcopy binary to use

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoOnly set CC if it's not set
Roger Pau Monne [Tue, 10 May 2016 11:58:39 +0000 (13:58 +0200)]
Only set CC if it's not set

This prevents overwriting CC if it's already set on the environment.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoInvlpg handling test
Andrew Cooper [Wed, 4 May 2016 14:41:48 +0000 (15:41 +0100)]
Invlpg handling test

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoExtend exception table support to include custom handlers
Andrew Cooper [Fri, 6 May 2016 16:40:02 +0000 (17:40 +0100)]
Extend exception table support to include custom handlers

Provide additional documentation, and a selftest.  Introduce __used to
indicate to the compiler that an object is referenced, even if the reference
isn't visible.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAvoid shifting a negative value
Roger Pau Monne [Fri, 6 May 2016 09:17:46 +0000 (11:17 +0200)]
Avoid shifting a negative value

Because it's undefined behaviour.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoFix usage of "-executable" with find
Roger Pau Monne [Fri, 6 May 2016 11:07:30 +0000 (13:07 +0200)]
Fix usage of "-executable" with find

"-executable" is a GNU only extension to find. Instead replace it with a
POSIX compatible one.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoDon't re-define __noinline
Roger Pau Monne [Fri, 6 May 2016 09:15:49 +0000 (11:15 +0200)]
Don't re-define __noinline

On FreeBSD __noinline is already defined in cdefs.h

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoProvide all {read,write}_cr[02348]() stub functions
Andrew Cooper [Thu, 5 May 2016 15:12:17 +0000 (16:12 +0100)]
Provide all {read,write}_cr[02348]() stub functions

Both GCC and Clang correctly encode %cr8 accesses using the lock
instruction prefix in 32bit mode.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAdd 64bit segment base MSRs to the index
Andrew Cooper [Thu, 5 May 2016 11:44:42 +0000 (12:44 +0100)]
Add 64bit segment base MSRs to the index

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoReserve space in the GDT for test use
Andrew Cooper [Thu, 5 May 2016 09:29:48 +0000 (10:29 +0100)]
Reserve space in the GDT for test use

Currently four entries, although this is an arbitrary choice.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoPrint more information when dumping exceptions
Andrew Cooper [Fri, 29 Apr 2016 12:08:20 +0000 (13:08 +0100)]
Print more information when dumping exceptions

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoHelper routines for decoding x86 architectural state
Andrew Cooper [Thu, 28 Apr 2016 13:24:06 +0000 (14:24 +0100)]
Helper routines for decoding x86 architectural state

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroduce snprintf() and give vsnprintf() an appropriate __printf() attribute
Andrew Cooper [Thu, 28 Apr 2016 12:04:51 +0000 (13:04 +0100)]
Introduce snprintf() and give vsnprintf() an appropriate __printf() attribute

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoCreate xtf.h and avoid using xtf/lib.h as the include-all header
Andrew Cooper [Fri, 1 Apr 2016 18:00:45 +0000 (19:00 +0100)]
Create xtf.h and avoid using xtf/lib.h as the include-all header

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoXSA-123 PoC
Andrew Cooper [Fri, 15 Jan 2016 15:44:58 +0000 (15:44 +0000)]
XSA-123 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoExtend the pv-iopl test to test VMASST_TYPE_architectural_iopl
Andrew Cooper [Sat, 19 Mar 2016 19:51:01 +0000 (19:51 +0000)]
Extend the pv-iopl test to test VMASST_TYPE_architectural_iopl

A varient of exec_user() is introduced which takes an IOPL parameter.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoPV IOPL emulation testing
Andrew Cooper [Sat, 19 Mar 2016 15:36:16 +0000 (15:36 +0000)]
PV IOPL emulation testing

A test to verify correct behaviour of vIOPL shadowing in Xen.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroduce DECLSTR() for declaring strings in ASM
Andrew Cooper [Fri, 22 Apr 2016 19:00:30 +0000 (20:00 +0100)]
Introduce DECLSTR() for declaring strings in ASM

Put the string in the mergeable string section, declare it as data, and set
its size.

Replace the partial open-coding of this in head_{pv,hvm}.S for main_err_msg,
and switch the label to being local.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroduce ENDFUNC() and annotate ASM functions as such
Andrew Cooper [Fri, 22 Apr 2016 18:59:02 +0000 (19:59 +0100)]
Introduce ENDFUNC() and annotate ASM functions as such

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAnnotate hvm pagetables as data
Andrew Cooper [Fri, 22 Apr 2016 18:57:17 +0000 (19:57 +0100)]
Annotate hvm pagetables as data

Introduce PAGETABLE_{START,END}() helpers which wrap the appropriate
directives.  Fix a copy&paste bug from c/s 3382222 "Introduce the hvm32pse
environment" which stated the size of pse_l1_identmap twice, and omitted
pse_l2_identmap.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAvoid generating *UND* symbols in object files
Andrew Cooper [Fri, 22 Apr 2016 18:49:32 +0000 (19:49 +0100)]
Avoid generating *UND* symbols in object files

The swint-emulation test contains hand-generated asm stubs which use arbitrary
identifiers just for their mnemonic properties.  Unfortunately, their use in
the .if statements generate *UND* symbols listed in the object files export
table.

Use .ifc rather than .if, which explicit interprets its parameters as strings
rather than expressions.  Unfortunately, there is no .elseifc directive.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAnnotate hypercall stubs as functions
Andrew Cooper [Fri, 22 Apr 2016 18:47:42 +0000 (19:47 +0100)]
Annotate hypercall stubs as functions

Move DECLARE_HYPERCALL() from asm_macros.h to being local, as it is not useful
elsewhere.  Link hypercall_page in .data rather than .text, to avoid polluting
the disassembly.  Annotate hypercall_page itself as data.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoMove arch/x86/hvm_pagetables.S into arch/x86/hvm/ directory
Andrew Cooper [Fri, 22 Apr 2016 18:40:02 +0000 (19:40 +0100)]
Move arch/x86/hvm_pagetables.S into arch/x86/hvm/ directory

This is a more appropriate place for it to live.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroduce more linker alignment assertions
Andrew Cooper [Fri, 22 Apr 2016 18:38:00 +0000 (19:38 +0100)]
Introduce more linker alignment assertions

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoFix XSA-168 PoC on Gen1 AMD hardware
Andrew Cooper [Fri, 22 Apr 2016 18:36:15 +0000 (19:36 +0100)]
Fix XSA-168 PoC on Gen1 AMD hardware

We care simply that the vulnerability is fixed, rather than the architectural
correctness of the emulation of `invlpg`.  Correctness should be implemented
by a functional test.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroduce Memory op ABI and infrastructure
Andrew Cooper [Mon, 21 Mar 2016 14:07:41 +0000 (14:07 +0000)]
Introduce Memory op ABI and infrastructure

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoFix GCC build following c/s 72442d4
Andrew Cooper [Sat, 26 Mar 2016 18:22:00 +0000 (18:22 +0000)]
Fix GCC build following c/s 72442d4

GCC and Clang have different permitted syntax for nested initialisers.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroduce the hvm32pse environment
Andrew Cooper [Tue, 23 Feb 2016 11:47:03 +0000 (11:47 +0000)]
Introduce the hvm32pse environment

This uses 32bit paging, along with the PSE extension.

Regular 32bit paging and PSE paging differ only in whether the PSE bit may be
set, to create 4M superpages.  Since PSE is available on all hardware Xen will
now run on, forgo the `hvm32pg` environment to avoid the overhead of requiring
small pages for all mappings.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoImprove the legibility of the pagetable generation code
Andrew Cooper [Sat, 26 Mar 2016 18:19:20 +0000 (18:19 +0000)]
Improve the legibility of the pagetable generation code

Factor the common _PAGE_xxx attributes out into PAGE_COMMON, and introduce a
macro for the index calculation.

Add _ACCESSED and _DIRTY to the common attributes, to avoid the processor
needing to set the bits.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoSplit common pagetable infrastructure from PAE specific infrastructure
Andrew Cooper [Fri, 26 Feb 2016 15:39:42 +0000 (15:39 +0000)]
Split common pagetable infrastructure from PAE specific infrastructure

In preparation for the introduction of PSE paging.  In most cases, add a PAE
prefix to existing constants.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoXSA-168 Proof of Concept test
Andrew Cooper [Thu, 10 Dec 2015 15:59:02 +0000 (15:59 +0000)]
XSA-168 Proof of Concept test

Must be run with shadow paging

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAllow tests to supply extra settings for their .cfg file
Andrew Cooper [Thu, 24 Mar 2016 19:56:38 +0000 (19:56 +0000)]
Allow tests to supply extra settings for their .cfg file

by setting $(TEST-EXTRA-CFG)

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoXSA-122 Proof of Concept test
Andrew Cooper [Fri, 15 Jan 2016 15:40:32 +0000 (15:40 +0000)]
XSA-122 Proof of Concept test

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroduce xen_version hypercall and ABI
Andrew Cooper [Thu, 24 Mar 2016 12:53:00 +0000 (12:53 +0000)]
Introduce xen_version hypercall and ABI

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoDrop CONFIG_PAGING_PAE
Andrew Cooper [Tue, 23 Feb 2016 11:43:19 +0000 (11:43 +0000)]
Drop CONFIG_PAGING_PAE

It can uniquely be determined from PAGING_LEVELS == 3 or 4, and doing so
simplifies the early ASM.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroduce IS_ALIGNED()
Andrew Cooper [Fri, 26 Feb 2016 18:30:44 +0000 (18:30 +0000)]
Introduce IS_ALIGNED()

While at it comment the entities in this file, and guard _p() to avoid it
accidentally being used in assembly code.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoTest `into` even in 64bit
Andrew Cooper [Mon, 7 Mar 2016 09:09:21 +0000 (09:09 +0000)]
Test `into` even in 64bit

In 64bit, the instruction should fail unilaterally with #UD.  Check that the
emulator provides this behaviour.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAdd memcpy() to the framework's libc implementation
Andrew Cooper [Mon, 21 Mar 2016 14:51:17 +0000 (14:51 +0000)]
Add memcpy() to the framework's libc implementation

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>