]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/log
people/andrewcoop/xen-test-framework.git
7 years agoUpdate xl.cfg files for Xen 4.10 support
Andrew Cooper [Fri, 6 Oct 2017 12:44:45 +0000 (13:44 +0100)]
Update xl.cfg files for Xen 4.10 support

From 4.10 onwards, the configuration file should use type= in preference to
builder/loader.  Leave the older options for legacy compatability.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agobuild: Avoid using initialisers for anonymous unions
Andrew Cooper [Thu, 28 Sep 2017 10:37:36 +0000 (11:37 +0100)]
build: Avoid using initialisers for anonymous unions

GCC 4.4 of CentOS 6 vintage can't cope.

Reported-by: Glenn Enright <glenn@rimuhosting.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agobuild: Opencode vmfunc as bytes
Andrew Cooper [Thu, 28 Sep 2017 10:04:57 +0000 (11:04 +0100)]
build: Opencode vmfunc as bytes

Binutils 2.20 of CentOS 6 vintage doesn't understand the mnemonic.  The
instruction doesn't encode any operands, so we don't lose any flexibility.

Reported-by: Glenn Enright <glenn@rimuhosting.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agobuild: Drop unnecessary register clobbers
Andrew Cooper [Thu, 28 Sep 2017 09:43:04 +0000 (10:43 +0100)]
build: Drop unnecessary register clobbers

The code in question is executing __HYPERVISOR_multicall which is 2-parameter
hypercall, which means that args 3-6 are preserved (as opposed to the
arguments in the multicall_entry_t list, which are clobbered).

GCC 4.4 in CentOS 6 can't cope with the ebp clobber.

Reported-by: Glenn Enright <glenn@rimuhosting.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agobuild: Support BUILD_BUG_ON() with compilers lacking _Static_assert()
Andrew Cooper [Thu, 28 Sep 2017 09:22:46 +0000 (10:22 +0100)]
build: Support BUILD_BUG_ON() with compilers lacking _Static_assert()

Implement enough compatibility so the code can use Clang's __has_extension()
logic when compiled with GCC.

Reported-by: Glenn Enright <glenn@rimuhosting.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoXSA-234 PoC
Andrew Cooper [Thu, 3 Aug 2017 10:28:33 +0000 (11:28 +0100)]
XSA-234 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoXSA-232 PoC
Andrew Cooper [Sun, 6 Aug 2017 10:40:12 +0000 (11:40 +0100)]
XSA-232 PoC

Based on an example provided by Matthew Daley.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoXSA-231 PoC
Andrew Cooper [Sun, 6 Aug 2017 10:39:51 +0000 (11:39 +0100)]
XSA-231 PoC

Based on an example provided by Matthew Daley.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce VCPU_OP and vcpu_*_context hypercall ABI
Andrew Cooper [Thu, 31 Aug 2017 14:09:57 +0000 (15:09 +0100)]
Introduce VCPU_OP and vcpu_*_context hypercall ABI

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agogitignore: add local vimrc
Petre Pircalabu [Wed, 19 Jul 2017 08:50:56 +0000 (11:50 +0300)]
gitignore: add local vimrc

Signed-off-by: Petre Pircalabu <ppircalabu@bitdefender.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoXSA-227 PoC
Andrew Cooper [Tue, 20 Jun 2017 18:18:54 +0000 (19:18 +0100)]
XSA-227 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoFunctional: Add a UMIP test
Boqun Feng [Tue, 15 Aug 2017 03:18:20 +0000 (11:18 +0800)]
Functional: Add a UMIP test

Add a "umip" test for the User-Model Instruction Prevention. The test
simply tries to run sgdt/sidt/sldt/str/smsw in guest user-mode with
CR4_UMIP = 1.

Signed-off-by: Boqun Feng (Intel) <boqun.feng@gmail.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
[Whitespace and docs fixups]
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoReplace uses of x86_decode_exinfo() with %pe
Andrew Cooper [Mon, 10 Jul 2017 10:35:04 +0000 (11:35 +0100)]
Replace uses of x86_decode_exinfo() with %pe

x86_exc_decode_ec() and x86_decode_exinfo() are awkward to use, as they
require a local buffer of (unknown) sufficient size.

