]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/log
people/andrewcoop/xen-test-framework.git
6 years agoldt vmfunc github/vmfunc
Andrew Cooper [Fri, 8 Feb 2019 12:59:32 +0000 (12:59 +0000)]
ldt

6 years agovmfunc
Andrew Cooper [Wed, 18 Jan 2017 13:51:16 +0000 (13:51 +0000)]
vmfunc

6 years agonested-vmx: exceptions take priority over VMFail*
Jan Beulich [Fri, 11 Jan 2019 09:50:20 +0000 (02:50 -0700)]
nested-vmx: exceptions take priority over VMFail*

The way the instruction invocations are coded, it is compiler version
dependent whether things work: With old gcc, fail_{,in}valid will not
get touched and hence remain at their initial values, while with newer
gcc evaluation of the status flags occurs outside of the asm(), i.e.
also when an exception was received (in which case EFLAGS didn't change
from its value before the faulting instruction).

Since it is more logical anyway to check for a possible exception first,
do so uniformly instead of trying to fiddle with the asm() in some way.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agoXSA-278 PoC
Andrew Cooper [Wed, 10 Oct 2018 10:09:12 +0000 (10:09 +0000)]
XSA-278 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agodebug-regs: Check the vcpu's initial register state
Andrew Cooper [Fri, 25 May 2018 10:04:32 +0000 (11:04 +0100)]
debug-regs: Check the vcpu's initial register state

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agodebug-regs: Detect the PV IO shadow handling bugs
Andrew Cooper [Fri, 1 Jun 2018 13:11:35 +0000 (14:11 +0100)]
debug-regs: Detect the PV IO shadow handling bugs

Also fix up some poor choice of constant names.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agoXSA-269 PoC
Andrew Cooper [Mon, 30 Jul 2018 17:32:06 +0000 (18:32 +0100)]
XSA-269 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agoXSA-265 PoC
Andrew Cooper [Mon, 25 Jun 2018 15:53:10 +0000 (16:53 +0100)]
XSA-265 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agoTSX intrinsics
Andrew Cooper [Sun, 29 Apr 2018 14:55:31 +0000 (15:55 +0100)]
TSX intrinsics

These are implemented to the GCC API, but are compatible with older
toolchains.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agoXSA-260: Work around toolchain problems with older GCC
Andrew Cooper [Tue, 5 Jun 2018 11:13:24 +0000 (12:13 +0100)]
XSA-260: Work around toolchain problems with older GCC

GCC 4.4.7 of RHEL/CentOS 6 vintage can't cope with an ebp/rbp register clobber
when compiling with frame pointers enabled.  Switch to ebx/rbx instead.

Reported-by: Glenn Enright <glenn@rimuhosting.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Glenn Enright <glenn@rimuhosting.com>
6 years agoXSA-261 PoC
Roger Pau Monne [Wed, 2 May 2018 14:22:35 +0000 (15:22 +0100)]
XSA-261 PoC

This requires adding some basic IO APIC and HPET functionality.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Compile fixes, misc cleanup and consistency improvements, and written
documentation.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agoXSA-260 PoC
Andrew Cooper [Thu, 22 Mar 2018 11:50:50 +0000 (11:50 +0000)]
XSA-260 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agox86/msr: Clean up MSR field declarations
Andrew Cooper [Thu, 24 May 2018 13:36:22 +0000 (14:36 +0100)]
x86/msr: Clean up MSR field declarations

 * Consistently use ULL for the benefit of 32bit builds
 * Drop leading MSR_ prefixes from bit names
 * Drop unnecessary bit-position defines

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agox86: mov to/from sreg can be encoded with a memory operand
Andrew Cooper [Thu, 10 May 2018 13:18:22 +0000 (14:18 +0100)]
x86: mov to/from sreg can be encoded with a memory operand

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoXSA-259 PoC
Andrew Cooper [Mon, 12 Mar 2018 13:35:23 +0000 (13:35 +0000)]
XSA-259 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoProperly bracket EXINFO()'s parameters before operating on them
Andrew Cooper [Wed, 2 May 2018 13:33:45 +0000 (14:33 +0100)]
Properly bracket EXINFO()'s parameters before operating on them

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoRudimentary syscall handling for PV guests
Andrew Cooper [Thu, 22 Mar 2018 11:50:50 +0000 (11:50 +0000)]
Rudimentary syscall handling for PV guests

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce __user_data
Andrew Cooper [Thu, 22 Mar 2018 11:50:50 +0000 (11:50 +0000)]
Introduce __user_data

