]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/log
people/andrewcoop/xen-test-framework.git
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>
8 years agoProvide a common user_stack[] for tests
Andrew Cooper [Thu, 2 Mar 2017 16:04:49 +0000 (16:04 +0000)]
Provide a common user_stack[] for tests

Automatically remap this frame as _PAGE_USER.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoImplement exec_user() in C rather than asm
Andrew Cooper [Fri, 3 Mar 2017 16:23:18 +0000 (16:23 +0000)]
Implement exec_user() in C rather than asm

It is trivial to implement as a static inline wrapper around
exec_user_param(), and avoids unnecessary stack manipulation in 32bit builds.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoUse zeroes for filling holes in .text
Andrew Cooper [Thu, 2 Mar 2017 16:03:04 +0000 (16:03 +0000)]
Use zeroes for filling holes in .text

In paged environments, this is more likely to cause a fault than using nops,
and the resulting disassembly is shorter.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce _ASM_{{A,C,D,B}X,{B,S}P,{S,D}I} to aid common asm code
Andrew Cooper [Fri, 3 Mar 2017 14:35:49 +0000 (14:35 +0000)]
Introduce _ASM_{{A,C,D,B}X,{B,S}P,{S,D}I} to aid common asm code

This removes the need to #ifdef around code requiring a word-sized register.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoMove arch-specific headers to arch/$arch/include/
Andrew Cooper [Fri, 3 Mar 2017 16:50:05 +0000 (16:50 +0000)]
Move arch-specific headers to arch/$arch/include/

This avoids having common code/headers referring to an arch-specific header by
its arch-specific name.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86: add UMIP feature bit
Wei Liu [Thu, 2 Mar 2017 08:42:31 +0000 (08:42 +0000)]
x86: add UMIP feature bit

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoDocs: Add a build note about glibc-devel.i686 on RHEL-based distros
Andrew Cooper [Wed, 1 Mar 2017 11:58:54 +0000 (11:58 +0000)]
Docs: Add a build note about glibc-devel.i686 on RHEL-based distros

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoDeclare environment_description as an array
Andrew Cooper [Tue, 21 Feb 2017 15:03:53 +0000 (15:03 +0000)]
Declare environment_description as an array

There is no point following a pointer into the string section when a direct
reference will do.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-203 PoC
Andrew Cooper [Fri, 9 Dec 2016 16:20:04 +0000 (16:20 +0000)]
XSA-203 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoalso test AVX exceptions
Jan Beulich [Wed, 15 Feb 2017 16:21:34 +0000 (16:21 +0000)]
also test AVX exceptions

... as they're different from SSE and FPU ones.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Update documentation in line with the changes.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agobuild: disable PIE during linking if necessary
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>
8 years agoImprove documentation and error handling around FEP
Andrew Cooper [Mon, 30 Jan 2017 13:54:33 +0000 (13:54 +0000)]
Improve documentation and error handling around FEP

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoCollect max{phys,virt}addr along with other CPUID information
Andrew Cooper [Mon, 30 Jan 2017 11:20:56 +0000 (11:20 +0000)]
Collect max{phys,virt}addr along with other CPUID information

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agodon't overrun memory object
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>
8 years agoBuild: Use $(CC) for linking
Andrew Cooper [Fri, 21 Oct 2016 17:53:29 +0000 (18:53 +0100)]
Build: Use $(CC) for linking

This is a prerequisite for using LTO.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoBuild: Disable implicit make variables
Andrew Cooper [Tue, 13 Dec 2016 15:15:16 +0000 (15:15 +0000)]
Build: Disable implicit make variables

Perform immediate expansion variables

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-200 PoC
Andrew Cooper [Fri, 9 Dec 2016 15:16:31 +0000 (15:16 +0000)]
XSA-200 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoDocs: Fix the generated advisory links
Andrew Cooper [Mon, 19 Dec 2016 17:47:17 +0000 (17:47 +0000)]
Docs: Fix the generated advisory links

