Commit Graph
100 Commits
Author SHA1 Message Date
Wei Liu 4cbc298570 automation: add two Arm64 builds to Gitlab CI
Add two gcc builds. Clang builds are known to be broken at the moment.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Doug Goldstein <cardoe@cardoe.com>
2018-11-13 13:48:42 +00:00
Wei Liu 8cf264cba5 automation: add debian unstable arm64v8 image
Unfortunately sharing dockerfile has proven impossible: 1) the base
image is different; 2) Arm doesn't need libc-dev-i386; 3) Arm needs
libfdt-dev.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Doug Goldstein <cardoe@cardoe.com>
2018-11-13 13:48:40 +00:00
Wei Liu 94bd9df0f7 x86: fix hvm_migrate_irq assertion
782cf8ba46 ("pass-through: adjust pIRQ migration") added an assertion
to hvm_migrate_irq.

PVH Dom0 is broken because it doesn't have dpci allocated. Add an
is_hardware_domain check to the assertion.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
2018-11-12 15:16:12 +00:00
Wei Liu 28f1c549e7 x86: eliminate pv_post_outb_hook
Use amd_acpi_c1e_quirk and amd_check_disable_c1e instead.

Requested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-11-12 09:31:55 +00:00
Wei Liu a34eb9ff15 x86/traps: use only one stub function for l/cstar
And place it into .text.cold.

Requested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2018-11-09 11:33:32 +00:00
Wei Liu 21b17f9eaa automation: build with Ubuntu 18.04
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-11-08 18:15:37 +00:00
Wei Liu 77533e4f7d automation: add dockerfile for Ubuntu 18.04
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-11-08 18:15:24 +00:00
Wei Liu 9044a8c185 Revert "arch/x86: Add registers to vm_event"
This reverts commit da61a2102f, because
it breaks !CONFIG_HVM builds.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-11-08 17:22:35 +00:00
Wei Liu 7ef789d79f automation: build some customised configs
Introduce a new directory to put in configs we care about. Modify
build script to build with those configs.

While we only introduce x86 configs initially, provision for non-x86
configs.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Doug Goldstein <cardoe@cardoe.com>
2018-11-08 16:40:20 +00:00
Wei Liu 657b303878 x86: expose CONFIG_PV
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-11-08 16:40:20 +00:00
Wei Liu 02cd416985 x86: make PV hypercall entry points work with !CONFIG_PV
We want Xen to crash if we hit these paths when PV is disabled.

For syscall, we provide stubs for {l,c}star_enter which end up calling
panic.  For sysenter, we initialise CS to 0 so that #GP can be raised.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-11-08 16:40:20 +00:00
Wei Liu 20c076d13b x86/amd: don't set pv_post_outb_hook when !CONFIG_PV
Obviously it won't exist when PV is disabled.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
2018-11-08 16:40:20 +00:00
Wei Liu a76e48f879 x86: put x86emul_{read,write}_dr under CONFIG_PV
A build breakage is discovered by a non-debug build. Debug build
worked because the ASSERT made the compiler eliminate the rest of the
functions.

Currently they are PV only. There are comments alluding to possible
future HVM support but we can cross the bridge when we get there.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-11-06 10:19:32 +00:00
Wei Liu ec651bd246 x86: make entry point code build when !CONFIG_PV
Skip building x86_64/compat/entry.S and put CONFIG_PV in
x86_64/entry.S.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-11-05 17:23:47 +00:00
Wei Liu f8810d333e x86: update help string for CONFIG_HVM
Update text. Change "guest" to "domain" where appropriate because
"guest" doesn't include Domain 0.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-11-05 16:12:12 +00:00
Wei Liu 9ea75d2c13 x86: rearrange x86_64/entry.S
Split the file into two halves. The first half pertains to PV guest
code while the second half is mostly used by the hypervisor itself to
handle interrupts and exceptions.

No functional change intended.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-11-05 16:10:35 +00:00
Wei Liu f969bc9fc9 x86/domctl: rework XEN_DOMCTL_{set,get}_address_size
Going through toolstack code, they are used for PV guests only.

