]> xenbits.xensource.com Git - xen.git/log
xen.git
7 years agox86/acpi: use plain bool
Wei Liu [Fri, 30 Jun 2017 15:44:12 +0000 (16:44 +0100)]
x86/acpi: use plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoConfig.mk: update mini-os changeset
Wei Liu [Tue, 4 Jul 2017 13:31:01 +0000 (14:31 +0100)]
Config.mk: update mini-os changeset

The changes contain implementations for some termios functions.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
7 years agotools/libxl/libxl_pci.c: Judge igd through class code instead of device ID
Xiong Zhang [Sun, 2 Jul 2017 19:25:53 +0000 (03:25 +0800)]
tools/libxl/libxl_pci.c: Judge igd through class code instead of device ID

IGD passthrough couldn't work on Skylake and Kabylake, because their
Device ID aren't in fixup_ids[]. Currently we need to add every intel
graphic ID into fixup_ids[], it is hard to maintain.

This patch judge intel graphics through vendor id (0x8086) and class
code(0x030000), this could support both the old and new intel graphics,
and reduce maintain work in future.

Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agotools/libxl/libxl_pci.c: Extract sysfs_dev_get_class from libxl__grant_vga_iomem_perm...
Xiong Zhang [Sun, 2 Jul 2017 19:25:52 +0000 (03:25 +0800)]
tools/libxl/libxl_pci.c: Extract sysfs_dev_get_class from libxl__grant_vga_iomem_permission

No functional change. Just extract this function for next patch and avoid
code repetition.

Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agotools: utility to dump guest grant table info
Dongli Zhang [Sun, 2 Jul 2017 23:34:13 +0000 (07:34 +0800)]
tools: utility to dump guest grant table info

As both xen-netfront and xen-blkfront support multi-queue, they would
consume a lot of grant table references when there are many paravirtual
devices and vcpus assigned to guest. Guest domU might panic or hang due to
grant allocation failure when nr_grant_frames in guest has reached its max
value.

This utility would help the administrators to diagnose xen issue. There is
only one command gnttab_query_size so far to monitor the guest grant table
frame usage on dom0 side so that it is not required to debug on guest
kernel side for crash/hang analysis anymore.

It is extensible for adding new commands for more diagnostic functions and
the framework of xen-diag.c is from xen-livepatch.c.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agotools/libxc: add interface for GNTTABOP_query_size
Dongli Zhang [Sun, 2 Jul 2017 23:34:12 +0000 (07:34 +0800)]
tools/libxc: add interface for GNTTABOP_query_size

This patch adds new interface for GNTTABOP_query_size in libxc to help
query the current grant table frames and maximum grant table frames for a
specific domain.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agooxenstored: trim history in the frequent_ops function
Thomas Sanders [Tue, 28 Mar 2017 17:57:52 +0000 (18:57 +0100)]
oxenstored: trim history in the frequent_ops function

We were trimming the history of commits only at the end of each
transaction (regardless of how it ended).

Therefore if non-transactional writes were being made but no
transactions were being ended, the history would grow
indefinitely. Now we trim the history at regular intervals.

Signed-off-by: Thomas Sanders <thomas.sanders@citrix.com>
7 years agox86/vmx: expose LMCE feature via guest MSR_IA32_FEATURE_CONTROL
Haozhong Zhang [Tue, 4 Jul 2017 08:44:03 +0000 (10:44 +0200)]
x86/vmx: expose LMCE feature via guest MSR_IA32_FEATURE_CONTROL

If MCG_LMCE_P is present in guest MSR_IA32_MCG_CAP, then set LMCE and
LOCK bits in guest MSR_IA32_FEATURE_CONTROL. Intel SDM requires those
bits are set before SW can enable LMCE.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/mce_intel: detect and enable LMCE on Intel host
Haozhong Zhang [Tue, 4 Jul 2017 08:43:32 +0000 (10:43 +0200)]
x86/mce_intel: detect and enable LMCE on Intel host

