]> xenbits.xensource.com Git - people/iwj/xen.git/log
people/iwj/xen.git
6 years agofixup! tools/pygrub: Add `xen' to fsimage python module name t
Ian Jackson [Fri, 12 Oct 2018 14:25:30 +0000 (15:25 +0100)]
fixup! tools/pygrub: Add `xen' to fsimage python module name

6 years agofixup! tools/pygrub: Add `xen' to fsimage python module name
Ian Jackson [Thu, 11 Oct 2018 12:48:20 +0000 (13:48 +0100)]
fixup! tools/pygrub: Add `xen' to fsimage python module name

6 years agofixup! tools/pygrub: Add `xen' to fsimage python module name
Ian Jackson [Wed, 10 Oct 2018 14:11:44 +0000 (15:11 +0100)]
fixup! tools/pygrub: Add `xen' to fsimage python module name

6 years agotools/libfsimage: Rename /usr/lib/fs to /usr/lib/xenfsimage
Ian Jackson [Tue, 9 Oct 2018 16:15:48 +0000 (17:15 +0100)]
tools/libfsimage: Rename /usr/lib/fs to /usr/lib/xenfsimage

Again, avoid namespace pollution.  These paths are purely internal to
libfsimage and its fs-specific modules, so no visible change from the
outside.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
6 years agotools/pygrub: Add `xen' to fsimage python module name
Ian Jackson [Tue, 9 Oct 2018 16:14:34 +0000 (17:14 +0100)]
tools/pygrub: Add `xen' to fsimage python module name

This module should be called `libxenfsimage' for the same reasons that
the C library should.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
6 years agotools/libfsimage: Add `xen' to .h names and principal .so name
Ian Jackson [Tue, 9 Oct 2018 16:02:42 +0000 (17:02 +0100)]
tools/libfsimage: Add `xen' to .h names and principal .so name

`fsimage' is rather general.  And we do not expect this library to be
very useful out of tree because of its unstable ABI.

So add the word `xen'.  This will avoid naming conflicts with anyone
else's fsimage library.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
6 years agotools/libfsimage: Bump soname to 4.12
Ian Jackson [Tue, 9 Oct 2018 16:02:34 +0000 (17:02 +0100)]
tools/libfsimage: Bump soname to 4.12

This library does not have a stable ABI promise.  As far as we know it
is used only by pygrub.  Bump its soname to the Xen version (and
intend to change it each time).

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
6 years agoxenstore.h: Put ( ) around XS_* define shifts
Ian Jackson [Tue, 9 Oct 2018 15:25:38 +0000 (16:25 +0100)]
xenstore.h: Put ( ) around XS_* define shifts

These definitions were not properly protected from unwanted operator
precedence interactions.

Existing use sites in-tree all use & or |, so this does not change any
actual behaviour in-tree.

The same seems likely to be true in external callers.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
6 years agotools/libxenstat: Bump soname to 4.12
Ian Jackson [Tue, 9 Oct 2018 16:41:59 +0000 (17:41 +0100)]
tools/libxenstat: Bump soname to 4.12

In 57077cc42ea0 tools/xenstat: Fix shared library version
we set the MAJOR to 4.11 because the patch was prepared against
4.11.  But, upstream, we are at 4.12 now.  So bump the soname again.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
6 years agotools/xenstore: Re-introduce (fake) xs_restrict call to preserve ABI
Hans van Kranenburg [Fri, 24 Aug 2018 17:45:17 +0000 (18:45 +0100)]
tools/xenstore: Re-introduce (fake) xs_restrict call to preserve ABI

libxenstore3.0 in Xen 4.8 had this function.  We don't really want to
bump the ABI version (soname) just for this, since we don't think
there are actual callers anywhere.  But tools complain about the
symbol going away.

So, provide a function xs_restrict which conforms to the original
semantics, although it always fails.

Gbp-Pq: Topic xenstore
Gbp-Pq: Name tools-fake-xs-restrict.patch
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
6 years agotools/debugger/kdd: Install as `xen-kdd', not just `kdd'
Ian Jackson [Fri, 28 Sep 2018 14:30:54 +0000 (15:30 +0100)]
tools/debugger/kdd: Install as `xen-kdd', not just `kdd'

`kdd' is an unfortunate namespace landgrab.

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
6 years agoxenmon: Install as xenmon, not xenmon.py
Ian Jackson [Fri, 28 Sep 2018 14:27:21 +0000 (15:27 +0100)]
xenmon: Install as xenmon, not xenmon.py

Adding the implementation language as a suffix to a program name is
poor practice.

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agopygrub fsimage.so: Honour LDFLAGS when building
Ian Jackson [Thu, 4 Oct 2018 11:32:00 +0000 (12:32 +0100)]
pygrub fsimage.so: Honour LDFLAGS when building

This seems to have been simply omitted.  Obviously this is needed when
building and not just when installing.  Passing only when installing
is ineffective.

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
6 years agogdbsx: Honour LDFLAGS when linking
Ian Jackson [Thu, 4 Oct 2018 11:30:37 +0000 (12:30 +0100)]
gdbsx: Honour LDFLAGS when linking

This command does the link, so it needs LDFLAGS.

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
6 years agoINSTALL: Mention kconfig
Ian Jackson [Fri, 21 Sep 2018 14:40:19 +0000 (15:40 +0100)]
INSTALL: Mention kconfig

Firstly, add a reference to the documentation for the kconfig system.

Secondly, warn the user about the XEN_CONFIG_EXPERT problem.

CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Jan Beulich <JBeulich@suse.com>
Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
Reviewed-by: Doug Goldstein <cardoe@cardoe.com>
---
v2: Fix typos

6 years agotools/Rules.mk: Honour PREPEND_LDFLAGS_XEN_TOOLS
Ian Jackson [Fri, 5 Oct 2018 16:52:54 +0000 (17:52 +0100)]
tools/Rules.mk: Honour PREPEND_LDFLAGS_XEN_TOOLS

This allows the caller to provide some LDFLAGS to the Xen build
system.

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
6 years agolibfsimage: Honour general LDFLAGS
Ian Jackson [Thu, 4 Oct 2018 11:31:25 +0000 (12:31 +0100)]
libfsimage: Honour general LDFLAGS

Do not reset LDFLAGS to empty.  Instead, append the fsimage-special
LDFLAGS.

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agotools/xenstat: Fix shared library version
Bastian Blank [Sat, 5 Jul 2014 09:46:50 +0000 (11:46 +0200)]
tools/xenstat: Fix shared library version

libxenstat does not have a stable ABI.  Set its version to the current
Xen release version.

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agodocs/man/xen-pv-channel.pod.7: Remove a spurious blank line
Ian Jackson [Wed, 3 Oct 2018 17:43:55 +0000 (18:43 +0100)]
docs/man/xen-pv-channel.pod.7: Remove a spurious blank line

No functional change.

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agodocs/man: Provide properly-formatted NAME sections
Ian Jackson [Wed, 3 Oct 2018 17:42:42 +0000 (18:42 +0100)]
docs/man: Provide properly-formatted NAME sections

A manpage `foo.7.pod' must start with

  =head NAME

  foo - some summary of what foo is or what this manpage is

