Commit Graph
36828 Commits
Author SHA1 Message Date
Ian Jackson 8d2983ec79 Revert "xl: Default guest mode changed from PV to PVH with PV shim"
This breaks ARM.  It should be protected by some x86 #if.  For now,
revert it, as it's not critical (and it isn't included in the
comet/vixen security patch branches published via XSA-254).

This reverts commit 63080b7043.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Julien Grall <julien.grall@linaro.org>
2018-01-17 14:29:24 +00:00
Wei Liu db3ae8becc tools: fix arm build after bdf693ee61
The ramdisk fields were removed. We should use modules[0] instead.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2018-01-17 11:32:23 +00:00
Wei Liu 36c560e7f3 Don't build xen-shim for 32 bit build host
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:56:45 +00:00
Ian Jackson 63080b7043 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>
2018-01-16 18:34:05 +00:00
Ian Jackson 3115091dde xl: pvshim: Provide and document xl config
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:05 +00:00
Ian Jackson fb65102f8a 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>
2018-01-16 18:34:05 +00:00
Ian Jackson 62982da926 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>
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:05 +00:00
Roger Pau Monne 62269fdcd4 xen/shim: allow DomU to have as many vcpus as available
Since the shim VCPUOP_{up/down} hypercall is wired to the plug/unplug
of CPUs to the shim itself, start the shim DomU with only the BSP
online, and let the guest bring up other CPUs as it needs them.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
2018-01-16 18:34:05 +00:00
Roger Pau Monne 9633299703 xen/shim: crash instead of reboot in shim mode
All guest shutdown operations are forwarded to L0, so the only native
calls to machine_restart happen from crash related paths inside the
hypervisor, hence switch the reboot code to instead issue a crash
shutdown.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
[ wei: fix arm build ]
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:05 +00:00
Roger Pau Monne 8aeda5e06a xen/pvshim: use default position for the m2p mappings
When running a 32bit kernel as Dom0 on a 64bit hypervisor the
hypervisor will try to shrink the hypervisor hole to the minimum
needed, and thus requires the Dom0 to use XENMEM_machphys_mapping in
order to fetch the position of the start of the hypervisor virtual
mappings.

Disable this feature when running as a PV shim, since some DomU
kernels don't implemented XENMEM_machphys_mapping and break if the m2p
doesn't begin at the default address.

NB: support for the XENMEM_machphys_mapping was added in Linux by
commit 7e7750.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-01-16 18:34:05 +00:00
Roger Pau Monne 4c543dc0a1 xen/shim: modify shim_mem parameter behaviour
shim_mem will now account for both the memory used by the hypervisor
loaded in memory and the free memory slack given to the shim for
runtime usage.

From experimental testing it seems like the total amount of MiB used
by the shim (giving it ~1MB of free memory for runtime) is:

memory/113 + 20

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
2018-01-16 18:34:05 +00:00
Roger Pau Monne b2245acc60 xen/pvshim: memory hotplug
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
2018-01-16 18:34:05 +00:00
Roger Pau Monne 129e09b515 xen/pvshim: support vCPU hotplug
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
2018-01-16 18:34:05 +00:00
Roger Pau Monne b667d9f62f xen/pvshim: set max_pages to the value of tot_pages
So that the guest is not able to deplete the memory pool of the shim
itself by trying to balloon up.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-01-16 18:34:05 +00:00
Sergey Dyasli daed6261fd xen/pvshim: add shim_mem cmdline parameter
Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
2018-01-16 18:34:05 +00:00
Roger Pau Monne e89cb79aae xen/pvshim: add migration support
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
2018-01-16 18:34:05 +00:00
Sergey Dyasli 5ef49f185c x86/pv-shim: shadow PV console's page for L2 DomU
Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
[remove notify_guest helper and directly use pv_shim_inject_evtchn]
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:05 +00:00
Roger Pau Monne 49f79fe03d 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>
2018-01-16 18:34:05 +00:00
Roger Pau Monne 368ae9a05f 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: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
2018-01-16 18:34:05 +00:00
Roger Pau Monne 785190fa86 xen/pvshim: set correct domid value
If domid is not provided by L0 set domid to 1 by default. Note that L0
not provinding the domid can cause trouble if the guest tries to use
it's domid instead of DOMID_SELF when performing hypercalls that are
forwarded to the L0 hypervisor.

Since the domain created is no longer the hardware domain add a hook
to the domain shutdown path in order to forward shutdown operations to
the L0 hypervisor.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
2018-01-16 18:34:05 +00:00
Roger Pau Monne 4be9107b34 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. Also set
the correct values in the start_info for DomU operation.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
2018-01-16 18:34:05 +00:00
Roger Pau Monne b968719e2d xen: mark xenstore/console pages as RAM
This si required so that later they can be shared with the guest if
Xen is running in shim mode.

Also prevent them from being used by Xen by marking them as bad pages
in init_boot_pages.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:05 +00:00
Roger Pau Monne d9527b2a51 xen/pvshim: skip Dom0-only domain builder parts
Do not allow access to any iomem or ioport by the shim, and also
remove the check for Dom0 kernel support.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-01-16 18:34:05 +00:00
Roger Pau Monne 01fe63ce35 xen/pvh: do not mark the low 1MB as IO mem
On PVH there's nothing special on the low 1MB.

