]> xenbits.xensource.com Git - people/royger/xen-test-framework.git/log
people/royger/xen-test-framework.git
9 years agoxtf: fix usage of "-executable" with find for-andrew
Roger Pau Monne [Fri, 6 May 2016 11:07:30 +0000 (13:07 +0200)]
xtf: 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>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoxtf: avoid shifting a negative value
Roger Pau Monne [Fri, 6 May 2016 09:17:46 +0000 (11:17 +0200)]
xtf: avoid shifting a negative value

Because it's undefined behaviour.

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

On FreeBSD __noinline is already defined in cdefs.h

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoProvide all {read,write}_cr[02348]() stub functions master
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>
9 years agoCorrect the generation of the `cd 03` instruction
Andrew Cooper [Sun, 6 Mar 2016 21:19:05 +0000 (21:19 +0000)]
Correct the generation of the `cd 03` instruction

Some assemblers "helpfully" turn the two-byte `int $3` into its one-byte form
`int3`.  This defeats the purpose of the test case, so hand-roll the
instrucion.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoReintroduce the test_NULL_unmapped() selftest
Andrew Cooper [Sun, 6 Mar 2016 20:26:12 +0000 (20:26 +0000)]
Reintroduce the test_NULL_unmapped() selftest

c/s f571b0b "Implement the hvm32 environment" introduced a guard to the
test_NULL_unmapped() selftest, as it is inapplicable in an unpaged
environment.

However, CONFIG_PAGING wasn't ever defined (it disappeared during
development), causing the selftest to be unconditionally omitted even in paged
environments.

Reintroduce the check, based on CONFIG_PAGING_LEVELS being non-zero.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoUtility for dumping MSRs visible to a guest
Andrew Cooper [Sat, 5 Mar 2016 19:11:34 +0000 (19:11 +0000)]
Utility for dumping MSRs visible to a guest

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoUtility for dumping the CPUID information visible to a guest
Andrew Cooper [Sun, 30 Aug 2015 21:43:17 +0000 (22:43 +0100)]
Utility for dumping the CPUID information visible to a guest

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAdd documentation noting that swint-emulation serves as a test for XSAs 106 and 156
Andrew Cooper [Tue, 23 Feb 2016 22:37:06 +0000 (22:37 +0000)]
Add documentation noting that swint-emulation serves as a test for XSAs 106 and 156

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

Introduce a brand new category called 'xsa' for dedicated XSA tests.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAlter xtf_success() to take a string to print
Andrew Cooper [Mon, 22 Feb 2016 18:04:28 +0000 (18:04 +0000)]
Alter xtf_success() to take a string to print

... to be consistent with the rest of the reporting interface.  Every
reporting function is modified to accept NULL if there is nothing interesting
to print.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroduce test categories and create a test-info.json for each test
Andrew Cooper [Mon, 22 Feb 2016 12:43:51 +0000 (12:43 +0000)]
Introduce test categories and create a test-info.json for each test

test-info.json will accumulate relevant test metadata.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoInstall each test into a separate directory
Andrew Cooper [Mon, 22 Feb 2016 12:43:49 +0000 (12:43 +0000)]
Install each test into a separate directory

This allows for better delineation of tests and their resources.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAccept a PREFIX parameter when generating test configuration
Andrew Cooper [Mon, 22 Feb 2016 12:43:46 +0000 (12:43 +0000)]
Accept a PREFIX parameter when generating test configuration

This allows the test paths to be configured for the install destination if it
isn't to be run out the build working tree.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroduce links from test descriptions to their main.c
Andrew Cooper [Mon, 15 Feb 2016 15:33:23 +0000 (15:33 +0000)]
Introduce links from test descriptions to their main.c

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoDocument the build requirements
Andrew Cooper [Mon, 15 Feb 2016 15:33:23 +0000 (15:33 +0000)]
Document the build requirements

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoSpecify initalisers for each structure item
Andrew Cooper [Mon, 15 Feb 2016 15:33:23 +0000 (15:33 +0000)]
Specify initalisers for each structure item

Fixes an error from clang.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoDon't doubly declare the name label in ENTRY()
Andrew Cooper [Mon, 15 Feb 2016 15:33:23 +0000 (15:33 +0000)]
Don't doubly declare the name label in ENTRY()

