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