Make the functions local to decode.c and refactor the callsites to use %pe
instead.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoImplement arch_fmt_pointer() for custom %pe handling
Andrew Cooper [Mon, 10 Jul 2017 10:25:48 +0000 (11:25 +0100)]
Implement arch_fmt_pointer() for custom %pe handling

This allows %pe to be used to print an exinfo_t.  The implementation uses
x86_decode_exinfo() under the hook.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoExport some vsprintf() internals
Andrew Cooper [Mon, 10 Jul 2017 09:35:13 +0000 (10:35 +0100)]
Export some vsprintf() internals

Rename number() to fmt_number() and export it.  Carve fmt_string() out of
vsnprintf() and export it.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoFix xtf_init_grant_table() to actually work on older versions of Xen
Andrew Cooper [Thu, 10 Aug 2017 11:35:22 +0000 (12:35 +0100)]
Fix xtf_init_grant_table() to actually work on older versions of Xen

(Now that such testing has taken place.)

On such versions of Xen, GNTTABOP_set_version will return -ENOSYS even when
trying to set a version of 1.  In such a case, v1 is the only version known to
Xen, so treat this condition non-fatally.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoXSA-224 PoC
Andrew Cooper [Mon, 19 Jun 2017 13:55:21 +0000 (14:55 +0100)]
XSA-224 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoBasic grant table infrastructure
Andrew Cooper [Mon, 19 Jun 2017 13:55:21 +0000 (14:55 +0100)]
Basic grant table infrastructure

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoImplement xtf_get_domid() for tests which need to know their own domid
Andrew Cooper [Wed, 9 Aug 2017 15:09:30 +0000 (16:09 +0100)]
Implement xtf_get_domid() for tests which need to know their own domid

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoBasic xenstore read implementation
Andrew Cooper [Sat, 2 Apr 2016 13:36:09 +0000 (14:36 +0100)]
Basic xenstore read implementation

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoInfrastructure for connecting the xenbus ring
Andrew Cooper [Wed, 30 Mar 2016 17:50:03 +0000 (18:50 +0100)]
Infrastructure for connecting the xenbus ring

Extra ABI and setup to obtain the xenstore ring location.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoProvide non-PV compatability for mfn related functions
Andrew Cooper [Tue, 8 Aug 2017 14:51:01 +0000 (15:51 +0100)]
Provide non-PV compatability for mfn related functions

Similar to non-paged compatability.  This allows for extra #ifdef'ary removal
from setup.c

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agobuild: append -fno-pic to CFLAGS
Wei Liu [Mon, 31 Jul 2017 17:20:57 +0000 (18:20 +0100)]
build: append -fno-pic to CFLAGS

It appears that Stretch's gcc has this on by default, which causes the
generating of several get_pc_thunk's, which breaks xsa-192 test.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoFurther LTO cleanup
Andrew Cooper [Tue, 25 Jul 2017 12:13:49 +0000 (13:13 +0100)]
Further LTO cleanup

Drop __used annotations for extable handlers, and use an "X" constraint.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoImplement pv_read_some
Felix Schmoll [Mon, 24 Jul 2017 06:24:15 +0000 (08:24 +0200)]
Implement pv_read_some

Implement reading from PV console. Making use of polling.

Signed-off-by: Felix Schmoll <eggi.innovations@gmail.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce hypercall_poll() infrastructure for the console
Andrew Cooper [Tue, 4 Jul 2017 09:05:37 +0000 (09:05 +0000)]
Introduce hypercall_poll() infrastructure for the console