Tighten their access to PV only. Return -EOPNOTSUPP if they are called
on HVM guests. Rewrite the code in a pattern that makes DCE work.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-11-05 16:09:50 +00:00
Wei Liu aa0816b74f x86: make traps.c build with !CONFIG_PV
Provide a stub for pv_inject_event. Put code that accesses PV fields
and GDT / LDT fault handling code under CONFIG_PV. Move set_debugreg
to pv/misc-hypercalls.c.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-11-05 16:08:03 +00:00
Wei Liu 3cbecb3c63 x86: put vcpumask_to_pcpumask under CONFIG_PV
This function is used by PV code only. This issue is discovered by
clang build.

Drop spurious inline while at it.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-11-05 10:30:29 +00:00
Wei Liu 2cf113891a libxl/arm: fix guest type conversion
Commit 359970fd8b ("tools/libxl: Switch Arm guest type to PVH") missed
changing the type field in c_info. This issue didn't surface until
ef72c93df9 which made creating PV guest on Arm unusable.

Create libxl__arch_domain_create_info_setdefault and switch the type
there.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2018-11-02 14:22:20 +00:00
Wei Liu 079df73c0a x86: put some code in arch_set_info_guest under CONFIG_PV
This function is called by both PV and HVM. Unfortunately the code is
very convoluted. We can reason that code between the call to
hvm_set_info_guest and out label is PV only. Put that portion under
CONFIG_PV.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-10-28 20:01:58 +00:00
Wei Liu de5a2bdced x86: make mm.c build with !CONFIG_PV
Start by putting hypercall handlers which are supposed to be PV only
under CONFIG_PV. Shuffle some code around to avoid introducing
excessive numbers of CONFIG_PV.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-10-28 20:01:37 +00:00
Wei Liu 76bfbcec42 arm: fix Dom0 creation after ef72c93df9
ARM Dom0 creation was broken by the said commit because ARM neither
provided XEN_DOMCTL_CDF_hvm_guest nor had CONFIG_PV set.

Set XEN_DOMCTL_CDF_hvm_guest flag for ARM Dom0 to fix the issue. Also
set XEN_DOMCTL_CDF_hap while at it.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
2018-10-22 14:43:40 +01:00
Wei Liu 3528426cb9 x86: don't setup legacy syscall vector when !CONFIG_PV
The code snippet is to switch between SYS_DECS_trap_gate and
SYS_DESC_irq_gate depending on whether XPTI is used. When PV is
disabled there is no need to switch.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-10-22 12:31:09 +01:00
Wei Liu d7ccb75b96 x86: stub out PV only code in do_debug
When PV is disabled those symbols won't be available. It is impossible
for Xen to hit #DB there.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-10-20 12:31:48 +01:00
Wei Liu ef72c93df9 x86: connect guest creation with CONFIG_PV
This is a bit more complicated than the HVM case because system
domains have PV guest type. Leave them like that.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-10-20 12:31:48 +01:00
Wei Liu 6f407dc4fc x86/pv: make guest_io_{read,write} local functions
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-10-20 12:31:48 +01:00
Wei Liu 29b0678b3c x86: make construct_dom0 build with !CONFIG_PV
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-10-20 12:31:41 +01:00
Wei Liu d1b7c32e73 x86: provide stub for arch_do_multicall_call
This hypercall is PV only on x86. Provide a stub for it when
!CONFIG_PV.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-10-15 15:32:42 +01:00
Wei Liu 0af580cdd5 x86: make x86_64/traps.c build with !CONFIG_PV
Provide declarations for hypercall_page_initialise_ring*_kernel, make
sure DCE work as expected.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-10-15 15:29:08 +01:00
Wei Liu e386c47882 x86: introduce is_pv_64bit_{vcpu,domain}
This is useful to rewrite the following pattern (v is PV vcpu)

   if ( is_pv_32bit_vcpu(v) )
       do_foo;
   else
       do_bar;

to

   if ( is_pv_32bit_vcpu(v) )
       do_foo;
   else if ( is_pv_64bit_vcpu(v) )
       do_bar;
   else
       ASSERT_UNREACHABLE;
.