The ./make-new-test.sh script was failing to write the correct URL.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoImplement exec_user_param()
Andrew Cooper [Tue, 23 Aug 2016 14:55:22 +0000 (15:55 +0100)]
Implement exec_user_param()

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoDocument the interaction of x32 ABI support and hvm64 tests
Andrew Cooper [Wed, 14 Dec 2016 13:41:15 +0000 (13:41 +0000)]
Document the interaction of x32 ABI support and hvm64 tests

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agodon't require x32 support in binutils
Jan Beulich [Wed, 14 Dec 2016 13:31:25 +0000 (13:31 +0000)]
don't require x32 support in binutils

Older binutils don't have this at all, and newer may not have it
configured in.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
8 years agoXSA-196 PoC
Andrew Cooper [Thu, 27 Oct 2016 10:33:32 +0000 (11:33 +0100)]
XSA-196 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-195 PoC
Andrew Cooper [Wed, 2 Nov 2016 18:44:43 +0000 (18:44 +0000)]
XSA-195 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-194 PoC
Andrew Cooper [Tue, 15 Nov 2016 17:40:45 +0000 (17:40 +0000)]
XSA-194 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-193 PoC
Andrew Cooper [Tue, 25 Oct 2016 11:00:45 +0000 (12:00 +0100)]
XSA-193 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-192 PoC
Andrew Cooper [Thu, 27 Oct 2016 10:53:46 +0000 (11:53 +0100)]
XSA-192 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-191 PoC
Andrew Cooper [Thu, 3 Nov 2016 11:27:15 +0000 (11:27 +0000)]
XSA-191 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoDocs: Minor grammar improvements
Andrew Cooper [Mon, 21 Nov 2016 17:22:36 +0000 (17:22 +0000)]
Docs: Minor grammar improvements

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-170 PoC
Andrew Cooper [Sat, 9 Jan 2016 15:25:14 +0000 (15:25 +0000)]
XSA-170 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoAdd a Live Patch privilege check test
Ross Lagerwall [Mon, 21 Nov 2016 09:24:22 +0000 (09:24 +0000)]
Add a Live Patch privilege check test

Add a test to check that Live Patch operations cannot be called from an
unprivileged domain.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Fix build with clang

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoUniformly enable WP for HVM environments
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>
8 years agoPrint test titles earlier during startup
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>
8 years agoInclude an optional local Makefile by default
Andrew Cooper [Wed, 16 Nov 2016 13:07:12 +0000 (13:07 +0000)]
Include an optional local Makefile by default

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoImprovements to the cpuid utility
Andrew Cooper [Mon, 14 Nov 2016 10:03:58 +0000 (10:03 +0000)]
Improvements to the cpuid utility

 * Enable viridian for HVM guests to expose more leaves
 * Identify the Xen leaves, and add subleaf logic

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-186: Work around suspected Broadwell TLB erratum
Andrew Cooper [Fri, 28 Oct 2016 10:34:53 +0000 (11:34 +0100)]
XSA-186: Work around suspected Broadwell TLB erratum

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce exinfo_t to formalise the existing ad-hoc exception encapsulation
Andrew Cooper [Mon, 3 Oct 2016 13:12:00 +0000 (13:12 +0000)]
Introduce exinfo_t to formalise the existing ad-hoc exception encapsulation

Set the top bit to distinguish a DivideError from no exception.  Add
x86_decode_exinfo() to assist printing an exinfo_t.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce mnemonics for x86 selectors
Andrew Cooper [Thu, 6 Oct 2016 16:52:39 +0000 (17:52 +0100)]
Introduce mnemonics for x86 selectors

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoFix the build with Clang 3.9
Andrew Cooper [Fri, 21 Oct 2016 14:32:33 +0000 (14:32 +0000)]
Fix the build with Clang 3.9

Clang 3.9 complains that `fild` is ambiguous with respect to the size of its
memory operand.  Specify `fildq` explicitly.