Fix up the missing __user_text in Doxyfile, and the missing linker assertions
that the user bss boundaries are page aligned.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/io-apic: Fix 64bit MMIO accesses
Andrew Cooper [Fri, 13 Apr 2018 18:37:21 +0000 (19:37 +0100)]
x86/io-apic: Fix 64bit MMIO accesses

While most of the IO-APIC registers are 64 bits wide, the spec states that
they must be accessed with 32bit accesses.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce some basic IO-APIC infrastructure
Andrew Cooper [Fri, 13 Apr 2018 13:41:21 +0000 (13:41 +0000)]
Introduce some basic IO-APIC infrastructure

Replace some opencoded IOAPIC_DEFAULT_BASE constants.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce some basic HPET infrastructure
Roger Pau Monne [Fri, 30 Mar 2018 12:39:42 +0000 (13:39 +0100)]
Introduce some basic HPET infrastructure

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce __{KERN,USER}_{CS,DS}32 selector constants
Andrew Cooper [Mon, 9 Apr 2018 13:06:20 +0000 (14:06 +0100)]
Introduce __{KERN,USER}_{CS,DS}32 selector constants

These are intended to facilitate 64bit compatiblity mode segments, but are
exposed in 32bit builds as straight aliases of __{KERN,USER}_{CS,DS} for the
benefit of common code.

Fix up one opencoded use in the XSA-196 PoC.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce and use __user_page_aligned_bss
Andrew Cooper [Thu, 22 Mar 2018 11:50:50 +0000 (11:50 +0000)]
Introduce and use __user_page_aligned_bss

This avoids special casing user_stack[] as data, and allows the
!test_wants_user_mappings remapping logic to become entirely generic.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoUse a linker ASSERT() to check that the mappings are within l1_identmap[]
Andrew Cooper [Thu, 22 Mar 2018 11:50:50 +0000 (11:50 +0000)]
Use a linker ASSERT() to check that the mappings are within l1_identmap[]

This avoids needing the runtime checks in hvm's arch_init_traps()

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce and use __maybe_unused
Andrew Cooper [Thu, 22 Mar 2018 11:50:50 +0000 (11:50 +0000)]
Introduce and use __maybe_unused

This allows for the 32bit ifdefary of ex_pf_user to be dropped without
suffering a warning in the 64bit build, while still allowing LTO to drop the
function.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoXSA-255 PoC
Jan Beulich [Thu, 15 Feb 2018 17:28:09 +0000 (17:28 +0000)]
XSA-255 PoC

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoFix latent bug in 64bit exec_user_param()
Andrew Cooper [Wed, 4 Apr 2018 20:18:34 +0000 (21:18 +0100)]
Fix latent bug in 64bit exec_user_param()

Use a full %rsp reference rather than %esp.  Only a latent bug as the upper
bits will be clear.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce a basic test for debugging infrastructure
Andrew Cooper [Fri, 23 Mar 2018 15:38:05 +0000 (15:38 +0000)]
Introduce a basic test for debugging infrastructure

To begin with, this just checks that the PV %dr7 latch issue is resolved.
There are many more bugs to fix.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce new debug register definitions and helpers
Andrew Cooper [Fri, 23 Mar 2018 13:38:35 +0000 (13:38 +0000)]
Introduce new debug register definitions and helpers

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoFactor out debug register infrastructure into a new header
Andrew Cooper [Fri, 23 Mar 2018 13:17:05 +0000 (13:17 +0000)]
Factor out debug register infrastructure into a new header

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce update_desc() for updates to live descriptor entries
Andrew Cooper [Fri, 2 Mar 2018 14:19:56 +0000 (14:19 +0000)]
Introduce update_desc() for updates to live descriptor entries

GCC 4.4 from CentOS 6 is clever enough to turn the invlpg test's

  gdt[GDTE_AVAIL0] = GDTE_SYM(0, 1, COMMON, DATA, DPL0, B, W);
  write_fs(GDTE_AVAIL0 << 3);

