Commit Graph
35693 Commits
Author SHA1 Message Date
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
Andrew Cooper 5bba2b362f x86/mm: Fix infinite loop in get_spage_pages()
c/s 2b8eb37 switched int i to being unsigned, but the undo logic on failure
relied in i being signed.  As i being unsigned in still preforable, adjust the
undo logic to work with an unsigned i.

Coverity-ID: 1413017
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Konrad Rzeszutek Will <konrad.wilk@oracle.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
2017-06-26 14:32:46 +01:00
Bhupinder Thakur d5f6383d9a xen/arm: Rename vgic_reg* functions definitions and calls to vreg_reg*
This patch renames the vgic_reg* access functions defined in vreg.h to vreg_reg*
and replaces all calls to vgic_reg* functions in vgic/its emulation code to vreg_reg*.

vreg_reg* are generic functions, which can be used to operate on 32/64-bit registers.

SBSA UART emulation code will also use vreg_reg* access functions for
accessing emulated pl011 registers.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Julien Grall <julien.grall@arm.com>
2017-06-23 11:03:18 -07:00
Bhupinder Thakur c6b6916279 xen/arm: vpl011: Move vgic register access functions to vreg.h
These functions are generic in nature and can be reused by other emulation
code in Xen. vGICv3 ITS and SBSA UART emulation code, would use these
functions to operate on their registers.

This patch moves the register access function definitions from vgic.h to
vreg.h.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Acked-by: Julien Grall <julien.grall@arm.com>
2017-06-23 11:03:17 -07:00
Andrew Cooper e47d920e07 x86/mm: Rename d to currd in do_mmuext_op()
This will make future cleanup more obviously correct.  No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2017-06-23 17:15:33 +01:00
Jan Beulich 1aa803f94e x86emul: correct CF output of SHLD/SHRD
CF reflects the last bit shifted out, i.e. can't possibly be derived
from the result value.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-23 17:59:12 +02:00
Wei Liu 7f919ac319 xen-detect: handle asprintf error
Otherwise gcc with -Wunused will complain the return value is not
used.

Reported-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-23 16:08:40 +01:00
Wei Liu 0034cd9065 x86: fix coding a style issue in asm-x86/traps.h
And add an emacs block.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-23 16:06:19 +01:00
Wei Liu 69263eb0c3 x86: move compat_show_guest_statck near its non-compat variant
And make it static, remove the declaration in header.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-23 16:06:19 +01:00
Wei Liu 6937b34fee x86: move compat_iret along side its non-compat variant
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-23 16:06:19 +01:00
Wei Liu bc0c48953c x86: move hypercall_page_initialise_ring1_kernel
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-23 16:06:19 +01:00
Wei Liu f0e0505f54 x86: move hypercall_page_initialise_ring3_kernel to pv/hypercall.c
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-23 16:06:19 +01:00
Wei Liu 67a4e7aca3 x86/traps: move init_int80_direct_trap to pv/traps.c
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-23 16:06:19 +01:00
Wei Liu 538bb4c06e x86: move do_iret to pv/iret.c
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-23 16:06:19 +01:00
Wei Liu ffd13cd2b6 x86: move toggle_guest_mode to pv/domain.c
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-23 16:06:19 +01:00
Wei Liu 0142064421 x86/traps: move set_guest_{machine,nmi}_trapbounce
Take the opportunity to change their return type to bool. And rename
"v" to "curr".

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-23 16:06:19 +01:00
Wei Liu 970c4a2a19 x86/traps: move pv_inject_event to pv/traps.c
Take the opportunity to rename "v" to "curr".

No functional change.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-23 16:06:19 +01:00
Wei Liu b3f9e8bf7f x86: move some misc PV hypercalls to misc-hypercalls.c
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-23 16:06:19 +01:00
Wei Liu c7c623910d x86: clean up PV emulation code
Replace bool_t with bool. Fix coding style issues. Add spaces around
binary ops. Use 1U for shifting. Eliminate TOGGLE_MODE.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-23 16:06:19 +01:00
Andrew Cooper 2ff229643b xen/livepatch: Don't crash on encountering STN_UNDEF relocations
A symndx of STN_UNDEF is special, and means a symbol value of 0.  While
legitimate in the ELF standard, its existance in a livepatch is questionable
at best.  Until a plausible usecase presents itself, reject such a relocation
with -EOPNOTSUPP.

Additionally, fix an off-by-one error while range checking symndx, and perform
a safety check on elf->sym[symndx].sym before derefencing it, to avoid
tripping over a NULL pointer when calculating val.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> [x86 and arm32]
Reviewed-by: Jan Beulich <JBeulich@suse.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
2017-06-23 15:00:37 +01:00
Andrew Cooper bd53b85156 xen/livepatch: Use zeroed memory allocations for arrays
Each of these arrays is sparse.  Use zeroed allocations to cause uninitialised
array elements to contain deterministic values, most importantly for the
embedded pointers.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> [x86 and arm32]
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
2017-06-23 15:00:37 +01:00
Andrew Cooper bf570f5935 xen/livepatch: Clean up arch relocation handling
* Reduce symbol scope and initalisation as much as possible
 * Annotate a fallthrough case in arm64
 * Fix switch statement style in arm32

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> [x86 and arm32]
2017-06-23 15:00:37 +01:00
Andrew Cooper d5bd9fe27e xen: Replace ASSERT(0) with ASSERT_UNREACHABLE()
No functional change, but the result is more informative both in the code and
error messages if the assertions do get hit.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <julien.gralL@arm.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2017-06-23 15:00:37 +01:00
Andrew Cooper 28022c62de x86/mm: Drop is_guest_l1_slot()
No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2017-06-23 15:00:37 +01:00
Andrew Cooper 2b8eb37993 x86/mm: Misc nonfunctional cleanup
* Drop trailing whitespace
 * Apply Xen comment and space style
 * Switch bool_t to bool
 * Drop TOGGLE_MODE() macro
 * Replace erroneous mandatory barriers with smp barriers
 * Switch boolean ints for real bools

No (intended) functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2017-06-23 15:00:37 +01:00
Razvan Cojocaru b20f8cd11f x86/monitor: Fixed CID 1412966: Memory - corruptions (OVERRUN)
Fixed an issue where the maximum index allowed (31) goes beyond the
actual number of array elements (4) of ad->monitor.write_ctrlreg_mask.
Coverity-ID: 1412966

Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-06-23 15:00:37 +01:00
Jan Beulich a15516c0cf make steal_page() return a proper error value
... and use it where suitable (the tmem caller doesn't propagate an
error code). While it doesn't matter as much, also make donate_page()
follow suit on x86 (on ARM it already returns -ENOSYS).

Also move their declarations to common code and add __must_check.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
2017-06-23 15:49:41 +02:00