Drop "-no-integrated-as" from the docs, as both Clang 3.5 and 3.9 work fine
with or without it.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoMinor docs corrections
Andrew Cooper [Fri, 21 Oct 2016 12:49:13 +0000 (13:49 +0100)]
Minor docs corrections

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoUnify and shorten the I/L/GDT paths in x86_exc_decode_ec()
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>
8 years agoCPUID Faulting tests
Andrew Cooper [Fri, 14 Oct 2016 12:32:36 +0000 (13:32 +0100)]
CPUID Faulting tests

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoRun double faults on a separate stack
Andrew Cooper [Fri, 14 Oct 2016 14:51:18 +0000 (14:51 +0000)]
Run double faults on a separate stack

For 64bit, use interrupt stack tables.  For 32bit, use a task gate referring
to a dedicated double fault TSS.

This allows some situations to print error information rather than falling
into a triple fault.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce cr3_target as an alias of the pagetable pointed to by %cr3
Andrew Cooper [Mon, 17 Oct 2016 17:24:55 +0000 (18:24 +0100)]
Introduce cr3_target as an alias of the pagetable pointed to by %cr3

Use the new alias to simplify the pagetable setup in in head_hvm.S

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoProvide library {rdmsr,wrmsr}_safe() functions
Andrew Cooper [Mon, 17 Oct 2016 09:36:45 +0000 (10:36 +0100)]
Provide library {rdmsr,wrmsr}_safe() functions

Replace a local implementation in the MSR utility.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoRename ex_record_fault to ex_record_fault_eax
Andrew Cooper [Fri, 14 Oct 2016 12:38:23 +0000 (13:38 +0100)]
Rename ex_record_fault to ex_record_fault_eax

It is more descriptive, and future work will introduce equivalent handlers
which use different registers.

While making this change, improve the asm constraints at ex_record_fault()'s
current callsites.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoImplement write_cs() to match the existing read_cs()
Andrew Cooper [Fri, 14 Oct 2016 15:37:02 +0000 (16:37 +0100)]
Implement write_cs() to match the existing read_cs()

%cs can't be directly written to, so this is implemented using lret.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoExtend TOK_OR() to work with up to 11 parameters
Andrew Cooper [Thu, 13 Oct 2016 13:31:08 +0000 (14:31 +0100)]
Extend TOK_OR() to work with up to 11 parameters

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoModify exec_user() to pass a return value back from the called function
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>
8 years agoIntroduce static inline helpers for {l,s}{gdt,idt,ldt,tr}()
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>
8 years agoRefer some XSAs back to the functional tests which identify them
Andrew Cooper [Tue, 11 Oct 2016 09:56:47 +0000 (10:56 +0100)]
Refer some XSAs back to the functional tests which identify them

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoFPU Exception Emulation
Andrew Cooper [Wed, 28 Sep 2016 13:11:36 +0000 (14:11 +0100)]
FPU Exception Emulation

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce common extable helper functions
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>
8 years agoAllow ./make-new-test.sh to determine the default category more cleverly
Andrew Cooper [Wed, 28 Sep 2016 11:37:53 +0000 (12:37 +0100)]
Allow ./make-new-test.sh to determine the default category more cleverly

When making an XSA proof of concept test, automatically generate the standard
documentation template.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoAllow ./make-new-test.sh to take the test name as $1
Andrew Cooper [Wed, 28 Sep 2016 10:57:51 +0000 (11:57 +0100)]
Allow ./make-new-test.sh to take the test name as $1

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoMakefile: introduce gtags target
Wei Liu [Mon, 26 Sep 2016 15:07:33 +0000 (16:07 +0100)]
Makefile: introduce gtags target

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoCorrect the documentation for the XSA-186 PoC
Andrew Cooper [Fri, 9 Sep 2016 17:48:43 +0000 (18:48 +0100)]
Correct the documentation for the XSA-186 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-185 PoC
Andrew Cooper [Fri, 5 Aug 2016 17:25:07 +0000 (17:25 +0000)]
XSA-185 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-182 PoC
Andrew Cooper [Wed, 13 Jul 2016 20:51:11 +0000 (21:51 +0100)]
XSA-182 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-186 PoC
Andrew Cooper [Fri, 5 Aug 2016 15:34:46 +0000 (16:34 +0100)]
XSA-186 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoFix test fallout from recent Xen change
Andrew Cooper [Thu, 8 Sep 2016 15:33:16 +0000 (16:33 +0100)]
Fix test fallout from recent Xen change