into

  103927:       b8 48 00 00 00                  mov    $0x48,%eax
  10392c:       c7 05 48 f0 10 00 01 00 00 00   movl   $0x1,0x10f048
  103936:       8e e0                           mov    %eax,%fs
  103938:       c7 05 4c f0 10 00 00 93 c0 00   movl   $0xc09300,0x10f04c

which hardware rightfully complains about, as the descriptor isn't valid at
the point that %fs is loaded.

Introduce update_desc() which copes with PV and HVM differences, and enforces
a compiler barrier to prevent reordering of later operations.

Reported-by: Glenn Enright <glenn@rimuhosting.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoAdd more helpful GDTE() helpers
Andrew Cooper [Fri, 2 Mar 2018 14:02:35 +0000 (14:02 +0000)]
Add more helpful GDTE() helpers

All tests and some setup infrastructure need explicitly typed versions of
INIT_GDTE() and INIT_GDTE_SYM().  Introduce GDTE() and GDTE_SYM() to do just
this, and update the impacted users.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agovmx: Don't create strings[] on the stack of every vmx_insn_err_strerror() call
Andrew Cooper [Fri, 2 Mar 2018 13:19:53 +0000 (13:19 +0000)]
vmx: Don't create strings[] on the stack of every vmx_insn_err_strerror() call

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/apic: Set SPIV.EN in apic_init() so the device is ready for use
Andrew Cooper [Thu, 22 Feb 2018 17:21:34 +0000 (17:21 +0000)]
x86/apic: Set SPIV.EN in apic_init() so the device is ready for use

This is more useful behaviour than forcing all tests which call apic_init() to
set up SPIV themselves to actually receive interrupts.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoselftest: test x2apic basic initialisation as well if possible
Andrew Cooper [Thu, 22 Feb 2018 17:21:34 +0000 (17:21 +0000)]
selftest: test x2apic basic initialisation as well if possible

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoFix cdefs.h conflict with __section
Roger Pau Monne [Thu, 22 Feb 2018 12:03:48 +0000 (12:03 +0000)]
Fix cdefs.h conflict with __section

On FreeBSD the build fails with:

/root/src/xtf/include/xtf/compiler.h:13:9: error: '__section' macro redefined
      [-Werror,-Wmacro-redefined]
        ^
/usr/include/sys/cdefs.h:229:9: note: previous definition is here
        ^
1 error generated.

Only define __section if it's undefined in order to prevent conflicts.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoMemory operand and segment emulation tests
Andrew Cooper [Thu, 26 Oct 2017 10:31:31 +0000 (11:31 +0100)]
Memory operand and segment emulation tests

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoSupport the use of GDTs in PV guests
Andrew Cooper [Wed, 14 Feb 2018 17:37:09 +0000 (17:37 +0000)]
Support the use of GDTs in PV guests

GDT frames in PV guests need to be page aligned, and like pagetables, mapped
read-only.  Move gdt[] into __page_aligned_{data,bss} and leave it empty for
PV guests to begin with.

The PV arch_init_traps() code registers the frame with Xen, and tests wanting
to make use of it need to use hypercall_update_descriptor().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoAllow for fine tuning of the exec_user_* infrastructure
Andrew Cooper [Wed, 7 Feb 2018 10:41:41 +0000 (10:41 +0000)]
Allow for fine tuning of the exec_user_* infrastructure

At the moment, %cs, %ss and eflags are hard coded.  Introduce
exec_user_{cs,ss,efl_{and,or}_mask} with suitable defaults.

This allows for the complete removal of exec_user_with_iopl() from the pv-iopl
test, which can now use the common infrastructure.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoMove more includes into arch/xtf.h to ease writing tests
Andrew Cooper [Wed, 14 Feb 2018 18:24:46 +0000 (18:24 +0000)]
Move more includes into arch/xtf.h to ease writing tests

It is currently very hit and miss whether functionality is included, and some
current inclusions are already unnecessary.  Make it easier for tests by
putting all common includes in arch/xtf.h, so tests only have to include xtf.h

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years ago32bit: Save and restore %ds and %es when handling exceptions
Andrew Cooper [Wed, 14 Feb 2018 15:42:25 +0000 (15:42 +0000)]
32bit: Save and restore %ds and %es when handling exceptions

For tests which play with segments (especially those which reduce %ds.limit),
failing to restore usable segments can result in cascade failures (most
obviously when trying to poke characters into the console ring).

