Commit Graph
35719 Commits
Author SHA1 Message Date
Julien Grall 462ed06a98 xen/arm: domain_build: Redefine virt_to_mfn to support typesafe
The file xen/arch/arm/domain_build.c is using typesafe MFN in most of
the place. The only caller to virt_to_mfn is using prefixed with
_mfn(...).

To avoid extra _mfn(...), re-define virt_to_mfn within
arch/arm/domain_build.c to handle typesafe MFN.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2017-06-30 13:12:56 -07:00
Julien Grall d641694ddb xen/arm: mm: Redefine virt_to_mfn to support typesafe
The file xen/arch/arm/mm.c is using the typesafe MFN in most of the
place. This requires all caller of virt_to_mfn to prefixed by _mfn(...).

To avoid the extra _mfn(...), re-defined virt_to_mfn within arch/arm/mm.c
to handle typesafe MFN.

This patch also introduce __virt_to_mfn, so virt_to_mfn can be
re-defined easily.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2017-06-30 13:12:55 -07:00
Julien Grall 1127326bd5 xen/arm: p2m: Redefine mfn_to_page and page_to_mfn to use typesafe
The file xen/arch/arm/p2m.c is using typesafe MFN in most of the place.
This requires caller to mfn_to_page and page_to_mfn to use _mfn/mfn_x.

To avoid extra _mfn/mfn_x, re-define mfn_to_page and page_to_mfn within
xen/arch/arm/p2m.c to handle typesafe MFN.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2017-06-30 13:12:50 -07:00
Julien Grall 9c6545cf5d xen/arm: mm: Use typesafe mfn for xenheap_mfn_*
Add more safety when using xenheap_mfn_*.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2017-06-30 13:12:45 -07:00
Julien Grall 5e2af95aeb xen/arm: setup: Remove bogus xenheap_mfn_end in setup_mm for arm64
xenheap_mfn_end is storing an MFN and not a physical address. The value will
be reset after the loop. So drop this bogus xenheap_mfn_end.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2017-06-30 13:12:40 -07:00
Andrew Cooper c2ce38d3ad x86/shadow: Switch to using bool
* sh_pin() has boolean properties, so switch its return type.
 * sh_remove_shadows() uses ints everywhere other than its stub.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
2017-06-30 16:44:48 +01:00
Igor Druzhinin 143e0c2c2d tools/libxenforeignmemory: add xenforeignmemory_map2 function
The new function repeats the behavior of the first version
except it has an extended list of arguments which are subsequently
passed to mmap() call.

This is needed for QEMU depriviledging.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2017-06-30 15:27:05 +01:00
Marek Marczykowski-Górecki 90f1ba95b0 libxl: reformat cpuid_flags
Reverse sorting order, add blank lines at register change.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2017-06-30 15:25:07 +01:00
Marek Marczykowski-Górecki b84041bf95 libxl: make cpuid_flags array static const
To have it in .rodata, instead of reconstructing each time on stack.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2017-06-30 15:25:00 +01:00
Marek Marczykowski-Górecki e198f804da libxl: fix osvm cpuid flag
It's bit 9 not 10 (which is ibs).

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2017-06-30 15:24:55 +01:00
Marek Marczykowski-Górecki 90b2a267c1 libxl: add more cpuid flags handling
This is result of parsing cpu_map.xml from libvirt.
The most important part is handling leaf 0x00000007, but while at it add
other bits too.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2017-06-30 15:24:43 +01:00
Sergey Dyasli 6b792e28bc vvmx: fix ept_sync() for nested p2m
If ept_sync_domain() is called for np2m, the following happens:

    1. *np2m*::ept_data::invalidate cpumask is updated
    2. IPIs are sent for CPUs in domain_dirty_cpumask forcing vmexits
    3. vmx_vmenter_helper() checks *hostp2m*::ept_data::invalidate
       and does nothing

Which is clearly a bug. Make ept_sync_domain() to update hostp2m's
invalidate mask in nested p2m case and make vmx_vmenter_helper() to
invalidate EPT translations for all EPTPs if nested virt is enabled.

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2017-06-30 11:27:51 +01:00
Andrew Cooper 46c3acb308 x86/vvmx: Fix WRMSR interception of VMX MSRs
FEATURE_CONTROL is already read with LOCK bit set (so is unmodifiable), and
all VMX MSRs are read-only.  Also, fix the MSR_IA32_VMX_TRUE_ENTRY_CTLS bound
to be MSR_IA32_VMX_VMFUNC, rather than having the intervening MSRs falling
into the default case.

Raise #GP faults if the guest tries to modify any of them.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2017-06-30 11:27:50 +01:00
Julien Grall bbbe893512 xen/mm: Introduce {G,M}FN_INVALID_INITIALIZER
The current implementation of {G,M}FN_INVALID cannot be used to
initialize global variable because the initializer element is not a
constant.

