]> xenbits.xensource.com Git - people/iwj/xen.git/log
people/iwj/xen.git
7 years agofixup! libxl: pvshim: Provide first-class config settings to enable shim mode wip.pvshim
Ian Jackson [Fri, 12 Jan 2018 14:34:50 +0000 (14:34 +0000)]
fixup! libxl: pvshim: Provide first-class config settings to enable shim mode

Earlier versions of this patch have an erroneous hunk which will stop
PV guests from working at all!

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
7 years agoxl: Default guest mode changed from PV to PVH with PV shim
Ian Jackson [Fri, 5 Jan 2018 16:13:31 +0000 (16:13 +0000)]
xl: Default guest mode changed from PV to PVH with PV shim

If the config file specifies a type (or builder), it overrides this
default.  But if it doesn't, you now get a PV-in-PVH guest.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: New patch

7 years agoxl: pvshim: Provide and document xl config
Ian Jackson [Fri, 22 Dec 2017 16:12:23 +0000 (16:12 +0000)]
xl: pvshim: Provide and document xl config

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: pvshim, not pvhshim
    works with type "pvh", not type "pv"
    pvshim_etc. options in config are not erroneously ignored

7 years agolibxl: pvshim: Introduce pvshim_extra
Ian Jackson [Fri, 5 Jan 2018 15:59:29 +0000 (15:59 +0000)]
libxl: pvshim: Introduce pvshim_extra

And move the debugging options from the default config into a doc
comment in libxl_types.idl.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: pvshim, not pvhshim
    works with type "pvh", not type "pv"

7 years agolibxl: pvshim: Provide first-class config settings to enable shim mode
Ian Jackson [Fri, 5 Jan 2018 15:50:38 +0000 (15:50 +0000)]
libxl: pvshim: Provide first-class config settings to enable shim mode

This is API-compatible because old callers are supposed to call
libxl_*_init to initialise the struct; and the updated function clears
these members.

It is ABI-compatible because the new fields make this member of the
guest type union larger but only within the existing size of that
union.

Unfortunately it is not easy to backport because it depends on the PVH
domain type.  Attempts to avoid use of the PVH domain type involved
working with two views of the configuration: the "underlying" domain
type and the "visible" type (and corresponding config info).  Also
there are different sets of config settings for PV and PVH, which
callers would have to know to set.

And, unfortunately, it will not be possible, with this approach, to
enable the shim by default for all libxl callers.  (Although it could
perhaps be done in xl.)

For now, our config defaults are:
 * if enabled, path is "xen-shim" in the xen firmware directory
 * if enabled, cmdline is the one we are currently debugging with

The debugging arguments will be rationalised in a moment.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v2: pvshim, not pvhshim
    works with type "pvh", not type "pv"

7 years agopvgrub1: Disable build by default
Ian Jackson [Fri, 22 Dec 2017 16:14:30 +0000 (16:14 +0000)]
pvgrub1: Disable build by default

The change "tools/libxc: Multi modules support" breaks this build.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
7 years agoshim: Do not try to build 32-bit
Ian Jackson [Wed, 20 Dec 2017 15:56:05 +0000 (15:56 +0000)]
shim: Do not try to build 32-bit

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
7 years agolibxl: Introduce hack to allow PVH mode to add a shim
George Dunlap [Thu, 14 Dec 2017 16:16:20 +0000 (16:16 +0000)]
libxl: Introduce hack to allow PVH mode to add a shim

libxl will look for LIBXL_PVSHIM_PATH and LIBXL_PVSHIM_CMDLINE
environment variables.  If the first is present, it will boot with the
shim and the existing kernel / ramdisk.  (That is, the shim as the "kernel" and the
kernel and ramdisk both as extra modules.)

If not, it will just boot the kernel / ramdisk directly (that is, with
the kernel as "kernel" and the ramdisk as a module).

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
7 years agofirmware/xen-shim: Make a new copy of the xen tree to avoid dependencies
George Dunlap [Wed, 13 Dec 2017 16:54:08 +0000 (16:54 +0000)]
firmware/xen-shim: Make a new copy of the xen tree to avoid dependencies

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
7 years agoxen/pvshim: support vCPU hotplug
Roger Pau Monne [Tue, 12 Dec 2017 16:09:11 +0000 (16:09 +0000)]
xen/pvshim: support vCPU hotplug

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agosched/null: skip vCPUs on the waitqueue that are blocked
Roger Pau Monne [Wed, 13 Dec 2017 09:33:13 +0000 (09:33 +0000)]
sched/null: skip vCPUs on the waitqueue that are blocked