Enable LMCE if it's supported by the host CPU. If Xen boot parameter
"mce_fb = 1" is present, LMCE will be disabled forcibly.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/mce: handle host LMCE
Haozhong Zhang [Tue, 4 Jul 2017 08:42:45 +0000 (10:42 +0200)]
x86/mce: handle host LMCE

A round of mce_softirq() may handle multiple deferred MCE's.
 1/ If all of them are LMCE's, then mce_softirq() is called on one CPU
    and should not wait for others.
 2/ If at least one of them is non-local MCE, then mce_softirq()
    should sync with other CPUs. mce_softirq() should check those two
    cases and handle them accordingly.

Because mce_softirq() can be interrupted by MC# again, we should also
ensure the deferred MCE handling in mce_softirq() is immutable to the
change of the checking result.

A per-cpu list 'lmce_pending' is introduced to 'struct mc_telem_cpu_ctl'
along with the existing per-cpu list 'pending' for LMCE handling.

MC# handler mcheck_cmn_handler() ensures that
 1/ if all deferred MCE's on a CPU are LMCE's, then all of their
    telemetries will be only in 'lmce_pending' on that CPU;
 2/ if at least one of deferred MCE on a CPU is not LMCE, then all
    telemetries of deferred MCE's on that CPU will be only in
    'pending' on that CPU.

Therefore, the non-empty of 'lmce_pending' can be used to determine
whether it's the former of the beginning two cases in MCE softirq
handler mce_softirq().

mce_softirq() atomically moves deferred MCE's from either list
'lmce_pending' on the current CPU or lists 'pending' on the current or
other CPUs to list 'processing' in the current CPU, and then handles
deferred MCE's in list 'processing'.  New coming MC# before and after
the atomic move, which change the result of the check, do not change
whether MCE's in 'processing' are LMCE or not, so mce_softirq() can
still handle 'processing' according to the result of previous check.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/mce: allow mce_barrier_{enter,exit} to return without waiting
Haozhong Zhang [Mon, 3 Jul 2017 15:43:45 +0000 (17:43 +0200)]
x86/mce: allow mce_barrier_{enter,exit} to return without waiting

Add a 'wait' argument to mce_barrier_{enter,exit}() to specify whether
the barrier functions should return immediately without waiting
mce_barrier_{enter,exit}() on other CPUs. This is useful when handling
LMCE, where mce_barrier_{enter,exit} are called only on one CPU.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/mce: fix comment of struct mc_telem_cpu_ctl
Haozhong Zhang [Mon, 3 Jul 2017 15:43:36 +0000 (17:43 +0200)]
x86/mce: fix comment of struct mc_telem_cpu_ctl

