]> xenbits.xensource.com Git - xen.git/log
xen.git
7 years agopublic/sysctl: drop unnecessary typedefs and handles
Jan Beulich [Wed, 20 Sep 2017 15:25:01 +0000 (17:25 +0200)]
public/sysctl: drop unnecessary typedefs and handles

By virtue of the struct xen_sysctl container structure, most of them
are really just cluttering the name space.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
7 years agopublic/domctl: drop unnecessary typedefs and handles
Jan Beulich [Wed, 20 Sep 2017 15:23:41 +0000 (17:23 +0200)]
public/domctl: drop unnecessary typedefs and handles

By virtue of the struct xen_domctl container structure, most of them
are really just cluttering the name space.

While doing so,
- convert an enum typed (pt_irq_type_t) structure field to a fixed
  width type,
- make x86's paging_domctl() and descendants take a properly typed
  handle,
- add const in a few places.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Acked-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Meng Xu <mengxu@cis.upenn.edu>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
7 years agox86/hvm: break out __hvm_copy()'s translation logic
Andrew Cooper [Wed, 20 Sep 2017 15:21:29 +0000 (17:21 +0200)]
x86/hvm: break out __hvm_copy()'s translation logic

It will be reused by later changes.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Alexandru Isaila <aisaila@bitdefender.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/hvm: rename enum hvm_copy_result to hvm_translation_result
Andrew Cooper [Wed, 20 Sep 2017 15:20:53 +0000 (17:20 +0200)]
x86/hvm: rename enum hvm_copy_result to hvm_translation_result

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
7 years agoadd new domctl hypercall to set grant table resource limits
Juergen Gross [Wed, 20 Sep 2017 15:19:52 +0000 (17:19 +0200)]
add new domctl hypercall to set grant table resource limits

Add a domctl hypercall to set the domain's resource limits regarding
grant tables.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
7 years agoclean up grant_table.h
Juergen Gross [Wed, 20 Sep 2017 15:18:58 +0000 (17:18 +0200)]
clean up grant_table.h

Many definitions can be moved from xen/grant_table.h to
common/grant_table.c now, as they are no longer used in other sources.

Rearrange the elements of struct grant_table to minimize holes due to
alignment of elements.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
7 years agomove XENMAPSPACE_grant_table code into grant_table.c
Juergen Gross [Wed, 20 Sep 2017 15:18:23 +0000 (17:18 +0200)]
move XENMAPSPACE_grant_table code into grant_table.c

The x86 and arm versions of XENMAPSPACE_grant_table handling are nearly
identical. Move the code into a function in grant_table.c and add an
architecture dependant hook to handle the differences.

Switch to mfn_t in order to be more type safe.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <julien.grall@arm.com>
7 years agox86/vvmx: add hvm_intsrc_vector support to nvmx_intr_intercept()
Sergey Dyasli [Wed, 20 Sep 2017 15:17:21 +0000 (17:17 +0200)]
x86/vvmx: add hvm_intsrc_vector support to nvmx_intr_intercept()

Under the following circumstances:

    1. L1 doesn't enable PAUSE exiting or PAUSE-loop exiting controls
    2. L2 executes PAUSE in a loop with RFLAGS.IE == 0

L1's PV IPI through event channel will never reach the target L1's vCPU
which runs L2 because nvmx_intr_intercept() doesn't know about
hvm_intsrc_vector. This leads to infinite L2 loop without nested
vmexits and can cause L1 to hang.

The issue is easily reproduced with Qemu/KVM on CentOS-7-1611 as L1
and an L2 guest with SMP.

Fix nvmx_intr_intercept() by injecting hvm_intsrc_vector irq into L1
which will cause nested vmexit.

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
7 years agoxen/arm: Replace ioremap_attr(PAGE_HYPERVISOR_NOCACHE) call by ioremap_nocache
Julien Grall [Tue, 12 Sep 2017 10:03:18 +0000 (11:03 +0100)]
xen/arm: Replace ioremap_attr(PAGE_HYPERVISOR_NOCACHE) call by ioremap_nocache

ioremap_cache is a wrapper of ioremap_attr(...).

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: traps: Improve logging for data/prefetch abort fault
Julien Grall [Tue, 12 Sep 2017 10:03:17 +0000 (11:03 +0100)]
xen/arm: traps: Improve logging for data/prefetch abort fault

Walk the hypervisor page table for data/prefetch abort fault to help
diagnostics error in the page tables.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: traps: Introduce a helper to read the hypersivor fault register
Julien Grall [Tue, 12 Sep 2017 10:03:16 +0000 (11:03 +0100)]
xen/arm: traps: Introduce a helper to read the hypersivor fault register