Avoid scheduling vCPUs that are blocked, there's no point in assigning
them to a pCPU because they are not going to run anyway.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agoxen/pvshim: add shim_mem cmdline parameter
Sergey Dyasli [Tue, 12 Dec 2017 10:56:32 +0000 (10:56 +0000)]
xen/pvshim: add shim_mem cmdline parameter

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
7 years agoxen/pvshim: add migration support
Roger Pau Monne [Thu, 7 Dec 2017 13:57:59 +0000 (13:57 +0000)]
xen/pvshim: add migration support

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agolibxl/pvh: allow PVH guests to use the xenstore shutdown
Roger Pau Monne [Thu, 7 Dec 2017 13:51:53 +0000 (13:51 +0000)]
libxl/pvh: allow PVH guests to use the xenstore shutdown

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agox86/pv-shim: shadow PV console's page for L2 DomU
Sergey Dyasli [Thu, 7 Dec 2017 15:42:14 +0000 (15:42 +0000)]
x86/pv-shim: shadow PV console's page for L2 DomU

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
7 years agoxen/pvshim: add grant table operations
Roger Pau Monne [Tue, 5 Dec 2017 16:22:03 +0000 (16:22 +0000)]
xen/pvshim: add grant table operations

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoxen/pvshim: forward evtchn ops between L0 Xen and L2 DomU
Roger Pau Monne [Thu, 7 Dec 2017 11:20:01 +0000 (11:20 +0000)]
xen/pvshim: forward evtchn ops between L0 Xen and L2 DomU

Note that the unmask and the virq operations are handled by the shim
itself, and that FIFO event channels are not exposed to the guest.

Signed-off-by: Anthony Liguori <aliguori@amazon.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
7 years agoxen/pvshim: set correct domid value
Roger Pau Monne [Tue, 5 Dec 2017 16:21:58 +0000 (16:21 +0000)]
xen/pvshim: set correct domid value

If domid is not provided by L0 set domid to 1 by default.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
7 years agoxen/pvshim: modify Dom0 builder in order to build a DomU
Roger Pau Monne [Fri, 8 Dec 2017 14:39:45 +0000 (14:39 +0000)]
xen/pvshim: modify Dom0 builder in order to build a DomU

According to the PV ABI the initial virtual memory regions should
contain the xenstore and console pages after the start_info. Fix this
and add the pages to the p2m/m2p after the start_info page also.

Also set the correct values in the start_info for DomU operation.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agoxen: mark xenstore/console pages as RAM and add them to dom_io
Roger Pau Monne [Tue, 5 Dec 2017 16:21:57 +0000 (16:21 +0000)]
xen: mark xenstore/console pages as RAM and add them to dom_io

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agoxen/pvshim: don't allow access to iomem or ioports
Roger Pau Monne [Tue, 5 Dec 2017 16:21:57 +0000 (16:21 +0000)]
xen/pvshim: don't allow access to iomem or ioports

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agoxen/pvshim: remove Dom0 kernel support check
Roger Pau Monne [Tue, 5 Dec 2017 16:21:57 +0000 (16:21 +0000)]
xen/pvshim: remove Dom0 kernel support check

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agoxen/x86: remove is_pv_domain leftovers from the PV domain builder
Roger Pau Monne [Tue, 5 Dec 2017 16:21:57 +0000 (16:21 +0000)]
xen/x86: remove is_pv_domain leftovers from the PV domain builder

Those where added when PVHv1 was sharing the domain builder with PV.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agoxen/dom0: remove autotranslate leftovers
Roger Pau Monne [Tue, 5 Dec 2017 16:21:56 +0000 (16:21 +0000)]
xen/dom0: remove autotranslate leftovers

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agoxen/guest: fix fetching wallclock
Roger Pau Monne [Wed, 6 Dec 2017 14:19:52 +0000 (14:19 +0000)]
xen/guest: fix fetching wallclock

Should be merged with 917862d2734.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agoxen/pvh: do not mark the low 1MB as IO mem
Roger Pau Monne [Thu, 30 Nov 2017 12:03:04 +0000 (12:03 +0000)]
xen/pvh: do not mark the low 1MB as IO mem