GLOBAL() already declares it.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoDeclare the size of l1_identmap
Andrew Cooper [Mon, 15 Feb 2016 15:33:23 +0000 (15:33 +0000)]
Declare the size of l1_identmap

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoDisable implicit makefile rules
Andrew Cooper [Mon, 18 Jan 2016 10:48:59 +0000 (10:48 +0000)]
Disable implicit makefile rules

They are not needed, and cause unexpected behaviour.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoImplement the hvm32 environment; a 32bit HVM guest without paging
Andrew Cooper [Mon, 18 Jan 2016 10:48:56 +0000 (10:48 +0000)]
Implement the hvm32 environment; a 32bit HVM guest without paging

The test_NULL_unmapped() selftest is not applicable in an unpaged environment,
so is made conditional.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoRework config.h and head_hvm.S for better paging separation
Andrew Cooper [Mon, 18 Jan 2016 10:48:53 +0000 (10:48 +0000)]
Rework config.h and head_hvm.S for better paging separation

config.h is modified to turn CONFIG_ENV_$foo into the finer grain
CONFIG_{PV,HVM}, CONFIG_PAGING_LEVELS and possibly CONFIG_PAGING_PAE.  It then
undefines the CONFIG_ENV_$foo #define, to prevent mistakes in regular code.
Generation of environment_description is also moved into config.h, and it is
extended to include paging information.

head_hvm.S is then modified to use the finer grain #defines.  Specifically,
CR4.PAE is only set if CONFIG_PAGING_PAE, and CR3 and CR0.PG are only set if
CONFIG_PAGING_LEVELS is greater than 0.

The existing setting of CR0.PE is removed, as it is guaranteed always to be
set.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoRename the {pv,hvm}32 environments to {pv,hvm}32pae
Andrew Cooper [Mon, 18 Jan 2016 10:48:49 +0000 (10:48 +0000)]
Rename the {pv,hvm}32 environments to {pv,hvm}32pae

to indicate the paging mode in use.  More 32bit HVM environments will be
introduced, using different paging modes.

In principle, other 32bit PV environments exist, but are unable to run under a
64bit Xen, so are unlikely to be implemented.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoRename CONFIG_ENV_{pv,hvm} to CONFIG_{PV,HVM}
Andrew Cooper [Mon, 18 Jan 2016 10:48:44 +0000 (10:48 +0000)]
Rename CONFIG_ENV_{pv,hvm} to CONFIG_{PV,HVM}

to avoid them being easily confused with the environment-specific defined.

Additionally, reduce the usage of the environment-specific defines to an
absolute minimum, to avoid latent issues when introducing new environments.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoRework the build systems environment list generation
Andrew Cooper [Mon, 18 Jan 2016 10:48:26 +0000 (10:48 +0000)]
Rework the build systems environment list generation

and use this to reduce the amount of repetition in the object list generation.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoMisc docs improvements
Andrew Cooper [Fri, 15 Jan 2016 15:34:59 +0000 (15:34 +0000)]
Misc docs improvements

* Include assembly files.  They are not processed for structured comments, but
  are are available to be viewed and referred to.
* Use the preferred @# to prevent automatic linking when using #
* Disable timestamps.  Helps when comparing generated content.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoInclude local variables in all files currently missing them
Andrew Cooper [Fri, 15 Jan 2016 15:31:09 +0000 (15:31 +0000)]
Include local variables in all files currently missing them

Correct some accidental introduction of tabs in arch/x86/link.lds.S

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAvoid overflow in compare_extable_entry() when entries are far appart
Andrew Cooper [Fri, 15 Jan 2016 15:02:00 +0000 (15:02 +0000)]
Avoid overflow in compare_extable_entry() when entries are far appart

Constrain the return value to strictly between -1 and 1.  Without this,
sorting extable entries which are further than 2GB apart fails, as the
calculation overflows the return value.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoImport xen/errno.h from Xen's public API
Andrew Cooper [Fri, 15 Jan 2016 14:43:45 +0000 (14:43 +0000)]
Import xen/errno.h from Xen's public API

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroduce 'skip' as a test result
Andrew Cooper [Fri, 15 Jan 2016 12:48:07 +0000 (12:48 +0000)]
Introduce 'skip' as a test result