because otherwise manpage catalogue systems cannot generate a proper
`whatis' entry.

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agoVarious: Fix typo `mappping'
Ian Jackson [Wed, 3 Oct 2018 18:00:22 +0000 (19:00 +0100)]
Various: Fix typo `mappping'

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agoVarious: Fix typo `infomation'
Ian Jackson [Wed, 3 Oct 2018 17:59:18 +0000 (18:59 +0100)]
Various: Fix typo `infomation'

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
6 years agotools/python/xen/lowlevel: Fix typo `sucess'
Ian Jackson [Wed, 3 Oct 2018 17:57:13 +0000 (18:57 +0100)]
tools/python/xen/lowlevel: Fix typo `sucess'

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agoVarious: Fix typo `reseting'
Ian Jackson [Wed, 3 Oct 2018 17:56:39 +0000 (18:56 +0100)]
Various: Fix typo `reseting'

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agoVarious: Fix typo `occured'
Ian Jackson [Wed, 3 Oct 2018 17:55:36 +0000 (18:55 +0100)]
Various: Fix typo `occured'

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
6 years agoVarious: Fix typos `unkown', `retreive' (detected by lintian)
Ian Jackson [Wed, 3 Oct 2018 17:51:50 +0000 (18:51 +0100)]
Various: Fix typos `unkown', `retreive' (detected by lintian)

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agotools/xentrace/xenalyze: Fix typos detected by lintian
Ian Jackson [Wed, 3 Oct 2018 17:46:47 +0000 (18:46 +0100)]
tools/xentrace/xenalyze: Fix typos detected by lintian

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
6 years agodocs/man: Fix two typos detected by the Debian lintian tool
Ian Jackson [Wed, 3 Oct 2018 17:44:18 +0000 (18:44 +0100)]
docs/man: Fix two typos detected by the Debian lintian tool

Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agotools/ocaml: Release the global lock before invoking block syscalls
Yang Qian [Mon, 8 Oct 2018 03:10:14 +0000 (11:10 +0800)]
tools/ocaml: Release the global lock before invoking block syscalls

Functions related with event channel are parallelizable, so release global
lock before invoking C function which will finally call block syscalls.

Signed-off-by: Yang Qian <yang.qian@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agomm / iommu: split need_iommu() into has_iommu_pt() and need_iommu_pt_sync()
Paul Durrant [Fri, 5 Oct 2018 14:47:10 +0000 (16:47 +0200)]
mm / iommu: split need_iommu() into has_iommu_pt() and need_iommu_pt_sync()

The name 'need_iommu()' is a little confusing as it suggests a domain needs
to use the IOMMU but something might not be set up yet, when in fact it
represents a tri-state value (not a boolean as might be expected) where
-1 means 'IOMMU mappings being set up' and 1 means 'IOMMU mappings have
been fully set up'.

Two different meanings are also inferred from the macro it in various
places in the code:

- Some callers want to test whether a domain has IOMMU mappings at all
- Some callers want to test whether they need to synchronize the domain's
  P2M and IOMMU mappings

This patch replaces the 'need_iommu' tri-state value with a defined
enumeration and adds a boolean flag 'need_sync' to separate these meanings,
and places both of these in struct domain_iommu, rather than directly in
struct domain.
This patch also creates two new boolean macros:

- 'has_iommu_pt()' evaluates to true if a domain has IOMMU mappings, even
  if they are still under construction.
- 'need_iommu_pt_sync()' evaluates to true if a domain requires explicit
  synchronization of the P2M and IOMMU mappings.

All callers of need_iommu() are then modified to use the macro appropriate
to what they are trying to test, except for the instance in
xen/drivers/passthrough/pci.c:assign_device() which has simply been
removed since it appears to be unnecessary.

NOTE: There are some callers of need_iommu() that strictly operate on
      the hardware domain. In some of these case a more global flag is
      used instead.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
6 years agomm / iommu: include need_iommu() test in iommu_use_hap_pt()
Paul Durrant [Fri, 5 Oct 2018 14:36:56 +0000 (16:36 +0200)]
mm / iommu: include need_iommu() test in iommu_use_hap_pt()

The name 'iommu_use_hap_pt' suggests that that P2M table is in use as the
domain's IOMMU pagetable which, prior to this patch, is not strictly true
since the macro did not test whether the domain actually has IOMMU
mappings.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
6 years agovtd: add lookup_page method to iommu_ops
Paul Durrant [Fri, 5 Oct 2018 14:35:23 +0000 (16:35 +0200)]
vtd: add lookup_page method to iommu_ops

This patch adds a new method to the VT-d IOMMU implementation to find the
MFN currently mapped by the specified DFN along with a wrapper function
in generic IOMMU code to call the implementation if it exists.

NOTE: This patch only adds a Xen-internal interface. This will be used by
      a subsequent patch.
      Another subsequent patch will add similar functionality for AMD
      IOMMUs.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
6 years agopass-through: provide two !HVM stubs
Jan Beulich [Fri, 5 Oct 2018 14:25:43 +0000 (16:25 +0200)]
pass-through: provide two !HVM stubs

Older gcc (4.3 in my case), despite eliminating pci_clean_dpci_irqs()
when !HVM, does not manage to also eliminate pci_clean_dpci_irq(). Cope
with this.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agofix uninitialized variable error in do_poll()
Jan Beulich [Fri, 5 Oct 2018 14:24:56 +0000 (16:24 +0200)]
fix uninitialized variable error in do_poll()

Now that CONFIG_HVM can (and should) be turned off for the shim, gcc 8.2
apparently is no longer sure that "port" is indeed initialized at

    if ( sched_poll->nr_ports == 1 )
        v->poll_evtchn = port;