On PVH there's nothing special on the low 1MB

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoxen/x86: report domain id on cpuid
Roger Pau Monne [Thu, 30 Nov 2017 09:53:26 +0000 (09:53 +0000)]
xen/x86: report domain id on cpuid

Use the ebx register of the hypervisor leaf 1. The eax register on
this leaf is already used to report the Xen major and minor versions.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agoxen/x86: make VGA support selectable
Roger Pau Monne [Tue, 28 Nov 2017 09:54:17 +0000 (09:54 +0000)]
xen/x86: make VGA support selectable

Through a Kconfig option. Enable it by default, and disable it for the
PV-in-PVH shim.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agotools/libxc: Multi modules support
Jonathan Ludlam [Mon, 27 Nov 2017 16:18:58 +0000 (16:18 +0000)]
tools/libxc: Multi modules support

Signed-off-by: Jonathan Ludlam <jonathan.ludlam@citrix.com>
Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/pv-shim: Force CPUID faulting in pv-shim mode
Andrew Cooper [Fri, 24 Nov 2017 15:34:07 +0000 (15:34 +0000)]
x86/pv-shim: Force CPUID faulting in pv-shim mode

This is necessary to prevent the PV guest seeing HVM Xen leaves via native
cpuid.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86: Common cpuid faulting support
Andrew Cooper [Sat, 25 Nov 2017 15:07:12 +0000 (15:07 +0000)]
x86: Common cpuid faulting support

With CPUID Faulting offered to SVM guests, move Xen's faulting code to being
common rather than Intel specific.

This is necessary for nested Xen (inc. pv-shim mode) to prevent PV guests from
finding the outer HVM Xen leaves via native cpuid.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/svm: Offer CPUID Faulting to AMD HVM guests as well
Andrew Cooper [Fri, 24 Nov 2017 21:03:28 +0000 (21:03 +0000)]
x86/svm: Offer CPUID Faulting to AMD HVM guests as well

CPUID Faulting can be virtulised for HVM guests without hardware support,
meaning it can be offered to SVM guests.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agotools/firmware: Build and install xen-shim
Andrew Cooper [Wed, 22 Nov 2017 13:31:26 +0000 (13:31 +0000)]
tools/firmware: Build and install xen-shim

XXX: Probably very broken, many TODO

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years ago--- x86/shim: Kconfig and command line options
Andrew Cooper [Fri, 10 Nov 2017 16:35:26 +0000 (16:35 +0000)]
--- x86/shim: Kconfig and command line options

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/guest: use PV console for Xen/Dom0 I/O
Sergey Dyasli [Fri, 24 Nov 2017 11:21:17 +0000 (11:21 +0000)]
x86/guest: use PV console for Xen/Dom0 I/O

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
7 years agox86/guest: add PV console code
Sergey Dyasli [Fri, 24 Nov 2017 11:07:32 +0000 (11:07 +0000)]
x86/guest: add PV console code

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/guest: enable event channels upcalls
Sergey Dyasli [Thu, 23 Nov 2017 15:09:00 +0000 (15:09 +0000)]
x86/guest: enable event channels upcalls

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86: don't swallow the first command line item in pvh mode
Wei Liu [Fri, 17 Nov 2017 16:40:10 +0000 (16:40 +0000)]
x86: don't swallow the first command line item in pvh mode

Instead, special case GRUB1 rather assuming that all bootloaders except GRUB2
need a parameter stripping.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86: read wallclock from Xen running in pvh mode
Wei Liu [Fri, 17 Nov 2017 15:19:09 +0000 (15:19 +0000)]
x86: read wallclock from Xen running in pvh mode

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
7 years agox86: APIC timer calibration
Wei Liu [Fri, 17 Nov 2017 12:46:41 +0000 (12:46 +0000)]
x86: APIC timer calibration

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
7 years agox86: xen pv clock time source
Wei Liu [Thu, 16 Nov 2017 17:56:18 +0000 (17:56 +0000)]
x86: xen pv clock time source