Previously it is not possible to rely on DCE to eliminate the do_bar
part. It becomes possible with the new code structure.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-10-15 15:23:44 +01:00
Wei Liu d87dd1bd6c x86: turn is_pv_{,32bit_}{domain,vcpu} into inline functions
And make them work with CONFIG_PV.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2018-10-15 15:23:36 +01:00
Wei Liu c49894090c x86: don't report PV support when !CONFIG_PV
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-10-14 20:23:58 +01:00
Wei Liu 23058e7b36 x86/shadow: put PV L1TF functions under CONFIG_PV
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-10-11 09:41:23 +01:00
Wei Liu 0c0677f003 x86/vtd: fix IOMMU share PT destruction path
Commit 2916951c1 ("mm / iommu: include need_iommu() test in
iommu_use_hap_pt()") included need_iommu() in iommu_use_hap_pt and
91d4eca7ad ("mm / iommu: split need_iommu() into has_iommu_pt() and
need_iommu_pt_sync()") made things finer grain by spliting need_iommu
into three states.

The destruction path can't use iommu_use_hap_pt because at the point
platform op is called, IOMMU is either already switched to or has
always been in disabled state, and the shared PT test would always be
false.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2018-10-11 09:33:46 +01:00
Wei Liu 5e00f02763 iommu: fix arm build after e9be34be5
The function iommu_share_p2m_table is used by both ARM and x86 but
hap_enabled macro is x86 only. Put the ASSERT under CONFIG_X86.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-10-10 11:26:33 +01:00
Wei Liu d36b770458 x86: fix !CONFIG_HVM build for clang 3.8
It is discovered that hvm_funcs made it into monitor.o even when HVM
is disabled. This version of clang doesn't seem to completely
eliminate the code after is_hvm_domain() in
arch_monitor_get_capabilities().

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-10-05 10:04:06 +01:00
Wei Liu 146bb7e193 xen: initialise opt_xen_console early in PVH boot path
This helps capture issues before console is initialised.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-10-01 11:12:21 +01:00
Wei Liu c88397db5c x86: make sure module array is large enough in pvh-boot.c
The relocation code in __start_xen requires one extra element in the
module array. By the looks of it the temporary array is already large
enough. Panic if that's not the case.

While at it, turn an ASSERT to panic() as well.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-10-01 11:12:21 +01:00
Wei Liu edb4724e36 x86: undefine BOOSTRAP_MAP_LIMIT after its last user
Requested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-09-28 18:08:07 +01:00
Wei Liu a917d607e2 x86: fix comment on super page alignment requirement
BOOTSTRAP_DIRECTMAP_END is gone. The comment in question should refer
to BOOSTRAP_MAP_BASE and 4GB instead.

Move the entire comment block to where it belongs -- immediately
before the loop which does the things said in the comment.

Remove two trailing spaces while at it.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-09-28 18:07:54 +01:00
Wei Liu c759fb5bc3 x86: move hvm_domain_use_pirq to hvm files
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-09-26 09:50:17 +01:00
Wei Liu 17fbe6504d automation: introduce a new variable to control container user
Sometimes it is handy to create a container and play with its setup
manually as root.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Doug Goldstein <cardoe@cardoe.com>
2018-09-26 09:50:17 +01:00
Wei Liu 1bd9cc34e1 x86: expose CONFIG_HVM
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-09-24 18:10:04 +01:00
Wei Liu 026eac063b x86/mm: put HVM only code under CONFIG_HVM
Going through the code, HAP, EPT, PoD and ALTP2M depend on HVM code.
Put these components under CONFIG_HVM. This further requires putting
one of the vm event under CONFIG_HVM.

Altp2m requires a bit more attention because its code is embedded in
generic x86 p2m code.

Also make hap_enabled evaluate to false when !CONFIG_HVM. Make sure it
evaluate its parameter to avoid unused variable warnings in its users.

Also sort items in Makefile while at it.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
2018-09-24 17:47:27 +01:00
Wei Liu 9629b62005 x86/mm: put nested p2m code under CONFIG_HVM
These functions are only useful for nested hvm, which isn't enabled
when CONFIG_HVM is false.

Enclose relevant code and fields in CONFIG_HVM.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
2018-09-24 17:45:36 +01:00
Wei Liu 72a901d7a0 x86/p2m/pod: make it build with !CONFIG_HVM
Populate-on-demand is HVM only.

Provide a bunch of stubs for common p2m code and guard one invocation
of guest_physmap_mark_populate_on_demand with is_hvm_domain.

Put relevant fields in p2m_domain and code which touches those fields
under CONFIG_HVM.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
2018-09-24 17:45:16 +01:00
Wei Liu 940185b2f6 x86/mem_access: put p2m_{get/set}_suppress_ve under CONFIG_HVM
They are used by HVM code only.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
2018-09-22 10:17:17 +01:00
Wei Liu 7be2c4c54b automation: skip some branches in gitlab CI
Ignore branches which are always fast-forwarded to staging* branches.
List of filters taken from Travis CI setup.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Doug Goldstein <cardoe@cardoe.com>
2018-09-18 09:23:26 +01:00
Wei Liu 558408cab9 xen: connect guest creation with CONFIG_HVM
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-09-14 16:42:58 +01:00
Wei Liu 981c9a78dc x86: provide stubs, declarations and macros in hvm.h
Make sure hvm_enabled evaluate to false then provide necessary things
to make xen build when !CONFIG_HVM.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-09-14 16:42:54 +01:00
Wei Liu d7c60727a3 x86/mm: put paging_update_nestedmode under CONFIG_HVM
Nested HVM is not enabled when !CONFIG_HVM.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
2018-09-13 18:05:57 +01:00
Wei Liu 0e2c886efa xen: decouple HVM and IOMMU capabilities
HVM and IOMMU are two distinct hardware features, yet they were
bundled together in sysctl and xl's output.

Decouple them on sysctl level. On toolstack level we still need to
maintain a sensible semantics for `xl info`. Massage the information
according to the following table:

pv      hvm     iommu           flags in xl info
0       0       0               n/a
0       0       1               n/a
0       1       0               hvm
0       1       1               hvm hvm_directio
1       0       0               NIL
1       0       1               directio
1       1       0               hvm
1       1       1               hvm hvm_directio directio

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2018-09-13 17:03:32 +01:00
Wei Liu e6a8fe423e docs: document ~/control/sysrq
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
2018-09-11 08:54:22 +01:00
Wei Liu 1d069e45f7 mkdeb: use compression level 0
This requires calling dpkg-deb directly and pass it -z0.

It reduces the time to run the mkdeb script from 14 seconds to 3
seconds on my workstation with SSD, from 87s to 15s on a machine
with HDD. The deb file grows from 49M to 58M.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2018-09-07 15:06:00 +01:00
Wei Liu b824478103 libxl: don't set PoD target for PV guests
Previously PoD target was unconditionally set for both PV and HVM
guests, but in fact PoD has always been an HVM (now PVH as well) only
feature.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2018-09-07 15:01:39 +01:00
Wei Liu e39a9148ed x86/hvm: rearrange content of hvm.h
Move enum and function declarations to first half of the file.

Static inline functions and macros, which reference HVM specific
fields directly are grouped together in second half of the file.

The movement is needed because in a later patch the second half is
going to be enclosed in CONFIG_HVM.

Pure code movement. No functional change.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-09-07 08:52:00 +01:00
Wei Liu 583037acab automation: specify -j$(nproc) in build script
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Doug Goldstein <cardoe@cardoe.com>
2018-09-07 08:39:10 +01:00
Wei Liu 833a81b439 x86: PIT emulation is common to both PV and HVM
Move the file to x86 common code and change its name to emul-i8254.c.

Put HVM only code under CONFIG_HVM or is_hvm_domain.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-09-06 16:54:38 +01:00
Wei Liu 49136c3898 x86: XENMEM_resource_ioreq_server is HVM only
Put the entire case branch under CONFIG_HVM.

Lift the check from hvm_get_ioreq_server_frame into its caller.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2018-09-06 16:54:38 +01:00
Wei Liu 5d30a977d4 x86: introduce and use a set of internal emulation flags
Use these flags in has_* tests and emulation_flags_ok.

Not using raw flags directly enables DCE to kick in for has_* tests,
while at the same time makes sure emulation_flags_ok won't go out of
sync.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2018-09-06 16:54:38 +01:00
Wei Liu e2f092127a x86: monitor.o is currently HVM only
There has been plan to make PV work, but it is not yet there.  Provide
stubs to make it build with !CONFIG_HVM.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
2018-09-05 10:59:49 +01:00
Wei Liu 9d7cda4c2d x86: change name of parameter for various invlpg functions
They all incorrectly named a parameter virtual address while it should
have been linear address.

Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
2018-09-05 10:59:47 +01:00
Wei Liu aed19fb537 x86/pt: split out HVM functions from vtd.c
Functions are moved to hvm.c. Reorder makefile items while at it.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2018-08-30 08:34:29 +01:00
Wei Liu 54ab98a715 x86/pt: make it build with !CONFIG_HVM
This requires providing stubs for a few functions which are part of
HVM code.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
2018-08-30 08:34:05 +01:00
Wei Liu 566882ee4e x86/domctl: XEN_DOMCTL_debug_op is HVM only
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-08-28 16:30:58 +01:00
Wei Liu e3ba4709b7 xenforeignmemory: fix fd leakage in error path
b49ef5d3 (xenforeignmemory: work around bug in older privcmd) added an
error path but forgot to close fd there.

Spotted by Coverity.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-08-28 16:04:19 +01:00
Wei Liu 9df4c648d7 rombios: remove packed attribute for pushad_regs_t
The structure already has explicitly padding.

Removing the attribute silences a clang 6 warning:

tcgbios.c:1519:34: error: taking address of packed member 'u' of class or structure 'pushad_regs_t' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member]
                                                  ®s->u.r32.edx);
                                                   ^~~~~~~~~~~~~~~

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2018-08-28 15:14:56 +01:00
Wei Liu 674f9f7109 xen: is_hvm_{domain,vcpu} should evaluate to false when !CONFIG_HVM
Turn them into static inline functions which evaluate to false when
CONFIG_HVM is not set. ARM won't be broken because ARM guests are set
to PV type in the hypervisor.