This is an optional patch that doesn't affect the functionality of the
shim.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-01-16 18:34:05 +00:00
Roger Pau Monne ebb26b509f 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>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2018-01-16 18:34:04 +00:00
Andrew Cooper 4ee1b6eb8a tools/firmware: Build and install xen-shim
Link a minimum set of files to build the shim. The linkfarm rune can
handle creation and deletion of files. Introduce build-shim and
install-shim targets in xen/Makefile.

We can do better by properly generate the dependency from the list of
files but that's an improvement for later.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:04 +00:00
Andrew Cooper 6d101e6be5 x86/shim: Kconfig and command line options
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:04 +00:00
Sergey Dyasli 4f6609d6a6 x86/guest: use PV console for Xen/Dom0 I/O
Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:04 +00:00
Sergey Dyasli 335eba772b x86/guest: add PV console code
Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:04 +00:00
Roger Pau Monne 010e95e399 x86/guest: setup event channel upcall vector
And a dummy event channel upcall handler.

Note that with the current code the underlying Xen (L0) must support
HVMOP_set_evtchn_upcall_vector or else event channel setup is going to
fail. This limitation can be lifted by implementing more event channel
interrupt injection methods as a backup.

Register callback_irq to trick toolstack to think the domain is
enlightened.

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:04 +00:00
Wei Liu 1557ebd863 x86: don't swallow the first command line item in guest mode
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:04 +00:00
Wei Liu fe18227d82 x86: read wallclock from Xen when running in pvh mode
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2018-01-16 18:34:04 +00:00
Wei Liu 02e0de0115 x86: APIC timer calibration when running as a guest
The timer calibration currently depends on PIT. Introduce a variant
to wait for a tick's worth of time to elapse when running as a PVH
guest.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2018-01-16 18:34:04 +00:00
Wei Liu 357b4ede66 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>
2018-01-16 18:34:04 +00:00
Roger Pau Monne 5e6f257174 x86/guest: map per-cpu vcpu_info area.
Mapping the per-vcpu vcpu_info area is required in order to use more
than XEN_LEGACY_MAX_VCPUS.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:04 +00:00
Roger Pau Monne b53d2ae416 xen/guest: fetch vCPU ID from Xen
If available.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
[ wei: fix non-shim build ]
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:04 +00:00
Roger Pau Monne c99ce992fb x86/guest: map shared_info page
Use an unpopulated PFN in order to map it.

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-01-16 18:34:04 +00:00
Wei Liu b95c86b01a xen/pvshim: keep track of used PFN ranges
Simple infrastructure to keep track of PFN space usage, so that we can
use unpopulated PFNs to map special pages like shared info and grant
table.

As rangeset depends on malloc being ready so hypervisor_setup is
introduced for things that can be initialised late in the process.

Note that the PFN is marked as reserved at least up to 4GiB (or more
if the guest has more memory). This is not a perfect solution but
avoids using the MMIO hole below 4GiB. Ideally the shim (L1) should
have a way to ask the underlying Xen (L0) which memory regions are
populated, unpopulated, or MMIO space.

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:04 +00:00
Wei Liu 770e5c7f62 xen: introduce rangeset_claim_range
Reserve a hole in a rangeset.

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:04 +00:00
Wei Liu 5cf4b4617d xen/console: Introduce console=xen
This specifies whether to use Xen specific console output. There are
two variants: one is the hypervisor console, the other is the magic
debug port 0xe9.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:04 +00:00
Wei Liu ef3410a759 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>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
2018-01-16 18:34:04 +00:00
Andrew Cooper 765f921598 x86/shutdown: Support for using SCHEDOP_{shutdown,reboot}
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2018-01-16 18:34:04 +00:00
Andrew Cooper 338c73cddc x86/guest: Hypercall support
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:04 +00:00
Andrew Cooper f141540feb x86/entry: Probe for Xen early during boot
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-01-16 18:34:04 +00:00
Andrew Cooper 7d6f958d9d x86/boot: Map more than the first 16MB
TODO: Replace somehow (bootstrap_map() ?)

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-01-16 18:34:04 +00:00
Wei Liu d96bb172e8 x86/entry: Early PVH boot code
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-01-16 18:34:04 +00:00
Wei Liu 4ab99cb919 x86: produce a binary that can be booted as PVH
Produce a binary that can be booted as PVH. It doesn't do much yet.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-01-16 18:34:04 +00:00
Wei Liu cb3842d5ee x86: introduce ELFNOTE macro
It is needed later for introducing PVH entry point.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:04 +00:00
Andrew Cooper 0b280404c8 x86/link: Relocate program headers
When the xen binary is loaded by libelf (in the future) we rely on the
elf loader to load the binary accordingly. Specify the load address so
that the resulting binary can make p_vaddr and p_paddr have different
values.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:04 +00:00
Andrew Cooper d31efce487 x86/Kconfig: Options for Xen and PVH support
Introduce two options. One to detect whether the binary is running on
Xen, the other enables PVH ABI support.

The former will be useful to PV in HVM approach. Both will be used by
PV in PVH approach.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-01-16 18:34:04 +00:00