It is a variant of TSC clock source.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agox86: initialise shared_info page
Wei Liu [Wed, 15 Nov 2017 16:52:00 +0000 (16:52 +0000)]
x86: initialise shared_info page

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoxen/console: Introduce console=xen
Andrew Cooper [Thu, 23 Nov 2017 10:59:59 +0000 (10:59 +0000)]
xen/console: Introduce console=xen

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/pvh: Retrieve memory map from Xen
Wei Liu [Tue, 14 Nov 2017 18:19:09 +0000 (18:19 +0000)]
x86/pvh: Retrieve memory map from Xen

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/shutdown: Support for using SCHEDOP_{shutdown,reboot}
Andrew Cooper [Tue, 21 Nov 2017 14:43:32 +0000 (14:43 +0000)]
x86/shutdown: Support for using SCHEDOP_{shutdown,reboot}

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/guest: Hypercall support
Andrew Cooper [Tue, 21 Nov 2017 13:54:47 +0000 (13:54 +0000)]
x86/guest: Hypercall support

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/entry: Probe for Xen early during boot
Andrew Cooper [Tue, 28 Nov 2017 14:53:51 +0000 (14:53 +0000)]
x86/entry: Probe for Xen early during boot

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/boot: Map more than the first 16MB
Andrew Cooper [Wed, 22 Nov 2017 11:39:04 +0000 (11:39 +0000)]
x86/boot: Map more than the first 16MB

TODO: Replace somehow (bootstrap_map() ?)

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/entry: Early PVH boot code
Wei Liu [Mon, 13 Nov 2017 17:32:19 +0000 (17:32 +0000)]
x86/entry: Early PVH boot code

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86: produce a binary that can be booted as PVH
Wei Liu [Fri, 10 Nov 2017 16:19:40 +0000 (16:19 +0000)]
x86: produce a binary that can be booted as PVH

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86: introduce ELFNOTE macro
Wei Liu [Fri, 10 Nov 2017 12:36:49 +0000 (12:36 +0000)]
x86: introduce ELFNOTE macro

It is needed later for introducing PVH entry point.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
7 years agox86/link: Relocate program headers
Andrew Cooper [Wed, 22 Nov 2017 11:09:41 +0000 (11:09 +0000)]
x86/link: Relocate program headers

7 years agotools/libelf: fix elf notes check for PVH guest
Wei Liu [Tue, 14 Nov 2017 18:18:16 +0000 (18:18 +0000)]
tools/libelf: fix elf notes check for PVH guest

PVH only requires PHYS32_ENTRY to be set. Return immediately if that's
the case.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years ago---- x86/Kconfig: Options for Xen and PVH support
Andrew Cooper [Fri, 10 Nov 2017 16:35:26 +0000 (16:35 +0000)]
---- x86/Kconfig: Options for Xen and PVH support

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/fixmap: Modify fix_to_virt() to return a void pointer
Andrew Cooper [Tue, 28 Nov 2017 18:30:15 +0000 (18:30 +0000)]
x86/fixmap: Modify fix_to_virt() to return a void pointer

Almost all users of fix_to_virt() actually want a pointer.  Include the cast
within the definition, so the callers don't need to.

Two users which need the integer value are switched to using __fix_to_virt()
directly.  A few users stay fully unchanged, due to GCC's void pointer
arithmetic extension causing the same behaviour.  Most users however have
their explicit casting dropped.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agotools/ocaml: Extend domain_create() to take arch_domainconfig
Jon Ludlam [Thu, 30 Nov 2017 19:06:57 +0000 (19:06 +0000)]
tools/ocaml: Extend domain_create() to take arch_domainconfig

No longer passing NULL into xc_domain_create() allows for the creation
of PVH guests.

Signed-off-by: Jon Ludlam <jonathan.ludlam@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agotools/ocaml: Expose arch_config in domaininfo
Andrew Cooper [Thu, 23 Nov 2017 12:21:15 +0000 (12:21 +0000)]
tools/ocaml: Expose arch_config in domaininfo

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoxen/domctl: Return arch_config via getdomaininfo
Andrew Cooper [Thu, 23 Nov 2017 11:09:09 +0000 (11:09 +0000)]
xen/domctl: Return arch_config via getdomaininfo

This allows toolstack software to distinguish HVM from PVH guests.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoxen/acpi: mark the PM timer FADT field as optional
Roger Pau Monne [Tue, 28 Nov 2017 11:20:11 +0000 (11:20 +0000)]
xen/acpi: mark the PM timer FADT field as optional

According to the ACPI 6.1 specification this field is optional, so
mark it as such.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agox86/link: Introduce and use SECTION_ALIGN
Andrew Cooper [Wed, 22 Nov 2017 10:35:13 +0000 (10:35 +0000)]
x86/link: Introduce and use SECTION_ALIGN