A recent Xen change switched some use of -ENOSYS to -EOPNOTSUPP.  Treat them
equivelently where relevent.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-188 PoC
David Vrabel [Fri, 2 Sep 2016 12:39:36 +0000 (13:39 +0100)]
XSA-188 PoC

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoAppropriately mask out the address and flags parameters when constructing a pte
Andrew Cooper [Thu, 8 Sep 2016 11:46:05 +0000 (12:46 +0100)]
Appropriately mask out the address and flags parameters when constructing a pte

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoFix the use of ./xtf-runner on Python 2.4
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>
8 years agoxtf-runner: Introduce logfile mode for obtaining results
Wei Liu [Mon, 15 Aug 2016 14:55:22 +0000 (15:55 +0100)]
xtf-runner: Introduce logfile mode for obtaining results

Add --results-mode=logfile as an alternative method of obtaining test results.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoUpdate XSA-173 to use newer helpers
Andrew Cooper [Fri, 2 Sep 2016 12:26:00 +0000 (13:26 +0100)]
Update XSA-173 to use newer helpers

Use pte_from_*() and PF_SYM() rather than opencoding them.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoAdd helpers to fold and unfold a pv32pae guest cr3
Andrew Cooper [Tue, 30 Aug 2016 16:29:51 +0000 (17:29 +0100)]
Add helpers to fold and unfold a pv32pae guest cr3

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoUpdate the documentation to point at XTF's canonical location
Andrew Cooper [Thu, 18 Aug 2016 16:19:23 +0000 (17:19 +0100)]
Update the documentation to point at XTF's canonical location

Add a note concerning OSSTest, pointing elsewhere

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoFix Clang build following c/s 9f35dbe0
Andrew Cooper [Fri, 12 Aug 2016 12:32:01 +0000 (13:32 +0100)]
Fix Clang build following c/s 9f35dbe0

Clang objects to macros altering the prototypes in string.c, and redefining
the __builtin_*() varients.  Reduce the include to just <xen/types.h>.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce a binary representation of the Force Emulation Prefix
Andrew Cooper [Fri, 5 Aug 2016 17:20:16 +0000 (17:20 +0000)]
Introduce a binary representation of the Force Emulation Prefix

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce xtf_set_idte() to allow tests to add extra IDT entries
Andrew Cooper [Fri, 15 Jul 2016 16:02:56 +0000 (16:02 +0000)]
Introduce xtf_set_idte() to allow tests to add extra IDT entries

Add an extra entry to the selftests.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIDT Vector allocation and infrastructure
Andrew Cooper [Fri, 15 Jul 2016 15:31:58 +0000 (15:31 +0000)]
IDT Vector allocation and infrastructure

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoAdd `./xtf-runner --list --environments` to obtain the full environment list
Andrew Cooper [Wed, 3 Aug 2016 14:28:41 +0000 (15:28 +0100)]
Add `./xtf-runner --list --environments` to obtain the full environment list

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoAdd CONFIG_{32,64}BIT to config.h
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>
8 years agoAudit the use of the skip result
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>
8 years agoIntroduce test_needs_fep to help uniform handling of fep being unavailable
Andrew Cooper [Wed, 3 Aug 2016 11:33:52 +0000 (12:33 +0100)]
Introduce test_needs_fep to help uniform handling of fep being unavailable

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agobuild: Fix the install rule for configuration files
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>
8 years agomkinfo: Fix JSON damage from splitting an empty string
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>
8 years agoRework the pv-iopl test using variations
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>
8 years agoAdd an implementation of strcmp()
Andrew Cooper [Tue, 2 Aug 2016 17:07:18 +0000 (18:07 +0100)]
Add an implementation of strcmp()

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoXSA-183 PoC
Andrew Cooper [Thu, 14 Jul 2016 12:07:16 +0000 (13:07 +0100)]
XSA-183 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce GFN terminology to memory management
Andrew Cooper [Tue, 2 Aug 2016 15:09:00 +0000 (16:09 +0100)]
Introduce GFN terminology to memory management

