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