... to reduce the quantity of #ifdef EFI.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
7 years agox86/time: Print a more helpful error when a platform timer can't be found
Andrew Cooper [Wed, 15 Nov 2017 17:37:16 +0000 (17:37 +0000)]
x86/time: Print a more helpful error when a platform timer can't be found

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoxen/common: Widen the guest logging buffer slightly
Andrew Cooper [Fri, 17 Nov 2017 15:39:38 +0000 (15:39 +0000)]
xen/common: Widen the guest logging buffer slightly

This reduces the amount of line wrapping from guests; Xen in particular likes
to print lines longer than 80 characters.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agotools/libxc: remove extraneous newline in xc_dom_load_acpi
Wei Liu [Tue, 14 Nov 2017 18:18:15 +0000 (18:18 +0000)]
tools/libxc: remove extraneous newline in xc_dom_load_acpi

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agotools/libxc: initialise hvm loader elf log fd to get more logging
Wei Liu [Tue, 14 Nov 2017 18:18:14 +0000 (18:18 +0000)]
tools/libxc: initialise hvm loader elf log fd to get more logging

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/HVM: don't retain emulated insn cache when exiting back to guest
Jan Beulich [Wed, 6 Dec 2017 11:50:23 +0000 (12:50 +0100)]
x86/HVM: don't retain emulated insn cache when exiting back to guest

vio->mmio_retry is being set when a repeated string insn is being split
up. In that case we'll exit to the guest, expecting immediate re-entry.
Interruptions, however, may be serviced by the guest before re-entry
from the repeated string insn. Any emulation needed in the course of
handling the interruption must not fetch from the internally maintained
cache.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
7 years agodrop stray .0 from hypervisor version
Jan Beulich [Tue, 5 Dec 2017 16:25:40 +0000 (17:25 +0100)]
drop stray .0 from hypervisor version

7 years agox86: don't ignore foreigndom on L2/L3/L4 page table updates
Jan Beulich [Tue, 5 Dec 2017 16:23:53 +0000 (17:23 +0100)]
x86: don't ignore foreigndom on L2/L3/L4 page table updates

Silently assuming DOMID_SELF is unlikely to be a good idea for page
table updates. For PGT_writable pages, though, it seems better to allow
the writes, so the same check isn't being applied there.

Also add blank lines between the individual case blocks.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86: tighten MMU_*PT_UPDATE* check and combine error paths
Jan Beulich [Tue, 5 Dec 2017 16:23:18 +0000 (17:23 +0100)]
x86: tighten MMU_*PT_UPDATE* check and combine error paths

Don't accept anything other than r/w RAM pages as page table pages and
move the paged-out check into the (unlikely) error path following that
check.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/mm: drop yet another relic of translated PV domains from new_guest_cr3()
Jan Beulich [Tue, 5 Dec 2017 16:22:31 +0000 (17:22 +0100)]
x86/mm: drop yet another relic of translated PV domains from new_guest_cr3()

The function can be called for PV domains only, which commit 5a0b9fba92
("x86/mm: drop further relics of translated PV domains") sort of
realized, but not fully.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/HVM: tighten re-issue check in hvmemul_do_io()
Jan Beulich [Tue, 5 Dec 2017 16:18:37 +0000 (17:18 +0100)]
x86/HVM: tighten re-issue check in hvmemul_do_io()

I'm not sure why we had left out the address check in case of indirect
accesses (where "data" holds a guest physical address).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoXSM/flask: constification of IRQ mapping interfaces
Jan Beulich [Tue, 5 Dec 2017 16:17:57 +0000 (17:17 +0100)]
XSM/flask: constification of IRQ mapping interfaces

This clarifies that the involved structures are read-only.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
7 years agox86/MSI: leverage local variables
Jan Beulich [Tue, 5 Dec 2017 16:17:23 +0000 (17:17 +0100)]
x86/MSI: leverage local variables

... instead of using redundant calculations.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoefi: use ROUNDUP() macro instead of open code
Daniel Kiper [Tue, 5 Dec 2017 16:16:04 +0000 (17:16 +0100)]
efi: use ROUNDUP() macro instead of open code

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
7 years agognttab: improve GNTTABOP_cache_flush locking
Jan Beulich [Mon, 4 Dec 2017 10:04:18 +0000 (11:04 +0100)]
gnttab: improve GNTTABOP_cache_flush locking