Since c/s cbc585158f ("x86/mce: eliminate unnecessary NR_CPUS-sized
arrays"), struct mc_telem_cpu_ctl was introduced and has been used as
the type of per-cpu variables rather than global variables. However,
some comments within it have not been updated accordingly.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
7 years agoxen/arm: lpae: Switch from bool_t to bool
Julien Grall [Fri, 30 Jun 2017 15:54:31 +0000 (16:54 +0100)]
xen/arm: lpae: Switch from bool_t to bool

We are phasing out the use of bool_t in the hypervisor code.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: mm: Use __func__ rather than plain name in format string
Julien Grall [Fri, 30 Jun 2017 15:54:30 +0000 (16:54 +0100)]
xen/arm: mm: Use __func__ rather than plain name in format string

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabelllini <sstabellini@kernel.org>
7 years agoxen/arm: mm: Introduce temporary variable in create_xen_entries
Julien Grall [Fri, 30 Jun 2017 15:54:29 +0000 (16:54 +0100)]
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>
7 years agoxen/arm: mm: Use lpae_valid and lpae_table in create_xen_entries
Julien Grall [Fri, 30 Jun 2017 15:54:28 +0000 (16:54 +0100)]
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>
7 years agoxen/arm: p2m: Move lpae_* helpers in lpae.h
Julien Grall [Fri, 30 Jun 2017 15:54:27 +0000 (16:54 +0100)]
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>
7 years agoxen/arm: p2m: Rename p2m_valid, p2m_table, p2m_mapping and p2m_is_superpage
Julien Grall [Fri, 30 Jun 2017 15:54:26 +0000 (16:54 +0100)]
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>
7 years agoxen/arm: lpae: Fix comments coding style
Julien Grall [Fri, 30 Jun 2017 15:54:25 +0000 (16:54 +0100)]
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>
7 years agoxen/arm: Move LPAE definition in a separate header
Julien Grall [Fri, 30 Jun 2017 15:54:24 +0000 (16:54 +0100)]
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>
7 years agoxen/arm: create_xen_entries: Use typesafe MFN
Julien Grall [Fri, 30 Jun 2017 15:54:23 +0000 (16:54 +0100)]
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>
7 years agoxen/arm: livepatch: Redefine virt_to_mfn to support typesafe
Julien Grall [Fri, 30 Jun 2017 15:54:22 +0000 (16:54 +0100)]
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>
7 years agoxen/arm: alternative: Redefine virt_to_mfn to support typesafe
Julien Grall [Fri, 30 Jun 2017 15:54:21 +0000 (16:54 +0100)]
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>
7 years agoxen/arm: domain_build: Redefine virt_to_mfn to support typesafe
Julien Grall [Fri, 30 Jun 2017 15:54:20 +0000 (16:54 +0100)]
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>
7 years agoxen/arm: mm: Redefine virt_to_mfn to support typesafe
Julien Grall [Fri, 30 Jun 2017 15:54:19 +0000 (16:54 +0100)]
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>
7 years agoxen/arm: p2m: Redefine mfn_to_page and page_to_mfn to use typesafe
Julien Grall [Fri, 30 Jun 2017 15:54:18 +0000 (16:54 +0100)]
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>
7 years agoxen/arm: mm: Use typesafe mfn for xenheap_mfn_*
Julien Grall [Fri, 30 Jun 2017 15:54:17 +0000 (16:54 +0100)]
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>
7 years agoxen/arm: setup: Remove bogus xenheap_mfn_end in setup_mm for arm64
Julien Grall [Fri, 30 Jun 2017 15:54:16 +0000 (16:54 +0100)]
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>
7 years agox86/shadow: Switch to using bool
Andrew Cooper [Fri, 23 Jun 2017 11:26:31 +0000 (11:26 +0000)]
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>
7 years agotools/libxenforeignmemory: add xenforeignmemory_map2 function
Igor Druzhinin [Wed, 28 Jun 2017 19:27:08 +0000 (20:27 +0100)]
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>
7 years agolibxl: reformat cpuid_flags
Marek Marczykowski-Górecki [Fri, 30 Jun 2017 13:16:59 +0000 (15:16 +0200)]
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>
7 years agolibxl: make cpuid_flags array static const
Marek Marczykowski-Górecki [Fri, 30 Jun 2017 13:16:58 +0000 (15:16 +0200)]
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>
7 years agolibxl: fix osvm cpuid flag
Marek Marczykowski-Górecki [Fri, 30 Jun 2017 13:16:57 +0000 (15:16 +0200)]
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>
7 years agolibxl: add more cpuid flags handling
Marek Marczykowski-Górecki [Fri, 30 Jun 2017 13:16:56 +0000 (15:16 +0200)]
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>
7 years agovvmx: fix ept_sync() for nested p2m
Sergey Dyasli [Wed, 28 Jun 2017 09:35:45 +0000 (10:35 +0100)]
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>
7 years agox86/vvmx: Fix WRMSR interception of VMX MSRs
Andrew Cooper [Wed, 28 Jun 2017 14:05:35 +0000 (15:05 +0100)]
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>
7 years agoxen/mm: Introduce {G,M}FN_INVALID_INITIALIZER
Julien Grall [Tue, 27 Jun 2017 09:33:20 +0000 (10:33 +0100)]
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>
7 years agoRevert "mm: don't use _{g,m}fn for defining INVALID_{G,M}FN"
Julien Grall [Tue, 27 Jun 2017 09:33:19 +0000 (10:33 +0100)]
Revert "mm: don't use _{g,m}fn for defining INVALID_{G,M}FN"

This reverts commit 725039d39ef10c6e3c59ba4a2511188281133b19. 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>
7 years agoConfig.mk: update mini-os changeset
Wei Liu [Thu, 29 Jun 2017 11:15:38 +0000 (12:15 +0100)]
Config.mk: update mini-os changeset

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
7 years agox86/setup.c: use plain bool
Wei Liu [Wed, 28 Jun 2017 14:11:24 +0000 (15:11 +0100)]
x86/setup.c: use plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
7 years agox86/nmi.c: use plain bool
Wei Liu [Wed, 28 Jun 2017 13:49:03 +0000 (14:49 +0100)]
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>
7 years agox86/time.c: use plain bool
Wei Liu [Wed, 28 Jun 2017 13:45:56 +0000 (14:45 +0100)]
x86/time.c: use plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
7 years agox86/crash.c: use plain bool
Wei Liu [Wed, 28 Jun 2017 13:42:02 +0000 (14:42 +0100)]
x86/crash.c: use plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
7 years agox86/dom0_build.c: use plain bool
Wei Liu [Wed, 28 Jun 2017 13:41:13 +0000 (14:41 +0100)]
x86/dom0_build.c: use plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
7 years agox86/domain.c: use plain bool
Wei Liu [Wed, 28 Jun 2017 13:38:54 +0000 (14:38 +0100)]
x86/domain.c: use plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
7 years agox86/platform_hypercall.c: use plain bool
Wei Liu [Wed, 28 Jun 2017 13:32:03 +0000 (14:32 +0100)]
x86/platform_hypercall.c: use plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
7 years agox86/irq.c: use plain bool
Wei Liu [Wed, 28 Jun 2017 13:15:58 +0000 (14:15 +0100)]
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>
7 years agolibxc: add xc_domain_add_to_physmap_batch to wrap XENMEM_add_to_physmap_batch
Zhongze Liu [Thu, 22 Jun 2017 16:35:28 +0000 (00:35 +0800)]
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>
7 years agostubdom: fix vtpm compilation on GCC-7
Marek Marczykowski-Górecki [Tue, 27 Jun 2017 17:35:43 +0000 (19:35 +0200)]
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>
7 years agoxen/efi: Switch to using bool
Andrew Cooper [Fri, 23 Jun 2017 11:11:01 +0000 (11:11 +0000)]
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>
7 years agoxen/tmem: Switch to using bool
Andrew Cooper [Fri, 23 Jun 2017 10:48:21 +0000 (10:48 +0000)]
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>
7 years agox86/pv: reorder items in Makefile
Wei Liu [Wed, 28 Jun 2017 11:05:42 +0000 (12:05 +0100)]
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>
7 years agox86: clean up traps.c
Wei Liu [Thu, 8 Jun 2017 16:34:00 +0000 (17:34 +0100)]
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>
7 years agox86/traps.h: remove unused declaration of cpu_user_regs
Wei Liu [Mon, 26 Jun 2017 16:00:52 +0000 (17:00 +0100)]
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>
7 years agox86/traps: move some PV specific functions to pv/traps.c
Wei Liu [Mon, 26 Jun 2017 15:46:50 +0000 (16:46 +0100)]
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>
7 years agox86/callback.c: slightly change {un,}register_guest_nmi_callback
Wei Liu [Mon, 26 Jun 2017 15:06:18 +0000 (16:06 +0100)]
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>
7 years agox86/traps: move {un,}register_guest_nmi_callback to pv/callback.c
Wei Liu [Mon, 26 Jun 2017 14:54:51 +0000 (15:54 +0100)]
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>
7 years agoxen: move do_nmi_op and make it x86 only
Wei Liu [Mon, 26 Jun 2017 14:20:35 +0000 (15:20 +0100)]
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>
7 years agox86/traps: factor out pv_trap_init
Wei Liu [Mon, 5 Jun 2017 15:15:26 +0000 (16:15 +0100)]
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>
7 years agox86/traps: simplify and rename send_guest_trap
Wei Liu [Fri, 23 Jun 2017 17:53:28 +0000 (18:53 +0100)]
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>
7 years agoxen/pt: Avoid NULL dereference in hvm_pirq_eoi()
Andrew Cooper [Tue, 27 Jun 2017 17:45:03 +0000 (18:45 +0100)]
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>
7 years agoxen/pt: Unlock d->event_lock on error paths
Andrew Cooper [Tue, 27 Jun 2017 17:29:55 +0000 (18:29 +0100)]
xen/pt: Unlock d->event_lock on error paths

Introduced by c/s fba00494268 "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>
7 years agox86: simplify guest_has_trap_callback
Wei Liu [Fri, 23 Jun 2017 17:34:41 +0000 (18:34 +0100)]
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>
7 years agox86: remove the now empty x86_64/compat/traps.c
Wei Liu [Thu, 8 Jun 2017 16:24:20 +0000 (17:24 +0100)]
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>
7 years agox86: move compat_set_trap_table along side the non-compat variant
Wei Liu [Fri, 23 Jun 2017 17:19:12 +0000 (18:19 +0100)]
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>
7 years agox86: move do_set_trap_table to pv/callback.c
Wei Liu [Fri, 23 Jun 2017 17:12:53 +0000 (18:12 +0100)]
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>
7 years agox86: move the compat callback ops next to the non-compat variant
Wei Liu [Thu, 8 Jun 2017 16:19:48 +0000 (17:19 +0100)]
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>
7 years agox86: move callback_op code to pv/callback.c
Wei Liu [Mon, 5 Jun 2017 17:45:01 +0000 (18:45 +0100)]
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>
7 years agotravis: install ghostscript
Wei Liu [Tue, 27 Jun 2017 09:53:20 +0000 (10:53 +0100)]
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>
7 years agox86/vioapic: bind interrupts to PVH Dom0
Roger Pau Monne [Fri, 23 Jun 2017 09:59:51 +0000 (10:59 +0100)]
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>
7 years agox86/pt: enable binding of GSIs to a PVH Dom0
Roger Pau Monne [Mon, 26 Jun 2017 09:47:13 +0000 (10:47 +0100)]
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>
7 years agox86/vioapic: make gsi_vioapic private
Roger Pau Monne [Mon, 26 Jun 2017 09:46:42 +0000 (10:46 +0100)]
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>
7 years agorombios: prevent building with PIC/PIE
Olaf Hering [Mon, 26 Jun 2017 12:55:07 +0000 (14:55 +0200)]
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>
7 years agox86/mm: Fix infinite loop in get_spage_pages()
Andrew Cooper [Mon, 26 Jun 2017 11:58:25 +0000 (12:58 +0100)]
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>
7 years agoxen/arm: Rename vgic_reg* functions definitions and calls to vreg_reg*
Bhupinder Thakur [Thu, 22 Jun 2017 07:38:37 +0000 (13:08 +0530)]
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>
7 years agoxen/arm: vpl011: Move vgic register access functions to vreg.h
Bhupinder Thakur [Thu, 22 Jun 2017 07:38:36 +0000 (13:08 +0530)]
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>
7 years agox86/mm: Rename d to currd in do_mmuext_op()
Andrew Cooper [Tue, 18 Apr 2017 14:43:16 +0000 (14:43 +0000)]
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>
7 years agox86emul: correct CF output of SHLD/SHRD
Jan Beulich [Fri, 23 Jun 2017 15:59:12 +0000 (17:59 +0200)]
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>
7 years agoxen-detect: handle asprintf error
Wei Liu [Wed, 21 Jun 2017 14:41:52 +0000 (15:41 +0100)]
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>
7 years agox86: fix coding a style issue in asm-x86/traps.h
Wei Liu [Thu, 8 Jun 2017 16:28:46 +0000 (17:28 +0100)]
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>
7 years agox86: move compat_show_guest_statck near its non-compat variant
Wei Liu [Thu, 8 Jun 2017 16:22:33 +0000 (17:22 +0100)]
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>
7 years agox86: move compat_iret along side its non-compat variant
Wei Liu [Thu, 8 Jun 2017 16:13:29 +0000 (17:13 +0100)]
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>
7 years agox86: move hypercall_page_initialise_ring1_kernel
Wei Liu [Thu, 8 Jun 2017 16:09:49 +0000 (17:09 +0100)]
x86: move hypercall_page_initialise_ring1_kernel

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86: move hypercall_page_initialise_ring3_kernel to pv/hypercall.c
Wei Liu [Thu, 8 Jun 2017 16:06:19 +0000 (17:06 +0100)]
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>
7 years agox86/traps: move init_int80_direct_trap to pv/traps.c
Wei Liu [Thu, 8 Jun 2017 16:02:08 +0000 (17:02 +0100)]
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>
7 years agox86: move do_iret to pv/iret.c
Wei Liu [Mon, 5 Jun 2017 17:19:38 +0000 (18:19 +0100)]
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>
7 years agox86: move toggle_guest_mode to pv/domain.c
Wei Liu [Mon, 5 Jun 2017 17:13:16 +0000 (18:13 +0100)]
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>
7 years agox86/traps: move set_guest_{machine,nmi}_trapbounce
Wei Liu [Mon, 5 Jun 2017 14:58:25 +0000 (15:58 +0100)]
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>
7 years agox86/traps: move pv_inject_event to pv/traps.c
Wei Liu [Mon, 5 Jun 2017 14:53:54 +0000 (15:53 +0100)]
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>
7 years agox86: move some misc PV hypercalls to misc-hypercalls.c
Wei Liu [Mon, 5 Jun 2017 14:49:14 +0000 (15:49 +0100)]
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>
7 years agox86: clean up PV emulation code
Wei Liu [Mon, 5 Jun 2017 14:16:17 +0000 (15:16 +0100)]
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>
7 years agoxen/livepatch: Don't crash on encountering STN_UNDEF relocations
Andrew Cooper [Tue, 13 Jun 2017 20:36:58 +0000 (21:36 +0100)]
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>
7 years agoxen/livepatch: Use zeroed memory allocations for arrays
Andrew Cooper [Thu, 22 Jun 2017 17:55:31 +0000 (18:55 +0100)]
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>
7 years agoxen/livepatch: Clean up arch relocation handling
Andrew Cooper [Tue, 13 Jun 2017 20:17:47 +0000 (21:17 +0100)]
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]
7 years agoxen: Replace ASSERT(0) with ASSERT_UNREACHABLE()
Andrew Cooper [Wed, 21 Jun 2017 11:36:18 +0000 (12:36 +0100)]
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>
7 years agox86/mm: Drop is_guest_l1_slot()
Andrew Cooper [Tue, 18 Apr 2017 14:49:16 +0000 (15:49 +0100)]
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>
7 years agox86/mm: Misc nonfunctional cleanup
Andrew Cooper [Tue, 18 Apr 2017 14:41:16 +0000 (15:41 +0100)]
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>
7 years agox86/monitor: Fixed CID 1412966: Memory - corruptions (OVERRUN)
Razvan Cojocaru [Wed, 21 Jun 2017 16:37:31 +0000 (19:37 +0300)]
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>
7 years agomake steal_page() return a proper error value
Jan Beulich [Fri, 23 Jun 2017 13:49:41 +0000 (15:49 +0200)]
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>
7 years agox86emul: simplify SHLD/SHRD handling
Jan Beulich [Fri, 23 Jun 2017 13:48:28 +0000 (15:48 +0200)]
x86emul: simplify SHLD/SHRD handling

First of all there's no point considering the "shift == width" case,
when immediately before that check we mask "shift" by "width - 1". And
then truncate_word() use can be reduced too: dst.val, as obtained by
generic operand fetching code, is already suitably truncated, and its
use can also be made symmetric in the main conditional expression (on
only left shift results). Finally masking the result of a right shift
is not necessary when the left hand operand doesn't have more than
"width" significant bits.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>