Commit Graph
24205 Commits
Author SHA1 Message Date
Andres Lagar-Cavilla 3c42e2fcfa x86/mm: Fix liveness of pages in grant copy operations
We were immediately putting the p2m entry translation for grant
copy operations. This allowed for an unnecessary race by which the
page could have been swapped out between the p2m lookup and the actual
use. Hold on to the p2m entries until the grant operation finishes.

Also fixes a small bug: for the source page of the copy, get_page
was assuming the page was owned by the source domain. It may be a
shared page, since we don't perform an unsharing p2m lookup.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
2011-11-24 17:05:25 +00:00
Andres Lagar-Cavilla b61d7d4e30 x86/mm: Ensure liveness of pages involved in a guest page table walk
Instead of risking deadlock by holding onto the gfn's acquired during
a guest page table walk, acquire an extra reference within the get_gfn/
put_gfn critical section, and drop the extra reference when done with
the map. This ensures liveness of the map, i.e. the underlying page
won't be paged out.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
2011-11-24 17:05:25 +00:00
Ian Campbell ab375de6c2 libvchan: clean *.opic
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2011-11-24 17:00:33 +00:00
Jan Beulich 0244dc6768 x86: small fixes to pcpu platform op handling
XENPF_get_cpuinfo should init the flags output field rather than only
modify it.

XENPF_cpu_online must check for the input CPU number to be in range.