The current write() path stays using yield() until the xl/xenconsoled race
condition it tickles is understood.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agodocs: Fix up the doxygen formatting for _ASM_TRAP_OK()
Andrew Cooper [Mon, 10 Jul 2017 13:00:09 +0000 (14:00 +0100)]
docs: Fix up the doxygen formatting for _ASM_TRAP_OK()

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agocleanup to nmi-taskswitch-priv
Andrew Cooper [Mon, 10 Jul 2017 13:09:38 +0000 (14:09 +0100)]
cleanup to nmi-taskswitch-priv

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agodocs: Fix the list of changeset in the history section
Andrew Cooper [Mon, 10 Jul 2017 12:58:01 +0000 (13:58 +0100)]
docs: Fix the list of changeset in the history section

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoFunctional test for an NMI-triggered task switch which increases privilege
Andrew Cooper [Thu, 1 Jun 2017 11:15:22 +0000 (12:15 +0100)]
Functional test for an NMI-triggered task switch which increases privilege

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoSplit existing Gate Descriptor infrastructure out into x86-gate.h
Andrew Cooper [Thu, 1 Jun 2017 11:15:22 +0000 (12:15 +0100)]
Split existing Gate Descriptor infrastructure out into x86-gate.h

Following in the style of the TSS work:

 * Rename gate_desc to env_gate
 * Rename seg_gate{32,64} to x86_gate{32,64}

In addition,

 * Expose call gate parameter counts for completeness.
 * Introduce pack_gate() which works on the appropriate type of gate, which
   allows for removal of #ifdef'ary during HVM setup.
 * Introduce pack_task_gate() which wraps pack_gate(), and allows for further
   #ifdef'ary removal in setup_doublefault().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agohvm32: Fill in tss.cr3 for the default task
Andrew Cooper [Thu, 1 Jun 2017 11:15:22 +0000 (12:15 +0100)]
hvm32: Fill in tss.cr3 for the default task

This is necessary for 32bit tests in, which end up task switching back to the
default task.  %cr3 gets reloaded as part of a task switch, which causes a
triple fault for 32bit paged environments.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoAdd declarations for l?_table_offset() in unpaged environments
Andrew Cooper [Thu, 6 Jul 2017 15:45:32 +0000 (16:45 +0100)]
Add declarations for l?_table_offset() in unpaged environments

This helps with writing code with reduced #ifdef'ary.  Remove stray externs
from other compatibility functions.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoExtend APIC infrastructure with ICR helpers
Andrew Cooper [Thu, 1 Jun 2017 11:15:22 +0000 (12:15 +0100)]
Extend APIC infrastructure with ICR helpers

Abstract away the split MMIO write.  While adding the MSR side, fix the broken
constraints for apic_msr_write().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce locked bt* operations
Andrew Cooper [Tue, 4 Jul 2017 16:51:03 +0000 (16:51 +0000)]
Introduce locked bt* operations

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agovvmx: Test vmxon in VMX root w/ CPL = 3 and w/ current VMCS
Haozhong Zhang [Fri, 16 Dec 2016 13:43:48 +0000 (21:43 +0800)]
vvmx: Test vmxon in VMX root w/ CPL = 3 and w/ current VMCS

Fault #GP(0) is expected in this test.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Rebase and cleanup.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agovvmx: Test vmxon in VMX root w/ CPL = 0 and w/ current VMCS
Haozhong Zhang [Fri, 16 Dec 2016 13:43:47 +0000 (21:43 +0800)]
vvmx: Test vmxon in VMX root w/ CPL = 0 and w/ current VMCS

VMfailvalid() is expected in this test.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Rebase and cleanup.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agovvmx: Test vmxon in VMX root w/ CPL = 3 and w/o current VMCS
Haozhong Zhang [Fri, 16 Dec 2016 13:43:46 +0000 (21:43 +0800)]
vvmx: Test vmxon in VMX root w/ CPL = 3 and w/o current VMCS

Fault #GP(0) is expected in this test.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Rebase and cleanup.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agovvmx: Test vmxon in VMX root w/ CPL = 0 and w/o current VMCS
Haozhong Zhang [Fri, 16 Dec 2016 13:43:45 +0000 (21:43 +0800)]
vvmx: Test vmxon in VMX root w/ CPL = 0 and w/o current VMCS

VMfailInvalid is expected in this test.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Rebase and cleanup.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agovvmx: Test the correct vmxon
Haozhong Zhang [Fri, 16 Dec 2016 13:43:44 +0000 (21:43 +0800)]
vvmx: Test the correct vmxon

No error is expected in this test.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Rebase and cleanup.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agovvmx: Test vmxon with bit 31 of VMCS revision ID set
Haozhong Zhang [Fri, 16 Dec 2016 13:43:43 +0000 (21:43 +0800)]
vvmx: Test vmxon with bit 31 of VMCS revision ID set