Remove the vm86 special case in handle_exception() and load __KERN_DS into %ds
and %es unconditionally.  Forgo the unconditional loading of %fs and %gs as
they are unreferenced in exception context.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce and use xenstore_init()
Andrew Cooper [Mon, 12 Feb 2018 11:33:42 +0000 (11:33 +0000)]
Introduce and use xenstore_init()

This really should have been introduced along with xenstore_read(), but the
problem only becomes apparent when booting an XTF test as the initial domain.
The presence of xenstore must not be assumed.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce a nested-svm skeleton test
Andrew Cooper [Mon, 12 Feb 2018 13:38:31 +0000 (13:38 +0000)]
Introduce a nested-svm skeleton test

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoRename the vvmx test to nested-vmx
Andrew Cooper [Mon, 12 Feb 2018 13:38:06 +0000 (13:38 +0000)]
Rename the vvmx test to nested-vmx

In preparation for introducing nested-svm as well.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoCope being booting as the initial domain
Andrew Cooper [Sun, 28 Jan 2018 18:23:27 +0000 (18:23 +0000)]
Cope being booting as the initial domain

When booted as the initial domain (most commonly in PV-shim mode), the console
and xenbus rings aren't configured, as it is the responsibility of the initial
domain to provide xenconsole/xenstored services for other domains.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoIntroduce support for booting with the PVH ABI
Andrew Cooper [Fri, 26 Jan 2018 16:39:15 +0000 (16:39 +0000)]
Introduce support for booting with the PVH ABI

All XTF HVM guests are compatible with the PVH ABI.  Populate the PHYS32_ENTRY
elfnote and stash the pvh_start_info pointer provided by the domain builder.

Skip the Qemu console setup when booting PVH.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoRename start_info to pv_start_info
Andrew Cooper [Wed, 31 Jan 2018 10:57:58 +0000 (10:57 +0000)]
Rename start_info to pv_start_info

In preparation to introduce pvh_start_info.  Rename the type to match, fix up
the accidental double extern, and move the variable into pv/traps.c to match
with its declaration in traps.h.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoxtf-runner: Sort tests by variation as well
Andrew Cooper [Thu, 28 Dec 2017 18:07:24 +0000 (18:07 +0000)]
xtf-runner: Sort tests by variation as well

This removes instability in the running order of tests with multiple
variations.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/msr: Introduce xtf_msr_consistency_test()
Andrew Cooper [Thu, 9 Nov 2017 12:09:06 +0000 (12:09 +0000)]
x86/msr: Introduce xtf_msr_consistency_test()

To help with testing the correctness of MSRs which may be passed directly
through to a guest.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86: Split out new msr.h header
Andrew Cooper [Thu, 9 Nov 2017 12:09:06 +0000 (12:09 +0000)]
x86: Split out new msr.h header

Move the {rd,wr}msr wrappers from lib.h and bitfield unions from msr-index.h
to here, leaving msr-index.h to be purely name definitions.

Correct an XFT typo in the msr-index.h header guards, and include msr.h in
arch/xtf.h to avoid tests needing to include msr-index.h manually

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoxtf-runner: Adjust whitespace when running multiple tests
Andrew Cooper [Fri, 17 Nov 2017 17:42:18 +0000 (17:42 +0000)]
xtf-runner: Adjust whitespace when running multiple tests

This visually distinguishes the one test run from the next.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoXSA-239 PoC
Andrew Cooper [Fri, 6 Oct 2017 13:37:10 +0000 (14:37 +0100)]
XSA-239 PoC

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoUpdate XSA-182 PoC to cope with linear pagetables being globally disabled
Andrew Cooper [Tue, 17 Oct 2017 10:46:42 +0000 (11:46 +0100)]
Update XSA-182 PoC to cope with linear pagetables being globally disabled

One mitigation for XSA-240 is a global disable of linear pagetables.  Cope in
such configurations by skipping the test.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agolibc: Fix strcpy() assignment mistake
Paul Semel [Wed, 11 Oct 2017 13:07:29 +0000 (13:07 +0000)]
libc: Fix strcpy() assignment mistake

the strcpy function was doing a comparison instead of doing an
assignment.

Signed-off-by: Paul Semel <phentex@amazon.de>
Reviewed-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Martin Pohlack <mpohlack@amazon.de>
Reviewed-and-tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
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>