While ARM32 has 2 distinct registers for the hypervisor fault register
(one for prefetch abort, the other for data abort), AArch64 has only
one.

Currently, the logic is open-code but a follow-up patch will require to
read it too. So move the logic in a separate helper and use it instead
of open-coding it.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: Introduce hsr_xabt to gather common bits between hsr_{d,i}abt
Julien Grall [Tue, 12 Sep 2017 10:03:15 +0000 (11:03 +0100)]
xen/arm: Introduce hsr_xabt to gather common bits between hsr_{d,i}abt

This will allow to consolidate some part of the data abort and prefetch
abort handling in a single function later on.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: Add FnV field in hsr_*abt
Julien Grall [Tue, 12 Sep 2017 10:03:14 +0000 (11:03 +0100)]
xen/arm: Add FnV field in hsr_*abt

FnV (FAR not Valid) bit was introduced by ARMv8 in both AArch32 and
AArch64 (See D7-2275, D7-2277, G6-4958, G6-4962 in ARM DDI 0487B.a).

Note the new revision of ARMv8 defined more bits in HSR. They haven't
been added at the moment because we have no use of them in Xen.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: arm32: Don't define FAR_EL1
Julien Grall [Tue, 12 Sep 2017 10:03:13 +0000 (11:03 +0100)]
xen/arm: arm32: Don't define FAR_EL1

Aliasing FAR_EL1 to IFAR is wrong because on ARMv8 FAR_EL1[31:0] is
architecturally mapped to DFAR and FAR_EL1[63:32] to IFAR.

As FAR_EL1 is not currently used in ARM32 code, remove it.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: traps: Don't define FAR_EL2 for ARM32
Julien Grall [Fri, 15 Sep 2017 23:45:59 +0000 (16:45 -0700)]
xen/arm: traps: Don't define FAR_EL2 for ARM32

Aliasing FAR_EL2 to HIFAR makes the code confusing because on ARMv8
FAR_EL2[31:0] is architecturally mapped to HDFAR and FAR_EL2[63:32] to
HIFAR. See D7.2.30 in ARM DDI 0487B.a. Open-code the alias instead.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: hsr_iabt: Document RES0 field
Julien Grall [Tue, 12 Sep 2017 10:03:11 +0000 (11:03 +0100)]
xen/arm: hsr_iabt: Document RES0 field

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: mm: Redefine mfn_to_virt to use typesafe
Julien Grall [Tue, 12 Sep 2017 10:03:10 +0000 (11:03 +0100)]
xen/arm: mm: Redefine mfn_to_virt to use typesafe

This add a bit more safety in the memory subsystem code.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoMAINTAINERS: Add public/arch-arm.h under the ARM subsystem
Julien Grall [Tue, 19 Sep 2017 11:25:53 +0000 (12:25 +0100)]
MAINTAINERS: Add public/arch-arm.h under the ARM subsystem

The header public/arch-arm.h contains mostly ARM specific code. Avoid CC
the "THE REST" maintainers on it.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agocorrect gnttab_get_status_frames()
Juergen Gross [Tue, 19 Sep 2017 15:48:23 +0000 (17:48 +0200)]
correct gnttab_get_status_frames()

In gnttab_get_status_frames() all accesses to nr_status_frames should
be done with the grant table lock held.

While at it correct coding style: labels should be indented by one
space.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
7 years agomm: scrub pages returned back to heap if MEMF_no_scrub is set
Boris Ostrovsky [Tue, 19 Sep 2017 15:47:47 +0000 (17:47 +0200)]
mm: scrub pages returned back to heap if MEMF_no_scrub is set

Set free_heap_pages()'s need_scrub to true if alloc_domheap_pages()
returns pages back to heap as result of assign_pages() error when those
pages were requested with MEMF_no_scrub flag.

We need to do this because there is a possibility that
alloc_heap_pages() might clear buddy's PGC_need_scrubs flag without
actually clearing the page.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agohvmloader: Use MB(x) and GB(x) macros
Konrad Rzeszutek Wilk [Wed, 28 Sep 2016 19:20:52 +0000 (15:20 -0400)]
hvmloader: Use MB(x) and GB(x) macros

instead of hardcoding values. We also drop the uint64_t
cast as the macro uses ULL to produce the proper width
types.

Acked-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
7 years agoxl: avoid leaking memory in vdispl parser
Wei Liu [Mon, 18 Sep 2017 13:56:14 +0000 (14:56 +0100)]
xl: avoid leaking memory in vdispl parser