There are situations where the test cannot be completed, and this might be
considered success or failure, depending on the exact outcome intended by the
individual who is running the tests.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoInclude xtf/hypercall.h in xtf/lib.h
Andrew Cooper [Fri, 15 Jan 2016 14:04:55 +0000 (14:04 +0000)]
Include xtf/hypercall.h in xtf/lib.h

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoTest software injection of `into` in 32bit builds
Andrew Cooper [Thu, 14 Jan 2016 12:24:52 +0000 (12:24 +0000)]
Test software injection of `into` in 32bit builds

The `into` instruction is another software interrupt, which raises an #OF trap
if the overflow flag is set.  It is only recognised in 32bit code however, and
yields #UD if exectued in long mode.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoDocument the history of the framework
Andrew Cooper [Thu, 14 Jan 2016 12:41:46 +0000 (12:41 +0000)]
Document the history of the framework

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoSoftware interrupt emulation testing
Andrew Cooper [Thu, 6 Nov 2014 14:16:42 +0000 (14:16 +0000)]
Software interrupt emulation testing

Test documentation is at the head of main.c

Additionally

* Don't warn on unused parameters - there are legitimate reasons for a
  parameter to be unused.
* Make xtf/extable.h safe for inclusion in assembly files.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroductory documentation
Andrew Cooper [Wed, 6 Jan 2016 12:50:16 +0000 (12:50 +0000)]
Introductory documentation

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoUpdate Doxyfile to Doxygen 1.8.8
Andrew Cooper [Sun, 10 Jan 2016 19:09:02 +0000 (19:09 +0000)]
Update Doxyfile to Doxygen 1.8.8

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoProvide a Forced Emulation identifier rather than hand-rolling assembly
Andrew Cooper [Wed, 13 Jan 2016 10:49:46 +0000 (10:49 +0000)]
Provide a Forced Emulation identifier rather than hand-rolling assembly

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAllow tests to provide their own custom unhandled exception handler
Andrew Cooper [Mon, 11 Jan 2016 19:21:54 +0000 (19:21 +0000)]
Allow tests to provide their own custom unhandled exception handler

Useful for non-standard fixup, or for logging something more helpful than the
plain panic() message.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoError code constants for selector-based error codes
Andrew Cooper [Fri, 8 Jan 2016 19:11:59 +0000 (19:11 +0000)]
Error code constants for selector-based error codes

Provide symbolic constant support as well.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoMake symbolic constant generation more generic
Andrew Cooper [Fri, 8 Jan 2016 18:59:02 +0000 (18:59 +0000)]
Make symbolic constant generation more generic

The existing _GDTE_ATTR() macros are fine for GDT entries, but not much use
for anything else.

Replace the existing VAR_MACRO() with VAR_MACRO_C1(), which works in the same
way but passes a constant through, and use this to implement TOK_OR() which
works like _GDTE_ATTR() but takes a parameter rather than a hard coded
SEG_ATTR_.

Document the entities fully, and fix them to work correctly with empty
__VA_ARGS__.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoSplit out symbolic constant support into a separate file
Andrew Cooper [Fri, 8 Jan 2016 18:25:40 +0000 (18:25 +0000)]
Split out symbolic constant support into a separate file

While moving, rename _INIT_GDTE() to INIT_GDTE() and drop INIT_GDTE_RAW()
entirely.  Document the new INIT_GDTE() and implement INIT_GDTE_SYM() using
it.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoRearrange includes
Andrew Cooper [Fri, 8 Jan 2016 18:18:19 +0000 (18:18 +0000)]
Rearrange includes

For simplicity, tests should just include <xtf/lib.h> and get all the common
infrastructure for free.  All type definitions should come from <xtf/types.h>.
Fix one declaration vs definition mismatch uncovered.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoUnmap the page at 0 to catch errors with NULL pointers
Andrew Cooper [Fri, 8 Jan 2016 17:44:13 +0000 (17:44 +0000)]
Unmap the page at 0 to catch errors with NULL pointers

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroduce exec_user() to run a function at user privilege
Andrew Cooper [Thu, 24 Dec 2015 23:36:47 +0000 (23:36 +0000)]
Introduce exec_user() to run a function at user privilege