VMfailInvalid is expected in this test.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Rebase and cleanup.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agovvmx: Test vmxon with mismatched VMCS revision ID
Haozhong Zhang [Fri, 16 Dec 2016 13:43:42 +0000 (21:43 +0800)]
vvmx: Test vmxon with mismatched VMCS revision ID

VMfailInvalid is expected in this test.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Rebase and cleanup.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agovvmx: Test vmxon with unaligned VMXON region address
Haozhong Zhang [Fri, 16 Dec 2016 13:43:41 +0000 (21:43 +0800)]
vvmx: Test vmxon with unaligned VMXON region address

VMfailInvalid is expected in this case.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Rebase and cleanup.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agovvmx: Test vmxon with invalidly wide VMXON region address
Haozhong Zhang [Fri, 16 Dec 2016 13:43:40 +0000 (21:43 +0800)]
vvmx: Test vmxon with invalidly wide VMXON region address

VMfailInvalid is expected in this test.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Rebase and cleanup.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agovvmx: Test vmxon in CPL=3 inside and outside of VMX operation
Haozhong Zhang [Fri, 16 Dec 2016 13:43:39 +0000 (21:43 +0800)]
vvmx: Test vmxon in CPL=3 inside and outside of VMX operation

Faults #UD and #GP(0) are expected in this test.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Introduce a second test, checking both #UD and #GP(0)

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agovvmx: Test vmxon with CR4.VMXE cleared
Haozhong Zhang [Fri, 16 Dec 2016 13:43:38 +0000 (21:43 +0800)]
vvmx: Test vmxon with CR4.VMXE cleared

Fault #UD is expected in this test.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Rebase and cleanup.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoExtend exinfo_t with test-available bits
Andrew Cooper [Wed, 28 Jun 2017 15:35:48 +0000 (15:35 +0000)]
Extend exinfo_t with test-available bits

VT-x adds two extra logical errors from executing instructions.  Add two new
testa-avaialble bits into the generic infrastructure.

For the vvmx test, introduce XTF-wide helpers for the VMX Instruction Error
ABI, and test-specific helpers for VMX Instruction Error reporting via
extinfo_t, along with logic to decode the errors for printing.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agovvmx: Test whether MSR_IA32_VMX_BASIC is set correctly
Haozhong Zhang [Fri, 16 Dec 2016 13:43:35 +0000 (21:43 +0800)]
vvmx: Test whether MSR_IA32_VMX_BASIC is set correctly

It tests whether bit 31 and bit 48 are 0, and VMCS size is in the
range (0, 4096].

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Rebase and cleanup.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoDon't automatically recover from traps
Andrew Cooper [Thu, 1 Jun 2017 11:13:22 +0000 (12:13 +0100)]
Don't automatically recover from traps

While this property is useful for swint-emulation, it is unhelpful in other
situations, as it causes unexpected traps to get swallowed silently.

Reuse the existing extable logic (with fault == fixup) to recover, and
introduce _ASM_TRAP_OK() to introduce such an extable entry.

Adjust the swint-emulation and selftest logic following this behaviour change,
which removes the test_int3_breakpoint() case entirely.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoClean up extable.h
Andrew Cooper [Wed, 28 Jun 2017 14:51:06 +0000 (14:51 +0000)]
Clean up extable.h

Factor _ASM_EXTABLE() out of the C/ASM logic, and implement it in terms of
_ASM_EXTABLE_HANDLER().

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agovvmx: test whether MSR_FEATURE_CONTROL is set correctly
Haozhong Zhang [Fri, 16 Dec 2016 13:43:34 +0000 (21:43 +0800)]
vvmx: test whether MSR_FEATURE_CONTROL is set correctly

Guest MSR_FEATURE_CONTROL is set by Xen hypervisor instead by
guest firmware or hvmloader, so this test instead checks whether bits
in MSR_FEATURE_CONTROL are set correctly, rather than requiring
they are all zeroed.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Rebase and cleanup.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoBare-bones in-development test for nested VT-x
Andrew Cooper [Wed, 28 Jun 2017 12:17:41 +0000 (13:17 +0100)]
Bare-bones in-development test for nested VT-x