which allows for common code to use gfn_to_virt()/virt_to_gfn() without
needing to worry whether it is a PV or HVM guest.

Add a pte_from_virt() helper to construct a pagetable entry pointing at a data
item linked into the test microkernel.  To avoid inclusion problems, split the
independent pagetable modification functions out into a separate header file.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agorunner: Add --all and --non-default options to help with category selection
Andrew Cooper [Tue, 2 Aug 2016 09:46:45 +0000 (10:46 +0100)]
runner: Add --all and --non-default options to help with category selection

This allows calling software to easily find all tests to run without needing
to name categories, environments or tests specifically.

--all is expected to cover the usual case, while --non-default is provided
just in case.  It is not expected to be running the non-default category tests
in bulk.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoMisc documentation improvements
Andrew Cooper [Fri, 29 Jul 2016 16:22:13 +0000 (16:22 +0000)]
Misc documentation improvements

 * Update the test running examples to use ./xtf-runner
 * Correct two descriptions of issues fixed in Xen 4.7

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce 'hap' and 'shadow' variations
Andrew Cooper [Wed, 27 Jul 2016 12:24:01 +0000 (13:24 +0100)]
Introduce 'hap' and 'shadow' variations

Used for HVM-based tests pertaining to pagetable behaviour, which want running
both against both paging modes.

Modify the invlpg tests to run in both shadow and hap paging modes.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce test variations
Andrew Cooper [Wed, 27 Jul 2016 12:23:29 +0000 (13:23 +0100)]
Introduce test variations

In certain cases it will be useful to run the same test binary with different
configurations, providing logically separate results.

Introduce the concept of a test variation, which generates a different set of
configuraiton files referring to the same binary.  xtf-runner is updated to
understand variations.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agorunner: Rework test selection logic
Andrew Cooper [Fri, 29 Jul 2016 16:28:49 +0000 (16:28 +0000)]
runner: Rework test selection logic

The existing logic for test selection was awkward to use and somewhat
non-intuitive.  It also had an annoying habit of accidentially running the msr
utility and causing excessive logspam.

First of all, switch the all_{categories,environments} tuples to sets, which
allows for cleaner logic during selection.  Split all_categories into default
and non-default subsets, where the non-default subset is not available unless
explicitly referenced.

Introduce interpret_selection() with the purpse of interpreting a collection
of string parameter, and returning the commplete list of TestInstances covered
by the selection.

interpret_selection() is now called before action selection, and replaces the
existing ad-hoc logic in the list and run calls.  As a result, selections are
now identical for the list and run paths.

The --help documentation is also updated to reflect the new behaviour.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agorunner: Introduce TestInstance to wrap an individual test
Andrew Cooper [Mon, 1 Aug 2016 10:20:02 +0000 (11:20 +0100)]
runner: Introduce TestInstance to wrap an individual test

Implement vm_name() and cfg_path() methods to move those details out of the
test running logic.

Introduce parse_test_instance_string() as a single location tasked with
parsing the string representation of a test instance, and verifying the
provided information.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agorunner: Introduce TestInfo to wrap the raw test json
Andrew Cooper [Fri, 29 Jul 2016 15:31:26 +0000 (15:31 +0000)]
runner: Introduce TestInfo to wrap the raw test json

