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>
Wei Liu [Wed, 1 Feb 2017 16:21:14 +0000 (16:21 +0000)]
build: disable PIE during linking if necessary
Starting from ee3e265688, $(CC) is used for linking. That means all
default $(CC) flags coming from distro takes effect.
On Debian Stretch, gcc contains -pie by default, which makes the final
object fail to link. We need to explicitly disable PIE when linking.
Since not all versions of gcc support -no-pie, test its availability
before adding.
Example error message:
/usr/bin/ld: /local/work/xtf.git/arch/x86/boot/head_pv64.o: relocation R_X86_64_32S against symbol `start_info' can not be used when making a shared object;
recompile with -fPIC
/usr/bin/ld: /local/work/xtf.git/arch/x86/entry_64-pv64.o: relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile with
-fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Signed-off-by: Wei Liu <wei.liu2@citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Jan Beulich [Mon, 23 Jan 2017 10:45:49 +0000 (10:45 +0000)]
don't overrun memory object
Using MOVUPS on an 8-byte quantity is wrong. There's no need for memory
accesses in any of the probe_*() functions anyway - switch them all to
insns without any operands or with register ones.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Switch PXOR for MOVQ in the MMX case to avoid regression on older hypervisors
which lack an emulation of PXOR.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Andrew Cooper [Fri, 18 Nov 2016 13:21:34 +0000 (13:21 +0000)]
Uniformly enable WP for HVM environments
This brings them in line with PV environments (which have no choice in the
matter), and better matches usual expectations for the behaviour of read-only
pages.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Andrew Cooper [Thu, 17 Nov 2016 17:21:35 +0000 (17:21 +0000)]
Print test titles earlier during startup
Certain conditions, such as failing the test_needs_fep check, result in the
framework exiting before calling test_main(). Logs from such runs are
impossible to distinguish.
Require tests to provide a test_title string, and print it as part of the
startup banner.
Update make-new-test.sh and the introductory docs to match
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Andrew Cooper [Fri, 21 Oct 2016 13:17:19 +0000 (14:17 +0100)]
Unify and shorten the I/L/GDT paths in x86_exc_decode_ec()
The split between L/GDT selector (in hex) and IDT index (in decimal) is
awkward to read when both types of errors are seen together. Furthermore, the
vec/sel text adds unncessary length to the message.
Switch to uniformally reporting the table index in C array syntax which is
shorter to express.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Andrew Cooper [Fri, 14 Oct 2016 13:18:35 +0000 (14:18 +0100)]
Modify exec_user() to pass a return value back from the called function
This turns out to be rather more useful in general, and the only changes
required to make it work is not to clobber %eax on the return back to kernel.
A compatability exec_user_void() is introduced to wrap exec_user() for
existing users with void functions. The exec_user selftest is updated to use
the new functionality, instead of passing a result back via a static variable.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Andrew Cooper [Fri, 7 Oct 2016 15:03:03 +0000 (16:03 +0100)]
Introduce static inline helpers for {l,s}{gdt,idt,ldt,tr}()
And replace existing opencoded examples. The m16 forms of str/sldt are awkard
to encode in a way which doesn't impact the more common reg encoding. Leave
the asm constraints as reg only, which causes the processor to zero-extend the
selector into the destination register.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Andrew Cooper [Tue, 23 Aug 2016 14:55:22 +0000 (15:55 +0100)]
Introduce common extable helper functions
It is turning out to be a common pattern to use extable handlers to catch a
fault at an instruction under test. Introduce a common extable handler to
return fault information in %eax.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Andrew Cooper [Mon, 5 Sep 2016 16:49:10 +0000 (17:49 +0100)]
Fix the use of ./xtf-runner on Python 2.4
* subprocess has no check_output(). Opencode it.
* {} set notation doesn't exist. Call the set() constructor explicitly.
* tuple has no .index(). Switch all_results to being a list.
* OptionParser() has no epilog option. Monkeypatch it into the parser object.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Andrew Cooper [Wed, 3 Aug 2016 14:20:45 +0000 (15:20 +0100)]
Add CONFIG_{32,64}BIT to config.h
To allow the use of IS_DEFINED() in preference to #ifdef __x86_64__/__i386__
to reduce the likelihood of bitrot.
In turn, modify page.h and pagetable.h sufficiently to compile for unpaged
enviroments. This leaves a link error if dead-code-elimination doesn't manage
to elide the reference.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Andrew Cooper [Wed, 3 Aug 2016 11:48:39 +0000 (12:48 +0100)]
Audit the use of the skip result
Report a skip for swint-emulation if the main purpose of the test is unable to
be performed. However, run the first half of the tests against real hardware
to confirm that the algorithm is correct
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Andrew Cooper [Tue, 2 Aug 2016 18:43:12 +0000 (19:43 +0100)]
build: Fix the install rule for configuration files
install-$(env) should only depend on the $(env) subset of all configuration
files, and all configuration files should be installed, rather than just the
first listed.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Andrew Cooper [Tue, 2 Aug 2016 18:08:43 +0000 (19:08 +0100)]
mkinfo: Fix JSON damage from splitting an empty string
In python, splitting an empty string results in a single-entry list containing
an empty string. This causes the variations list to be wrong when no
variations are in use.
It is only by chance that doesn't cause an issue for ./xtf-runner
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Andrew Cooper [Tue, 2 Aug 2016 16:30:41 +0000 (17:30 +0100)]
Rework the pv-iopl test using variations
The hypercall and vmassist tests are logically separate, and while the
hypercall version has been around for a very long time, vmassist was only
introduced in Xen 4.7.
To be able to sensibly test the hypercall part on older versions of Xen, they
should be treated separately, so the skip from vmassist detection doesn't
influence the results from the hypercall test.
To test them independently, introduce variations which alter the cmdline
passed to the guest.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>