Based loosely on previous work from Haozhong Zhang, but rebased over
substantial upstream development work, altered to be more consistent with
existing tests, and extended to all HVM environments (rather than just hvm64)
to cover more test scenarios.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoTest basic driver initialisation in the selftests
Andrew Cooper [Wed, 28 Jun 2017 10:24:55 +0000 (11:24 +0100)]
Test basic driver initialisation in the selftests

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoXSA-221 PoC
Andrew Cooper [Tue, 30 May 2017 14:46:50 +0000 (15:46 +0100)]
XSA-221 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce some basic APIC infrastructure
Andrew Cooper [Thu, 1 Jun 2017 14:04:15 +0000 (14:04 +0000)]
Introduce some basic APIC infrastructure

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoFix fallthrough typo in XTF common/libc/vsnprintf.c
John Thomson [Sat, 24 Jun 2017 11:46:12 +0000 (21:46 +1000)]
Fix fallthrough typo in XTF common/libc/vsnprintf.c

fallthrough in one case is missing the r.
This fails to suppress -Wimplicit-fallthrough warning with GCC7

common/libc/vsnprintf.c:388:19: error: this statement may fall through [-Werror=implicit-fallthrough=]
             flags |= SIGNED;
                   ^
common/libc/vsnprintf.c:390:9: note: here
         case 'u': /* Unsigned decimal. */
         ^~~~
cc1: all warnings being treated as errors

Signed-off-by: John Thomson <git@johnthomson.fastmail.com.au>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoUse unsigned int in preference to unsigned
Andrew Cooper [Fri, 23 Jun 2017 15:28:16 +0000 (16:28 +0100)]
Use unsigned int in preference to unsigned

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoRearange user_desc structure union to reduce namespacing
Andrew Cooper [Mon, 5 Jun 2017 17:43:28 +0000 (18:43 +0100)]
Rearange user_desc structure union to reduce namespacing

This avoids having identically named fields in different named unions.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoImprovements to, and new TSS infrastructure
Andrew Cooper [Fri, 2 Jun 2017 12:33:58 +0000 (13:33 +0100)]
Improvements to, and new TSS infrastructure

 * Rename hw_tss to env_tss, to highlight that it is the TSS appropriate for
   the current environment
 * Rename hw_tss{32,64} to x86_tss{32,64} to highlight that it is a structure
   specified by x86
 * Replace reserved fields with empty bitfields
 * Remove erroneous link field from x86_tss64
 * Introduce dump_x86_tss{32,64}() to neatly format a TSS.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoSplit existing TSS infrastructure out into x86-tss.h
Andrew Cooper [Fri, 2 Jun 2017 12:13:09 +0000 (13:13 +0100)]
Split existing TSS infrastructure out into x86-tss.h

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoFix the declarations of __builtin_*() string functions
Andrew Cooper [Thu, 4 May 2017 11:29:46 +0000 (11:29 +0000)]
Fix the declarations of __builtin_*() string functions

The underlying function declaration needs to be ahead of the define which
alters the default to its __builtin_*() version

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoFix header files so they can be included in isolation
Andrew Cooper [Fri, 2 Jun 2017 18:25:02 +0000 (18:25 +0000)]
Fix header files so they can be included in isolation

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoCompile using -Winline to identify problematic functions
Andrew Cooper [Thu, 4 May 2017 15:29:35 +0000 (15:29 +0000)]
Compile using -Winline to identify problematic functions

A static inline function which can't be inlined for whatever reason ends up
being duplicated in all translation units in which it is used.

-Winline identifies why functions weren't inlined; snprintf() for example,
because it is varadic.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoRemove an unnecessary level of directory hierachy
Andrew Cooper [Wed, 31 May 2017 13:40:22 +0000 (13:40 +0000)]
Remove an unnecessary level of directory hierachy

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agodocs: Tweaks to the generated HTML
Andrew Cooper [Fri, 2 Jun 2017 14:59:31 +0000 (14:59 +0000)]
docs: Tweaks to the generated HTML

 * Default to a fully expanded index
 * Hide graphs by default

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoExperimental support for LTO builds, by passing lto=y to make
Andrew Cooper [Fri, 21 Oct 2016 18:16:09 +0000 (19:16 +0100)]
Experimental support for LTO builds, by passing lto=y to make