The constructor now performs appropriate verification on the json
configuration, rather than open-coding it in get_all_test_info().  Users of
the dictionary-like json are altered to use attributes.

An all_instances() method is added to return test instances for all suitable
environments, optionally with a subset filter.  This is used in preference to
three open-coded loops, generating instance names.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agorunner: Cache the combined test json
Andrew Cooper [Thu, 28 Jul 2016 11:54:26 +0000 (11:54 +0000)]
runner: Cache the combined test json

To avoid rereading the same data from the disk.  Later it will be needed on
several paths.  Additionally, rename 'test_info' to 'info_file' to make its
use more clear.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agorunner: Switch --host to being a real parameter
Andrew Cooper [Thu, 28 Jul 2016 11:47:00 +0000 (11:47 +0000)]
runner: Switch --host to being a real parameter

This avoids having extra magic parameters in the mix of categories,
environments and test names

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce .gitattributes
Andrew Cooper [Fri, 29 Jul 2016 13:02:42 +0000 (13:02 +0000)]
Introduce .gitattributes

This allows `git diff` and friends to be slightly more clever about generating
hunks for specific files.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agobuild: Generate xl configurations with a python script rather than by hand
Andrew Cooper [Tue, 26 Jul 2016 18:55:26 +0000 (19:55 +0100)]
build: Generate xl configurations with a python script rather than by hand

It is about to get more complicated.  Additionally, specify a dependency on
$(TEST-EXTRA-CFG) if specified by a test.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agomkinfo: Assign names to command line parameters
Andrew Cooper [Tue, 26 Jul 2016 18:53:18 +0000 (19:53 +0100)]
mkinfo: Assign names to command line parameters

This is easier to read, and has a side effect of bailing with a hard error if
the wrong number of parameters are passed.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoRename test-info.json to just info.json
Andrew Cooper [Mon, 25 Jul 2016 16:37:09 +0000 (17:37 +0100)]
Rename test-info.json to just info.json

There are enough files starting with test.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agobuild: Add move-if-changed helper
Andrew Cooper [Tue, 26 Jul 2016 15:33:43 +0000 (15:33 +0000)]
build: Add move-if-changed helper

And use it in preference to repeated opencoding

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoCorrect the usage of $(DESTDIR) and $(PREFIX)
Andrew Cooper [Wed, 20 Jul 2016 17:43:13 +0000 (18:43 +0100)]
Correct the usage of $(DESTDIR) and $(PREFIX)

The GNU coding standards expect $(DESTDIR) to be the root of everything
installed, and for $(PREFIX) to then be added to the path.  This is not how
XTF previously behaved.

XTF is not a typical package, and doesn't meet the usual semantics; it expects
to arrange all files under a single directory.  Drop the use of $(PREFIX)
entirely (to avoid the expectation that it behaves as $(prefix) usually
behaves) and introduce $(xtfdir) instead.

$(DESTDIR) now works as intended for staged installes, and $(xtfdir) is the
single selected directy containing all installed content.

The intended way to install XTF now:

  $ make install DESTDIR=/path/to/staging/area xtfdir=/local/scratch/xtf

Reported-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
8 years agoIntroduce $(INSTALL_DIR) and use it in preference to mkdir
Andrew Cooper [Thu, 21 Jul 2016 11:37:15 +0000 (12:37 +0100)]
Introduce $(INSTALL_DIR) and use it in preference to mkdir

Include the -p parameters by default for $(INSTALL*) variables rather than
opencoding them everywhere.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoIntroduce zeroptr[] for accessing virtual address 0
Andrew Cooper [Mon, 25 Jul 2016 15:29:03 +0000 (16:29 +0100)]
Introduce zeroptr[] for accessing virtual address 0

There are some times when access to 0 is really needed.  Use the linker to
work around NULL pointer logic in the compiler.

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