Coverity-ID: 1418095

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
7 years agolibxl: use libxl__read_xenstore_mandatory in vtpm function
Wei Liu [Mon, 18 Sep 2017 13:56:12 +0000 (14:56 +0100)]
libxl: use libxl__read_xenstore_mandatory in vtpm function

libxl__read_xenstore can return NULL. Use the _mandatory variant to
return early when the read fails.

Coverity-ID: 1418098

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
7 years agolibxl: use libxl__read_xenstore_mandatory in vdispl function
Wei Liu [Mon, 18 Sep 2017 13:56:13 +0000 (14:56 +0100)]
libxl: use libxl__read_xenstore_mandatory in vdispl function

Coverity-ID: 1418097

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
7 years agox86emul: re-order checks in test harness
Jan Beulich [Mon, 18 Sep 2017 10:31:02 +0000 (12:31 +0200)]
x86emul: re-order checks in test harness

On older systems printing the "n/a" messages (resulting from the
compiler not being new enough to deal with some of the test code) isn't
very useful: If both CPU and compiler are too old for a certain test,
we can as well omit those messages, as those tests wouldn't be run even
if the compiler did produce code. (This has become obvious with the
3DNow! tests, which I had to run on an older system still supporting
those insns, and that system naturally also had an older compiler.)

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agomm: use typesafe MFN for alloc_boot_pages return
Julien Grall [Mon, 18 Sep 2017 10:27:57 +0000 (12:27 +0200)]
mm: use typesafe MFN for alloc_boot_pages return

At the moment, most of the callers will have to use mfn_x. However
follow-up patches will remove some of them by propagating the typesafe a
bit further.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agox86/cpuidle: add new CPU families
Jan Beulich [Mon, 18 Sep 2017 10:27:06 +0000 (12:27 +0200)]
x86/cpuidle: add new CPU families

Bring code up-to-date with SDM version 063.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
7 years agoVMX: add new CPU families to LBR handling
Jan Beulich [Mon, 18 Sep 2017 10:26:22 +0000 (12:26 +0200)]
VMX: add new CPU families to LBR handling

Bring code up-to-date with SDM version 063, including the LBR format
enumeration.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
7 years agoVMX: convert CPU family numbers to hex
Jan Beulich [Mon, 18 Sep 2017 10:25:32 +0000 (12:25 +0200)]
VMX: convert CPU family numbers to hex

This makes it easier to match them against SDM updates. Also update a
few comments with names as per SDM version 063.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
7 years agoxen/arm: p2m: Check for p2m->domain to be initialized before releasing resources
Oleksandr Tyshchenko [Mon, 28 Aug 2017 17:32:26 +0000 (20:32 +0300)]
xen/arm: p2m: Check for p2m->domain to be initialized before releasing resources

Since p2m_teardown() can be called when p2m_init() haven't executed yet
we might deal with unitialized list "p2m->pages" which leads to crash.
To avoid this use back pointer to domain as end-of-initialization indicator.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: vgic: Check for vgic handler to be initialized before dereferencing it
Oleksandr Tyshchenko [Mon, 28 Aug 2017 17:32:25 +0000 (20:32 +0300)]
xen/arm: vgic: Check for vgic handler to be initialized before dereferencing it

Since domain_vgic_free() can be called when the vgic_ops haven't been
initialised yet, always check that d->arch.vgic.handler is not a null.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoarm: use plain bool in various headers
Wei Liu [Fri, 15 Sep 2017 09:24:09 +0000 (10:24 +0100)]
arm: use plain bool in various headers

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
7 years agoarm/vtimer.c: switch to plain bool
Wei Liu [Fri, 15 Sep 2017 09:18:38 +0000 (10:18 +0100)]
arm/vtimer.c: switch to plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
7 years agoarm/smpboot.c: switch to plain bool
Wei Liu [Fri, 15 Sep 2017 09:17:50 +0000 (10:17 +0100)]
arm/smpboot.c: switch to plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
7 years agoarm/decode.c: switch to plain bool
Wei Liu [Fri, 15 Sep 2017 09:16:18 +0000 (10:16 +0100)]
arm/decode.c: switch to plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
7 years agoarm/bootfdt.c: switch to plain bool
Wei Liu [Fri, 15 Sep 2017 09:12:33 +0000 (10:12 +0100)]
arm/bootfdt.c: switch to plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
7 years agoarm/cpu{errata,feature}.[ch]: switch to plain bool
Wei Liu [Fri, 15 Sep 2017 09:09:14 +0000 (10:09 +0100)]
arm/cpu{errata,feature}.[ch]: switch to plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
7 years agoarm/alternative.c: switch to plain bool
Wei Liu [Fri, 15 Sep 2017 09:06:55 +0000 (10:06 +0100)]
arm/alternative.c: switch to plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
7 years agoarm/platform: switch to plain bool
Wei Liu [Fri, 15 Sep 2017 09:03:35 +0000 (10:03 +0100)]
arm/platform: switch to plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
7 years agoarm/irq: switch to plain bool
Wei Liu [Fri, 15 Sep 2017 08:59:59 +0000 (09:59 +0100)]
arm/irq: switch to plain bool