This works with Clang 4.0.  It is broken with Clang 3.8, as the LTO build
ignore -mno-sse and "optimises" SSE instructions back into the binary.
Unknown with any other compilers.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoFix build with GCC 7
Andrew Cooper [Wed, 31 May 2017 14:21:59 +0000 (15:21 +0100)]
Fix build with GCC 7

c/s e399b894f0 tried to make the function parameter to _ASM_EXTABLE_HANDLER()
visible to the compiler, for the benefit of LTO builds.  Unfortunately, GCC 7
doesn't like the chosen method, citing:

    error: asm operand 4 probably doesn’t match constraints [-Werror]

Instead, revert back to using the function by name, and make it visible to the
compiler by using the "X" constraint.

While making these changes, add a missing reference to
fpu-exception-emulation's probe_avx() and xsa-212's test_main().

Reported-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Reported-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Wei Liu <wei.liu2@citrix.com>
7 years agodocs: Prevent Doxygen from interpreting __page_aligned_{bss,data} as a name
Andrew Cooper [Tue, 30 May 2017 10:47:48 +0000 (11:47 +0100)]
docs: Prevent Doxygen from interpreting __page_aligned_{bss,data} as a name

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agorunner: Introduce a --quiet command line option
Andrew Cooper [Fri, 26 May 2017 15:24:40 +0000 (15:24 +0000)]
runner: Introduce a --quiet command line option

Particularly useful when running lots of tests, in the expectation that they
will all pass, where the full console logging isn't wanted.

One necessary adjustment is to switch run_test_console()'s `xl create` from
using subprocess.call() to Popen(), so stderr can be captured and ignored if
quiet, but printed back unconditionally if there is a problem.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agorunner: Distinguish clean and unclean exits
Andrew Cooper [Thu, 6 Apr 2017 13:22:00 +0000 (14:22 +0100)]
runner: Distinguish clean and unclean exits

Defaulting to ERROR turns out to be unhelpful, as it merges clean and unclean
exits of the test.  Switch instead to using a new CRASH result which more
accurately describes the typical reason for an unclean exit.

Factor out the logic to interpret the guests final log line into a helper,
rather than duplicating in both run_test_*() functions.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoCorrect linear/virtual address terminology
Andrew Cooper [Fri, 26 May 2017 16:29:11 +0000 (16:29 +0000)]
Correct linear/virtual address terminology

As XTF uses a flat segmentation model, virtual address == linear address.
However, the terminology should be kept correct.

As a rule of thumb, a C pointer is a virtual address, while `unsigned long va`
is actually a linear address.  All pagetables are indexed in terms of linear
addresses, including the (misnamed) update_va_mapping() hypercall.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoMap the domains shared_info at boot
Andrew Cooper [Sun, 1 May 2016 13:47:11 +0000 (14:47 +0100)]
Map the domains shared_info at boot

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoImport the Xen ABI for shared_info
Andrew Cooper [Sun, 1 May 2016 13:47:11 +0000 (14:47 +0100)]
Import the Xen ABI for shared_info

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoMove head_{pv,hvm}.s to {pv,hvm}/head.S
Andrew Cooper [Thu, 16 Feb 2017 13:58:34 +0000 (13:58 +0000)]
Move head_{pv,hvm}.s to {pv,hvm}/head.S

They can also be built with the normal rules, rather than using special logic.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoGenerate $(env)_{arch,guest} mappings automatically
Andrew Cooper [Thu, 16 Feb 2017 14:23:55 +0000 (14:23 +0000)]
Generate $(env)_{arch,guest} mappings automatically

Rather than opencoding them.  Drop the defcfg-$(env) mapping entirely and
reimplement its user in terms of $(env)_guest.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoSeparate page aligned data/bss into separate sections
Andrew Cooper [Tue, 18 Oct 2016 13:08:00 +0000 (13:08 +0000)]
Separate page aligned data/bss into separate sections

