]> xenbits.xensource.com Git - xen.git/log
xen.git
7 years agox86: correct assertion in destroy_perdomain_mapping()
Jan Beulich [Mon, 23 Apr 2018 14:12:01 +0000 (16:12 +0200)]
x86: correct assertion in destroy_perdomain_mapping()

hvm_domain_initialise() may call this with nr being zero, which triggers
the "does not cross L3 boundary" check.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agolibxl: fix memory map reported to PVH guests
Roger Pau Monne [Fri, 20 Apr 2018 14:57:19 +0000 (15:57 +0100)]
libxl: fix memory map reported to PVH guests

PVH guests with 4GB of RAM or more get a memory map like the
following:

0x00000000000000 - 0x000000fee00000 RAM
0x000000fee00000 - 0x00000100000000 RESERVED
0x000000fc009000 - 0x000000fc009040 ACPI
0x000000fc000000 - 0x000000fc001000 ACPI
0x000000fc001000 - 0x000000fc009000 ACPI
0x00000100000000 - 0x000001fb200400 RAM

This is wrong because ACPI regions overlap with RAM regions. The cause
of this issue is not setting a big enough MMIO hole and marking the
whole MMIO hole as reserved, when it actually contains several pieces:

 - local APIC page.
 - ACPI tables.
 - HVM special pages.

Of those items only HVM special pages need to be marked as reserved in
order to advise the guest against using them for example for memory
hotplug.

After the fix the layout reported for the same guest is:

0x00000000000000 - 0x000000fc000000 RAM
0x000000feff8000 - 0x000000ff000000 RESERVED
0x000000fc009000 - 0x000000fc009040 ACPI
0x000000fc000000 - 0x000000fc001000 ACPI
0x000000fc001000 - 0x000000fc009000 ACPI
0x00000100000000 - 0x000001fe000400 RAM

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agoshim: don't let build modify shim.config
Juergen Gross [Fri, 20 Apr 2018 15:47:55 +0000 (17:47 +0200)]
shim: don't let build modify shim.config

Currently building the shim will modify shim.config in case some config
option was added or modified in the hypervisor.

Avoid that by copying shim.config to an intermediate file instead.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agodocs/parse-support-md: Correctly handle footnotes for non-leaf sections
Ian Jackson [Tue, 17 Apr 2018 13:34:36 +0000 (14:34 +0100)]
docs/parse-support-md: Correctly handle footnotes for non-leaf sections

Non-leaf sections with footnotes must have a row of their own, for
just that section, because footnotes only appear if there is status
information.

In that case, the footnote applies to only the rows for that section
in the markdown document, ie that RealSect.

And of course for a leaf section that is true too.

So for footnoes we always want to use a rowspan of the number of
Status elements in the section.  So (i) calculate this in
count_rows_sectlist and (ii) use it, instead of the total number of
rows including all the subsections', when writing out the footnote
ref.

This bug has been present in this script since the beginning.

Also, while we're here, suppress the rowspan if it would be 1.

Reported-by: Lars Kurth <lars.kurth@citrix.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agodocs/parse-support.md: Add some newlines to the table output
Ian Jackson [Tue, 17 Apr 2018 14:24:10 +0000 (15:24 +0100)]
docs/parse-support.md: Add some newlines to the table output

This makes the result easier for humans to read.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agoSUPPORT.md: Document the new text ordering rule
Ian Jackson [Thu, 12 Apr 2018 18:22:16 +0000 (19:22 +0100)]
SUPPORT.md: Document the new text ordering rule

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agoSUPPORT.md: Move descriptions up before Status info
Ian Jackson [Thu, 12 Apr 2018 16:32:32 +0000 (17:32 +0100)]
SUPPORT.md: Move descriptions up before Status info

This turns all the things which were treated as caveats, but which
don't need to be footnoted in the matrix, into descriptions.

For the benefit of the support matrix generator, this patch (or a
version of it) should be backported to 4.10.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agoSUPPORT.md, support matrix: Treat commentary before status as description
Ian Jackson [Thu, 12 Apr 2018 16:57:58 +0000 (17:57 +0100)]
SUPPORT.md, support matrix: Treat commentary before status as description

Running text in feature sections in the markdown document currently
might be (i) a caveat, qualifying or clarifying the support statement
(ii) a plain description of the feature.

Caveats can be version-specific and deserve the [*] annotation in the
relevant feature matrix cell.  They must link to SUPPORT.html for the
specific version.

Descriptions are not version specific.  In that case the [*]
annotation is visusal noise.  Rather, it is better to make a hyperlink
out of the text which is being expanded on.  The hyperlink can point
to any appropriate version.

There is a question about how to notate this distinction in
SUPPORT.md.  After IRL discussion with George and Lars I propose that
we should put text which helps describe a feature (ie, which expands
on a section heading) after the heading but before the Status
indications; whereas, caveats and supplementary information about
the actual status, should follow the Status block.

This patch implements this distinction in the support matrix
generator.  Only paragraphs containing _only_ italic content count as
descriptive; anything else is treated as a caveat.