Also removed a redundant pair of brackets.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
7 years agoarm/domain_build: switch to plain bool
Wei Liu [Thu, 14 Sep 2017 17:01:40 +0000 (18:01 +0100)]
arm/domain_build: switch to plain bool

Also fixed a coding style issue.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
7 years agoarm/{v,}gic: switch to plain bool
Wei Liu [Thu, 14 Sep 2017 16:54:49 +0000 (17:54 +0100)]
arm/{v,}gic: switch to plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
7 years agoarm/acpi: switch to plain bool
Wei Liu [Thu, 14 Sep 2017 16:49:01 +0000 (17:49 +0100)]
arm/acpi: switch to plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
7 years agoxen/arm: Limit the scope of cpregs.h
Julien Grall [Thu, 14 Sep 2017 17:08:59 +0000 (18:08 +0100)]
xen/arm: Limit the scope of cpregs.h

Currently, cpregs.h is indirectly included every files of the hypervisor even
for arm64. However, the only use for arm64 is when emulating co-processors.

For arm32, all users of processor.h expect cpregs.h to be included in
order to access co-processors. So move the inclusion in
asm-arm/arm32/processor.h.

cpregs.h will also be directly included in the co-processors emulation
to accommodate arm64.

This is drastically reducing the exposure of cpregs.h to any source file
on arm64.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: Move sysregs.h in arm64 sub-directory
Julien Grall [Thu, 14 Sep 2017 17:08:58 +0000 (18:08 +0100)]
xen/arm: Move sysregs.h in arm64 sub-directory

sysregs.h contains only code protected by #ifdef CONFIG_ARM_64. Move it
in arm64 sub-directory to reflect that and remove the #ifdef.

At the same time, fixup the guards.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: Move co-processor emulation outside of traps.c
Julien Grall [Thu, 14 Sep 2017 17:08:57 +0000 (18:08 +0100)]
xen/arm: Move co-processor emulation outside of traps.c

The co-processor emulation is quite big and pretty much standalone. Move
it in a separate file to shrink down the size of traps.c.

At the same time remove unused cpregs.h.

No functional change.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: Move sysreg emulation outside of traps.c
Julien Grall [Thu, 14 Sep 2017 17:08:56 +0000 (18:08 +0100)]
xen/arm: Move sysreg emulation outside of traps.c

The sysreg emulation is 64-bit specific and surrounded by #ifdef. Move
them in a separate file arm/arm64/vsysreg.c to shrink down a bit traps.c

No functional change.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: traps: Export a bunch of helpers to handle emulation
Julien Grall [Thu, 14 Sep 2017 17:08:55 +0000 (18:08 +0100)]
xen/arm: traps: Export a bunch of helpers to handle emulation

A follow-up patch will move some parts of traps.c in separate files.
The will require to use helpers that are currently statically defined.
Export the following helpers:
    - inject_undef64_exception
    - inject_undef_exception
    - check_conditional_instr
    - advance_pc
    - handle_raz_wi
    - handle_wo_wi
    - handle_ro_raz

Note that asm-arm/arm32/traps.h is empty but it is to keep parity with
the arm64 counterpart.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen: credit2: implement utilization cap
Dario Faggioli [Thu, 14 Sep 2017 16:30:36 +0000 (17:30 +0100)]
xen: credit2: implement utilization cap

This commit implements the Xen part of the cap mechanism for
Credit2.

A cap is how much, in terms of % of physical CPU time, a domain
can execute at most.

For instance, a domain that must not use more than 1/4 of
one physical CPU, must have a cap of 25%; one that must not
use more than 1+1/2 of physical CPU time, must be given a cap
of 150%.

Caps are per domain, so it is all a domain's vCPUs, cumulatively,
that will be forced to execute no more than the decided amount.

This is implemented by giving each domain a 'budget', and
using a (per-domain again) periodic timer. Values of budget
and 'period' are chosen so that budget/period is equal to the
cap itself.

Budget is burned by the domain's vCPUs, in a similar way to
how credits are.

When a domain runs out of budget, its vCPUs can't run any
longer. They can gain, when the budget is replenishment by
the timer, which event happens once every period.