But ARM has plan to switch to HVM guest type inside the hypervisor, so
preemptively introduce CONFIG_HVM for ARM here.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <julien.grall@arm.com>
2018-08-28 14:47:06 +01:00
Wei Liu 6ffa33b370 xen/pt: io.c contains HVM only code
We also need to make it x86 only because ARM will define CONFIG_HVM at
some point.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-08-28 10:49:27 +01:00
Wei Liu 6c851a9e5a x86/vpmu: put HVM only code under CONFIG_HVM
Change u32 to uint32_t while at it.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-08-28 10:49:12 +01:00
Wei Liu 0199416a2c x86: provide stub for memory_type_changed
Jan indicated that for PV guests the memory type is not changed, for
HVM guests memory_type_changed is needed for EPT's effective memory
type calculation.  This means memory_type_changed is HVM only.

Provide a stub to minimise code churn.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-08-28 10:49:02 +01:00
Wei Liu 3212e3464f x86/hvm: provide hvm_hap_supported
And replace direct accesses in non-HVM subsystems to
hvm_funcs.hap_supported with the new function, to avoid accessing an
internal data structure of another subsystem directly.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-08-28 10:48:45 +01:00
Wei Liu a0a6b2421f x86: enclose hvm_op and dm_op in CONFIG_HVM in relevant tables
PV guest (Dom0) needs to able to use these two hypercalls in order to
serve HVM guests. But if xen doesn't support HVM at all there is no
point in exposing them to PV guests.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2018-08-28 10:48:33 +01:00
Wei Liu e5d6ddcd31 x86/nestedhvm: provide some stubs for p2m code
Make two functions static inline so that they can be referenced in p2m
code. Check nestedhvm is enabled before calling
nestedhvm_vmcx_flushtlb (which also has a side effect of not issuing
unnecessary IPIs for non-nested case).