In the code:

 * Add a new entry to RealSect, HasDescription

 * When parsing, track whether we are before or after the first Status
   block in a new variable $has_feature.

 * In ri_Para, set HasDescription set to the input document index
   when we encounter text before the first feature.

 * When writing a `heading' (ie, the table cell for a feature name)
   look for HasDescription and make an appropriate hyperlink.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agodocs/parse-support-md: internals: Rename HasText to HasCaveat
Ian Jackson [Thu, 12 Apr 2018 16:57:43 +0000 (17:57 +0100)]
docs/parse-support-md: internals: Rename HasText to HasCaveat

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agodocs/parse-support-md: internals: Introduce docref_a
Ian Jackson [Thu, 12 Apr 2018 17:06:45 +0000 (18:06 +0100)]
docs/parse-support-md: internals: Introduce docref_a

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agox86/HVM: never retain emulated insn cache when exiting back to guest
Jan Beulich [Mon, 23 Apr 2018 09:01:09 +0000 (11:01 +0200)]
x86/HVM: never retain emulated insn cache when exiting back to guest

Commit 5fcb26e69e ("x86/HVM: don't retain emulated insn cache when
exiting back to guest") didn't go quite far enough: The insn emulator
may itself decide to return X86EMUL_RETRY (currently for certain
CMPXCHG failures and AVX2 gather insns), in which case we'd also exit
back to guest context. Tie the caching to whether we have an I/O
completion pending, instead of x86_emulate()'s return value.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agox86/HPET: fix race triggering ASSERT(cpu < nr_cpu_ids)
David Wang [Mon, 23 Apr 2018 09:00:07 +0000 (11:00 +0200)]
x86/HPET: fix race triggering ASSERT(cpu < nr_cpu_ids)

CPUs may share an in-use channel. Hence clearing of a bit from the
cpumask (in hpet_broadcast_exit()) as well as setting one (in
hpet_broadcast_enter()) must not race evaluation of that same cpumask.
Therefore avoid evaluating the cpumask twice in hpet_detach_channel().
Otherwise cpumask_empty() may e.g.return false while the subsequent
cpumask_first() could return nr_cpu_ids, which then triggers the
assertion in cpumask_of() reached through set_channel_irq_affinity().

Signed-off-by: David Wang <davidwang@zhaoxin.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agox86/spec_ctrl: Updates to retpoline-safety decision making
Andrew Cooper [Tue, 17 Apr 2018 12:48:01 +0000 (12:48 +0000)]
x86/spec_ctrl: Updates to retpoline-safety decision making

All of this is as recommended by the Intel whitepaper:

https://software.intel.com/sites/default/files/managed/1d/46/Retpoline-A-Branch-Target-Injection-Mitigation.pdf

The 'RSB Alternative' bit in MSR_ARCH_CAPABILITIES may be set by a hypervisor
to indicate that the virtual machine may migrate to a processor which isn't
retpoline-safe.  Introduce a shortened name (to reduce code volume), treat it
as authorative in retpoline_safe(), and print its value along with the other
ARCH_CAPS bits.

The exact processor models which do have RSB semantics which fall back to BTB
predictions are enumerated, and include Kabylake and Coffeelake.  Leave a
printk() in the default case to help identify cases which aren't covered.

The exact microcode versions from Broadwell RSB-safety are taken from the
referenced microcode update file (adjusting for the known-bad microcode
versions).  Despite the exact wording of the text, it is only Broadwell
processors which need a microcode check.

In practice, this means that all Broadwell hardware with up-to-date microcode
will use retpoline in preference to IBRS, which will be a performance
improvement for desktop and server systems which would previously always opt
for IBRS over retpoline.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agolibs/gnttab: fix FreeBSD gntdev interface
Roger Pau Monne [Tue, 17 Apr 2018 13:03:41 +0000 (14:03 +0100)]
libs/gnttab: fix FreeBSD gntdev interface

Current interface to the gntdev in FreeBSD is wrong, and mostly worked
out of luck before the PTI FreeBSD fixes, when kernel and user-space
where sharing the same page tables.

On FreeBSD ioctls have the size of the passed struct encoded in the ioctl
number, because the generic ioctl handler in the OS takes care of
copying the data from user-space to kernel space, and then calls the
device specific ioctl handler. Thus using ioctl structs with variable
sizes is not possible.

The fix is to turn the array of structs at the end of
ioctl_gntdev_alloc_gref and ioctl_gntdev_map_grant_ref into pointers,
that can be properly accessed from the kernel gntdev driver using the
copyin/copyout functions. Note that this is exactly how it's done for
the privcmd driver.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agox86: Use spec_ctrl_{enter,exit}_idle() in the S3/S5 path
Andrew Cooper [Tue, 17 Apr 2018 17:43:49 +0000 (18:43 +0100)]
x86: Use spec_ctrl_{enter,exit}_idle() in the S3/S5 path

The main purpose of this patch is to avoid opencoding the recovery logic at
the end, but also has the positive side effect of relaxing the SPEC_CTRL
mitigations when working to shut the final CPU down.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agox86/msr: further correct the emulation behaviour of MSR_PRED_CMD
Jan Beulich [Wed, 18 Apr 2018 09:16:37 +0000 (11:16 +0200)]
x86/msr: further correct the emulation behaviour of MSR_PRED_CMD

Following commit a6aa678fa3 ("x86/msr: Correct the emulation behaviour
of MSR_PRED_CMD") we may end up writing the low bit with the wrong
value. While it's unlikely for a guest to want to write zero there, we
should still permit (this without incurring the overhead of an actual
barrier). Correcting this right away will also help whenever further
bits in the MSR might become defined.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agoMerge remote-tracking branch 'origin/staging' into staging
Ian Jackson [Tue, 17 Apr 2018 17:28:11 +0000 (18:28 +0100)]
Merge remote-tracking branch 'origin/staging' into staging

7 years agoREADME, Xen/Makefile: Xen 4.11 is -RC now 4.11.0-rc1
Ian Jackson [Tue, 17 Apr 2018 16:22:49 +0000 (17:22 +0100)]
README, Xen/Makefile: Xen 4.11 is -RC now

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
7 years agoConfig.mk: Switch external trees to fixed tags for Xen 4.11.0-rc1
Ian Jackson [Tue, 17 Apr 2018 16:19:33 +0000 (17:19 +0100)]
Config.mk: Switch external trees to fixed tags for Xen 4.11.0-rc1

The minios tag `xen-4.11.0-rc1' was mistakenly made on the wrong
revision.  So we have burned that tag and use xen-4.11.0-rc1.1
instead.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
7 years agomktarball: For qemu upstream, use their scripts/archive-source.sh
Ian Jackson [Tue, 17 Apr 2018 16:53:01 +0000 (17:53 +0100)]
mktarball: For qemu upstream, use their scripts/archive-source.sh

qemu upstream uses git submodules.  git archive does not work with git
submodules (and could not work properly with them, because this is one
of the many things it is inherently impossible to do correctly with
git submodules).

qemu upstream have worked around this by providing a rather scary
shell script which attempts to do roughly the right thing.  It's close
enough that we can use it with only minor precautions.

Unfortunately this does mean that `mktarball' now executes the qemu
source code it was using, rather than merely shuffling it about, as it
did previously.  I think this is a less bad ill than copying (and,
effectively, forking) the scary script.

CC: Wei Liu <wei.liu2@citrix.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>
CC: Juergen Gross <jgross@suse.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
7 years agox86/traps: Misc non-functional improvements to set_debugreg()
Andrew Cooper [Fri, 23 Mar 2018 20:26:34 +0000 (20:26 +0000)]
x86/traps: Misc non-functional improvements to set_debugreg()

 * Change 'int i' to being unsigned, and move it into its most narrow scope.
 * Fold the access_ok() checks for %dr{0..3}.  This halves the compiled size
   of the function.
 * Additional newlines in appropriate places.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agox86/pv: Introduce and use x86emul_write_dr()
Andrew Cooper [Fri, 23 Mar 2018 20:26:34 +0000 (20:26 +0000)]
x86/pv: Introduce and use x86emul_write_dr()

set_debugreg() has several bugs:

 * %dr4/5 should function correctly as aliases of %dr6/7 when CR4.DE is clear.
 * Attempting to set the upper 32 bits of %dr6/7 should fail with #GP[0]
   rather than be silently corrected and complete.
 * For emulation, the #UD and #GP[0] cases need properly distinguishing.  Use
   -ENODEV for #UD cases, leaving -EINVAL (bad bits) and -EPERM (not allowed to
   use that valid bit) as before for hypercall callers.
 * A write which clears %dr7.L/G leaves the IO shadow intact, meaning that
   subsequent reads of %dr7 will see stale IO watchpoint configuration.

Implement x86emul_write_dr() as a thin wrapper around set_debugreg().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agox86/pv: Introduce and use x86emul_read_dr()
Andrew Cooper [Fri, 23 Mar 2018 20:13:50 +0000 (20:13 +0000)]
x86/pv: Introduce and use x86emul_read_dr()

do_get_debugreg() has several bugs:

 * The %cr4.de condition is inverted.  %dr4/5 should be accessible only when
   %cr4.de is disabled.
 * When %cr4.de is disabled, emulation should yield #UD rather than complete
   with zero.
 * Using -EINVAL for errors is a broken ABI, as it overlaps with valid values
   near the top of the address space.

Introduce a common x86emul_read_dr() handler (as we will eventually want to
add HVM support) which separates its success/failure indication from the data
value, and have do_get_debugreg() call into the handler.

The ABI of do_get_debugreg() remains broken, but switches from -EINVAL to
-ENODEV for compatibility with the changes in the following patch.

Take the opportunity to add a missing local variable block to x86_emulate.c

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agox86/msr: Correct the emulation behaviour of MSR_PRED_CMD
Andrew Cooper [Mon, 16 Apr 2018 10:56:00 +0000 (10:56 +0000)]
x86/msr: Correct the emulation behaviour of MSR_PRED_CMD

Experimentally, the behaviour of reserved bits in MSR_PRED_CMD changed between
beta and production microcode, and now raises a #GP fault for set reserved
bits.  The AMD spec for future hardware also specifies this behaviour, and it
is the more sensible behaviour to implement.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agomm: fix emfn calculation in init_domheap_pages()
Oleksandr Tyshchenko [Mon, 16 Apr 2018 12:11:09 +0000 (14:11 +0200)]
mm: fix emfn calculation in init_domheap_pages()

The "end" address must be rounded down before shifting,
otherwise we will insert wrong page range to a heap if address isn't
page aligned.

It seems that a copy-paste mistake took place in the following commit:
0c12972e34b20a26f2b42044b98bf12db7ed62b6
xen/mm: Switch some of page_alloc.c to typesafe MFN

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agox86: check feature flags after resume
Jan Beulich [Mon, 16 Apr 2018 12:10:33 +0000 (14:10 +0200)]
x86: check feature flags after resume

Make sure no previously present features are missing after resume (and
the re-loading of microcode), to avoid later crashes or (likely silent)
hangs / live locks. This doesn't go beyond checking x86_capability[],
but this should be good enough for the immediate need of making sure
that the BIT mitigation MSRs are still available.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agox86: suppress BTI mitigations around S3 suspend/resume
Jan Beulich [Mon, 16 Apr 2018 12:09:55 +0000 (14:09 +0200)]
x86: suppress BTI mitigations around S3 suspend/resume

NMI and #MC can occur at any time after S3 resume, yet the MSR_SPEC_CTRL
may become available only once we're reloaded microcode. Make
SPEC_CTRL_ENTRY_FROM_INTR_IST and DO_SPEC_CTRL_EXIT_TO_XEN no-ops for
the critical period of time.

Also set the MSR back to its intended value.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agox86: correct ordering of operations during S3 resume
Jan Beulich [Mon, 16 Apr 2018 12:08:30 +0000 (14:08 +0200)]
x86: correct ordering of operations during S3 resume

Microcode loading needs to happen before re-enabling interrupts, in case
only updated microcode allows the use of e.g. the SPEC_{CTRL,CMD} MSRs.
Otoh it doesn't need to happen at all when we didn't suspend in the
first place. It needs to happen before spin_debug_enable() though, as it
acquires a lock and hence would otherwise make
common/spinlock.c:check_lock() unhappy. As micrcode loading can be
pretty verbose, also make sure it only runs after console_end_sync().

cpufreq_add_cpu() doesn't need calling on the only "goto enable_cpu"
path, which sits ahead of cpufreq_del_cpu().

Reported-by: Simon Gaiser <simon@invisiblethingslab.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agodocs/gen-html-index: Make HTML::TreeBuilder::XPath optional again
Ian Jackson [Fri, 13 Apr 2018 13:55:27 +0000 (14:55 +0100)]
docs/gen-html-index: Make HTML::TreeBuilder::XPath optional again

7782db9260d4 "docs/gen-html-index: Extract titles from HTML documents"
requires HTML::TreeBuilder::XPath.

This is sadly not as widely available as I had hoped.  Work around
this problem by making the use of this module optional: instead of
`use'ing at the toplevel, we `require' it in the eval.  If it's not
present, then the title is simply not extracted and the filename is
used as before, which is tolerable.