Dropping the lock before returning from grant_map_exists() means handing
possibly stale information back to the caller. Return back the pointer
to the active entry instead, for the caller to release the lock once
done.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andre Przywara <andre.przywara@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agognttab: correct GNTTABOP_cache_flush empty batch handling
Jan Beulich [Mon, 4 Dec 2017 10:03:32 +0000 (11:03 +0100)]
gnttab: correct GNTTABOP_cache_flush empty batch handling

Jann validly points out that with a caller bogusly requesting a zero-
element batch with non-zero high command bits (the ones used for
continuation encoding), the assertion right before the call to
hypercall_create_continuation() would trigger. A similar situation would
arise afaict for non-empty batches with op and/or length zero in every
element.

While we want the former to succeed (as we do elsewhere for similar
no-op requests), the latter can clearly be converted to an error, as
this is a state that can't be the result of a prior operation.

Take the opportunity and also correct the order of argument checks:
We shouldn't accept zero-length elements with unknown bits set in "op".
Also constify cache_flush()'s first parameter.

Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andre Przywara <andre.przywara@linaro.org>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agopci: introduce a type to store a SBDF
Roger Pau Monné [Mon, 4 Dec 2017 10:02:46 +0000 (11:02 +0100)]
pci: introduce a type to store a SBDF

That provides direct access to all the members that constitute a SBDF.
The only function switched to use it is hvm_pci_decode_addr, because
it makes following patches simpler.

Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
7 years agox86/pio: allow internal PIO handlers to return RETRY
Roger Pau Monné [Mon, 4 Dec 2017 10:02:16 +0000 (11:02 +0100)]
x86/pio: allow internal PIO handlers to return RETRY

Fix handle_pio so internal PIO handlers can return X86EMUL_RETRY and
it is properly handled by not advancing the IP.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
7 years agolibelf: allow having HYPERCALL_PAGE entry before VIRT_BASE in __xen_guest section
Gregory Herrero [Mon, 4 Dec 2017 10:01:48 +0000 (11:01 +0100)]
libelf: allow having HYPERCALL_PAGE entry before VIRT_BASE in __xen_guest section

When filling __xen_guest section of a guest, user may define
HYPERCALL_PAGE earlier than VIRT_BASE in the section leading to an
incorrect hypercall page address since an undefined virt_base could be
used to compute hypercall page address.
If there is no VIRT_BASE entry in __xen_guest section, default value of
0 is used for virt_base. Thus, setting hypercall page address to
HYPERCALL_PAGE value is correct in this case too.

Signed-off-by: Gregory Herrero <gregory.herrero@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/physdev: remove redundant code in branch MAP_PIRQ_TYPE_MSI
Zhenzhong Duan [Mon, 4 Dec 2017 10:01:24 +0000 (11:01 +0100)]
x86/physdev: remove redundant code in branch MAP_PIRQ_TYPE_MSI

Same code is already in allocate_and_map_msi_pirq()

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
Reviewed-by: Joe Jin <joe.jin@oracle.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/boot: rename send_chr to print_err
David Esler [Mon, 4 Dec 2017 10:00:24 +0000 (11:00 +0100)]
x86/boot: rename send_chr to print_err

The send_chr function sends an entire C-string and not one character and
doesn't necessarily just send it over the serial UART anymore so rename
it to print_err so that its closer in name to what it does.

Signed-off-by: David Esler <drumandstrum@gmail.com>
Reviewed-by: Doug Goldstein <cardoe@cardoe.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agox86/svm: Add virtual GIF support
Brian Woods [Thu, 16 Nov 2017 22:11:15 +0000 (16:11 -0600)]
x86/svm: Add virtual GIF support

This patch detects and enables Virtual GIF if available.  This allows
a nested hypervisor to perform STGIs and CLGIs without having to be
intercepted by host hypervisor.

Signed-off-by: Brian Woods <brian.woods@amd.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/svm: Add virtual GIF feature definition
Brian Woods [Thu, 16 Nov 2017 22:11:14 +0000 (16:11 -0600)]
x86/svm: Add virtual GIF feature definition

Add support for enabling the virtual GIF feature.

Signed-off-by: Brian Woods <brian.woods@amd.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/traps: Drop redundant printk() in fatal_trap()
Andrew Cooper [Tue, 28 Nov 2017 18:48:07 +0000 (18:48 +0000)]
x86/traps: Drop redundant printk() in fatal_trap()

