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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>