XENPF_cpu_offline must also do that, and should also reject attempts to
offline CPU 0 (this fails in cpu_down() too, but preventing this here
appears more correct given that the code here calls
continue_hypercall_on_cpu(0, ...), which would be flawed if cpu_down()
would ever allow bringing down CPU 0 (and a distinct error code is
easier to deal with when debugging issues).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
2011-11-24 17:56:26 +01:00
Andres Lagar-Cavilla 41f1a2fac4 x86/mm: ASSERT we are putting the right gfn in the XENMAPSPACE_gmfn* cases
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
2011-11-24 16:34:34 +00:00
Andres Lagar-Cavilla 1bea6938ab x86/mm: handle HVMOP_modified_memory on shared pages
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Signed-off-by: Adin Scannell <adin@scannell.ca>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
2011-11-24 16:34:34 +00:00
Andres Lagar-Cavilla 2ad467f6a3 x86/mm: fix domain-paging's interaction with log-dirty
Allow pages typed log dirty to be paged out, and the proper type to
restored when paging pages back in.

Signed-off-by: Andres lagar-Cavilla <andres@lagarcavilla.org>
Signed-off-by: Adin Scannell <adin@scannell.ca>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
2011-11-24 16:34:34 +00:00
Keir Fraser 44fc6177ee x86/waitqueue: Because we have per-cpu stacks, we must wake up on teh
same cpu that we slept on. Otherwise stack references are bogus on
wakeup.

Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-24 15:50:08 +00:00
Keir Fraser 9333781f50 waitqueue: Reorder prepare_to_wait() so that vcpu is definitely on the
queue on exit, even after a wakeup.

Otherwise, when we go round the loop in wait_event(), we may not
actually sleep after the first iteration, as we do not put ourselves
back on the queue on wakeup.

Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-24 15:49:25 +00:00
Keir Fraser 7d798b7c99 waitqueue: Detect saved-stack overflow and crash the guest.
Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-24 15:48:10 +00:00
Andres Lagar-Cavilla b4c64fb443 Properly compare "pci" token when groking serial port config
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-24 15:45:19 +00:00
Andres Lagar-Cavilla 8900056b84 Trivial fix for rc val in hap track dirty vram
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-24 15:44:51 +00:00
Jean Guyader cefeffc7e5 hvmloader: Intel GPU passthrough, reverse OpRegion
The Intel GPU uses a two pages NVS region called OpRegion.
In order to get full support for the driver in the guest
we need to map this region.

This patch reserves 2 pages on the top of the memory in the
reserved area and mark this region as NVS in the e820. Then
we write the address to the config space (offset 0xfc) so the
device model can map the OpRegion at this address in the guest.

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-24 15:43:59 +00:00
Andres Lagar-Cavilla c00341e692 x86/mm/p2m: don't overwrite m2p entry of still-shared pages
When updating a p2m mapping to shared, previous code
unconditionally set the m2p entry for the old mfn to invalid.
We now check that the old mfn does not remain shared.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
2011-11-24 15:20:57 +00:00
Andres Lagar-Cavilla 5a7e47a73d x86/mm: change return code for log-dirty disabling
Disabling log dirty mode in HAP always returns -EINVAL. Make it
return the correct rc on success.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Signed-off-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
2011-11-24 15:20:57 +00:00
Andres Lagar-Cavilla 85826188d8 x86/mm/p2m: fix pod locking
The path p2m-lookup -> p2m-pt->get_entry -> 1GB PoD superpage ->
pod_demand_populate ends in the pod code performing a p2m_set_entry with
no locks held (in order to split the 1GB superpage into 512 2MB ones)

Further, it calls p2m_unlock after that, which will break the spinlock.

This patch attempts to fix that.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
2011-11-24 15:20:57 +00:00
Jan Beulich d0d0ded0b6 ia64: build fixes (again)
This undoes a single change from c/s 24136:3622d7fae14d
(common/grant_table.c) and several from c/s 24100:be8daf78856a
(common/memory.c). It also completes the former with two previously
missing ia64 specific code adjustments. Authors Cc-ed.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
2011-11-24 09:44:54 +01:00
Paul Durrant d7e49b1fe4 libxl: Prevent xl save from segfaulting when control/shutdown key is removed
To acknowledge the tools' setting of control/shutdown it is normal for
PV drivers to rm the key. This leads to libxl__xs_read() returning
NULL and thus a subsequent strcmp on the return value will cause a
segfault.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2011-11-23 12:03:37 +00:00
Ian Campbell 5aca159d27 tools: use system libaio for blktap1 as well.
24184:4ecd3615e726 missed this because I was accidentally testing with a
.config containing CONFIG_SYSTEM_LIBAIO=n. Tools tree now fully rebuilt
without this. There were no other issues.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2011-11-23 11:15:31 +00:00
Ian Campbell 1d3cf6bdf1 docs: remove some fatally out of date documentation
I think these are better off deleted than remaining to confuse people.

docs/misc/blkif-drivers-explained.txt:

 - Talks about Xen 2.0 beta, talks about the old pre-xenstored IPC mechanism.

docs/misc/cpuid-config-for-guest.txt:

 - Doesn't really say anything, in particular doesn't actually describe how to
   configure CPUID.

docs/misc/hg-cheatsheet.txt:

 - Not out of date per-se wrt mercural but talk about Xen 2.0 and gives URLs
   under www.cl.cam.ac.uk. Talks a lot about bitkeeper. Given that mercurial is
   hardly unusual anymore I think there must be better guides out there so this
   one is not worth resurecting.

docs/misc/network_setup.txt:

 - This is more comprehensively documented on the wiki these days.

docs/misc/VMX_changes.txt:

 - Is basically a changelog from the initial implementation of VMX in 2004.

I'm not sure about some of the other docs, but these ones seemed fairly
obvious.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2011-11-22 18:51:13 +00:00
Ian Campbell 3f857a8d12 tools: use system installed libaio by default.
I could have sworn I did this years ago.

IIRC the need for our own copy was due to the use of io_set_eventfd which is
not present in version 0.3.106. However it is in 0.3.107 the first version of
which was uploaded to Debian in June 2008 (I can't find a better reference for
the release date).

The necessary version is available in Debian Lenny onwards and is in at least
RHEL 6, Fedora 13 and OpenSuSE 11.3. The necessary version appears to not be
available in RHEL 5 or SLES 11 which is why I haven't simply nuked the in tree
version.

This is based on tools-system-libaio.diff from the Debian packaging although I
have made it optional (but default on).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2011-11-22 17:24:51 +00:00
Ian Jackson c977b08f1f Merge 2011-11-22 17:09:12 +00:00
Daniel De Graaf 27be7560a5 xenstore: xenbus cannot be opened read-only
In order to read keys from xenstore, the xenstore libraries need to
write the request to the xenbus socket. This means that the socket
cannot be opened read-only.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2011-11-22 17:07:32 +00:00
Jan Beulich d2e02c9b9c move pci_find_ext_capability() into common PCI code
There's nothing architecture specific about it. It requires, however,
that x86-32's pci_conf_read32() tolerates register accesses above 255
(for consistency the adjustment is done to all pci_conf_readNN()
functions).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
2011-11-22 17:22:31 +01:00
Stefano Stabellini ebbd2561b4 libxl: Add a vkbd frontend/backend pair for HVM guests
Linux PV on HVM guests can use vkbd, so add a vkbd frontend/backend
pair for HVM guests by default.  It is useful because it doesn't
require frequent qemu wakeups as the usb keyboard/mouse does.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2011-11-22 16:19:48 +00:00
Ian Jackson 549ec0f73f Update QEMU_TAG 2011-11-22 16:19:11 +00:00
Keir Fraser acbd69baab debug: Add domain/vcpu pause_count info to 'd' key.
Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-22 15:35:26 +00:00
Daniel De Graaf 2be4fe9b05 xsm/flask: fix resource list range checks
The FLASK security checks for resource ranges were not implemented
correctly - only the permissions on the endpoints of a range were
checked, instead of all items contained in the range. This would allow
certain resources (I/O ports, I/O memory) to be used by domains in
contravention to security policy.

This also corrects a bug where adding overlapping resource ranges did
not trigger an error.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-22 13:29:48 +00:00
Daniel De Graaf e7e7a86267 xsm/flask: Use correct flag to detect writable grant mappings
The flags passed to xsm_grant_mapref are the flags from the map
operation (GNTMAP_*), not status flags (GTF_*).

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-22 13:29:01 +00:00
Wei Wang 9c46139de8 amd iommu: Support INVALIDATE_IOMMU_ALL command.
It is one of the new architectural commands supported by iommu v2.
It instructs iommu to clear all address translation and interrupt
remapping caches for all devices and all domains.

Signed-off-by: Wei Wang <wei.wang2@amd.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-22 13:27:19 +00:00
Wei Wang 489fddfc08 amd iommu: Factor out iommu command handling functions,
and move them into a new file.

Signed-off-by: Wei Wang <wei.wang2@amd.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-22 13:26:46 +00:00
Wei Wang 550ca1beeb amd iommu: Fix incorrect definitions.
Signed-off-by: Wei Wang <wei.wang2@amd.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-22 13:26:11 +00:00
Wei Wang 7e82d0d14a amd iommu: Advertise iommu extended feature bits to xen.
Signed-off-by: Wei Wang <wei.wang2@amd.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-22 13:25:42 +00:00
Keir Fraser 28909bdbbe x86,waitqueue: Allocate whole page for shadow stack.
Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-22 13:00:21 +00:00
Keir Fraser 07b6d6bea1 x86,vmx: Remove broken and unused __vmptrst().
Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-22 12:53:48 +00:00
Keir Fraser 5a9a98a7a6 hvmloader: Fix memory relocation loop.
Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-21 21:28:34 +00:00
Jan Beulich 7442435170 x86/vioapic: clear remote IRR when switching RTE to edge triggered mode
Xen itself (as much as Linux) relies on this behavior, so it should
also emulate it properly. Not doing so reportedly gets in the way of
kexec inside a HVM guest.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Olaf Hering <olaf@aepfle.de>
2011-11-21 09:29:31 +01:00
Keir Fraser 28e312a8b7 x86: Fix RCU locking in XENMEM_add_to_physmap.
Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-19 22:13:51 +00:00
Jean Guyader cf95b2a9fd iommu: Introduce per cpu flag (iommu_dont_flush_iotlb) to avoid unnecessary iotlb flush
Add cpu flag that will be checked by the iommu low level code
to skip iotlb flushes. iommu_iotlb_flush shall be called explicitly.

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:43:26 +00:00
Jean Guyader e51e2e0e58 hvmloader: Change memory relocation loop when overlap with PCI hole
Change the way we relocate the memory page if they overlap with pci
hole.  Use new map space (XENMAPSPACE_gmfn_range) to move the loop
into xen.

This code usually get triggered when a device is pass through to a
guest and the PCI hole has to be extended to have enough room to map
the device BARs.  The PCI hole will starts lower and it might overlap
with some RAM that has been alocated for the guest. That usually
happen if the guest has more than 4G of RAM.  We have to relocate
those pages in high mem otherwise they won't be accessible.

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:42:46 +00:00
Jean Guyader a04811a315 mm: New XENMEM space, XENMAPSPACE_gmfn_range
XENMAPSPACE_gmfn_range is like XENMAPSPACE_gmfn but it runs on
a range of pages. The size of the range is defined in a new field.

This new field .size is located in the 16 bits padding between .domid
and .space in struct xen_add_to_physmap to stay compatible with older
versions.

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:42:08 +00:00
Jean Guyader 19c617a85b add_to_physmap: Move the code for XENMEM_add_to_physmap
Move the code for the XENMEM_add_to_physmap case into it's own
function (xenmem_add_to_physmap).

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:41:33 +00:00
Jean Guyader bf3292ca31 iommu: Introduce iommu_flush and iommu_flush_all.
Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:40:56 +00:00
Jean Guyader c312ccdeaf vtd: Refactor iotlb flush code
Factorize the iotlb flush code from map_page and unmap_page into
it's own function.

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:40:19 +00:00
Juergen Gross f42d7a66bf sched_sedf: Avoid panic when adjusting sedf parameters
When using sedf scheduler in a cpupool the system might panic when
setting sedf scheduling parameters for a domain.  Introduces
for_each_domain_in_cpupool macro as it is usable 4 times now.  Add
appropriate locking in cpupool_unassign_cpu().

Signed-off-by: Juergen Gross <juergen.gross@ts.fujitsu.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:34:43 +00:00
Paul Durrant 95ad9f65c9 hvmloader: Add configuration options to selectively disable S3 and S4 ACPI power states.
Introduce acpi_s3 and acpi_s4 configuration options (default=1). The
S3 and S4 packages are moved into separate SSDTs and their inclusion
is controlled by the new configuration options.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:32:50 +00:00
Paul Durrant 9307335747 hvmloader: Move acpi_enabled out of hvm_info_table into xenstore
Since hvmloader has a xentore client, use a platform key in xenstore
to indicate whether ACPI is enabled or not rather than the shared
hvm_info_table structure.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:31:43 +00:00
Jan Beulich 04678eb8f3 x86/xsave: provide guests with finit-like environment
Without the use of xsave, guests get their initial floating point
environment set up with finit. At least NetWare actually depends on
this (in particular on all exceptions being masked), so to be
consistent set the same environment also when using xsave. This is
also in line with all SSE exceptions getting masked initially.

To avoid further fragile casts in xstate_alloc_save_area() the patch
also changes xsave_struct's fpu_see member to have actually usable
fields.

The patch was tested in its technically identical, but modified-file-
wise different 4.1.2 version.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Charles Arnold <carnold@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
2011-11-18 09:22:45 +01:00
Jan Beulich 8eca0db0e8 x86/IRQ: prevent vector sharing within IO-APICs
Following the prevention of vector sharing for MSIs, this change
enforces the same within IO-APICs: Pin based interrupts use the IO-APIC
as their identifying device under the AMD IOMMU (and just like for
MSIs, only the identifying device is used to remap interrupts here,
with no regard to an interrupt's destination).

Additionally, LAPIC initiated EOIs (for level triggered interrupts) too
use only the vector for identifying which interrupts to end. While this
generally causes no significant problem (at worst an interrupt would be
re-raised without a new interrupt event actually having occurred), it
still seems better to avoid the situation.

For this second aspect, a distinction is being made between the
traditional and the directed-EOI cases: In the former, vectors should
not be shared throughout all IO-APICs in the system, while in the
latter case only individual IO-APICs need to be contrained (or, if the
firmware indicates so, sub- groups of them having the same GSI appear
at multiple pins).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2011-11-18 09:21:24 +01:00
Jan Beulich f0b7583fd5 x86/IO-APIC: refine EOI-ing of migrating level interrupts
Rather than going through all IO-APICs and calling io_apic_eoi_vector()
for the vector in question, just use eoi_IO_APIC_irq().

This in turn allows to eliminate quite a bit of other code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2011-11-18 09:18:41 +01:00