It doesn't look to be impossible for the compiler to prove it is not,
but we also can't rely on that to be the case. Add an initializer.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agox86: use VMLOAD for PV context switch
Jan Beulich [Fri, 5 Oct 2018 14:24:05 +0000 (16:24 +0200)]
x86: use VMLOAD for PV context switch

Having noticed that VMLOAD alone is about as fast as a single of the
involved WRMSRs, I thought it might be a reasonable idea to also use it
for PV. Measurements, however, have shown that an actual improvement can
be achieved only with an early prefetch of the VMCB (thanks to Andrew
for suggesting to try this), which I have to admit I can't really
explain. This way on my Fam15 box context switch takes over 100 clocks
less on average (the measured values are heavily varying in all cases,
though).

This is intentionally not using a new hvm_funcs hook: For one, this is
all about PV, and something similar can hardly be done for VMX.
Furthermore the indirect to direct call patching that is meant to be
applied to most hvm_funcs hooks would be ugly to make work with
functions having more than 6 parameters.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Brian Woods <brian.woods@amd.com>
Acked-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agomemory: add check_get_page_from_gfn() as a wrapper...
Paul Durrant [Fri, 5 Oct 2018 14:22:37 +0000 (16:22 +0200)]
memory: add check_get_page_from_gfn() as a wrapper...

...for some uses of get_page_from_gfn().

There are many occurrences of the following pattern in the code:

    q = <readonly look-up> ? P2M_ALLOC : P2M_UNSHARE;
    page = get_page_from_gfn(d, gfn, &p2mt, q);

    if ( p2m_is_paging(p2mt) )
    {
        if ( page )
            put_page(page);

        p2m_mem_paging_populate(d, gfn);
        return <-EAGAIN or equivalent>;
    }

    if ( (q & P2M_UNSHARE) && p2m_is_shared(p2mt) )
    {
        if ( page )
            put_page(page);

        return <-EAGAIN or equivalent>;
    }

    if ( !page )
        return <-EINVAL or equivalent>;

There are some small differences between the exact way the occurrences
are coded but the desired semantic is the same.

This patch introduces a new common implementation of this code in
check_get_page_from_gfn() and then converts the various open-coded patterns
into calls to this new function.

NOTE: A forward declaration of p2m_type_t enum has been introduced in
      p2m-common.h so that it is possible to declare
      check_get_page_from_gfn() there rather than having to add
      duplicate declarations in the per-architecture p2m headers.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Roger Pau Monne <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <julien.grall@arm.com>
6 years agoiommu: push use of type-safe DFN and MFN into iommu_ops
Paul Durrant [Fri, 5 Oct 2018 14:21:05 +0000 (16:21 +0200)]
iommu: push use of type-safe DFN and MFN into iommu_ops

This patch modifies the methods in struct iommu_ops to use type-safe DFN
and MFN. This follows on from the prior patch that modified the functions
exported in xen/iommu.h.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Acked-by: Julien Grall <julien.grall@arm.com>
6 years agoiommu: make use of type-safe DFN and MFN in exported functions
Paul Durrant [Fri, 5 Oct 2018 14:16:13 +0000 (16:16 +0200)]
iommu: make use of type-safe DFN and MFN in exported functions

This patch modifies the declaration of the entry points to the IOMMU
sub-system to use dfn_t and mfn_t in place of unsigned long. A subsequent
patch will similarly modify the methods in the iommu_ops structure.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
6 years agoAMD/IOMMU: Drop get_field_from_byte()
Andrew Cooper [Mon, 24 Sep 2018 10:39:46 +0000 (11:39 +0100)]
AMD/IOMMU: Drop get_field_from_byte()

It is MASK_EXTR() in disguise, but less flexible.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Brian Woods <brian.woods@amd.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
6 years agoAMD/IOMMU: Don't opencode memcpy() in queue_iommu_command()
Andrew Cooper [Mon, 24 Sep 2018 10:16:21 +0000 (11:16 +0100)]
AMD/IOMMU: Don't opencode memcpy() in queue_iommu_command()

In practice, this allows the compiler to replace the loop with a pair of movs.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Brian Woods <brian.woods@amd.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
6 years agox86: fix !CONFIG_HVM build for clang 3.8
Wei Liu [Thu, 4 Oct 2018 16:37:56 +0000 (17:37 +0100)]
x86: fix !CONFIG_HVM build for clang 3.8

It is discovered that hvm_funcs made it into monitor.o even when HVM
is disabled. This version of clang doesn't seem to completely
eliminate the code after is_hvm_domain() in
arch_monitor_get_capabilities().

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
6 years agotools/ocaml: Delete the Xenctrl.with_intf wrapper
Andrew Cooper [Wed, 3 Oct 2018 13:11:20 +0000 (14:11 +0100)]
tools/ocaml: Delete the Xenctrl.with_intf wrapper

This wrapper hides an opening and closing of the xenctrl handle, which amongst
other things opens and closes multiple device files.

A process should create one handle at the start of day and reuse that; indeed
there is no guarentee that the process will retain sufficient permissions to
re-open /dev/xen/privcmd at a later point.

With the final user of Xenctrl.with_intf removed, drop the wrapper entirely.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
6 years agooxenstored: Don't re-open a xenctrl handle for every domain introduction
Andrew Cooper [Wed, 3 Oct 2018 09:32:54 +0000 (10:32 +0100)]
oxenstored: Don't re-open a xenctrl handle for every domain introduction

Currently, an xc handle is opened in main() which is used for cleanup
activities, and a new xc handle is temporarily opened every time a domain is
introduced.  This is inefficient, and amongst other things, requires full root
privileges for the lifetime of oxenstored.

All code using the Xenctrl handle is in domains.ml, so initialise xc as a
global (now happens just before main() is called) and drop it as a parameter
from Domains.create and Domains.cleanup.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
6 years agotools/ocaml: Strip all trailing whitespace
Andrew Cooper [Wed, 3 Oct 2018 09:31:39 +0000 (10:31 +0100)]
tools/ocaml: Strip all trailing whitespace

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
6 years agotools/xen-hvmctx: drop bogus casts from dump_mtrr()
Jan Beulich [Thu, 4 Oct 2018 12:55:38 +0000 (14:55 +0200)]
tools/xen-hvmctx: drop bogus casts from dump_mtrr()