Add a selftest to confirm functionality.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAllow a test to raise privilege back to kernel level
Andrew Cooper [Thu, 24 Dec 2015 23:22:48 +0000 (23:22 +0000)]
Allow a test to raise privilege back to kernel level

to facilitate tests which switches privilege during the course of its run.

This is achieved by providing a dpl3 IDT entry which restores %esp and jumps
to the %eip found in the exception frame.

Therefore, 'int $0x20' acts as function call which returns at the kernels cpl.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoSetup for 32bit PV userspace execution
Andrew Cooper [Thu, 24 Dec 2015 21:09:47 +0000 (21:09 +0000)]
Setup for 32bit PV userspace execution

* Implement hypercall_update_va_mapping().
* Walk the live pagetables setting _PAGE_USER.

For now, 32bit PV XTF guests need to be run on a hypervisor booted with
"smep=0 smap=0" to prevent Xen's %cr4 settings from interfering.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoSetup for 64bit PV userspace execution
Andrew Cooper [Thu, 24 Dec 2015 21:06:00 +0000 (21:06 +0000)]
Setup for 64bit PV userspace execution

* Implement read_cr3(), HYPERCALL4() and hypercall_mmuext_op().
* Use FLAT_RING3_SS64 for __{KERN,USER}_DS.
* Set user %cr3.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoSetup for common PV userspace execution
Andrew Cooper [Thu, 24 Dec 2015 21:04:27 +0000 (21:04 +0000)]
Setup for common PV userspace execution

* Implement and use hypercall_stack_switch().
* Implement {read,write}_[cdefgs]s() wrappers.
* Use __USER_DS for the regular data segment selectors.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoSetup for HVM userspace execution
Andrew Cooper [Thu, 24 Dec 2015 20:45:43 +0000 (20:45 +0000)]
Setup for HVM userspace execution

* Introduce definitions for a task state segment and load one.
* Use __USER_DS for the regular data segment selectors.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoFactor low level difference between PV and HVM into macros
Andrew Cooper [Thu, 24 Dec 2015 23:14:23 +0000 (23:14 +0000)]
Factor low level difference between PV and HVM into macros

to reduce code duplication when further entry/exit paths are added.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoCommon infrastructure for userspace execution
Andrew Cooper [Thu, 24 Dec 2015 20:22:30 +0000 (20:22 +0000)]
Common infrastructure for userspace execution

Introduce __USER_{CS,DS}, expand the boot stack to two pages, add some DPL3
GDT descriptors, and space in GDT for a TSS.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroduce test_setup() to detect runtime support relevant for tests
Andrew Cooper [Tue, 22 Dec 2015 20:20:23 +0000 (20:20 +0000)]
Introduce test_setup() to detect runtime support relevant for tests

Currently it just identifies whether the Forced Emulation Prefix is available.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoException Logging support
Andrew Cooper [Mon, 21 Dec 2015 10:47:22 +0000 (10:47 +0000)]
Exception Logging support

Provide an interface whereby a test can log all exceptions which occur, and
query the log after the fact.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAlter pv64 kernel selectors to be rpl0
Andrew Cooper [Mon, 21 Dec 2015 19:01:58 +0000 (19:01 +0000)]
Alter pv64 kernel selectors to be rpl0

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoException table infrastructure
Andrew Cooper [Wed, 16 Dec 2015 19:04:03 +0000 (19:04 +0000)]
Exception table infrastructure

To redirect control flow if a fault occurs.  Entries are registered with the
_ASM_EXTABLE() and placed in the .ex_table section, which is collected
together by the linker.

The .ex_table section is sorted on boot (to facilitate fast searching), and
searched in do_exception() when a fault or abort is encountered.  If a
matching entry is found, control flow is redirected and the exception returned
from.

Some of the changes are to make the two asm_macros.h files safe to include in
C code.  In addition, an extra selftest is added, making use of the exception
table infrastructure.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoProvide a heapsort() implementation
Andrew Cooper [Thu, 17 Dec 2015 11:20:36 +0000 (11:20 +0000)]
Provide a heapsort() implementation

