Andrew Cooper [Tue, 7 May 2019 10:19:58 +0000 (11:19 +0100)]
Use named asm parameters for _ASM_EXTABLE_HANDLER()
LTO builds need to know that ex_record_fault_{eax,edi} are referenced from
within asm, to avoid the functions being discarded.
Previously, this was done with an "X" parameter listing the function twice,
but this can lead to copy/paste mistakes. Instead, use a named parameter and
the "p" type and "P" modifier, which works compatibly between GCC and Clang.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Andrew Cooper [Thu, 16 May 2019 18:12:33 +0000 (18:12 +0000)]
Simplify the unhandled_exception handling for tests
Tests, being single-purpose by their very nature, don't in practice use the
flexibility to change the unhandled exception hook. Furthermore, updating the
pointer has to be done carefully (i.e. with compiler barriers) because the
compiler doesn't see any connection between the hook and surrounding code
which may fault.
Switch to the using method already used by the syscall infrastructure and use
a single weak do_unhandled_exception() function which may be overridden by
guests wanting to implement their own custom behaviour.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Andrew Cooper [Fri, 10 May 2019 16:22:15 +0000 (16:22 +0000)]
Misc trivial code cleanup
* Use named asm parameters for non-trivial blocks
* "=r" (x) : "r" (x) is more commonly "+r" (x)
* Correct the header guard in x86-gate.h
* Remove brackets from absolute memory addresss
* Use unsigned int rather than unsigned long and forcing back to int with %k
* Drop unused ex_record_fault_eax reference
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Andrew Cooper [Sat, 11 May 2019 18:20:34 +0000 (19:20 +0100)]
libc: Fix strcmp() ABI violations
The C standard specifies that strcmp() interprets the provided strings as
unsigned char, rather than signed. This affects the result when used on
strings with the high bit set.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
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>
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>
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>