show_page_walk() already prints the linear address of the walk, and
show_execution_state() has printed a raw %cr2 value.  This avoids having
two adjacent log lines with identical information.

  (XEN) Faulting linear address: 00000000025ff028
  (XEN) Pagetable walk from 00000000025ff028:
  ...

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/vmx: Drop more PVHv1 remenants
Andrew Cooper [Mon, 20 Nov 2017 13:18:45 +0000 (13:18 +0000)]
x86/vmx: Drop more PVHv1 remenants

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
7 years agox86/pvh: Do not add DSDT and FACS to PVH dom0 XSDT
Boris Ostrovsky [Thu, 9 Nov 2017 15:37:53 +0000 (10:37 -0500)]
x86/pvh: Do not add DSDT and FACS to PVH dom0 XSDT

These tables are pointed to from FADT. Adding them will
result in duplicate entries in the guest's tables.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
7 years agox86/vvmx: Remove enum vmx_regs_enc
Euan Harris [Thu, 26 Oct 2017 17:03:11 +0000 (18:03 +0100)]
x86/vvmx: Remove enum vmx_regs_enc

This is the standard register encoding, is not VVMX-specific and is only
used in a couple of places.

Signed-off-by: Euan Harris <euan.harris@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
7 years agox86/vvmx: don't enable vmcs shadowing for nested guests
Sergey Dyasli [Mon, 23 Oct 2017 09:33:02 +0000 (10:33 +0100)]
x86/vvmx: don't enable vmcs shadowing for nested guests

Running "./xtf_runner vvmx" in L1 Xen under L0 Xen produces the
following result on H/W with VMCS shadowing:

    Test: vmxon
    Failure in test_vmxon_in_root_cpl0()
      Expected 0x8200000f: VMfailValid(15) VMXON_IN_ROOT
           Got 0x82004400: VMfailValid(17408) <unknown>
    Test result: FAILURE

This happens because SDM allows vmentries with enabled VMCS shadowing
VM-execution control and VMCS link pointer value of ~0ull. But results
of a nested VMREAD are undefined in such cases.

Fix this by not copying the value of VMCS shadowing control from vmcs01
to vmcs02.

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
7 years agox86/svm: add virtual VMLOAD/VMSAVE support
Brian Woods [Tue, 31 Oct 2017 22:03:08 +0000 (17:03 -0500)]
x86/svm: add virtual VMLOAD/VMSAVE support

On AMD family 17h server processors, there is a feature called virtual
VMLOAD/VMSAVE.  This allows a nested hypervisor to preform a VMLOAD or
VMSAVE without needing to be intercepted by the host hypervisor.
Virtual VMLOAD/VMSAVE requires the host hypervisor to be in long mode
and nested page tables to be enabled.  For more information about it
please see:

AMD64 Architecture Programmer’s Manual Volume 2: System Programming
http://support.amd.com/TechDocs/24593.pdf
Section: VMSAVE and VMLOAD Virtualization (Section 15.33.1)

This patch series adds support to check for and enable the virtual
VMLOAD/VMSAVE features if available.

Signed-off-by: Brian Woods <brian.woods@amd.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
7 years agox86/svm: add virtual VMLOAD/VMSAVE feature definition
Brian Woods [Tue, 31 Oct 2017 22:03:07 +0000 (17:03 -0500)]
x86/svm: add virtual VMLOAD/VMSAVE feature definition

Adding support for enabling the virtual VMLOAD/VMSAVE feature..

Signed-off-by: Brian Woods <brian.woods@amd.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
7 years agox86/svm: rename lbr control field in vmcb
Brian Woods [Tue, 31 Oct 2017 22:03:06 +0000 (17:03 -0500)]
x86/svm: rename lbr control field in vmcb

Rename the lbr_control field in the vmcb for future/upcoming changes.

Signed-off-by: Brian Woods <brian.woods@amd.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
7 years agox86_64/mm: drop redundant MFN to page conventions in cleanup_frame_table()
Haozhong Zhang [Mon, 11 Sep 2017 04:37:43 +0000 (12:37 +0800)]
x86_64/mm: drop redundant MFN to page conventions in cleanup_frame_table()

Replace pdx_to_page(pfn_to_pdx(pfn)) by mfn_to_page(pfn), which is
identical to the former.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/vmx: Don't use rdmsr() to fill HOST_SYSENTER_{CS,EIP}
Andrew Cooper [Fri, 20 Oct 2017 13:56:23 +0000 (14:56 +0100)]
x86/vmx: Don't use rdmsr() to fill HOST_SYSENTER_{CS,EIP}