Modelled after qsort() in the C standard library.  Sorts in place.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAvoid __always_inline conflicting with cdef.h
Andrew Cooper [Fri, 18 Dec 2015 11:46:13 +0000 (11:46 +0000)]
Avoid __always_inline conflicting with cdef.h

Fixes build issues with the build-time selftests.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoXTF Selftests
Andrew Cooper [Tue, 8 Dec 2015 12:37:04 +0000 (12:37 +0000)]
XTF Selftests

Provide a sanity test of the environment and infrastructure provided by the
test framework itself.  These are all expected to pass.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoModify entry points to be able to return from exceptions
Andrew Cooper [Tue, 15 Dec 2015 09:33:45 +0000 (09:33 +0000)]
Modify entry points to be able to return from exceptions

Trap and Interrupt exceptions will now return, while Fault and Abort
exceptions are still fatal.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoRepresent exception frames in C
Andrew Cooper [Mon, 14 Dec 2015 09:00:02 +0000 (09:00 +0000)]
Represent exception frames in C

Introduce struct cpu_regs, and make the entry points create the expected
layout.

As part of this, split the very x86 bits of asm_macros.h into a new header
file.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoPV exception entry points
Andrew Cooper [Fri, 11 Dec 2015 17:12:01 +0000 (17:12 +0000)]
PV exception entry points

Infrastructure to register the virtual IDT with Xen and get execution back
into C when an exception occurs.  The existing 32 and 64bit entry points are
mostly reused, with small adjustments for PV guests.

Most of this change is importing and implementing Xen ABI bits for PV guests.

Exceptions are currently fatal.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoHVM exception entry points
Andrew Cooper [Fri, 11 Dec 2015 15:50:25 +0000 (15:50 +0000)]
HVM exception entry points

Infrastructure to set up the IDT and get execution back into C when an
exception occurs.

Exceptions are currently fatal.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoRefactor architectural trap setup
Andrew Cooper [Fri, 11 Dec 2015 15:35:12 +0000 (15:35 +0000)]
Refactor architectural trap setup

The setup of entry points is very different between PV and HVM guests.
Introduce two new traps.c to accommodate, a stub arch_init_traps(), and a stub
do_trap() as the C entry point for traps.

Adjust the single arch_crash_hard() into the relevant arch traps.c to reduce
the #ifdef'ary

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agox86 architectural infrastructure for exception handling
Andrew Cooper [Fri, 11 Sep 2015 13:21:24 +0000 (14:21 +0100)]
x86 architectural infrastructure for exception handling

Unlike the GDT which PV guests might have a legitimate interest in, a PV guest
genuinely has no interest in an x86 architectural IDT.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoMove build system into build/
Andrew Cooper [Thu, 10 Dec 2015 16:03:57 +0000 (16:03 +0000)]
Move build system into build/

In hindsight, config/ was not the best choice of names.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoImport and declare all hypercall entry points
Andrew Cooper [Thu, 10 Dec 2015 15:04:03 +0000 (15:04 +0000)]
Import and declare all hypercall entry points

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoReduce the quantity of token concatenation with hypercall declarations
Andrew Cooper [Thu, 10 Dec 2015 16:45:04 +0000 (16:45 +0000)]
Reduce the quantity of token concatenation with hypercall declarations

Allows better indexing from tools such as cscope

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoAvoid a constantly rebooting domain when triple faults occur
Andrew Cooper [Thu, 10 Dec 2015 14:03:30 +0000 (14:03 +0000)]
Avoid a constantly rebooting domain when triple faults occur

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoFix booting the HVM tests on hardware without hap support
Andrew Cooper [Wed, 9 Dec 2015 10:44:16 +0000 (10:44 +0000)]
Fix booting the HVM tests on hardware without hap support

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoIntroduce __noinline and __always_inline annotations
Andrew Cooper [Mon, 7 Dec 2015 21:43:38 +0000 (21:43 +0000)]
Introduce __noinline and __always_inline annotations

Additionally, switch to uniformly use of the double-underscore variants of
attribute names.

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