While moving, reformat code and use proper boolean.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-08-26 11:01:03 +01:00
Wei Liu 06d473a135 x86/mm/shadow: split out HVM only code
Move the code previously enclosed in CONFIG_HVM into its own file.

Note that although some code explicitly check is_hvm_*, which hints it
can be used for PV too, I can't find a code path that would be the
case.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
2018-08-26 11:01:03 +01:00
Wei Liu 29ac2ad612 x86/mm/shadow: make it build with !CONFIG_HVM
Enclose HVM only emulation code under CONFIG_HVM. Add some BUG()s to
to catch any issue.

Note that although some code checks is_hvm_*, which hints it can be
called for PV as well, I can't find such paths.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
2018-08-26 11:01:03 +01:00
Wei Liu f0f14cc277 x86/vm_event: put vm_event_fill_regs under CONFIG_HVM
Ideally the HVM specific part of VM event should be moved into hvm/ at
some point, but this will do for now.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
2018-08-26 11:01:03 +01:00
Wei Liu 59fa681b5f x86/mem_access: put HVM only function under CONFIG_HVM
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
2018-08-26 11:01:03 +01:00
Wei Liu cc4e0524e0 x86: guard HAS_VPCI with CONFIG_HVM
VPCI is only useful for PVH / HVM guests. Ideally CONFIG_HVM should
imply !PV_SHIM_EXCLUSIVE, but we still want to build PV_SHIM_EXCLUSIVE
with CONFIG_HVM at this stage because a lot of things are still
entangled.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-08-26 11:01:02 +01:00
Wei Liu 4be26bd61e tools: building IPXE should be determined by CONFIG_IPXE
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2018-08-26 10:52:18 +01:00
Wei Liu 1385a14bfc x86/oprofile: put SVM only code under CONFIG_HVM
The code snippet in question is to detect NMI held by SVM until STGI
is called. When Xen doesn't even support HVM guests there is no need
to check svm_stgi_label.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-08-21 15:17:14 +01:00
Wei Liu d6876bf23d x86/mtrr: move is_var_mtrr_overlapped
Move it to x86 generic code. While at it, use proper boolean type and
fix some cosmetic issues.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-08-21 15:13:34 +01:00
Wei Liu c94ea358a3 x86/amd: skip OSVW function calls if !CONFIG_HVM
The two functions are not needed when HVM is not supported in
hypervisor.