Also add some debugging.

Reported-by: Doug Goldstein <cardoe@cardoe.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Reviewed-by: Doug Goldstein <cardoe@cardoe.com>
Tested-by: Doug Goldstein <cardoe@cardoe.com>
7 years agosndif: Add explicit back and front parameter negotiation
Oleksandr Andrushchenko [Wed, 7 Mar 2018 08:21:20 +0000 (10:21 +0200)]
sndif: Add explicit back and front parameter negotiation

In order to provide explicit stream parameter negotiation between
backend and frontend the following changes are introduced in the protocol:
add XENSND_OP_HW_PARAM_QUERY request to read/update
configuration space for the parameter given: request passes
desired parameter interval (mask) and the response to this request
returns min/max interval (mask) for the parameter to be used.

Parameters supported by this request/response:
 - format mask
 - sample rate interval
 - number of channels interval
 - buffer size, interval, frames
 - period size, interval, frames

Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agosndif: Add explicit back and front synchronization
Oleksandr Andrushchenko [Mon, 5 Feb 2018 07:41:57 +0000 (09:41 +0200)]
sndif: Add explicit back and front synchronization

In order to provide explicit synchronization between backend and
frontend the following changes are introduced in the protocol:
 - add new ring buffer for sending asynchronous events from
   backend to frontend to report number of bytes played by the
   frontend (XENSND_EVT_CUR_POS)
 - introduce trigger events for playback control: start/stop/pause/resume
 - add "req-" prefix to event-channel and ring-ref to unify naming
   of the Xen event channels for requests and events

Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agosndif: Make requests and responses 64 octets long
Oleksandr Andrushchenko [Fri, 16 Mar 2018 09:58:20 +0000 (11:58 +0200)]
sndif: Make requests and responses 64 octets long

Extend the size of the requests and responses to 64 octets.
Bump protocol version to 2.

Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agosndif: Fix missed "reserved" fields in comments
Oleksandr Andrushchenko [Fri, 16 Mar 2018 09:55:00 +0000 (11:55 +0200)]
sndif: Fix missed "reserved" fields in comments

Some of the request descriptions have "reserved" fields
missed: fix this by adding corresponidng entries.

Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agosndif: Introduce protocol version
Oleksandr Andrushchenko [Thu, 2 Nov 2017 06:35:24 +0000 (08:35 +0200)]
sndif: Introduce protocol version

Protocol version was referenced in the protocol description,
but missed its definition. Fix this by adding a constant
for current protocol version.

Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agodocs/parse-support-md: Unify identical [*] in footnotes
Ian Jackson [Thu, 12 Apr 2018 11:59:24 +0000 (12:59 +0100)]
docs/parse-support-md: Unify identical [*] in footnotes

A section in the SUPPORT.md may mention multiple
   Status, something: Supported
and then have some text.  The text is linked to from [*] footnotes
in the table.  But, this means that each bit of text needs to
apply to multiple rows.

Before this commit this was a separate [*] after each applicable item.
But multiple apparently-different links to the same thing are annoying
for the reader.