These are compile-time constants, and don't need to be read back from
hardware.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
7 years agox86/vmx: Don't rewrite HOST_TR_SELECTOR on every context switch
Andrew Cooper [Tue, 17 Oct 2017 17:06:23 +0000 (18:06 +0100)]
x86/vmx: Don't rewrite HOST_TR_SELECTOR on every context switch

TSS_ENTRY is a compile time constant, so HOST_TR_SELECTOR can be set up during
VMCS construction and left alone thereafter, rather than rewriting it on every
context switch.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
7 years agox86/pv: Misc improvements to pv_destroy_gdt()
Andrew Cooper [Tue, 3 Oct 2017 18:46:40 +0000 (19:46 +0100)]
x86/pv: Misc improvements to pv_destroy_gdt()

Hoist the l1e_from_pfn(zero_pfn, __PAGE_HYPERVISOR_RO) calculation out of the
loop, and switch the code over to using mfn_t.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/pv: Use DIV_ROUND_UP() when converting between GDT entries and frames
Andrew Cooper [Tue, 3 Oct 2017 15:30:54 +0000 (15:30 +0000)]
x86/pv: Use DIV_ROUND_UP() when converting between GDT entries and frames

Also consistently use use nr_frames, rather than mixing nr_pages with a
frames[] array.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/pv: Move compat_set_gdt() to be beside do_set_gdt()
Andrew Cooper [Tue, 3 Oct 2017 15:30:01 +0000 (15:30 +0000)]
x86/pv: Move compat_set_gdt() to be beside do_set_gdt()

This also makes the do_update_descriptor() pair of functions adjacent.

Purely code motion; no functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/pv: Factor out the calculation of LDT/GDT descriptor pointers
Andrew Cooper [Fri, 13 Oct 2017 10:55:00 +0000 (10:55 +0000)]
x86/pv: Factor out the calculation of LDT/GDT descriptor pointers

Rather than opencoding it in two places.  While only used in the PV emulation
code, this helper is in principle usable anywhere in the hypervisor.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
7 years agoxen/pv: Construct d0v0's GDT properly
Andrew Cooper [Mon, 16 Oct 2017 13:20:07 +0000 (13:20 +0000)]
xen/pv: Construct d0v0's GDT properly

c/s cf6d39f8199 "x86/PV: properly populate descriptor tables" changed the GDT
to reference zero_page for intermediate frames between the guest and Xen
frames.

Because dom0_construct_pv() doesn't call arch_set_info_guest(), some bits of
initialisation are missed, including the pv_destroy_gdt() which initially
fills the references to zero_page.

In practice, this means there is a window between starting and the first call
to HYPERCALL_set_gdt() were lar/lsl/verr/verw suffer non-architectural
behaviour.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
This probably wants backporting to Xen 4.7 and later.

7 years agox86/ldt: Alter how invalidate_shadow_ldt() deals with TLB flushes
Andrew Cooper [Mon, 2 Oct 2017 14:13:38 +0000 (14:13 +0000)]
x86/ldt: Alter how invalidate_shadow_ldt() deals with TLB flushes

Modify invalidate_shadow_ldt() to return a boolean indicating whether mappings
have been dropped, rather than taking a flush parameter.  Tweak the internal
logic to be able to ASSERT() that v->arch.pv_vcpu.shadow_ldt_mapcnt matches
the number of PTEs removed.

This allows MMUEXTOP_SET_LDT to avoid a local TLB flush if no LDT entries had
been faulted in to begin with.

Finally, correct a comment in __get_page_type().  Under no circumstance is it
safe to forgo the TLB shootdown for GDT/LDT pages, as that would allow one
vcpu to gain a writeable mapping to a frame still mapped as a GDT/LDT by
another vcpu.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agoxen/x86: Introduce static inline wrappers for l{idt,gdt,ldt,tr}()
Andrew Cooper [Mon, 2 Oct 2017 13:58:17 +0000 (13:58 +0000)]
xen/x86: Introduce static inline wrappers for l{idt,gdt,ldt,tr}()

This avoids indirection and parameter constraint issues.  Doing so relaxes the
load_LDT() constraints from %ax to any general purpose register.  The helpers
are upgraded to full compiler barriers, because nothing good will come of
having these reordered with respect to other segment accesses.

The triple-fault reboot method stays as is, to avoid the int3 possibly getting
moved relative to the lidt.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>