Note that using hvm_enabled won't work because early_microcode_init
gets to cpu_request_microcode before hvm_enabled is set in presmp init
call stage.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-08-21 15:01:13 +01:00
Wei Liu d6abbaec75 x86/vmce: enclose HVM load / save code in CONFIG_HVM
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-08-21 15:00:29 +01:00
Wei Liu a3562d8c36 x86/pt: add HVM check to XEN_DOMCTL_unbind_pt_irq
Its counterpart is HVM only. Add the check to help dead code
elimination to figure out the call to pt_irq_destroy_bind is not
needed when HVM is not enabled.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-08-21 14:59:04 +01:00
Wei Liu 502f755147 x86/mm: don't reference hvm_funcs directly
It is generally not a good idea to reference the internal data
structure of the another subsystem directly. Introduce a wrapper
function for the invlpg hook.

No functional change.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-08-21 14:57:31 +01:00
Wei Liu e4b866d703 x86/vvmx: make get_shadow_eptp static function
Its callers live within the same file.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-08-21 14:57:11 +01:00
Wei Liu 060a3fb4ad x86: HVM_FEP should depend on HVM
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
2018-08-21 14:56:36 +01:00
Wei Liu 1fe5e617d4 xen: fix building !CONFIG_LOCK_PROFILE
The init function shouldn't be built or called at all when
!CONFIG_LOCK_PROFILE.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2018-08-21 14:55:35 +01:00
Wei Liu 10c3fd91bd MAINTAINERS: add myself as a reviewer for x86 patches
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-08-21 08:33:52 +01:00
Wei Liu 37b7c808b3 automation: build with debian unstable
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Doug Goldstein <cardoe@cardoe.com>
2018-08-20 14:05:11 +01:00
Wei Liu 3a2b8525b8 tools/tests: fix an xs-test.c issue
The ret variable can be used uninitialised when iters is 0. Initialise
ret at the beginning to fix this issue.

Reported-by: Steven Haigh <netwiz@crc.id.au>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2018-08-20 11:50:17 +01:00
Wei Liu 48a70499e6 tools/kdd: work around gcc 8.1 bug
Gcc 8.1 has a bug that causes kdd fail to build. Rewrite the code to
work around that bug.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86827