Due to a bug in GCC 4.9 and older ([1]), it is not easy to find a common
value to initialize a variable and directly passed as an argument.

Introduce 2 news define {G,M}FN_INVALID_INITIALIZER to be used for
initializing a variable.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64856

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Tim Deegan <tim@xen.org>
2017-06-30 11:27:50 +01:00
Julien Grall 26c6885fe5 Revert "mm: don't use _{g,m}fn for defining INVALID_{G,M}FN"
This reverts commit 725039d39e. The change
was intended to solve compilation when using INVALID_{G,M}FN for global
variables.

However, due to a compiler bug this will not work for GCC up to 5.0 (see
[1]).

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64856

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Tim Deegan <tim@xen.org>
2017-06-30 11:27:50 +01:00
Wei Liu 989563f97b Config.mk: update mini-os changeset
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
2017-06-29 12:15:38 +01:00
Wei Liu 7cf8304aae x86/setup.c: use plain bool
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
2017-06-29 11:57:04 +01:00
Wei Liu a0979fe323 x86/nmi.c: use plain bool
While at it, change check_nmi_watchdog to return void because its
return value is not used anyway.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
2017-06-29 11:57:04 +01:00
Wei Liu 65c6246d6e x86/time.c: use plain bool
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
2017-06-29 11:57:04 +01:00
Wei Liu 8761e112ee x86/crash.c: use plain bool
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
2017-06-29 11:57:04 +01:00
Wei Liu 33b0ad0bf0 x86/dom0_build.c: use plain bool
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
2017-06-29 11:57:04 +01:00
Wei Liu ce084f309b x86/domain.c: use plain bool
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
2017-06-29 11:57:03 +01:00
Wei Liu 650924b82b x86/platform_hypercall.c: use plain bool
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
2017-06-29 11:57:03 +01:00
Wei Liu 5b4b81a4be x86/irq.c: use plain bool
Replace bool_t with bool and adjust code accordingly.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
2017-06-29 11:57:03 +01:00
Zhongze Liu 20e725e936 libxc: add xc_domain_add_to_physmap_batch to wrap XENMEM_add_to_physmap_batch
This is a preparation for the proposal "allow setting up shared memory areas
between VMs from xl config file". See:
V2: https://lists.xen.org/archives/html/xen-devel/2017-06/msg02256.html
V1: https://lists.xen.org/archives/html/xen-devel/2017-05/msg01288.html

The plan is to use XENMEM_add_to_physmap_batch in xl to map foregin pages from
one DomU to another so that the page could be shared. But currently there is no
wrapper for XENMEM_add_to_physmap_batch in libxc, so we just add a wrapper for
it.

Signed-off-by: Zhongze Liu <blackskygg@gmail.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2017-06-29 11:23:15 +01:00
Marek Marczykowski-Górecki bda2696f29 stubdom: fix vtpm compilation on GCC-7
GCC-7 have -Wimplicit-fallthrough enabled with -Wextra. Add appropriate
comment which both mute the warning and improve readibility.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2017-06-29 11:21:42 +01:00
Andrew Cooper 2d7021cfd7 xen/efi: Switch to using bool
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
2017-06-28 17:41:59 +01:00
Andrew Cooper 288e279513 xen/tmem: Switch to using bool
* Drop redundant initialisers
 * Style corrections while changing client_over_quota()
 * Drop all write-only bools from do_tmem_op()

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
2017-06-28 17:41:04 +01:00
Wei Liu 4194816d0e x86/pv: reorder items in Makefile
Split it into two sections, one for obj-y and the other for
obj-bin-y.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-28 12:20:33 +01:00
Wei Liu 979d1e4dd3 x86: clean up traps.c
Replace bool_t with bool. Delete trailing white spaces. Fix some
coding style issues.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2017-06-28 12:09:58 +01:00
Wei Liu 657291b2e6 x86/traps.h: remove unused declaration of cpu_user_regs
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-28 11:56:53 +01:00
Wei Liu d59d24c90b x86/traps: move some PV specific functions to pv/traps.c
Those functions must be moved at the same time. Also move softirq_trap
because it is only used there.

Fix some coding style issues while moving code.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-28 11:56:53 +01:00
Wei Liu 093973bd77 x86/callback.c: slightly change {un,}register_guest_nmi_callback
Make register_guest_nmi_callback return int and make
unregister_guest_nmi_callback void. Adjust the callers where
necessary.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-28 11:56:52 +01:00
Wei Liu 635af64d4f x86/traps: move {un,}register_guest_nmi_callback to pv/callback.c
Move these helper functions along side their users. Now all users of
these functions are within the same file, make them static.