Also make the iteration variable unsigned.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agotools/xen-hvmctx: drop bogus casts from dump_hpet()
Jan Beulich [Thu, 4 Oct 2018 12:55:15 +0000 (14:55 +0200)]
tools/xen-hvmctx: drop bogus casts from dump_hpet()

Also specify field widths of the multiple similar lines printed in the
course of the loop, to help readability.

Make the iteration variable unsigned.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agotools/xen-hvmctx: drop bogus casts from dump_lapic_regs()
Jan Beulich [Thu, 4 Oct 2018 12:55:01 +0000 (14:55 +0200)]
tools/xen-hvmctx: drop bogus casts from dump_lapic_regs()

The casts weren't even to the right type - all LAPIC registers are
32-bit (pairs/groups of registers may be combined to form larger logical
ones, but this is not visible in the given data representation).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agotools/xen-hvmctx: drop bogus casts from dump_cpu()
Jan Beulich [Thu, 4 Oct 2018 12:54:48 +0000 (14:54 +0200)]
tools/xen-hvmctx: drop bogus casts from dump_cpu()

Also avoid printing the MSR flags (they're always zero as of commit
2f1add6e1c "x86/vmx: Don't leak host syscall MSR state into HVM
guests"), and print FPU registers only when the respective flag
indicates the space holds valid data.

Adjust format specifiers a little at the same time, in particular to
avoid at least some leading zeros to be printed when the positions
can't ever be non-zero. This helps readability in my opinion.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agovtd: add missing check for shared EPT...
Paul Durrant [Thu, 4 Oct 2018 12:53:57 +0000 (14:53 +0200)]
vtd: add missing check for shared EPT...

...in intel_iommu_unmap_page().

This patch also includes some non-functional modifications in
intel_iommu_map_page().

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
6 years agoiommu: introduce the concept of DFN...
Paul Durrant [Thu, 4 Oct 2018 12:50:41 +0000 (14:50 +0200)]
iommu: introduce the concept of DFN...

...meaning 'device DMA frame number' i.e. a frame number mapped in the IOMMU
(rather than the MMU) and hence used for DMA address translation.

This patch is a largely cosmetic change that substitutes the terms 'gfn'
and 'gaddr' for 'dfn' and 'daddr' in all the places where the frame number
or address relate to a device rather than the CPU.

The parts that are not purely cosmetic are:

 - the introduction of a type-safe declaration of dfn_t and definition of
   INVALID_DFN to make the substitution of gfn_x(INVALID_GFN) mechanical.
 - the introduction of __dfn_to_daddr and __daddr_to_dfn (and type-safe
   variants without the leading __) with some use of the former.

Subsequent patches will convert code to make use of type-safe DFNs.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Acked-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
6 years agox86: fix "xpti=" and "pv-l1tf=" yet again
Jan Beulich [Thu, 4 Oct 2018 12:49:56 +0000 (14:49 +0200)]
x86: fix "xpti=" and "pv-l1tf=" yet again

While commit 2a3b34ec47 ("x86/spec-ctrl: Yet more fixes for xpti=
parsing") indeed fixed "xpti=dom0", it broke "xpti=no-dom0", in that
this then became equivalent to "xpti=no". In particular, the presence
of "xpti=" alone on the command line means nothing as to which default
is to be overridden; "xpti=no-dom0", for example, ought to have no
effect for DomU-s, as this is distinct from both "xpti=no-dom0,domu"
and "xpti=no-dom0,no-domu".

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agox86: split opt_pv_l1tf
Jan Beulich [Thu, 4 Oct 2018 12:49:19 +0000 (14:49 +0200)]
x86: split opt_pv_l1tf

Use separate tracking variables for the hardware domain and DomU-s.

No functional change intended, but adjust the comment in
init_speculation_mitigations() to match prior as well as resulting code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agox86: split opt_xpti
Jan Beulich [Thu, 4 Oct 2018 12:48:18 +0000 (14:48 +0200)]
x86: split opt_xpti

Use separate tracking variables for the hardware domain and DomU-s.

No functional change intended.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agoxentrace: handle sparse cpu ids correctly in xen trace buffer handling
Juergen Gross [Thu, 4 Oct 2018 11:47:24 +0000 (12:47 +0100)]
xentrace: handle sparse cpu ids correctly in xen trace buffer handling

The per-cpu buffers for Xentrace are addressed by cpu-id, but the info
array for the buffers is sized only by number of online cpus. This
might lead to crashes when using Xentrace with smt=0.

The t_info structure has to be sized based on nr_cpu_ids.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
6 years agoxentrace: allow sparse cpu list
Juergen Gross [Thu, 4 Oct 2018 11:47:23 +0000 (12:47 +0100)]
xentrace: allow sparse cpu list

Modify the xentrace utility to allow sparse cpu list resulting in not
all possible cpus having a trace buffer allocated.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
6 years agotools/libxl: Switch Arm guest type to PVH
Julien Grall [Mon, 1 Oct 2018 18:57:21 +0000 (19:57 +0100)]
tools/libxl: Switch Arm guest type to PVH

Currently, the toolstack is considering Arm guest always PV. However,
they are very similar to PVH because HW virtualization extension are used
and QEMU is not started. So switch Arm guest type to PVH.

To keep compatibility with toolstack creating Arm guest with PV type
(e.g libvirt), libxl will now convert those guests to PVH.

Furthermore, the default type for Arm in xl will now be PVH to allow
smooth transition for user.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agotools/libxl: Deprecate PV fields kernel, ramdisk, cmdline
Julien Grall [Mon, 1 Oct 2018 18:57:19 +0000 (19:57 +0100)]
tools/libxl: Deprecate PV fields kernel, ramdisk, cmdline

The PV fields kernel, ramdisk, cmdline are only there for compatibility
with old toolstack. Instead of manually copying them over to there new
field, use the deprecated_by attribute in the IDL.

Suggested-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agotools/libxl: Rename libxl__arch_domain_build_info_acpi_setdefault to...
Julien Grall [Mon, 1 Oct 2018 18:57:17 +0000 (19:57 +0100)]
tools/libxl: Rename libxl__arch_domain_build_info_acpi_setdefault to...

libxl__arch_domain_build_info_setdefault

A follow-up will require to modify default of multiple fields of
build_info. So rename the function accordingly.

No functional change.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agoxen/arm: vgic-v3: Don't create empty re-distributor regions
Julien Grall [Mon, 1 Oct 2018 16:42:27 +0000 (17:42 +0100)]
xen/arm: vgic-v3: Don't create empty re-distributor regions

At the moment, Xen is assuming the hardware domain will have the same
number of re-distributor regions as the host. However, as the
number of CPUs or the stride (e.g on GICv4) may be different we end up
exposing regions which does not contain any re-distributors.

When booting, Linux will go through all the re-distributor region to
check whether a property (e.g vPLIs) is available accross all the
re-distributors. This will result to a data abort on empty regions
because there are no underlying re-distributor.

So we need to limit the number of regions exposed to the hardware
domain. The code reworked to only expose the minimun number of regions
required by the hardware domain. It is assumed the regions will be
populated starting from the first one.

Lastly, rename vgic_v3_rdist_count to reflect the value return by the
helper.

Reported-by: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>
Signed-off-by: Julien Grall <julien.grall@arm.com>
Tested-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
6 years agoxen/arm: vgic-v3: Delay the initialization of the domain information
Julien Grall [Mon, 1 Oct 2018 16:42:26 +0000 (17:42 +0100)]
xen/arm: vgic-v3: Delay the initialization of the domain information

A follow-up patch will require to know the number of vCPUs when
initializating the vGICv3 domain structure. However this information is
not available at domain creation. This is only known once
XEN_DOMCTL_max_vpus is called for that domain.

In order to get the max vCPUs around, delay the domain part of the vGIC
v3 initialization until the first vCPU of the domain is initialized.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Tested-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Acked-but-disliked-by: Stefano Stabellini <sstabellini@kernel.org>
6 years agoamd/iommu: remove hidden AMD inclusive mappings
Roger Pau Monné [Tue, 2 Oct 2018 15:02:33 +0000 (17:02 +0200)]
amd/iommu: remove hidden AMD inclusive mappings

And just rely on arch_iommu_hwdom_init to setup the correct inclusive
mappings as it's done for Intel.

AMD has code in amd_iommu_hwdom_init to setup inclusive mappings up to
max_pdx, remove this since it's now a duplication of
arch_iommu_hwdom_init. Note that AMD mapped every page with a valid
mfn up to max_pdx, arch_iommu_hwdom_init will only do so for memory
below 4GB, so this is a functional change for AMD.

Move the default setting of iommu_hwdom_{inclusive/reserved} to
arch_iommu_hwdom_init since the defaults are now the same for both
Intel and AMD.

Reported-by: Paul Durrant <paul.durrant@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Suravee Suthikulpanit <suravee.suthikupanit@amd.com>
6 years agox86/iommu: fix wrong usage of iommu_hwdom_inclusive
Roger Pau Monné [Tue, 2 Oct 2018 15:01:41 +0000 (17:01 +0200)]
x86/iommu: fix wrong usage of iommu_hwdom_inclusive

iommu_hwdom_inclusive was used where iommu_hwdom_reserved should be
used.

Reported-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
6 years agoxen/arm: Replace call_smc with arm_smccc_smc
Julien Grall [Mon, 1 Oct 2018 12:46:39 +0000 (13:46 +0100)]
xen/arm: Replace call_smc with arm_smccc_smc

call_smc is a subset of arm_smccc_smc. Rather than having 2 methods to
do SMCCC call, replace all call to the former by the later.

Signed-off-by: Julien Grall <julien.grall@arm.com>
[PSCI_RET(res.a0)/PSCI_RET(res)]
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
6 years agoxen/arm: smccc: Add wrapper to automatically select the calling convention
Julien Grall [Mon, 1 Oct 2018 12:46:38 +0000 (13:46 +0100)]
xen/arm: smccc: Add wrapper to automatically select the calling convention

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
6 years agoxen/arm: cpufeature: Add helper to check constant caps
Julien Grall [Mon, 1 Oct 2018 12:46:37 +0000 (13:46 +0100)]
xen/arm: cpufeature: Add helper to check constant caps

Some capababilities are set right during boot and will never change
afterwards. At the moment, the function cpu_have_caps will check whether
the cap is enabled from the memory.

It is possible to avoid the load from the memory by using an
ALTERNATIVE. With that the check is just reduced to 1 instruction.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
6 years agoxen/arm: add SMC wrapper that is compatible with SMCCC v1.0
Volodymyr Babchuk [Mon, 1 Oct 2018 12:46:36 +0000 (13:46 +0100)]
xen/arm: add SMC wrapper that is compatible with SMCCC v1.0

Existing SMC wrapper call_smc() allows only 4 parameters and
returns only one value. This is enough for existing
use in PSCI code, but TEE mediator will need a call that is
fully compatible with ARM SMCCC v1.0.

This patch adds a wrapper for both arm32 and arm64. In the case of
arm32, the wrapper is just an alias to the ARM SMCCC v1.1 as the
convention is the same.

CC: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
[julien: Rework the wrapper to make it closer to SMCC 1.1 wrapper]
Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
6 years agoRevert "Make credit2 the default scheduler"
George Dunlap [Mon, 1 Oct 2018 16:14:22 +0000 (17:14 +0100)]
Revert "Make credit2 the default scheduler"

The migration code reads scheduler parameters on the sending side and
tries to set them again on the receiving side, failing if this fails;
the result is that a simple upgrade from 4.11 -> 4.12 will now fail
all migrations.  Solving this is not simple; revert the credit2
upgrade until we can sort something out.

This reverts commit ec6662445b1ec9231ca69583863de644206ef313.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
6 years agoxen/vsprintf: Introduce %pd formatter for domains
Andrew Cooper [Wed, 29 Aug 2018 16:16:50 +0000 (16:16 +0000)]
xen/vsprintf: Introduce %pd formatter for domains

This allows all system domids to be printed by name, rather than special
casing the idle vcpus alone.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
6 years agoxen/arm: smccc-1.1: Handle function result as parameters
Marc Zyngier [Tue, 25 Sep 2018 17:20:39 +0000 (18:20 +0100)]
xen/arm: smccc-1.1: Handle function result as parameters

If someone has the silly idea to write something along those lines:

extern u64 foo(void);

void bar(struct arm_smccc_res *res)
{
arm_smccc_1_1_smc(0xbad, foo(), res);
}

they are in for a surprise, as this gets compiled as:

0000000000000588 <bar>:
 588:   a9be7bfd        stp     x29, x30, [sp, #-32]!
 58c:   910003fd        mov     x29, sp
 590:   f9000bf3        str     x19, [sp, #16]
 594:   aa0003f3        mov     x19, x0
 598:   aa1e03e0        mov     x0, x30
 59c:   94000000        bl      0 <_mcount>
 5a0:   94000000        bl      0 <foo>
 5a4:   aa0003e1        mov     x1, x0
 5a8:   d4000003        smc     #0x0
 5ac:   b4000073        cbz     x19, 5b8 <bar+0x30>
 5b0:   a9000660        stp     x0, x1, [x19]
 5b4:   a9010e62        stp     x2, x3, [x19, #16]
 5b8:   f9400bf3        ldr     x19, [sp, #16]
 5bc:   a8c27bfd        ldp     x29, x30, [sp], #32
 5c0:   d65f03c0        ret
 5c4:   d503201f        nop

The call to foo "overwrites" the x0 register for the return value,
and we end up calling the wrong secure service.

A solution is to evaluate all the parameters before assigning
anything to specific registers, leading to the expected result:

0000000000000588 <bar>:
 588:   a9be7bfd        stp     x29, x30, [sp, #-32]!
 58c:   910003fd        mov     x29, sp
 590:   f9000bf3        str     x19, [sp, #16]
 594:   aa0003f3        mov     x19, x0
 598:   aa1e03e0        mov     x0, x30
 59c:   94000000        bl      0 <_mcount>
 5a0:   94000000        bl      0 <foo>
 5a4:   aa0003e1        mov     x1, x0
 5a8:   d28175a0        mov     x0, #0xbad
 5ac:   d4000003        smc     #0x0
 5b0:   b4000073        cbz     x19, 5bc <bar+0x34>
 5b4:   a9000660        stp     x0, x1, [x19]
 5b8:   a9010e62        stp     x2, x3, [x19, #16]
 5bc:   f9400bf3        ldr     x19, [sp, #16]
 5c0:   a8c27bfd        ldp     x29, x30, [sp], #32
 5c4:   d65f03c0        ret

Reported-by: Stefano Stabellini <stefanos@xilinx.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
6 years agoxen/arm: smccc-1.1: Make return values unsigned long
Marc Zyngier [Tue, 25 Sep 2018 17:20:38 +0000 (18:20 +0100)]
xen/arm: smccc-1.1: Make return values unsigned long

An unfortunate consequence of having a strong typing for the input
values to the SMC call is that it also affects the type of the
return values, limiting r0 to 32 bits and r{1,2,3} to whatever
was passed as an input.

Let's turn everything into "unsigned long", which satisfies the
requirements of both architectures, and allows for the full
range of return values.

Reported-by: Stefano Stabellini <stefanos@xilinx.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
6 years agoxen/arm: vgic-v3-its: Make vgic_v3_its_free_domain idempotent
Julien Grall [Tue, 4 Sep 2018 19:21:53 +0000 (20:21 +0100)]
xen/arm: vgic-v3-its: Make vgic_v3_its_free_domain idempotent

vgic_v3_its_free_domain may be called before vgic_v3_its_init_domain if
the vGIC was failing to initalize itself. This means the list would be
unitialized and result in a crash.

Thankfully, we only allow ITS for the hardware domain. So the crash is
not a security issue. Fix it by checking whether the list the NULL.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
6 years agoxen: initialise opt_xen_console early in PVH boot path
Wei Liu [Fri, 28 Sep 2018 08:15:06 +0000 (09:15 +0100)]
xen: initialise opt_xen_console early in PVH boot path

This helps capture issues before console is initialised.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agox86: make sure module array is large enough in pvh-boot.c
Wei Liu [Wed, 26 Sep 2018 10:52:54 +0000 (11:52 +0100)]
x86: make sure module array is large enough in pvh-boot.c

The relocation code in __start_xen requires one extra element in the
module array. By the looks of it the temporary array is already large
enough. Panic if that's not the case.

While at it, turn an ASSERT to panic() as well.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agox86: undefine BOOSTRAP_MAP_LIMIT after its last user
Wei Liu [Fri, 28 Sep 2018 08:39:58 +0000 (09:39 +0100)]
x86: undefine BOOSTRAP_MAP_LIMIT after its last user

Requested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
6 years agox86: fix comment on super page alignment requirement
Wei Liu [Fri, 28 Sep 2018 08:39:57 +0000 (09:39 +0100)]
x86: fix comment on super page alignment requirement

BOOTSTRAP_DIRECTMAP_END is gone. The comment in question should refer
to BOOSTRAP_MAP_BASE and 4GB instead.

Move the entire comment block to where it belongs -- immediately
before the loop which does the things said in the comment.

Remove two trailing spaces while at it.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
6 years agotools/libgnttab: Fix build following c/s 3d3feaa4560
Andrew Cooper [Fri, 28 Sep 2018 15:56:24 +0000 (16:56 +0100)]
tools/libgnttab: Fix build following c/s 3d3feaa4560

VERS_1.2 can't extend itself.  It should extend VERS_1.1

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agotools/libgnttab: Undo incorrect SONAME bump in c/s ee8105cab
Andrew Cooper [Fri, 28 Sep 2018 15:21:54 +0000 (16:21 +0100)]
tools/libgnttab: Undo incorrect SONAME bump in c/s ee8105cab

Xen 4.11 shipped with a SONAME of 1.1.

For staging (and 4.12 eventually), the SONAME was bumped to 1.2 by c/s
28ca696a3.  Further changes before 4.12 ships should not bump the SONAME.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agotools/configure: Drop libgcrypt detection
Andrew Cooper [Fri, 28 Sep 2018 14:46:53 +0000 (15:46 +0100)]
tools/configure: Drop libgcrypt detection

This was last used by blktap1, which was deleted by c/s f6bcc035084 in 2014.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
6 years agox86: hap_enabled() is HVM-only
Jan Beulich [Fri, 28 Sep 2018 15:13:38 +0000 (17:13 +0200)]
x86: hap_enabled() is HVM-only

There at least two cases where the field so far got accessed for PV
guests as well: One is in iommu_construct(), via iommu_use_hap_pt(),
and the other is
arch_domain_create()
-> paging_domain_init()
   -> p2m_init()
      -> p2m_init_hostp2m()
         -> p2m_init_one()
            -> p2m_initialise()
It just so happens that the field currently lives in struct hvm_domain
at an offset larger than sizeof(struct pv_domain).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agox86: silence false log messages for plain "xpti" / "pv-l1tf"
Jan Beulich [Fri, 28 Sep 2018 15:12:14 +0000 (17:12 +0200)]
x86: silence false log messages for plain "xpti" / "pv-l1tf"

While commit 2a3b34ec47 ("x86/spec-ctrl: Yet more fixes for xpti=
parsing")  claimed to have got rid of the 'parameter "xpti" has invalid
value "", rc=-22!' log message for "xpti" alone on the command line,
this wasn't the case (the option took effect nevertheless).

Fix this there as well as for plain "pv-l1tf".

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agostubdom/grub.patches: Drop docs changes, for licensing reasons
Ian Jackson [Tue, 18 Sep 2018 10:25:20 +0000 (11:25 +0100)]
stubdom/grub.patches: Drop docs changes, for licensing reasons

The patch file 00cvs is an import of a new upstream version of
grub1 from upstream CVS.

Unfortunately, in the period covered by the update, upstream changed
the documentation licence from a simple permissive licence, to the GNU
"Free Documentation Licence" with Front and Back Cover Texts.

The Debian Project is of the view that use the Front and Back Cover
Texts feature of the GFDL makes the resulting document not Free
Software, because of the mandatory redistribution of these immutable
texts.  (Personally, I agree.)

This is awkward because Debian do not want to ship non-free content.
So the Debian maintainers need to launder the upstream source code, to
remove the troublesome files.  This is an extra step when
incorporating new upstream versions.  It's particularly annoying for
security response, which often involves rebasing onto a new upstream
release.

grub1 is obsolete and the last change to Xen's PV grub1 stubdom code
was in 2016.  Furthermore, the grub1 documentation is not built and
installed by the Xen pv-grub stubdom Makefiles.

Therefore, remove all docs changes from stubdom/grub.patches.  This
means that there are now no longer any GFDL-licenced grub docs in
xen.git.

There is no user impact, and Debian is helped.  This change would
complicate any attempts to update to a new version of upstream grub1,
but it seems unlikely that such a thing will ever happen.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Doug Goldstein <cardoe@cardoe.com>
CC: Juergen Gross <jgross@suse.com>
CC: pkg-xen-devel@lists.alioth.debian.org
Acked-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
6 years agoarm/traps: coding style fixes
Andrii Anisov [Tue, 11 Sep 2018 15:48:02 +0000 (18:48 +0300)]
arm/traps: coding style fixes

Signed-off-by: Andrii Anisov <andrii_anisov@epam.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
6 years agotools/ocaml: Add OCaml binding of virq bind
Yang Qian [Thu, 27 Sep 2018 07:53:04 +0000 (15:53 +0800)]
tools/ocaml: Add OCaml binding of virq bind

1. Add a common bind virq function
2. Reduce the stub code of `bind_dom_exc_virq`

Signed-off-by: Yang Qian <yang.qian@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
6 years agox86/boot: Allocate one extra module slot for Xen image placement
Daniel Kiper [Thu, 27 Sep 2018 10:05:07 +0000 (12:05 +0200)]
x86/boot: Allocate one extra module slot for Xen image placement

Commit 9589927 (x86/mb2: avoid Xen image when looking for
module/crashkernel position) fixed relocation issues for
Multiboot2 protocol. Unfortunately it missed to allocate
module slot for Xen image placement in early boot path.
So, let's fix it right now.

Reported-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agox86: move hvm_domain_use_pirq to hvm files
Wei Liu [Mon, 24 Sep 2018 17:27:56 +0000 (18:27 +0100)]
x86: move hvm_domain_use_pirq to hvm files

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
6 years agoautomation: introduce a new variable to control container user
Wei Liu [Tue, 25 Sep 2018 14:19:31 +0000 (15:19 +0100)]
automation: introduce a new variable to control container user

Sometimes it is handy to create a container and play with its setup
manually as root.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Doug Goldstein <cardoe@cardoe.com>
6 years agox86emul: fix test harness build after e8dfbc2962
Jan Beulich [Wed, 26 Sep 2018 08:49:38 +0000 (10:49 +0200)]
x86emul: fix test harness build after e8dfbc2962

There was another stdio.h inclusion left in place. Re-order #include-s
altogether in test_x86_emulator.c.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Wei Liu <wei.liu2@citrix.com>
6 years agoarm: fix Dom build after cd8015b634
Jan Beulich [Tue, 25 Sep 2018 12:56:58 +0000 (06:56 -0600)]
arm: fix Dom build after cd8015b634

The removal of the VLA there has changed sizeof() for the array.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
6 years agox86/altp2m: clean up p2m_{get/set}_suppress_ve()
Razvan Cojocaru [Tue, 25 Sep 2018 14:35:52 +0000 (15:35 +0100)]
x86/altp2m: clean up p2m_{get/set}_suppress_ve()

Move p2m_{get/set}_suppress_ve() to p2m.c, replace incorrect
ASSERT() in p2m-pt.c (since a guest can run in shadow mode even on
a system with virt exceptions, which would trigger the ASSERT()),
move the VMX-isms (cpu_has_vmx_virt_exceptions checks) to
p2m_ept_{get/set}_entry(), and fix locking code in
p2m_get_suppress_ve().

Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
6 years agofuzz, test x86_emulator: disable sse before including always_inline fns
Christopher Clark [Tue, 25 Sep 2018 14:30:32 +0000 (16:30 +0200)]
fuzz, test x86_emulator: disable sse before including always_inline fns

Workaround for compiler rejection of SSE-using always_inlines defined before
SSE is disabled.

Compiling with _FORTIFY_SOURCE or higher levels of optimization enabled
will always_inline several library fns (memset, memcpy, ...)
(with gcc 8.2.0 and glibc 2.28).

In fuzz and x86_emulator test, the compiler is instructed not
to generate SSE instructions via: #pragma GCC target("no-sse")
because those registers are needed for use by the workload.

The combination above causes compilation failure as the inline functions
use those instructions. This is resolved by reordering the inclusion of
<stdio.h> and <string.h> to after the pragma disabling SSE generation.

It would be preferable to locate the no-sse pragma within x86-emulate.h at the
top of the file, prior to including any other headers; unfortunately doing so
before <stdlib.h> causes compilation failure due to declaration of 'atof' with:
  "SSE register return with SSE disabled".
Fortunately there is no (known) current dependency on any always_inline
SSE-inclined function declared in <stdlib.h> or any of its dependencies, so the
pragma is therefore issued immediately after inclusion of <stdlib.h> with a
comment introduced to explain its location there.

Add compile-time checks for unwanted prior inclusion of <string.h> and
<stdio.h>, which are the two headers that provide the library functions that
are handled with wrappers and listed within "x86-emulate.h" as ones "we think
might access any of the FPU state".
* Use standard-defined "EOF" macro to detect prior <stdio.h> inclusion.
* Use "_STRING_H" (non-standardized guard macro) as best-effort
  for detection of prior <string.h> inclusion. This is non-universally
  viable but will provide error output on common GLIBC systems, so
  provides some defensive coverage.

Adds conditional #include <stdio.h> to x86-emulate.h because fwrite, printf,
etc. are referenced when WRAP has been defined.

Signed-off-by: Christopher Clark <christopher.clark6@baesystems.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
6 years agox86/mm: don't crash on unknown memory types in page_get_ram_type
Roger Pau Monné [Tue, 25 Sep 2018 14:29:59 +0000 (16:29 +0200)]
x86/mm: don't crash on unknown memory types in page_get_ram_type

Instead return RAM_TYPE_UNKNOWN.

Reported-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
6 years agox86/hvm: change gethvmcontext_partial error code for offline vcpus
Alexandru Isaila [Tue, 25 Sep 2018 14:29:18 +0000 (16:29 +0200)]
x86/hvm: change gethvmcontext_partial error code for offline vcpus

This patch is needed in order to have a different return error for invalid vcpu
and offline vcpu on the per vcpu king.

Signed-off-by: Alexandru Isaila <aisaila@bitdefender.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
6 years agoxen: Disallow variable length arrays
Andrew Cooper [Mon, 17 Sep 2018 14:49:14 +0000 (15:49 +0100)]
xen: Disallow variable length arrays

Variable length arrays result in excess stack utilisation, with a risk
of stack overflow if the length is too large.  It also results in fairly
poor asm generation, because of requiring a divide as part of the space
calcuation.

Xen no longer has any variable length arrays, so take the opportunity to
formally disallow them.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
6 years agox86/hvm: Adjust hvmemul_rep_stos() to compile with -Wvla
Andrew Cooper [Mon, 17 Sep 2018 15:32:32 +0000 (16:32 +0100)]
x86/hvm: Adjust hvmemul_rep_stos() to compile with -Wvla

When using -Wvla, the typecast of buf triggers a Variable Length Array
warning.  This is less than ideal, as this typecast doesn't occupy any stack
space, but we don't have a finer grain option to use.

Alter the asm expression to avoid the typecast, which necessitates the
introduction of a memory clobber as the compiler can no longer identify
the total quantity of written memory.

Despite the memory clobber, there is no change to the generated asm.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
6 years agox86/PoD: Avoid using variable length arrays in p2m_pod_zero_check()
Andrew Cooper [Mon, 17 Sep 2018 15:30:53 +0000 (16:30 +0100)]
x86/PoD: Avoid using variable length arrays in p2m_pod_zero_check()

Callers of p2m_pod_zero_check() pass a count of up to POD_SWEEP_STRIDE.
Move the definition of POD_SWEEP_STRIDE and give the arrays a fixed
bound.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
6 years agox86/PoD: Simplify handling of the quick check
Andrew Cooper [Mon, 17 Sep 2018 15:21:53 +0000 (16:21 +0100)]
x86/PoD: Simplify handling of the quick check

There is no need to duplicate the contents of the skip block.

While cleaning up this function, change 4 ints to be unsigned.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
6 years agox86/hvm: Add check for cpu_has_vmx_virt_exceptions
Alexandru Isaila [Tue, 25 Sep 2018 09:10:38 +0000 (12:10 +0300)]
x86/hvm: Add check for cpu_has_vmx_virt_exceptions

This is useful so HVMOP_altp2m_vcpu_enable_notify will fail and not
silently succeed. It save a call to HVMOP_altp2m_set_suppress_ve.

Signed-off-by: Alexandru Isaila <aisaila@bitdefender.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agoMake credit2 the default scheduler
George Dunlap [Tue, 25 Sep 2018 09:47:10 +0000 (10:47 +0100)]
Make credit2 the default scheduler

Credit2 was declared "supported" in 4.8, and as of 4.10 had two other
critical features implemented (soft affinity / NUMA and caps).

Why change the default?

The code is better: more predictable, less jitter, easier to determine
how modifications will affect overall behavior, easier in the future
to make load-balancing behavior more subtle (e.g., taking into account
the cost of powering up extra cores, &c).

Overall performance compared to Credit1 is somewhat of a mixed bag.
Unfortunately most of what I have are tests using XenServer's internal
perf testing system, so I can't share the raw data (via links anyway).

Here is a summary of data from an internal e-mail Dario sent in the
past:

* DVDbench: On underloaded systems, credit2 outperformed credit1 by
about 4%.  On overloaded systems, credit2 underperformed by about 3%.

* On a range of tests (unixbench, lmbench, &c), credit and credit2
perform within 5% of each other (up and down).

* Credit2 fairly consistently beats credit for TCP-style workloads.

* Credit2 is sometimes equal to, sometimes 5-15% worse than, credit for
synthetic CPU workloads (e.g., Dhrystone).

* On LoginVSI, credit2 fairly consistently outperforms credit by about 10%.

Credit2, like credit, has a number of workloads / setups for which
performance could be improved.  Personally I think networking and
partially-loaded systems is going to be more representative of what
Xen is actually used for; so I think credit2 is on the whole the
better scheduler to use by default.  And in any case, making those
improvements on credit2 will be easier than on credit.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Dario Faggioli <dfaggioli@suse.com>
6 years agox86: expose CONFIG_HVM
Wei Liu [Fri, 21 Sep 2018 15:54:52 +0000 (16:54 +0100)]
x86: expose CONFIG_HVM

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
6 years agox86/mm: put HVM only code under CONFIG_HVM
Wei Liu [Fri, 21 Sep 2018 15:54:51 +0000 (16:54 +0100)]
x86/mm: put HVM only code under CONFIG_HVM

Going through the code, HAP, EPT, PoD and ALTP2M depend on HVM code.
Put these components under CONFIG_HVM. This further requires putting
one of the vm event under CONFIG_HVM.

Altp2m requires a bit more attention because its code is embedded in
generic x86 p2m code.

Also make hap_enabled evaluate to false when !CONFIG_HVM. Make sure it
evaluate its parameter to avoid unused variable warnings in its users.

Also sort items in Makefile while at it.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>