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>
Andrew Cooper [Mon, 7 Dec 2015 14:37:28 +0000 (14:37 +0000)]
Adjust linker script to avoid having a PT_LOAD header all the way from zero
Previously, the generated binaries had a single PT_LOAD header all the
way from 0 to the end of the generated code.
When building, the domain builder maps the entire region and
zeroes/copies the data as appropriate. This causes a failure to build
when the header overlaps with unmapped addresses such as the HVM legacy
VGA range.
Link all binaries to load and run at 1MB to avoid the legacy VGA hole in
HVM guests.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Andrew Cooper [Sun, 6 Dec 2015 18:30:46 +0000 (18:30 +0000)]
Create hvm64 test binaries as elf32, take 2
Experimentally, gcc/binutils from Debian Jessie (4.9.2/2.25) and CentOS
7.1 (4.8.3/2.23) don't make valid binaries when linking x86-64 object
files as elf32-x86-64.
Issues include corrupt DWARF debugging information (as confirmed by
gdb/readelf), and erroneously merged strings in .rodata (as confirmed by
strings).
Instead, link all binaries in their natural width, and objcopy hvm64
binaries to elf32-x86-64 after the fact.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>