Commit Graph
35728 Commits
Author SHA1 Message Date
Julien Grall e97138de4e xen/arm: mm: Introduce temporary variable in create_xen_entries
This is improving the code readability and avoid to dereference the
table every single time we need to access the entry.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2017-06-30 13:13:04 -07:00
Julien Grall 7b7a5587ba xen/arm: mm: Use lpae_valid and lpae_table in create_xen_entries
This newly introduced lpae_valid and lpae_table helpers will recude the
code and make more readable.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2017-06-30 13:13:03 -07:00
Julien Grall 9f3bbd8df3 xen/arm: p2m: Move lpae_* helpers in lpae.h
lpae_* helpers can work on any LPAE translation tables. Move them in
lpae.h to allow other part of Xen to use them.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2017-06-30 13:13:02 -07:00
Julien Grall d77def6830 xen/arm: p2m: Rename p2m_valid, p2m_table, p2m_mapping and p2m_is_superpage
The helpers p2m_valid, p2m_table, p2m_mapping and p2m_is_superpage are
not specific to the stage-2 translation tables. They can also work on
any LPAE translation tables. So rename then to lpae_* and use pte.walk
to look for the value of the field.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2017-06-30 13:13:01 -07:00
Julien Grall 9d590f56a6 xen/arm: lpae: Fix comments coding style
Also adding one missing full stop + fix description

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2017-06-30 13:13:01 -07:00
Julien Grall 0b435afa6a xen/arm: Move LPAE definition in a separate header
page.h is getting bigger. Move out every LPAE definitions in a separate
header. There is no functional changes.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
2017-06-30 13:13:00 -07:00
Julien Grall d75241c4cd xen/arm: create_xen_entries: Use typesafe MFN
Add a bit more safety when using create_xen_entries.

Also when destroying/modifying mapping, the MFN is currently not used.
Rather than passing _mfn(0) use INVALID_MFN to stay consistent with the
other usage.

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

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

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel..org>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2017-06-30 13:12:58 -07:00
Julien Grall 0a0d82720a xen/arm: alternative: Redefine virt_to_mfn to support typesafe
The file xen/arch/arm/alternative.c is using typesafe MFN in most of
the place. The only caller to virt_to_mfn is using with _mfn(...).

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

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabelllini <sstabellini@kernel.org>
2017-06-30 13:12:57 -07:00
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