So, in this commit we combine them.  Formatting the result is not
entirely trivial.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
---
v3: New patch
v3.1: Drop `}' in multi-row [*] notes.  I put this in to help work
   around firefox bugs eg
     https://bugzilla.mozilla.org/show_bug.cgi?id=244135
   but I have been convinced it is not generally wanted.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
7 years agodocs: Provide support-matrix-generate, to generate a support matrix in HTML
Ian Jackson [Wed, 11 Apr 2018 10:42:27 +0000 (11:42 +0100)]
docs: Provide support-matrix-generate, to generate a support matrix in HTML

This archaeology script:
 - figures out what the current and previous Xen versions were
 - looks for appropriate git branches for them
 - finds SUPPORT.md for each one
 - feeds its findings to parse-support-md

We do not intend to integrate this into docs/Makefile, because it
relies on the git history.  Instead, we will take the rune provided in
the head comment and paste a variant of it into an appropriate cronjob
on xenbits.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Acked-by: Lars Kurth <lars.kurth@citrix.com>
---
v3: Provide -D option.

7 years agodocs: Provide parse-support-md
Ian Jackson [Thu, 5 Apr 2018 17:12:21 +0000 (18:12 +0100)]
docs: Provide parse-support-md

This utility reads json format pandoc output, from parsing one or more
SUPPORT.md files, and generates an HTML table element containing the
principal version and feature information.

This is rather hairier than I anticipated when I started out; hence
the 400-odd-line Perl script.

Machinery to assemble the appropriate inputs for parse-support-md
will be in the next commit.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Acked-by: Lars Kurth <lars.kurth@citrix.com>
---
v2: New in this version of the series.
v3: Refactor to introduce RealSect
v3: Add [*] footnote to all applicable entries, not just the last

7 years agodocs/Makefile: Format SUPPORT.md into the toplevel
Ian Jackson [Fri, 6 Apr 2018 17:13:50 +0000 (18:13 +0100)]
docs/Makefile: Format SUPPORT.md into the toplevel

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Acked-by: Lars Kurth <lars.kurth@citrix.com>
7 years agodocs/Makefile: Introduce GENERATE_PANDOC_RULE_RAW
Ian Jackson [Fri, 6 Apr 2018 17:12:37 +0000 (18:12 +0100)]
docs/Makefile: Introduce GENERATE_PANDOC_RULE_RAW

We are going to want to format SUPPORT.md which does not match the
filename patterns in docs/.  So provide a way to make an ad-hoc rule
using pandoc with the standard options.

No functional change in this patch.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Acked-by: Lars Kurth <lars.kurth@citrix.com>
7 years agodocs/gen-html-index: Support documents at the toplevel
Ian Jackson [Fri, 6 Apr 2018 18:09:16 +0000 (19:09 +0100)]
docs/gen-html-index: Support documents at the toplevel

There are none yet.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Acked-by: Lars Kurth <lars.kurth@citrix.com>
7 years agodocs/gen-html-index: Extract titles from HTML documents
Ian Jackson [Fri, 6 Apr 2018 18:09:02 +0000 (19:09 +0100)]
docs/gen-html-index: Extract titles from HTML documents

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Acked-by: Lars Kurth <lars.kurth@citrix.com>
7 years agoSUPPORT.md: Syntax: Provide a title rather than a spurious empty section
Ian Jackson [Fri, 6 Apr 2018 17:16:35 +0000 (18:16 +0100)]
SUPPORT.md: Syntax: Provide a title rather than a spurious empty section

This commits (more or less) this file to be processed with pandoc,
rather than other markdown processors.  There is, unfortunately, no
widely-accepted way to declare a title for the document.

I tested feeding the document to markdown(1) on Debian jessie and it
reproduced the % line as if it were simple text.  I guess many other
markdown processors will do something similarly tolerable.  My
internet searches did not discover a markdown processor that used
lines starting with % for something else.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Lars Kurth <lars.kurth@citrix.com>
7 years agoSUPPORT.md: Syntax: Fix a typo "States"
Ian Jackson [Fri, 6 Apr 2018 14:20:22 +0000 (15:20 +0100)]
SUPPORT.md: Syntax: Fix a typo "States"

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Lars Kurth <lars.kurth@citrix.com>
7 years agoSUPPORT.md: Syntax: Fix some bullet lists
Ian Jackson [Thu, 5 Apr 2018 16:19:31 +0000 (17:19 +0100)]
SUPPORT.md: Syntax: Fix some bullet lists

Continuations of bullet list items must be indented by exactly 4
spaces (according to pandoc_markdown(5) on Debian jessie).

This is most easily achieved by making the bullet list items have two
spaces before the `*'.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Lars Kurth <lars.kurth@citrix.com>
7 years agox86/VT-x: Fix determination of EFER.LMA in vmcs_dump_vcpu()
Andrew Cooper [Mon, 9 Apr 2018 17:56:03 +0000 (18:56 +0100)]
x86/VT-x: Fix determination of EFER.LMA in vmcs_dump_vcpu()

The LMA setting comes from the entry controls.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agox86/HVM: suppress I/O completion for port output
Jan Beulich [Wed, 11 Apr 2018 08:42:24 +0000 (10:42 +0200)]
x86/HVM: suppress I/O completion for port output

We don't break up port requests in case they cross emulation entity
boundaries, and a write to an I/O port is necessarily the last
operation of an instruction instance, so there's no need to re-invoke
the full emulation path upon receiving the result from an external
emulator.

In case we want to properly split port accesses in the future, this
change will need to be reverted, as it would prevent things working
correctly when e.g. the first part needs to go to an external emulator,
while the second part is to be handled internally.