Take the chance to change v to curr and remove some unneeded
parentheses.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-28 11:56:52 +01:00
Wei Liu 0e97a5b6f9 xen: move do_nmi_op and make it x86 only
Since ARM doesn't need {compat,do}_nmi_op, move the hypercall handlers
from common/kernel.c to pv/callback.c. Drop the stubs in ARM. Delete
the common and ARM nmi.h and adjust header inclusions in various
files.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
2017-06-28 11:56:52 +01:00
Wei Liu fd74631103 x86/traps: factor out pv_trap_init
Factor out pv_trap_init and call it at the beginning of trap_init. We
then need to tune the code to generate stub handlers in entry.S. Take
the chance to tune init_irq_data so that 0x80 and 0x82 can be used for
regular interrupts in !CONFIG_PV case.

While at it, fix some coding style issues in init_irq_data and replace
0x80 with LEGACY_SYSCALL_VECTOR in pv_trap_init.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reivewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-28 11:56:52 +01:00
Wei Liu 873dd3aaeb x86/traps: simplify and rename send_guest_trap
Rename it to pv_raise_interrupt. Simplify the code by using the vcpu
structure already at hand in the caller.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-28 11:56:52 +01:00
Andrew Cooper 34c06658c1 xen/pt: Avoid NULL dereference in hvm_pirq_eoi()
Coverity warns that pirq_dpci unconditionally dereferences a NULL pointer.
This warning appears to be triggered by pirq_dpci() which is a hidden ternary
expression.  In reality, it appears that both callers pass a non-NULL pirq
parameter, so the code is ok in practice.

Rearange the logic to fail-safe, which should quiesce Coverity.

Clean up bool_t => bool and trailing whitespace for hvm_domain_use_pirq()
while auditing this area.

No (intended) functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
2017-06-28 11:18:40 +01:00
Andrew Cooper ca49c64543 xen/pt: Unlock d->event_lock on error paths
Introduced by c/s fba0049426 "x86/pt: enable binding of GSIs to a PVH Dom0"

Spotted by Coverity.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
2017-06-28 11:18:40 +01:00
Wei Liu 8b9793bfe6 x86: simplify guest_has_trap_callback
Simplify that function, rename it to pv_trap_callback_registered and
move it to pv/traps.h. Adjust vmce.c accordingly.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-27 17:04:13 +01:00
Wei Liu fca33ce269 x86: remove the now empty x86_64/compat/traps.c
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-27 17:04:13 +01:00
Wei Liu ad755eb3a1 x86: move compat_set_trap_table along side the non-compat variant
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-27 17:04:13 +01:00
Wei Liu c8ecb34e67 x86: move do_set_trap_table to pv/callback.c
That hypercall is used to set guest callbacks for traps.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-27 17:04:13 +01:00
Wei Liu e55bf825b2 x86: move the compat callback ops next to the non-compat variant
Take the chance to change v to curr.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-27 17:04:12 +01:00
Wei Liu 9f6db6679c x86: move callback_op code to pv/callback.c
Take the chance to change v to curr.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-27 17:04:12 +01:00
Wei Liu f7826750eb travis: install ghostscript
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Doug Goldstein <cardoe@cardoe.com>
2017-06-27 16:58:17 +01:00
Roger Pau Monne 3e68095ef9 x86/vioapic: bind interrupts to PVH Dom0
Add the glue in order to bind the PVH Dom0 GSI from bare metal. This
is done when Dom0 unmasks the vIO APIC pins, by fetching the current
pin settings and setting up the PIRQ, which will then be bound to
Dom0.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2017-06-26 14:32:46 +01:00
Roger Pau Monne fba0049426 x86/pt: enable binding of GSIs to a PVH Dom0
Achieve this by expanding pt_irq_create_bind in order to support
mapping interrupts of type PT_IRQ_TYPE_PCI to a PVH Dom0. GSIs bound
to Dom0 are always identity bound, which means the all the fields
inside of the u.pci sub-struct are ignored, and only the machine_irq
is actually used in order to determine which GSI the caller wants to
bind.

Also, the hvm_irq_dpci struct is not used by a PVH Dom0, since that's
used to route interrupts and allow different host to guest GSI
mappings, which is not used by a PVH Dom0.

This requires adding some specific handlers for such directly mapped
GSIs, which bypass the PCI interrupt routing done by Xen for HVM
guests.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2017-06-26 14:32:46 +01:00
Roger Pau Monne c2d9461920 x86/vioapic: make gsi_vioapic private
And introduce vioapic_get_{mask/vector} in order to replace it's
usage.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2017-06-26 14:32:46 +01:00
Olaf Hering 672949d6c6 rombios: prevent building with PIC/PIE
If the default compiler silently defaults to to -fPIC/-fPIE building
rombios fails:

 ld -melf_i386 -s -r 32bitbios.o tcgbios/tcgbiosext.o util.o pmm.o -o 32bitbios_all.o
 There are undefined symbols in the BIOS:
          U _GLOBAL_OFFSET_TABLE_
 make[10]: *** [Makefile:26: 32bitbios_all.o] Error 11

Prevent the failure by enforcing non-PIC/PIE mode.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-26 14:32:46 +01:00