Blocking the vCPUs because of lack of budget happens by
means of a new (_VPF_parked) pause flag, so that, e.g.,
vcpu_runnable() still works. This is similar to what is
done in sched_rtds.c, as opposed to what happens in
sched_credit.c, where vcpu_pause() and vcpu_unpause()
(which means, among other things, more overhead).

Note that, while adding new fields to csched2_vcpu and
csched2_dom, currently existing members are being moved
around, to achieve best placement inside cache lines.

Note also that xenalyze and tools/xentrace/format are being
updated too.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
7 years agox86/mm: initialize ol1e in create_grant_pv_mapping() for older compilers
Boris Ostrovsky [Thu, 14 Sep 2017 16:01:38 +0000 (18:01 +0200)]
x86/mm: initialize ol1e in create_grant_pv_mapping() for older compilers

On gcc 4.4.4:

mm.c: In function \91create_grant_pv_mapping\92:
mm.c:3839: error: \91ol1e.l1\92 may be used uninitialized in this function

While ol1e would not be used uninitialized (because rc needs to be properly
set) we have to accommodate these older compliers.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agolibxl: fix disk listing function
Wei Liu [Thu, 14 Sep 2017 15:38:11 +0000 (16:38 +0100)]
libxl: fix disk listing function

The path should be "vbd" not "disk".