Signed-off-by: Tim Deegan <tim@xen.org>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2018-08-20 11:49:46 +01:00
Wei Liu e75c9dc85f xenpmd: make 32 bit gcc 8.1 non-debug build work
32 bit gcc 8.1 non-debug build yields:

xenpmd.c:354:23: error: '%02x' directive output may be truncated writing between 2 and 8 bytes into a region of size 3 [-Werror=format-truncation=]
     snprintf(val, 3, "%02x",
                       ^~~~
xenpmd.c:354:22: note: directive argument in the range [40, 2147483778]
     snprintf(val, 3, "%02x",
                      ^~~~~~
xenpmd.c:354:5: note: 'snprintf' output between 3 and 9 bytes into a destination of size 3
     snprintf(val, 3, "%02x",
     ^~~~~~~~~~~~~~~~~~~~~~~~
              (unsigned int)(9*4 +
              ~~~~~~~~~~~~~~~~~~~~
                             strlen(info->model_number) +
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                             strlen(info->serial_number) +
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                             strlen(info->battery_type) +
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                             strlen(info->oem_info) + 4));
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

All info->* used in calculation are 32 bytes long, and the parsing
code makes sure they are null-terminated, so the end result of the
expression won't exceed 255, which should be able to be fit into 3
bytes in hexadecimal format.

Add an assertion to make gcc happy.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2018-08-20 11:49:03 +01:00
Wei Liu 9bf0dc7437 tools: update ipxe changeset
This placates gcc 8.1. The commit comes from ipxe master branch as of
July 25, 2018.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2018-08-20 11:48:53 +01:00
Wei Liu aa67b97ed3 xl.conf: Add global affinity masks
XSA-273 involves one hyperthread being able to use Spectre-like
techniques to "spy" on another thread.  The details are somewhat
complicated, but the upshot is that after all Xen-based mitigations
have been applied:

* PV guests cannot spy on sibling threads
* HVM guests can spy on sibling threads

(NB that for purposes of this vulnerability, PVH and HVM guests are
identical.  Whenever this comment refers to 'HVM', this includes PVH.)

There are many possible mitigations to this, including disabling
hyperthreading entirely.  But another solution would be:

* Specify some cores as PV-only, others as PV or HVM
* Allow HVM guests to only run on thread 0 of the "HVM-or-PV" cores
* Allow PV guests to run on the above cores, as well as any thread of the PV-only cores.

For example, suppose you had 16 threads across 8 cores (0-7).  You
could specify 0-3 as PV-only, and 4-7 as HVM-or-PV.  Then you'd set
the affinity of the HVM guests as follows (binary representation):

0000000010101010

And the affinity of the PV guests as follows:

1111111110101010

In order to make this easy, this patches introduces three "global affinity
masks", placed in xl.conf:

    vm.cpumask
    vm.hvm.cpumask
    vm.pv.cpumask

These are parsed just like the 'cpus' and 'cpus_soft' options in the
per-domain xl configuration files.  The resulting mask is AND-ed with
whatever mask results at the end of the xl configuration file.
`vm.cpumask` would be applied to all guest types, `vm.hvm.cpumask`
would be applied to HVM and PVH guest types, and `vm.pv.cpumask`
would be applied to PV guest types.

The idea would be that to implement the above mask across all your
VMs, you'd simply add the following two lines to the configuration
file:

    vm.hvm.cpumask=8,10,12,14
    vm.pv.cpumask=0-8,10,12,14

See xl.conf manpage for details.

This is part of XSA-273 / CVE-2018-3646.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2018-08-14 16:56:47 +01:00
Wei Liu 4b60c40659 x86: move arch_evtchn_inject to x86 common code
It is not specific to HVM. It just so happens that PV doesn't need
special handling.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-08-08 10:36:46 +01:00
Wei Liu 6cf17a267a x86: add missing "inline" keyword
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-08-08 10:36:13 +01:00
Wei Liu 95725b96d1 x86: put compat.o and x86_64/compat.o under CONFIG_PV
They contain code for compat hypercall for PV guests.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-08-08 10:35:52 +01:00