While this addresses the reported problem of Windows paging out the
buffer underneath an in-process REP OUTS, it does not address the wider
problem of the re-issued insn (to the insn emulator) being prone to
raise an exception (#PF) during a replayed, previously successful memory
access (we only record prior MMIO accesses).

Leaving aside the problem tried to be worked around here, I think the
performance aspect alone is a good reason to change the behavior.

Also take the opportunity and change bool_t -> bool as
hvm_vcpu_io_need_completion()'s return type.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agolibxl: arm: Fix build after c/s 74fd984ae
Julien Grall [Tue, 10 Apr 2018 11:24:53 +0000 (12:24 +0100)]
libxl: arm: Fix build after c/s 74fd984ae

c/s 74fd984ae "tools/libxl: Drop xc_domain_configuration_t from
libxl__domain_build_state" removed state->config completely but missed
some conversion libxl_arm.c.

Furthermore, not all the fields of xc_domain_configuration_t have a
corresponding field in libxl_domain_build_info. This is the case of
clock_frequency. As the field should not be exposed to the user, add a
corresponding field in libxl__domain_build_state. This require some
modification in the prototype of libxl__domain_make in order to have the
state.

For all the other fields, use the up-to-date version in
libxl_domain_build_info.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agoxen/arm: fix build after f20a6e309
Wei Liu [Mon, 9 Apr 2018 13:49:49 +0000 (14:49 +0100)]
xen/arm: fix build after f20a6e309

Commit f20a6e309 removed a parameter from smp_prepare_cpus but only
the x86 parts were submitted and committed.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agox86/PVH/libxl: Check whether Linux guest can handle RSDP at 4G boundary
Boris Ostrovsky [Mon, 9 Apr 2018 14:24:59 +0000 (10:24 -0400)]
x86/PVH/libxl: Check whether Linux guest can handle RSDP at 4G boundary

Commit 4a5733771e6f ("libxl: put RSDP for PVH guest near 4GB") breaks
pre-4.17 Linux guests since they do not use start_info's rsdp_paddr
pointer and instread scan BIOS memory for RSDP signature.

Introduce XENFEAT_linux_rsdp_unrestricted feature flag that indicates
whether the guest can handle RSDP at locations pointed to by
rsdp_paddr.

Since only Linux PVH guests suffer from this problem (BSD has always
relied on rsdp_paddr) we check this flag just for those guests. If the
flag is not set we place RSDP in BIOS, as before.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86/pv: Fix up erroneous segments for 32bit syscall entry
Andrew Cooper [Mon, 9 Apr 2018 09:39:32 +0000 (09:39 +0000)]
x86/pv: Fix up erroneous segments for 32bit syscall entry

The existing FLAT_KERNEL_SS expands to the correct value, 0xe02b, but is the
wrong constant to use.  Switch to FLAT_USER_SS32.

For compat domains however, the reported values are entirely bogus.
FLAT_USER_SS32 (value 0xe02b) is FLAT_RING3_CS in the 32bit ABI, while
FLAT_USER_CS32 (value 0xe023) is FLAT_RING1_DS with an RPL of 3.

The guests SYSCALL callback is invoked with a broken iret frame, and if left
unmodified by the guest, will fail on the way back out when Xen's iret tries
to load a code segment into %ss.

In practice, this is only a problem for 32bit PV guests on AMD hardware, as
Intel hardware doesn't permit the SYSCALL instruction outside of 64bit mode.

This appears to have been broken ever since 64bit support was added to Xen,
and has gone unnoticed because Linux doesn't use SYSCALL in 32bit builds.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agox86: remove unused parameter from smp_prepare_cpus
Wei Liu [Fri, 6 Apr 2018 09:36:45 +0000 (10:36 +0100)]
x86: remove unused parameter from smp_prepare_cpus

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agox86/ioreq: Fix build from a collision of c/s f46b61973 and c/s 6e387461ed
Andrew Cooper [Fri, 6 Apr 2018 17:56:42 +0000 (18:56 +0100)]
x86/ioreq: Fix build from a collision of c/s f46b61973 and c/s 6e387461ed

Drop the _mfn() wrappers now that page_to_mfn() returns the correct type.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agoxen/arm: Add MVEBU UART driver for Marvell Armada 3700 SoC
Amit Singh Tomar [Fri, 6 Apr 2018 16:00:35 +0000 (21:30 +0530)]
xen/arm: Add MVEBU UART driver for Marvell Armada 3700 SoC

This patch adds driver for UART controller found on Armada 3700 SoC.

There is no reference manuals available for 3700 SoC in public and it
is derived by looking at Linux driver[1].

[1]https://github.com/torvalds/linux/blob/master/drivers/tty/serial/mvebu-uart.c
commit-id: c685af1108d7c303f0b901413405d68eaeac4477

Signed-off-by: Amit Singh Tomar <amittomer25@gmail.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Tested-by: Andre Przywara <andre.przywara@arm.com>
Acked-by: Julien Grall <julien.grall@arm.com>
7 years agoxen/arm: Add Marvell ARMADA 3700 early printk support
Amit Singh Tomar [Thu, 5 Apr 2018 10:16:13 +0000 (15:46 +0530)]
xen/arm: Add Marvell ARMADA 3700 early printk support

Signed-off-by: Amit Singh Tomar <amittomer25@gmail.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Tested-by: Andre Pzywara <andre.przywara@arm.com>
Acked-by: Julien Grall <julien.grall@arm.com>
7 years agoxen: Convert page_to_mfn and mfn_to_page to use typesafe MFN
Julien Grall [Wed, 21 Feb 2018 13:46:27 +0000 (13:46 +0000)]
xen: Convert page_to_mfn and mfn_to_page to use typesafe MFN

Most of the users of page_to_mfn and mfn_to_page are either overriding
the macros to make them work with mfn_t or use mfn_x/_mfn because the
rest of the function use mfn_t.

So make page_to_mfn and mfn_to_page return mfn_t by default. The __*
version are now dropped as this patch will convert all the remaining
non-typesafe callers.

Only reasonable clean-ups are done in this patch. The rest will use
_mfn/mfn_x for the time being.

Lastly, domain_page_to_mfn is also converted to use mfn_t given that
most of the callers are now switched to _mfn(domain_page_to_mfn(...)).

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoRevert "tools/libxl: Fix build following c/s 74fd984ae"
Wei Liu [Fri, 6 Apr 2018 09:33:58 +0000 (10:33 +0100)]
Revert "tools/libxl: Fix build following c/s 74fd984ae"

This reverts commit d96f17f50c621be30e5c73da9317c91d8cbbf3e1.

It doesn't fix the build.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
7 years agoxen/x86: Switch mfn_to_page in x86_64/mm.c to use typesafe MFN
Julien Grall [Wed, 21 Feb 2018 13:46:27 +0000 (13:46 +0000)]
xen/x86: Switch mfn_to_page in x86_64/mm.c to use typesafe MFN

Other than MFN 0 -> INVALID_MFN, no functional change intended.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
7 years agoxen/grant: Switch common/grant_table.c to use typesafe MFN
Julien Grall [Wed, 21 Feb 2018 13:46:26 +0000 (13:46 +0000)]
xen/grant: Switch common/grant_table.c to use typesafe MFN

At the same time replace MFN 0 by INVALID_MFN or drop the initializer
when it is not necessary. This will make clearer that the MFN
initialized is not valid.

Other than MFN 0 -> INVALID_MFN, no functional change intended.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/grant: Switch {create, replace}_grant_p2m_mapping to typesafe MFN
Julien Grall [Wed, 21 Feb 2018 13:46:26 +0000 (13:46 +0000)]
xen/grant: Switch {create, replace}_grant_p2m_mapping to typesafe MFN

The current prototype is slightly confusing because it takes a guest
physical address and a machine physical frame (not address!). Switching to
MFN will improve safety and reduce the chance to mistakenly invert the
2 parameters.

Signed-off-by: Julien grall <julien.grall@arm.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/mm: Switch common/memory.c to use typesafe MFN
Julien Grall [Wed, 21 Feb 2018 13:46:26 +0000 (13:46 +0000)]
xen/mm: Switch common/memory.c to use typesafe MFN

A new helper __copy_mfn_to_guest is introduced to easily to copy a MFN to
the guest memory.

Not functional change intended

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agoxen/mm: Switch some of page_alloc.c to typesafe MFN
Julien Grall [Wed, 21 Feb 2018 13:46:26 +0000 (13:46 +0000)]
xen/mm: Switch some of page_alloc.c to typesafe MFN

No functional change intended.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
7 years agoxen/mm: Switch map_pages_to_xen to use MFN typesafe
Julien Grall [Wed, 21 Feb 2018 13:46:25 +0000 (13:46 +0000)]
xen/mm: Switch map_pages_to_xen to use MFN typesafe

The current prototype is slightly confusing because it takes a virtual
address and a physical frame (not address!). Switching to MFN will improve
safety and reduce the chance to mistakenly invert the 2 parameters.

Also, take the opportunity to switch (a - b) >> PAGE_SHIFT to
PFN_DOWN(a - b) in the code modified.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/mm: Drop the parameter mfn from populate_pt_range
Julien Grall [Wed, 21 Feb 2018 13:46:25 +0000 (13:46 +0000)]
xen/mm: Drop the parameter mfn from populate_pt_range

The function populate_pt_range is used to populate in advance the
page-table but it will not do the actual mapping. So passing the MFN in
parameter is pointless. Note that the only caller pass 0...

At the same time replace 0 by INVALID_MFNs. While this does not matter
as the entry will marked as not valid and populated, INVALID_MFN
helps the reader to know the MFN is invalid.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
--

Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Julien Grall <julien.grall@arm.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Tim Deegan <tim@xen.org>
    Changes in v6:
        - Add George's and Wei's reviewed-by
        - Add Andrew's acked-by

    Changes in v5:
        - Update the commit message to explain why 0 -> INVALID_MFN.

    Changes in v4:
        - Patch added.

7 years agoxen/arm: mm: Remove unused relinquish_shared_pages
Julien Grall [Wed, 21 Feb 2018 13:46:24 +0000 (13:46 +0000)]
xen/arm: mm: Remove unused relinquish_shared_pages

relinquish_shared_pages is never called on Arm.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: mm: Remove unused M2P code
Julien Grall [Wed, 21 Feb 2018 13:46:24 +0000 (13:46 +0000)]
xen/arm: mm: Remove unused M2P code

Arm does not have an M2P and very unlikely to get one in the future,
therefore don't keep defines that are not necessary in the common code.

At the same time move the remaining M2P define just above
set_gpfn_from_mfn to keep all the dummy helpers for M2P together.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: mm: Use gaddr_to_gfn rather than _gfn(paddr_to_pfn(...))
Julien Grall [Wed, 21 Feb 2018 13:46:23 +0000 (13:46 +0000)]
xen/arm: mm: Use gaddr_to_gfn rather than _gfn(paddr_to_pfn(...))

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agoxen/arm: setup: use maddr_to_mfn rather than _mfn(paddr_to_pfn(...))
Julien Grall [Wed, 21 Feb 2018 13:46:23 +0000 (13:46 +0000)]
xen/arm: setup: use maddr_to_mfn rather than _mfn(paddr_to_pfn(...))

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
7 years agotools: reduce copies b/w ocaml Strings and Bytes
Marcello Seri [Thu, 5 Apr 2018 10:40:21 +0000 (11:40 +0100)]
tools: reduce copies b/w ocaml Strings and Bytes

When xenstore was ported to the new safe-string interface, it mostly
happened by making copyies of string into bytes and back.  The ideal
fix would be to rewrite all of the relevant interfaces to be uniformly
using bytes, but in the meanwhile we can improve the code by using unsafe
conversion functions (see
 https://caml.inria.fr/pub/docs/manual-ocaml/libref/Bytes.html#3_Unsafeconversionsforadvancedusers).

In most cases we own the bytes that we are converting to string, or we
immediately make copies that we then mutate, or we use them immutably
as payloads for writes. In all these cases it is safe to use the unsafe
functions and prevent a copy.

This patch updates the code to use the unsafe conversions where possible.

Signed-off-by: Marcello Seri <marcello.seri@citrix.com>
Reviewed-by: Christian Lindig <christian.lindig@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agotools/libxl: Fix build following c/s 74fd984ae
Andrew Cooper [Thu, 5 Apr 2018 18:54:26 +0000 (19:54 +0100)]
tools/libxl: Fix build following c/s 74fd984ae

c/s 74fd984ae "tools/libxl: Drop xc_domain_configuration_t from
libxl__domain_build_state" removed state->config completely, but the GIC
version is available in info.  Use the up-to-date version.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Release-Acked-by: Juergen Gross <jgross@suse.com>
7 years agotools/kdd: mute spurious gcc warning
Marek Marczykowski-Górecki [Thu, 5 Apr 2018 01:50:55 +0000 (03:50 +0200)]
tools/kdd: mute spurious gcc warning

gcc-8 complains:

    kdd.c:698:13: error: 'memcpy' offset [-204, -717] is out of the bounds [0, 216] of object 'ctrl' with type 'kdd_ctrl' {aka 'union <anonymous>'} [-Werror=array-bounds]
                 memcpy(buf, ((uint8_t *)&ctrl.c32) + offset, len);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    kdd.c: In function 'kdd_select_callback':
    kdd.c:642:14: note: 'ctrl' declared here
         kdd_ctrl ctrl;
                  ^~~~

But this is impossible - 'offset' is unsigned and correctly validated
few lines before.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Release-Acked-by: Juergen Gross <jgross@suse.com>
7 years agotools/blktap2: fix hypothetical buffer overflow
Marek Marczykowski-Górecki [Thu, 5 Apr 2018 01:50:51 +0000 (03:50 +0200)]
tools/blktap2: fix hypothetical buffer overflow

gcc-8 complains:

    vhd-util-read.c: In function 'vhd_util_read':
    vhd-util-read.c:50:24: error: '%lu' directive output may be truncated writing between 1 and 20 bytes into a region of size 15 [-Werror=format-truncation=]
      snprintf(nbuf, nsize, "%" PRIu64, num);
                            ^~~
    vhd-util-read.c:50:25: note: format string is defined here
      snprintf(nbuf, nsize, "%" PRIu64, num);
    vhd-util-read.c:50:24: note: directive argument in the range [0, 18446744073709551614]
      snprintf(nbuf, nsize, "%" PRIu64, num);
                            ^~~
    vhd-util-read.c:50:2: note: 'snprintf' output between 2 and 21 bytes into a destination of size 15
      snprintf(nbuf, nsize, "%" PRIu64, num);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    vhd-util-read.c:43:24: error: '%#lx' directive output may be truncated writing between 1 and 18 bytes into a region of size 15 [-Werror=format-truncation=]
      snprintf(nbuf, nsize, "%#" PRIx64 , num);
                            ^~~~
    vhd-util-read.c:43:25: note: format string is defined here
      snprintf(nbuf, nsize, "%#" PRIx64 , num);
    vhd-util-read.c:43:24: note: directive argument in the range [0, 18446744073709551614]
      snprintf(nbuf, nsize, "%#" PRIx64 , num);
                            ^~~~
    vhd-util-read.c:43:2: note: 'snprintf' output between 2 and 19 bytes into a destination of size 15
      snprintf(nbuf, nsize, "%#" PRIx64 , num);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Make the buffer larger.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Release-Acked-by: Juergen Gross <jgross@suse.com>
7 years agotools/blktap2: fix possible '\0' truncation
Marek Marczykowski-Górecki [Thu, 5 Apr 2018 01:50:52 +0000 (03:50 +0200)]
tools/blktap2: fix possible '\0' truncation

gcc-8 complains:

    tapdisk-vbd.c: In function 'tapdisk_vbd_resume_ring':
    tapdisk-vbd.c:1671:53: error: 'snprintf' output may be truncated before the last format character [-Werror=format-truncation=]
       snprintf(params.name, sizeof(params.name) - 1, "%s", message);
                                                         ^
    tapdisk-vbd.c:1671:3: note: 'snprintf' output between 1 and 256 bytes into a destination of size 255
       snprintf(params.name, sizeof(params.name) - 1, "%s", message);
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The "- 1" in buffer size should be actually applied to message, to leave
place for terminating '\0', not the other way around (truncate '\0' even
if it would fit).

    In function 'tapdisk_control_open_image',
        inlined from 'tapdisk_control_handle_request' at tapdisk-control.c:660:10:
    tapdisk-control.c:465:2: error: 'strncpy' specified bound 256 equals destination size [-Werror=stringop-truncation]
      strncpy(params.name, vbd->name, BLKTAP2_MAX_MESSAGE_LEN);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    In function 'tapdisk_control_create_socket',
        inlined from 'tapdisk_control_open' at tapdisk-control.c:836:9:
    tapdisk-control.c:793:2: error: 'strncpy' specified bound 108 equals destination size [-Werror=stringop-truncation]
      strncpy(saddr.sun_path, td_control.path, sizeof(saddr.sun_path));
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    block-qcow.c: In function 'qcow_create':
    block-qcow.c:1216:5: error: 'strncpy' specified bound 4096 equals destination size [-Werror=stringop-truncation]
         strncpy(backing_filename, backing_file,
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          sizeof(backing_filename));
          ~~~~~~~~~~~~~~~~~~~~~~~~~

I those cases, reduce size of copied string and make sure final '\0' is
added.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Release-Acked-by: Juergen Gross <jgross@suse.com>
7 years agotools/gdbsx: fix -Wstringop-truncation warning
Marek Marczykowski-Górecki [Thu, 5 Apr 2018 01:50:54 +0000 (03:50 +0200)]
tools/gdbsx: fix -Wstringop-truncation warning

gcc-8 complains:

    gx_main.c: In function 'prepare_stop_reply':
    gx_main.c:385:9: error: 'strncpy' output truncated before terminating nul copying 6 bytes from a string of the same length [-Werror=stringop-truncation]
             strncpy(buf, "watch:", 6);
             ^~~~~~~~~~~~~~~~~~~~~~~~~

Since terminating '\0' isn't needed here at all, switch to memcpy.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Release-Acked-by: Juergen Gross <jgross@suse.com>
7 years agotools/xenpmd: fix possible '\0' truncation
Marek Marczykowski-Górecki [Thu, 5 Apr 2018 01:50:53 +0000 (03:50 +0200)]
tools/xenpmd: fix possible '\0' truncation

gcc-8 complains:
    xenpmd.c:207:9: error: 'strncpy' specified bound 32 equals destination size [-Werror=stringop-truncation]
             strncpy(info->oem_info, attrib_value, 32);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    xenpmd.c:201:9: error: 'strncpy' specified bound 32 equals destination size [-Werror=stringop-truncation]
             strncpy(info->battery_type, attrib_value, 32);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    xenpmd.c:195:9: error: 'strncpy' specified bound 32 equals destination size [-Werror=stringop-truncation]
             strncpy(info->serial_number, attrib_value, 32);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    xenpmd.c:189:9: error: 'strncpy' specified bound 32 equals destination size [-Werror=stringop-truncation]
             strncpy(info->model_number, attrib_value, 32);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Copy 31 chars, then make sure terminating '\0' is present. Those fields
are passed to strlen and as '%s' for snprintf later.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Release-Acked-by: Juergen Gross <jgross@suse.com>
7 years agotools/misc: fix hypothetical buffer overflow in xen-lowmemd
Marek Marczykowski-Górecki [Thu, 5 Apr 2018 01:50:50 +0000 (03:50 +0200)]
tools/misc: fix hypothetical buffer overflow in xen-lowmemd

gcc-8 complains:

    xen-lowmemd.c: In function 'handle_low_mem':
    xen-lowmemd.c:80:55: error: '%s' directive output may be truncated writing up to 511 bytes into a region of size 489 [-Werror=format-truncation=]
             snprintf(error, BUFSZ,"Failed to write target %s to xenstore", data);
                                                           ^~               ~~~~
    xen-lowmemd.c:80:9: note: 'snprintf' output between 36 and 547 bytes into a destination of size 512
             snprintf(error, BUFSZ,"Failed to write target %s to xenstore", data);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In practice it wouldn't happen, because 'data' contains string
representation of 64-bit unsigned number (20 characters at most).
But place a limit to mute gcc warning.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Release-Acked-by: Juergen Gross <jgross@suse.com>
7 years agotools/libxc: fix strncpy size
Marek Marczykowski-Górecki [Thu, 5 Apr 2018 01:50:49 +0000 (03:50 +0200)]
tools/libxc: fix strncpy size

gcc-8 warns about possible truncation of trailing '\0'.
Final character is overridden by '\0' anyway, so don't bother to copy
it.

This fixes compile failure:

    xc_pm.c: In function 'xc_set_cpufreq_gov':
    xc_pm.c:308:5: error: 'strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation]
         strncpy(scaling_governor, govname, CPUFREQ_NAME_LEN);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Release-Acked-by: Juergen Gross <jgross@suse.com>
7 years agopython: xc: fix max_cpu_index sign error
Petre Eftime [Thu, 5 Apr 2018 12:49:23 +0000 (12:49 +0000)]
python: xc: fix max_cpu_index sign error

When 0-indexing, maximum index is num_entries - 1. The python xc library had a
sign error where the minus was replaced by a plus, making tools that depended
on it to look for CPUs that did not exist.

Signed-off-by: Petre Eftime <epetre@amazon.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
7 years agolibxl: add libxl_domain_suspend_only to simply suspend a domain, without saving it
Marek Marczykowski-Górecki [Wed, 4 Apr 2018 17:01:12 +0000 (19:01 +0200)]
libxl: add libxl_domain_suspend_only to simply suspend a domain, without saving it

Similar functionality to libxl_domain_suspend(), but do not save domains
state to any file. Only suspend the domain and keep it in suspended
shutdown state (do not destroy it). Such domain can be later woken up
with libxl_domain_resume. The main reason for this functionality is to
suspend the host while some domains are running, potentially holding PCI
devices. This will give a chance to a driver in such a domain to
properly suspend the device.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Signed-off-by: Marcus of Wetware Labs <marcus@wetwa.re>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agoxen/pdx: Introduce helper to convert MFN <-> PDX
Julien Grall [Wed, 21 Feb 2018 13:46:25 +0000 (13:46 +0000)]
xen/pdx: Introduce helper to convert MFN <-> PDX

This will avoid use of pfn_to_pdx(mfn_x(mfn)) over the code base.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoxen/x86: mm: Switch x86/mm.c to use typesafe for virt_to_mfn
Julien Grall [Wed, 21 Feb 2018 13:46:24 +0000 (13:46 +0000)]
xen/x86: mm: Switch x86/mm.c to use typesafe for virt_to_mfn

No functional change intended.

While we are here, use PFN_DOWN() rather than open coding it.

Signed-off Julien Grall <julien.grall@arm.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
7 years agoxen/x86: Remove unused override of page_to_mfn/mfn_to_page
Julien Grall [Wed, 21 Feb 2018 13:46:24 +0000 (13:46 +0000)]
xen/x86: Remove unused override of page_to_mfn/mfn_to_page

A few files override page_to_mfn/mfn_to_page but actually never use
those macros. So drop them.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/mm: skip incrementing mfn if it is not a valid mfn
Wei Liu [Fri, 9 Mar 2018 17:20:14 +0000 (17:20 +0000)]
x86/mm: skip incrementing mfn if it is not a valid mfn

In a follow-up patch, some callers will be switched to pass
INVALID_MFN instead of zero for non-present mappings. So skip
incrementing mfn if it is not a valid one.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/XPTI: reduce .text.entry
Jan Beulich [Mon, 19 Mar 2018 13:40:12 +0000 (07:40 -0600)]
x86/XPTI: reduce .text.entry

This exposes less code pieces and at the same time reduces the range
covered from slightly above 3 pages to a little below 2 of them.

The code being moved is unchanged, except for the removal of trailing
blanks, insertion of blanks between operands, and a pointless q suffix
from "retq".

A few more small pieces could be moved, but it seems better to me to
leave them where they are to not make it overly hard to follow code
paths.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agox86: log XPTI enabled status
Jan Beulich [Mon, 19 Mar 2018 13:39:04 +0000 (07:39 -0600)]
x86: log XPTI enabled status

At the same time also report the state of the two defined
ARCH_CAPABILITIES MSR bits. To avoid further complicating the
conditional around that printk(), drop it (it's a debug level one only
anyway).

Issue the main message without any XENLOG_*, and also drop XENLOG_INFO
from the respective BTI message, to make sure they're visible at default
log level also in release builds.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
7 years agox86: disable XPTI when RDCL_NO
Jan Beulich [Mon, 19 Mar 2018 13:37:54 +0000 (07:37 -0600)]
x86: disable XPTI when RDCL_NO

Use the respective ARCH_CAPABILITIES MSR bit, but don't expose the MSR
to guests yet.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agox86/vtx: Introduce a typed union for CR access exit information
Andrew Cooper [Thu, 25 Jan 2018 15:45:37 +0000 (15:45 +0000)]
x86/vtx: Introduce a typed union for CR access exit information

This reduces code volume, and has a minor improvement on compiled size,
probably due to the removal of several temporary variables.

  add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-50 (-50)
  function                                     old     new   delta
  vmx_vmexit_handler                          6881    6878      -3
  nvmx_n2_vmexit_handler                      3473    3426     -47

Take the opportunity to make some style corrections, and add some
ASSERT_UNREACHABLE()s in appropriate places.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
7 years agoxen/public: Rename xen_domctl_createdomain.config to arch
Andrew Cooper [Fri, 16 Mar 2018 16:57:18 +0000 (16:57 +0000)]
xen/public: Rename xen_domctl_createdomain.config to arch

This is a tools only hypercall so fine to change.  Altering the name avoids
having confusing code such as config->config all over the hypervisor and
toolstack.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agotools/libxl: Don't prepare or save xc_config when soft resetting a domain
Andrew Cooper [Fri, 9 Mar 2018 13:03:26 +0000 (13:03 +0000)]
tools/libxl: Don't prepare or save xc_config when soft resetting a domain

xc_config is only used by xc_domain_create(), but by calling
libxl__arch_domain_{prepare,save}_config() we clobber the real settings with
the default settings.

Move all data and calls relating to xc_domain_create() into the path which
calls it.

As far as I can tell, soft_reset has always been broken for ARM domains using
LIBXL_GIC_VERSION_DEFAULT, which elicits a hard error out of
libxl__arch_domain_save_config(), and only works on x86 because this function
is a no-op.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agotools/libxl: Drop xc_domain_configuration_t from libxl__domain_build_state
Andrew Cooper [Fri, 9 Mar 2018 12:24:13 +0000 (12:24 +0000)]
tools/libxl: Drop xc_domain_configuration_t from libxl__domain_build_state

The data it stores is initialised and exclusively used within
libxl__domain_make(), with the important details written back elsewhere by
libxl__arch_domain_save_config().  Prepare xc_config on libxl__domain_make()'s
stack, and drop the parameter.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agox86/cpuid: update signature of hvm_cr4_guest_valid_bits()
Sergey Dyasli [Thu, 22 Mar 2018 11:32:36 +0000 (11:32 +0000)]
x86/cpuid: update signature of hvm_cr4_guest_valid_bits()

With the new cpuid infrastructure there is a domain-wide struct cpuid
policy and there is no need to pass a separate struct vcpu * into
hvm_cr4_guest_valid_bits() anymore. Make the function accept struct
domain * instead and update callers.

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
7 years agox86/altp2m: support for setting restrictions for an array of pages
Razvan Cojocaru [Fri, 30 Mar 2018 15:39:05 +0000 (18:39 +0300)]
x86/altp2m: support for setting restrictions for an array of pages

For the default EPT view we have xc_set_mem_access_multi(), which
is able to set an array of pages to an array of access rights with
a single hypercall. However, this functionality was lacking for the
altp2m subsystem, which could only set page restrictions for one
page at a time. This patch addresses the gap.

HVMOP_altp2m_set_mem_access_multi has been added as a HVMOP (as opposed to a
DOMCTL) for consistency with its HVMOP_altp2m_set_mem_access counterpart (and
hence with the original altp2m design, where domains are allowed - with the
proper altp2m access rights - to alter these settings), in the absence of an
official position on the issue from the original altp2m designers.

Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Signed-off-by: Petre Pircalabu <ppircalabu@bitdefender.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
7 years agox86/hvm/ioreq: fix two bugs in hvm_create_ioreq_server
Wei Liu [Wed, 4 Apr 2018 11:03:14 +0000 (12:03 +0100)]
x86/hvm/ioreq: fix two bugs in hvm_create_ioreq_server

It is possible to call the error path with i pointing beyond the end
of the array.

There is another bug that if there is already a default ioreq server,
the code will actually sets the element to NULL, hence leaking memory.

Move setting NULL to where it is needed.

Coverity-ID: 1433777
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
7 years agoRevert "Config.mk: update mini-os commit"
Wei Liu [Tue, 3 Apr 2018 17:51:14 +0000 (18:51 +0100)]
Revert "Config.mk: update mini-os commit"

This reverts commit 55e0590e4bed56db0ea628826409572c94c54ebf.

The update has broken stubdom tests.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
7 years agotools/libxenforeignmemory: reduce xenforeignmemory_restrict code footprint
Paul Durrant [Tue, 29 Aug 2017 14:18:23 +0000 (15:18 +0100)]
tools/libxenforeignmemory: reduce xenforeignmemory_restrict code footprint

By using a static inline stub in private.h for OS where this functionality
is not implemented, the various duplicate stubs in the OS-specific source
modules can be avoided.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
7 years agotools/libxenforeignmemory: add support for resource mapping
Paul Durrant [Mon, 31 Jul 2017 15:28:39 +0000 (16:28 +0100)]
tools/libxenforeignmemory: add support for resource mapping

A previous patch introduced a new HYPERVISOR_memory_op to acquire guest
resources for direct priv-mapping.

This patch adds new functionality into libxenforeignmemory to make use
of a new privcmd ioctl [1] that uses the new memory op to make such
resources available via mmap(2).

[1] http://xenbits.xen.org/gitweb/?p=people/pauldu/linux.git;a=commit;h=ce59a05e6712

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
7 years agox86/mm: add an extra command to HYPERVISOR_mmu_update...
Paul Durrant [Mon, 30 Oct 2017 11:39:33 +0000 (11:39 +0000)]
x86/mm: add an extra command to HYPERVISOR_mmu_update...

...to allow the calling domain to prevent translation of specified l1e
value.

Despite what the comment in public/xen.h might imply, specifying a
command value of MMU_NORMAL_PT_UPDATE will not simply update an l1e with
the specified value. Instead, mod_l1_entry() tests whether foreign_dom
has PG_translate set in its paging mode and, if it does, assumes that the
the pfn value in the l1e is a gfn rather than an mfn.

To allow PV tools domain to map mfn values from a previously issued
HYPERVISOR_memory_op:XENMEM_acquire_resource, there needs to be a way
to tell HYPERVISOR_mmu_update that the specific l1e value does not
require translation regardless of the paging mode of foreign_dom. This
patch therefore defines a new command value, MMU_PT_UPDATE_NO_TRANSLATE,
which has the same semantics as MMU_NORMAL_PT_UPDATE except that the
paging mode of foreign_dom is ignored and the l1e value is used verbatim.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/hvm/ioreq: add a new mappable resource type...
Paul Durrant [Wed, 9 Aug 2017 16:39:01 +0000 (17:39 +0100)]
x86/hvm/ioreq: add a new mappable resource type...

... XENMEM_resource_ioreq_server

This patch adds support for a new resource type that can be mapped using
the XENMEM_acquire_resource memory op.

If an emulator makes use of this resource type then, instead of mapping
gfns, the IOREQ server will allocate pages which are assigned to the
emulating domain. These pages will never be present in the P2M of the
guest at any point (and are not even shared with the guest) and so are not
vulnerable to any direct attack by the guest.

NOTE: Use of the new resource type is not compatible with use of
      XEN_DMOP_get_ioreq_server_info unless the XEN_DMOP_no_gfns flag is
      set.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <julien.grall@arm.com>
7 years agox86/mm: add HYPERVISOR_memory_op to acquire guest resources
Paul Durrant [Wed, 27 Sep 2017 09:00:54 +0000 (10:00 +0100)]
x86/mm: add HYPERVISOR_memory_op to acquire guest resources

Certain memory resources associated with a guest are not necessarily
present in the guest P2M.

This patch adds the boilerplate for new memory op to allow such a resource
to be priv-mapped directly, by either a PV or HVM tools domain.

NOTE: Whilst the new op is not intrinsically specific to the x86 architecture,
      I have no means to test it on an ARM platform and so cannot verify
      that it functions correctly.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <julien.grall@arm.com>
7 years agox86/hvm/ioreq: defer mapping gfns until they are actually requested
Paul Durrant [Wed, 9 Aug 2017 15:22:35 +0000 (16:22 +0100)]
x86/hvm/ioreq: defer mapping gfns until they are actually requested

A subsequent patch will introduce a new scheme to allow an emulator to
map ioreq server pages directly from Xen rather than the guest P2M.

This patch lays the groundwork for that change by deferring mapping of
gfns until their values are requested by an emulator. To that end, the
pad field of the xen_dm_op_get_ioreq_server_info structure is re-purposed
to a flags field and new flag, XEN_DMOP_no_gfns, defined which modifies the
behaviour of XEN_DMOP_get_ioreq_server_info to allow the caller to avoid
requesting the gfn values.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
7 years agox86/hvm/ioreq: use gfn_t in struct hvm_ioreq_page
Paul Durrant [Wed, 9 Aug 2017 13:19:25 +0000 (14:19 +0100)]
x86/hvm/ioreq: use gfn_t in struct hvm_ioreq_page

This patch adjusts the ioreq server code to use type-safe gfn_t values
where possible. No functional change.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>