Fixes fbbaf2cc9 ("libxl: change disk to use generic getting list
functions").

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
7 years agolibxl: add back libxl_device_v{k,f}b_add
Wei Liu [Wed, 13 Sep 2017 13:44:09 +0000 (14:44 +0100)]
libxl: add back libxl_device_v{k,f}b_add

The two functions, unlike a lot others, were hand-coded. They were
deleted by accident while the device framework was reworked. Add them
back.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
7 years agox86/oprofile: Add a missing space to initialisation failure message
Andrew Cooper [Wed, 13 Sep 2017 13:41:07 +0000 (14:41 +0100)]
x86/oprofile: Add a missing space to initialisation failure message

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/mce: remove extra blanks in mctelem.c
Haozhong Zhang [Mon, 11 Sep 2017 07:57:58 +0000 (15:57 +0800)]
x86/mce: remove extra blanks in mctelem.c

The entire file of mctelem.c is in Linux coding style, so do not
change the coding style and only remove trailing spaces and extra
blank lines.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/mce: add emacs block to mctelem.c
Haozhong Zhang [Mon, 11 Sep 2017 07:57:57 +0000 (15:57 +0800)]
x86/mce: add emacs block to mctelem.c

mctelem.c uses the tab indention. Add an emacs block to avoid mixed
indention styles in certain editors.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/mce: adapt mce_intel.c to Xen hypervisor coding style
Haozhong Zhang [Mon, 11 Sep 2017 07:57:56 +0000 (15:57 +0800)]
x86/mce: adapt mce_intel.c to Xen hypervisor coding style

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/mce: adapt mcation.c to Xen hypervisor coding style
Haozhong Zhang [Mon, 11 Sep 2017 07:57:55 +0000 (15:57 +0800)]
x86/mce: adapt mcation.c to Xen hypervisor coding style

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/vmce: adapt vmce.c to Xen hypervisor coding style
Haozhong Zhang [Mon, 11 Sep 2017 07:57:54 +0000 (15:57 +0800)]
x86/vmce: adapt vmce.c to Xen hypervisor coding style

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/mce: adapt mce.{c, h} to Xen hypervisor coding style
Haozhong Zhang [Mon, 11 Sep 2017 07:57:53 +0000 (15:57 +0800)]
x86/mce: adapt mce.{c, h} to Xen hypervisor coding style

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/mm: Prevent 32bit PV guests using out-of-range linear addresses
Andrew Cooper [Fri, 11 Aug 2017 13:02:31 +0000 (13:02 +0000)]
x86/mm: Prevent 32bit PV guests using out-of-range linear addresses

The grant ABI uses 64 bit values, and allows a PV guest to specify linear
addresses.  There is nothing interesting a 32bit PV guest can reference which
will pass an __addr_ok() check (and therefore succeed), but we should still
explicitly check and reject such an attempt.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/mm: Combine {destroy,replace}_grant_{pte,va}_mapping()
Andrew Cooper [Tue, 1 Aug 2017 15:39:59 +0000 (16:39 +0100)]
x86/mm: Combine {destroy,replace}_grant_{pte,va}_mapping()

As with the create side of things, these are largely identical.  Most cases
are actually destroying the mapping rather than replacing it with a stolen
entry.

Reimplement their logic in replace_grant_pv_mapping() in a mostly common
way.

No (intended) change in behaviour from a guests point of view.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/mm: Carve steal_linear_address() out of replace_grant_host_mapping()
Andrew Cooper [Tue, 1 Aug 2017 15:39:59 +0000 (16:39 +0100)]
x86/mm: Carve steal_linear_address() out of replace_grant_host_mapping()

Document its curious semantics.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/mm: Combine create_grant_{pte,va}_mapping()
Andrew Cooper [Tue, 1 Aug 2017 15:39:59 +0000 (15:39 +0000)]
x86/mm: Combine create_grant_{pte,va}_mapping()

create_grant_{pte,va}_mapping() are nearly identical; all that is really
different between them is how they convert their addr parameter to the pte to
install the grant into.

Reimplement their logic in create_grant_pv_mapping() in a mostly common way.

No (intended) change in behaviour from a guests point of view.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/mm: Misc cleanup to {create,replace}_grant_host_mapping()
Andrew Cooper [Tue, 1 Aug 2017 15:39:59 +0000 (16:39 +0100)]
x86/mm: Misc cleanup to {create,replace}_grant_host_mapping()

The purpose of this patch is solely to simplify the resulting diff of later
changes.

 * Factor out curr and currd at the start of the functions.
 * Rename pte to nl1e.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/mm: Factor out the grant flags to pte flags conversion logic
Andrew Cooper [Fri, 11 Aug 2017 11:20:40 +0000 (11:20 +0000)]
x86/mm: Factor out the grant flags to pte flags conversion logic

This fixes a bug where the requested AVAIL* flags were not honoured in an
unmap_and_replace operation.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/mm: Improvements to PV l1e mapping helpers
Andrew Cooper [Wed, 2 Aug 2017 11:40:02 +0000 (12:40 +0100)]
x86/mm: Improvements to PV l1e mapping helpers

Drop guest_unmap_l1e() and use unmap_domain_page() directly.  This will
simplify future cleanup.  Rename guest_map_l1e() to map_guest_l1e() to closer
match the mapping nomenclature.

Switch map_guest_l1e() to using mfn_t.  Correct the comment to indicate that
it takes a linear address (not a virtual address), and correct the parameter
name.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
7 years agogitignore: add local vimrc files
Petre Pircalabu [Tue, 12 Sep 2017 14:32:03 +0000 (17:32 +0300)]
gitignore: add local vimrc files

Signed-off-by: Petre Pircalabu <ppircalabu@bitdefender.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agolibxl: remove unneeded DEVICE_ADD macro
Oleksandr Grytsov [Tue, 11 Jul 2017 16:52:28 +0000 (19:52 +0300)]
libxl: remove unneeded DEVICE_ADD macro

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agolibxl: change vtpm to use generec add function
Oleksandr Grytsov [Tue, 11 Jul 2017 16:26:07 +0000 (19:26 +0300)]
libxl: change vtpm to use generec add function

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agolibxl: fix memory leak in libxl__colo_save_setup
Oleksandr Grytsov [Tue, 12 Sep 2017 13:31:58 +0000 (16:31 +0300)]
libxl: fix memory leak in libxl__colo_save_setup

Getting nic list in case userspace proxy is called
without freeing. The fix is to use cds->nics to
keep nic list. cds->nics will be freed in
devices_teardown_cb.

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agolibxl: change nic to use generec add function
Oleksandr Grytsov [Tue, 11 Jul 2017 14:26:09 +0000 (17:26 +0300)]
libxl: change nic to use generec add function

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
[ wei: add missing semicolon ]
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
7 years agolibxl: change disk to use generic getting list functions
Oleksandr Grytsov [Tue, 11 Jul 2017 13:55:47 +0000 (16:55 +0300)]
libxl: change disk to use generic getting list functions

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agolibxl: change vfb to use generec add function
Oleksandr Grytsov [Mon, 10 Jul 2017 17:34:07 +0000 (20:34 +0300)]
libxl: change vfb to use generec add function

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agolibxl: change vkb to use generec add function
Oleksandr Grytsov [Mon, 10 Jul 2017 17:17:49 +0000 (20:17 +0300)]
libxl: change vkb to use generec add function

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agolibxl: change p9 to use generec add function
Oleksandr Grytsov [Mon, 10 Jul 2017 14:03:59 +0000 (17:03 +0300)]
libxl: change p9 to use generec add function

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agodocs: add PV display driver information
Oleksandr Grytsov [Thu, 25 May 2017 11:55:27 +0000 (14:55 +0300)]
docs: add PV display driver information

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agoxl: add PV display device commands
Oleksandr Grytsov [Thu, 23 Mar 2017 15:26:41 +0000 (17:26 +0200)]
xl: add PV display device commands

Add commands: vdispl-attach, vdispl-list, vdispl-detach
and domain config vdispl parser

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agolibxl: add vdispl device
Oleksandr Grytsov [Mon, 26 Jun 2017 11:36:41 +0000 (14:36 +0300)]
libxl: add vdispl device

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agolibxl: add generic functions to get and free device list
Oleksandr Grytsov [Mon, 10 Jul 2017 13:50:12 +0000 (16:50 +0300)]
libxl: add generic functions to get and free device list

Add libxl__device_list and libxl__device_list_free
functions to handle device list using the device
framework.

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agolibxl: add generic function to add device
Oleksandr Grytsov [Mon, 26 Jun 2017 13:08:56 +0000 (16:08 +0300)]
libxl: add generic function to add device

Add libxl__device_add to simple write XenStore device conifg
and libxl__device_add_async to update domain configuration
and write XenStore device config asynchroniously.
Almost all devices have similar libxl__device_xxxx_add function.
This generic functions implement same functionality but
using the device handling framework. Th device specific
part such as setting xen store configurationis moved
to set_xenstore_config callback of the device framework.

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agoxen/arm: Move arch/arm/vtimer.h to include/asm-arm/vtimer.h
Julien Grall [Tue, 12 Sep 2017 10:36:17 +0000 (11:36 +0100)]
xen/arm: Move arch/arm/vtimer.h to include/asm-arm/vtimer.h

It will be necessary to include vtimer.h from subdirectory making the
inclusion a bit awkward.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: traps: Re-order the includes alphabetically
Julien Grall [Tue, 12 Sep 2017 10:36:16 +0000 (11:36 +0100)]
xen/arm: traps: Re-order the includes alphabetically

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agognttab: also validate PTE permissions upon destroy/replace
Jan Beulich [Tue, 12 Sep 2017 12:45:13 +0000 (14:45 +0200)]
gnttab: also validate PTE permissions upon destroy/replace

In order for PTE handling to match up with the reference counting done
by common code, presence and writability of grant mapping PTEs must
also be taken into account; validating just the frame number is not
enough. This is in particular relevant if a guest fiddles with grant
PTEs via non-grant hypercalls.

Note that the flags being passed to replace_grant_host_mapping()
already happen to be those of the existing mapping, so no new function
parameter is needed.

This is CVE-2017-14319 / XSA-234.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agotools/xenstore: dont unlink connection object twice
Juergen Gross [Tue, 12 Sep 2017 12:44:56 +0000 (14:44 +0200)]
tools/xenstore: dont unlink connection object twice

A connection object of a domain with associated stubdom has two
parents: the domain and the stubdom. When cleaning up the list of
active domains in domain_cleanup() make sure not to unlink the
connection twice from the same domain. This could happen when the
domain and its stubdom are being destroyed at the same time leading
to the domain loop being entered twice.

Additionally don't use talloc_free() in this case as it will remove
a random parent link, leading eventually to a memory leak. Use
talloc_unlink() instead specifying the context from which the
connection object should be removed.

This is CVE-2017-14317 / XSA-233.

Reported-by: Eric Chanudet <chanudete@ainfosec.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>
7 years agogrant_table: fix GNTTABOP_cache_flush handling
Andrew Cooper [Tue, 12 Sep 2017 12:44:11 +0000 (14:44 +0200)]
grant_table: fix GNTTABOP_cache_flush handling

Don't fall over a NULL grant_table pointer when the owner of the domain
is a system domain (DOMID_{XEN,IO} etc).

This is CVE-2017-14318 / XSA-232.

Reported-by: Matthew Daley <mattd@bugfuzz.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agoxen/mm: make sure node is less than MAX_NUMNODES
George Dunlap [Tue, 12 Sep 2017 12:43:16 +0000 (14:43 +0200)]
xen/mm: make sure node is less than MAX_NUMNODES

The output of MEMF_get_node(memflags) can be as large as nodeid_t can
hold (currently 255).  This is then used as an index to arrays of size
MAX_NUMNODE, which is 64 on x86 and 1 on ARM, can be passed in by an
untrusted guest (via memory_exchange and increase_reservation) and is
not currently bounds-checked.

Check the value in page_alloc.c before using it, and also check the
value in the hypercall call sites and return -EINVAL if appropriate.
Don't permit domains other than the hardware or control domain to
allocate node-constrained memory.

This is CVE-2017-14316 / XSA-231.

Reported-by: Matthew Daley <mattd@bugfuzz.com>
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/shadow: Use ERR_PTR infrastructure for sh_emulate_map_dest()
Andrew Cooper [Fri, 8 Sep 2017 16:05:33 +0000 (19:05 +0300)]
x86/shadow: Use ERR_PTR infrastructure for sh_emulate_map_dest()

sh_emulate_map_dest() predates the introduction of the generic ERR_PTR()
infrastructure, but take the opportunity to avoid opencoding it.

The chosen error constants require need to be negative to work with IS_ERR(),
but no other changes.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
7 years agoxen/mm: Use __virt_to_mfn in map_domain_page instead of virt_to_mfn
Julien Grall [Tue, 12 Sep 2017 10:03:09 +0000 (11:03 +0100)]
xen/mm: Use __virt_to_mfn in map_domain_page instead of virt_to_mfn

virt_to_mfn may by overridden by the source files, for improving locally
typesafe.

Therefore map_domain_page has to use __virt_to_mfn to prevent any
compilation issue in sources files that override the helper.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
7 years agoxen/x86: mm: Introduce {G, M}FN <-> {G, M}ADDR helpers
Julien Grall [Tue, 12 Sep 2017 10:03:07 +0000 (11:03 +0100)]
xen/x86: mm: Introduce {G, M}FN <-> {G, M}ADDR helpers

The new wrappers will add more safety when converting an address to a
frame number (either machine or guest). They are already existing for
Arm and could be useful in common code.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
7 years agoxen/x86: Replace mandatory barriers with compiler barriers
Andrew Cooper [Wed, 16 Aug 2017 17:07:27 +0000 (18:07 +0100)]
xen/x86: Replace mandatory barriers with compiler barriers

In this case, rmb() is being used for its compiler barrier property.  Replace
it with an explicit barrer() and comment, to avoid it becoming an unnecessary
lfence instruction (when rmb() gets fixed) or looking like an SMP issue.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agomem_access: switch to plain bool
Wei Liu [Mon, 11 Sep 2017 11:16:28 +0000 (12:16 +0100)]
mem_access: switch to plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
7 years agox86/mm: Allow map_domain_page_global() to be used during boot
Andrew Cooper [Thu, 7 Sep 2017 16:38:52 +0000 (17:38 +0100)]
x86/mm: Allow map_domain_page_global() to be used during boot

map_domain_page_global() uses vmap under the hood, which is set up immediately
after switching to SYS_STATE_boot.  Relax the local_irq_is_enabled() part of
the assertion before Xen has finished booting, so map_domain_page_global() can
be used duing SMP preparation.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agopci: constify domain parameter of pci_get_pdev_by_domain
Roger Pau Monné [Fri, 8 Sep 2017 14:25:24 +0000 (16:25 +0200)]
pci: constify domain parameter of pci_get_pdev_by_domain

While there fix the indentation.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
7 years agohvmloader: clone REP INSW test from REP INSB one
Jan Beulich [Fri, 8 Sep 2017 14:24:57 +0000 (16:24 +0200)]
hvmloader: clone REP INSW test from REP INSB one

This also covers an individual string insn access crossing a page
boundary.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agohvmloader: dynamically determine scratch memory range for tests
Jan Beulich [Fri, 8 Sep 2017 14:24:41 +0000 (16:24 +0200)]
hvmloader: dynamically determine scratch memory range for tests

This re-enables tests on configurations where commit 0d6968635c
("hvmloader: avoid tests when they would clobber used memory") forced
them to be skipped.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/HVM: correct repeat count update in linear->phys translation
Jan Beulich [Fri, 8 Sep 2017 14:23:46 +0000 (16:23 +0200)]
x86/HVM: correct repeat count update in linear->phys translation

For the insn emulator's fallback logic in REP INS/OUTS handling
to work correctly, *reps must not be set to zero when returning
X86EMUL_UNHANDLEABLE.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Paul Durrant <paul.durrant@citrix.com>
7 years agomonitor: switch to plain bool
Wei Liu [Fri, 8 Sep 2017 13:44:33 +0000 (14:44 +0100)]
monitor: switch to plain bool

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Otherwise, Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
7 years agotools: eliminate LIBXL_BLKTAP2
Wei Liu [Mon, 4 Sep 2017 13:44:47 +0000 (14:44 +0100)]
tools: eliminate LIBXL_BLKTAP2

Use CONFIG_BLKTAP2 directly. There is no reason why one would want to
set LIBXL_BLKTAP2 separately as things stand.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
7 years agotools: disable blktap2 by default
Wei Liu [Mon, 4 Sep 2017 13:44:46 +0000 (14:44 +0100)]
tools: disable blktap2 by default

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
7 years agobuild: run autogen.sh on Stretch
Wei Liu [Mon, 4 Sep 2017 13:44:45 +0000 (14:44 +0100)]
build: run autogen.sh on Stretch

Signed-off-by: Wei Liu <wei.liu2@citrix.com>