This alone drops the size of HVM tests by 8k.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoExtend %p vsprintf() handling to include hex buffers
Andrew Cooper [Fri, 19 May 2017 15:10:13 +0000 (15:10 +0000)]
Extend %p vsprintf() handling to include hex buffers

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoConvert cpu_regs_{sp,ss}() to being static inlines
Andrew Cooper [Wed, 17 May 2017 16:45:08 +0000 (17:45 +0100)]
Convert cpu_regs_{sp,ss}() to being static inlines

The 64bit case decomposes to a straight reads.  The 32bit case is likely less
overhead for the caller when inlined, but the compiler can always chose to
out-of-line the functions if it wants.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce xtf_exit()
Andrew Cooper [Wed, 17 May 2017 13:41:28 +0000 (14:41 +0100)]
Introduce xtf_exit()

This is more convenient for tests which want to terminate cleanly from the
middle of their logic, rather than needing to arrange for execution to return
from test_main().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agodocs: Fix the See Also cross-reference for livepatch-priv-check
Andrew Cooper [Thu, 18 May 2017 17:06:43 +0000 (18:06 +0100)]
docs: Fix the See Also cross-reference for livepatch-priv-check

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce an 'in-development' category for tests which don't want automating yet
Andrew Cooper [Thu, 11 May 2017 15:54:44 +0000 (16:54 +0100)]
Introduce an 'in-development' category for tests which don't want automating yet

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoxtf/vpmu: Add Intel PMU MSR addresses
Mohit Gambhir [Thu, 4 May 2017 21:32:59 +0000 (17:32 -0400)]
xtf/vpmu: Add Intel PMU MSR addresses

This patch adds Intel PMU MSR addresses as macros for VPMU testing

Signed-off-by: Mohit Gambhir <mohit.gambhir@oracle.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-213 PoC
Andrew Cooper [Wed, 5 Apr 2017 18:04:56 +0000 (19:04 +0100)]
XSA-213 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-212 PoC
Andrew Cooper [Fri, 17 Mar 2017 13:28:14 +0000 (13:28 +0000)]
XSA-212 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce _u() to compliement _p()
Andrew Cooper [Thu, 16 Jun 2016 10:28:07 +0000 (11:28 +0100)]
Introduce _u() to compliement _p()

This wraps (unsigned long) casts when pointers are needed to be handled as
integers.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agocpuid: Collect and expose max_{,extd_}leaf with other cpuid information
Andrew Cooper [Tue, 25 Apr 2017 17:33:25 +0000 (18:33 +0100)]
cpuid: Collect and expose max_{,extd_}leaf with other cpuid information

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agomake-new-test: Add a placeholder to docs/all-tests.dox
Andrew Cooper [Tue, 25 Apr 2017 16:40:34 +0000 (17:40 +0100)]
make-new-test: Add a placeholder to docs/all-tests.dox

This should help to avoid it being forgotten.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoHYPERCALL_callback infrastructure for PV guests
Andrew Cooper [Thu, 13 Apr 2017 16:40:26 +0000 (17:40 +0100)]
HYPERCALL_callback infrastructure for PV guests

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoLBR/TSX VMentry failure test
Andrew Cooper [Wed, 12 Oct 2016 17:23:42 +0000 (18:23 +0100)]
LBR/TSX VMentry failure test

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoPass _ASM_EXTABLE_HANDLER() references by asm() parameter
Andrew Cooper [Tue, 11 Apr 2017 10:38:50 +0000 (11:38 +0100)]
Pass _ASM_EXTABLE_HANDLER() references by asm() parameter

... rather than embedding a reference directly.  This makes LTO aware of the
reference (rather than finding no C-level references, dropping the functions
and subsequently failing to link), and allows local fault handlers to be
static.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoReorganise the extable helpers to export their declarations
Andrew Cooper [Tue, 11 Apr 2017 10:37:32 +0000 (11:37 +0100)]
Reorganise the extable helpers to export their declarations

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agodocs: Fix Getting Started instructions
Andrew Cooper [Mon, 10 Apr 2017 16:03:39 +0000 (17:03 +0100)]
docs: Fix Getting Started instructions

This correction was accidentally omitted from c/s 4945bd69498e72

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoproperly parenthesize BUILD_BUG_ON()'s parameter use
Jan Beulich [Thu, 6 Apr 2017 14:26:16 +0000 (15:26 +0100)]
properly parenthesize BUILD_BUG_ON()'s parameter use

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-204 PoC
Andrew Cooper [Sun, 18 Dec 2016 13:54:13 +0000 (13:54 +0000)]
XSA-204 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoRevert "Drop test_wants_user_mappings infrastructure" and "Switch tests over to using...
Andrew Cooper [Mon, 6 Mar 2017 18:54:23 +0000 (18:54 +0000)]
Revert "Drop test_wants_user_mappings infrastructure" and "Switch tests over to using .text.user"

It turns out not to be safe without fixes to Xen's pagetable walk.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoDrop test_wants_user_mappings infrastructure
Andrew Cooper [Mon, 6 Mar 2017 11:58:05 +0000 (11:58 +0000)]
Drop test_wants_user_mappings infrastructure

As noted in Errata, the test_wants_user_mappings infrastructure has problems
for pv32pae environments on Xen 4.6 and earlier, if Xen leaks SMEP/SMAP
settings into the guest.

Now that all tests have moved to the new .text.user infrastructure, drop
test_wants_user_mappings.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoSwitch tests over to using .text.user
Andrew Cooper [Mon, 6 Mar 2017 11:41:10 +0000 (11:41 +0000)]
Switch tests over to using .text.user

... in preference to test_wants_user_mappings.  This involves duplicating the
stubs which need to be executed in user context, and moving them into
.text.user.

As a result, the tests become SMEP/SMAP-safe, even in cases were such settings
are leaked from Xen.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoFix x{get,set}bv() build with Clang 3.9
Andrew Cooper [Mon, 6 Mar 2017 13:31:42 +0000 (13:31 +0000)]
Fix x{get,set}bv() build with Clang 3.9

In 32bit builds, Clang objects to using uint64_t's with 32bit asm operands.

  In file included from /local/xen-test-framework.git/arch/x86/pv/traps.c:7:
  /local/xen-test-framework.git/arch/x86/include/arch/lib.h:404:52: error:
  invalid output size for constraint '=d'
      asm volatile ("xgetbv" : "=a" (feat_lo), "=d" (feat_hi)
                                                     ^

  /local/xen-test-framework.git/arch/x86/include/arch/lib.h:412:59: error:
  invalid input size for constraint 'd'
      asm volatile ("xsetbv" :: "a" ((uint32_t)value), "d" (value >> 32),
                                                            ^

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoAlter selftest to test the SMEP/SMAP safety of exec_user()
Andrew Cooper [Thu, 2 Mar 2017 18:01:00 +0000 (18:01 +0000)]
Alter selftest to test the SMEP/SMAP safety of exec_user()

Drop the test_wants_user_mappings setting and place test_exec_user_cpl3() in
.text.user.  Enable CR4.{SMEP,SMAP} whenever available.

While adding __section(s) to compiler.h, take the opportunity to clean it up.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoMake exec_user_param() safe with SMEP and SMAP active
Andrew Cooper [Thu, 2 Mar 2017 18:20:31 +0000 (18:20 +0000)]
Make exec_user_param() safe with SMEP and SMAP active

To make this safe, the iret must move straight from supervisor code/stack to
user code/stack.  Therefore, the stack cannot be shared any more.

The existing user_stack[] can be used as the separate stack.  This make the
exec_user_param() infrastructure no longer reentrant, but this isn't expected
to be a problem for tests.

A new .text.user section is introduced, which is automatically mapped as user
during setup.

The behaviour of exec_user_param() and X86_VEC_RET2KERN are altered to match.
exec_user_param() stores the supervisor stack in %rbp across the user
execution, and fakes up a return address as if it had simply called the user
code.  X86_VEC_RET2KERN restores the stack from %rbp and follows the fake
return address to reenter exec_user_param()'s context.

Invocation of the user function call moves into exec_user_stub() which is
located inside .text.user.  The 32bit version must pass all parameters in
registers, rather than on the stack.

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