Commit Graph
31342 Commits
Author SHA1 Message Date
Andrew Cooper 7eaec00dd9 docs/libxl: Introduce CHECKPOINT_END to support migration v2 remus streams
In a remus scenario, libxc will write a CHECKPOINT record, then hand
ownership of the fd to libxl.  Libxl then writes any records required
and finishes with a CHECKPOINT_END record, then hands ownership of the
fd back to libxc.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
2015-07-15 11:22:54 +01:00
Andrew Cooper 210b481752 tools/libxc+libxl+xl: Save v2 streams
This is a complicated set of changes which must be done together for
bisectability.

 * libxl-save-helper is updated to unconditionally use libxc migration v2.
 * libxl compatibility workarounds in libxc are disabled for save operations.
 * libxl__stream_write_start() is logically spliced into the event location
   where libxl__xc_domain_save() used to reside.
 * Ownership of the helper state moves into stream_write_state.
 * xl is updated to indicate that the stream is now v2

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>

---
v4:
 * Don't use _init() needlessly

v3: Many small changes, follwing similar review to the restore side
2015-07-15 11:22:54 +01:00
Ross Lagerwall 7c4027c6a0 tools/libxl: Infrastructure for writing a v2 stream
This contains the event machinery and state machines to write
non-checkpointed migration v2 stream (with the exception of the
xc_domain_save() handling which is spliced later in a bisectable way).

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

---
v4: Don't make _init() mandatory, use FILLZERO(), adjust stream_success()
v3: Similar changes to the read side, following the read side review.
2015-07-15 11:22:53 +01:00
Andrew Cooper 3a9ace0147 tools/libxc+libxl+xl: Restore v2 streams
This is a complicated set of changes which must be done together for
bisectability.

 * libxl-save-helper is updated to unconditionally use libxc migration
   v2.
 * libxl compatibility workarounds in libxc are disabled for restore
   operations.
 * libxl__stream_read_start() is logically spliced into the event
   location where libxl__xc_domain_restore() used to reside.
 * Ownership of the save_helper_state moves to stream_read_state.

The parameters 'hvm', 'pae', and 'superpages' were previously
superfluous, and are completely unused in migration
v2. callbacks->toolstack_restore is handled via a migration v2 record
now, rather than via a callback from libxc.

NB: this change breaks Remus.  Further untangling needs to happen
before Remus will function.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>

---
v4:
 * Don't use _init() needlessly
v3:
 * Simplify from v2.
 * Alter the ownership of save_helper_state

v2:
 * Drop "legacy_width" from the IDL
 * Gain a LIBXL_HAVE_ to signify support of migration v2 streams
2015-07-15 11:22:53 +01:00
Andrew Cooper d9c8790393 tools/libxl: Convert a legacy stream if needed
For backwards compatibility, a legacy stream needs converting before
it can be read by the v2 stream logic.

This causes the v2 stream logic to need to juggle two parallel tasks.
check_all_finished() is introduced for the purpose of joining the
tasks in both success and error cases.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

---
v4: Alter logic layout in check_all_finished()
v3: Simplified greatly from v2.  No practical change.
2015-07-15 11:22:53 +01:00
Andrew Cooper 4b405e6cff tools/libxl: Infrastructure to convert a legacy stream
Provide a thin wrapper around exec()ing the python conversion utility,
and a stub implementation for cases where conversion is not wanted
(i.e. not x86).

One complication is that the caller of this interface needs to assume
ownership of the output fd, to prevent it being closed while still in
use in a datacopier.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

---
v4: Formatting tweaks, description of the width field.
v3: Trimmed down massively from v2, provide libxl_no_convert_callout.c
2015-07-15 11:22:53 +01:00
Ross Lagerwall bf4c9d2d0c tools/libxl: Infrastructure for reading a libxl migration v2 stream
This contains the event machinery and state machines to read an act on
a non-checkpointed migration v2 stream (with the exception of the
xc_domain_restore() handling which is spliced later in a bisectable
way).

It also contains some boilerplate to help support checkpointed
streams, which shall be introduced in a later patch.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

---
v4:
 * Don't make _init() mandatory
 * Don't unilaterally clobber rc from datacopier callback
 * Comment adjustments
 * More assertions

v3: More descriptions of the internal state, shuffle function order, add
    an _init() call, condense error handling
2015-07-15 11:22:53 +01:00
Ross Lagerwall d3ea965258 tools/libxl: Migration v2 stream format
C structures describing the Libxl migration v2 stream format

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>

---
v2: Move into libxl__ namespace
2015-07-15 11:22:53 +01:00
Andrew Cooper 74a7c7a928 tools/python: Conversion utility for legacy migration streams
This utility will take a legacy stream as in input, and produce a v2
stream as an output.  It is exec()'d by libxl to provide backwards
compatibility.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
2015-07-15 11:22:53 +01:00
Andrew Cooper 19c6d0784a tools/python: Verification utility for v2 stream spec compliance
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>

---
This is exceedingly useful for development, but not of practical use being
installed into a production dom0.
2015-07-15 11:22:53 +01:00
Andrew Cooper f95d457f44 tools/python: Other migration infrastructure
Contains:
 * Reverse-engineered notes of the legacy format from xg_save_restore.h
 * Python implementation of the legacy format
 * Public HVM Params used in the legacy stream
 * XL header format

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>

---
New in v2 - removes various many magic numbers from subsequent scripts
2015-07-15 11:22:53 +01:00
Andrew Cooper 67b02060ca tools/python: Libxl migration v2 infrastructure
Contains:
 * Python implementation of the libxl migration v2 records
 * Verification code for spec compliance
 * Unit tests

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
2015-07-15 11:22:53 +01:00
Andrew Cooper 10ea555fc0 tools/python: Libxc migration v2 infrastructure
Contains:
 * Python implementation of the libxc migration v2 records
 * Verification code for spec compliance
 * Unit tests

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
2015-07-15 11:22:53 +01:00
Andrew Cooper 65f13e2b4c docs: Libxl migration v2 stream specification
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>

---
v3: Spelling fixes
2015-07-15 11:22:53 +01:00
Andrew Cooper e72ce244dc tools/xl: Mandatory flag indicating the format of the migration stream
Introduced at this point so the python stream conversion code has a
concrete ABI to use.  Later when libxl itself starts supporting a v2
stream, it will be added to XL_MANDATORY_FLAG_ALL.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>

---
v2: Expand commit message
2015-07-15 11:22:53 +01:00
Andrew Cooper a8d23067bc tools/libxl: Fix libxl__carefd_opened() to be more useful with an invalid fd
In the case that fd is -1, preserve errno and don't attempt to set
CLOEXEC.

Note that the implementation can still fail, as it ignores fcntl()
errors and may not set CLOEXEC properly.  Update the documentation
accordingly until it is fixed.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

---
Fixing the fnctl() error issue involves more TUITs than I currently
have.

New in v4
2015-07-15 11:22:53 +01:00
Andrew Cooper aefc3418c2 tools/libxl: Add save_helper_state pointers to libxl__xc_domain_{save,restore}()
Currently, libxl__xc_domain_{save,restore}() have specific knowledge
of where the libxl__save_helper_state lives inside a
libxl__domain_{create,save}_state object.

In later changes, the logical ownership of the
libxl__save_helper_state will change and will no longer be
d{c,s}s->shs.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>

---
New in v3
2015-07-15 11:22:53 +01:00
Andrew Cooper fa6b3e1735 tools/libxl: Extra management APIs for the save helper
With migration v2, there are several moving parts needing to be
juggled at once.  This requires the error handling logic to be able to
query the state of each moving part, possibly before they have been
started, and be able to cancel them.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

---
v4: Don't force _init() to be mandatory
v3: Adjust helper_{stop,failed,done} to use libxl__save_helper_inuse()
v2: Add an _init() function which allows _inuse() to be safe to call even
    before the save helper has started.
2015-07-15 11:22:53 +01:00
Andrew Cooper ed8d3c56aa tools/libxl: Split libxl__domain_create_state.restore_fd in two
In a future patch, we shall support automatically converting a legacy
stream to a v2 stream, in which case libxc needs to read from a
different fd.

Simply overwriting restore_fd does not work; the two fd's have
different circumstances.  The restore_fd needs to be returned to its
original state before libxl_domain_create_restore() returns, while in
the converted case, the fd needs allocating and deallocating
appropriately.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>

---
New in v2
2015-07-15 11:22:53 +01:00
Andrew Cooper 321d636e18 tools/libxl: Stash all restore parameters in domain_create_state
Shortly more parameters will appear, and this saves unboxing each one.
libxl_domain_restore_params is mandatory for restore streams, and
ignored for plain creation.  The old 'checkpointed_stream' was
incorrectly identified as a private parameter when it was infact
public.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
Reviewed-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>

---
Since v1:
 * Gate validity on restore_fd being valid.
2015-07-15 11:22:53 +01:00
Andrew Cooper 0abec849ca tools/libxl: Introduce libxl__kill()
as a wrapper to kill(2), and use it in preference to sendsig in
libxl_save_callout.c.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>

---
v3: Fix typo, add _hidden

Logically new in v2 - split out from a v1 change which was itself a
cherrypick-and-modify from the AO Abort series
2015-07-15 11:22:53 +01:00
Andrew Cooper 9438f98dba tools/libxl: Introduce ROUNDUP()
This is the same as is used by libxc.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
2015-07-15 11:22:53 +01:00
Andrew Cooper e0dfe9a316 tools/libxc: Always compile the compat qemu variables into xc_sr_context
This is safe (as the variables will simply be unused), and is required
for correct compilation when midway through untangling the libxc/libxl
interaction.

The #define is left in place to highlight that the variables can be
removed once the untangling is complete.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
2015-07-15 11:22:52 +01:00
Ian Jackson 3b1fc24d4d bsd-sys-queue-h-seddery: Massage `offsetof'
For some reason BSD's queue.h uses `__offsetof'.  It expects it to
work just like offsetof.  So use offsetof.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2015-07-15 11:22:52 +01:00
Wei Liu e3935318bf xl: fix a typo in error string in create_domain
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2015-07-15 10:58:08 +01:00
Wei Liu 581d92166e xl: correctly handle null extra config in main_config_update
Don't dereference NULL.

Also fixed a typo in error string while I was there.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2015-07-15 10:58:08 +01:00
Wei Liu 705c9e1242 xl: correct handling of extra_config in main_cpupoolcreate
Don't dereference extra_config if it's NULL. Don't leak extra_config in
the end.

Also fixed a typo in error string while I was there.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2015-07-15 10:58:08 +01:00
Wei Liu 573150f8f1 libxl: qmp_init_handler can return NULL
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2015-07-15 10:58:08 +01:00
Wei Liu 974e208b40 libxl: avoid leaking in libxl__initiate_device_remove
Change "return" to "goto out_success" to correctly dispose of the
structure.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2015-07-15 10:57:01 +01:00
Wei Liu 94ef16a42a libxl: turn two malloc's to libxl__malloc
One is to combine malloc + libxl__alloc_failed. The other is to avoid
dereferencing NULL pointer in case of malloc failure. Also use gc for
memory allocation and remove free() in second case.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2015-07-15 10:56:04 +01:00
Wei Liu 048f1a170a libxl: don't check s!=NULL in libxl__abs_path
That argument should not be NULL. Let subsequent dereferencing crashes
the process.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2015-07-15 10:56:04 +01:00
Ian Campbell e9d3a85997 tools: libxl: Handle failure to create qemu dm logfile
If libxl_create_logfile fails for some reason then
libxl__create_qemu_logfile previously just carried on and dereferenced
the uninitialised logfile.

Check for the error from libxl_create_logfile, which has already
logged for us.

This was reported as Debian bug #784880.

Reported-by: Russell Coker <russell@coker.com.au>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: 784880@bugs.debian.org
Acked-by: Wei Liu <wei.liu2@citrix.com>
2015-07-15 10:53:51 +01:00
Jan Beulich d924ddbf59 x86/HVM: drop now wrong ASSERT() from hvm_broadcast_ioreq()
The function is now also being used for IOREQ_TYPE_TIMEOFFSET.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
2015-07-14 15:20:15 +02:00
Chao Peng 42b79d4ad8 x86: avoid invalid phys_proc_id reference
phys_proc_id is invalidated in remove_siblinginfo() which gets called
before cpu_smpboot_free(). This means calling cpu_to_socket(cpu) in
cpu_smpboot_free() is not possible to be correct.

This patch moves the invalidating of phys_proc_id from
remove_siblinginfo() to cpu_smpboot_free() so that cpu_to_socket(cpu)
can be used in cpu_smpboot_free().

The same is done for cpu_core_id/compute_unit_id and due to that
cpu_sibling_setup_map is private to the file so it's moved as well.

Reported-by: Dario Faggioli <dario.faggioli@citrix.com>
Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
2015-07-13 13:46:48 +02:00
Tamas K Lengyel dbe6530f46 MAINTAINERS: support for xen-access and email change
Add tools/tests/xen-acess to the supported list under VM EVENT/MEM ACCESS.
Also, changing my e-mail to the preferred one, as it is in many of the headers
already.

Signed-off-by: Tamas K Lengyel <tlengyel@novetta.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2015-07-13 13:46:31 +02:00
Ben Catterall d16eaeda35 x86: remove sh_{un}map_domain_page() and hap_{un}map_domain_page()
Removed as they were wrappers around map_domain_page() to
make it appear to take an mfn_t type.

Signed-off-by: Ben Catterall <Ben.Catterall@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
2015-07-13 12:30:06 +02:00
Ben Catterall 8db5cd22d4 convert map_domain_page() to use the new mfn_t type
Reworked the internals and declaration, applying (un)boxing
where needed. Converted calls to map_domain_page() to
provide mfn_t types, boxing where needed.

Signed-off-by: Ben Catterall <Ben.Catterall@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2015-07-13 12:27:29 +02:00
Paul Durrant 0462444238 x86/hvm: fix deadlock in emulation of rep mov to or from VRAM
Razvan Cojocaru reported a hypervisor deadlock with the following stack:

(XEN)    [<ffff82d08012c3f1>] _spin_lock+0x31/0x54
(XEN)    [<ffff82d0801d09b6>] stdvga_mem_accept+0x3b/0x125
(XEN)    [<ffff82d0801cb23a>] hvm_find_io_handler+0x68/0x8a
(XEN)    [<ffff82d0801cb410>] hvm_mmio_internal+0x37/0x67
(XEN)    [<ffff82d0801c2403>] __hvm_copy+0xe9/0x37d
(XEN)    [<ffff82d0801c3e5d>] hvm_copy_from_guest_phys+0x14/0x16
(XEN)    [<ffff82d0801cb107>] hvm_process_io_intercept+0x10b/0x1d6
(XEN)    [<ffff82d0801cb291>] hvm_io_intercept+0x35/0x5b
(XEN)    [<ffff82d0801bb440>] hvmemul_do_io+0x1ff/0x2c1
(XEN)    [<ffff82d0801bc0b9>] hvmemul_do_io_addr+0x117/0x163
(XEN)    [<ffff82d0801bc129>] hvmemul_do_mmio_addr+0x24/0x26
(XEN)    [<ffff82d0801bcbb5>] hvmemul_rep_movs+0x1ef/0x335
(XEN)    [<ffff82d080198b49>] x86_emulate+0x56c9/0x13088
(XEN)    [<ffff82d0801bbd26>] _hvm_emulate_one+0x186/0x281
(XEN)    [<ffff82d0801bc1e8>] hvm_emulate_one+0x10/0x12
(XEN)    [<ffff82d0801cb63e>] handle_mmio+0x54/0xd2
(XEN)    [<ffff82d0801cb700>] handle_mmio_with_translation+0x44/0x46
(XEN)    [<ffff82d0801c27f6>] hvm_hap_nested_page_fault+0x15f/0x589
(XEN)    [<ffff82d0801e9741>] vmx_vmexit_handler+0x150e/0x188d
(XEN)    [<ffff82d0801ee7d1>] vmx_asm_vmexit_handler+0x41/0xc0

The problem here is the call to hvm_mmio_internal() being made by
__hvm_copy().

When the emulated VRAM access was originally started by
hvm_io_intercept() a few frames up the stack, it would have called
stdvga_mem_accept() which would then have acquired the per-domain
stdvga lock. Unfortunately the call to hvm_mmio_internal(), to avoid
a costly P2M walk, speculatively calls stdvga_mem_accept() again to
see if the page handed to __hvm_copy() is actually an internally
emulated page and hence the vcpu deadlocks.

The fix is to do the range-check in stdvga_mem_accept() without taking
the stdvga lock. This is safe because the range is constant and we know
the I/O will never actually be accepted by the stdvga device model
because hvmemul_do_io_addr() makes sure that the source of the I/O is
actually RAM.

Reported-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2015-07-13 11:56:36 +02:00
Paul Durrant f6bf39f84f x86/hvm: add support for broadcast of buffered ioreqs...
...and make RTC timeoffset ioreqs use it.

Without this patch RTC timeoffset updates go nowhere and Xen complains
with a (non-rate-limited) printk.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2015-07-13 11:53:18 +02:00
David Vrabel 8f4fc2d2bc x86: reintroduce read_unlock() optimization
Commit 902d1b5c31 (x86,arm: remove
asm/spinlock.h from all architectures) inadvertantly removed an
x86-specific optimization for read_unlock*().

Re-add asm/spinlock.h to allow architectures to provide an optmized
_raw_read_unlock() and make x86 provide the previous implementation.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
2015-07-13 11:50:51 +02:00
Paul Durrant 47b4d562b6 x86/hvm: avoid potential NULL pointer dereferences
Coverity flagged that hvm_next_io_handler() will return NULL after
calling domain_crash() and this will then lead to NULL pointer
dereferences in calling functions.

This patch checks for NULL in the callers and bails in that case.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2015-07-10 17:45:46 +02:00
Tamas K Lengyel 4012b9a466 x86/vm_event: toggle singlestep from vm_event response
Add an option to the vm_event response to toggle singlestepping on the vCPU.
This is only supported on Intel CPUs which have Monitor Trap Flag capability.

Signed-off-by: Tamas K Lengyel <tlengyel@novetta.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Acked-by: Ian Campbell <Ian.campbell@citrix.com>
2015-07-10 14:04:21 +02:00
Vitaly Kuznetsov 3b9bfeb1e7 x86/arm/mm: use gfn instead of pfn in p2m_{get,set}_mem_access
'pfn' and 'start_pfn' are ambiguous, both these functions expect GFNs as input.

On x86 the interface of p2m_set_mem_access() in p2m.c doesn't match the
declaration in p2m-common.h as 'pfn' is being used instead of 'start_pfn'.

On ARM both p2m_set_mem_access and p2m_get_mem_access interfaces don't match
declarations from p2m-common.h: p2m_set_mem_access uses 'pfn' instead of
'start_pfn' and p2m_get_mem_access uses 'gpfn' instead of 'pfn'.

Convert p2m_get_mem_access/p2m_set_mem_access (and __p2m_get_mem_access on ARM)
interfaces to using gft_t instead of unsigned long and update all users of
these functions.

There is also an issue in p2m_get_mem_access on x86: 'gfn' parameter passed to
gfn_lock/gfn_unlock is not defined. This code compiles only because of a
coincidence: gfn_lock/gfn_unlock are currently macros which don't use their
second argument.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2015-07-10 13:58:24 +02:00
Jan Beulich 968099c0a8 x86/monitor: move comment after 35f4aec5a0
It belongs with the check, not at a random other place.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
2015-07-10 13:56:54 +02:00
Andrew Cooper 09e53bf430 convert copy/clear_domain_page() to using mfn_t
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Convert grant_table.c to pass mfn_t types and fix ARM compiling.

Signed-off-by: Ben Catterall <Ben.Catterall@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2015-07-10 12:54:10 +02:00
Andrew Cooper 377f4e532e convert map_domain_page_global() to using mfn_t
The sh_map/unmap wrappers can be dropped, and take the opportunity to turn
some #define's into static inlines, for added type saftey.

As part of adding the type safety, GCC highlights an problematic include cycle
with arm/mm.h including domain_page.h which includes xen/mm.h and falls over
__page_to_mfn being used before being declared.  Simply dropping the inclusion
of domain_page.h fixes the compilation issue.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2015-07-10 12:53:24 +02:00
Tamas K Lengyel 2062f31bb3 x86/monitor: don't use hvm_funcs directly
A couple spots in x86/monitor used hvm_funcs directly. This patch adds an extra
wrapper for enable_msr_exit_interception and changes monitor.c to use only the
wrappers.

Signed-off-by: Tamas K Lengyel <tlengyel@novetta.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
2015-07-10 12:39:02 +02:00
Tamas K Lengyel 35f4aec5a0 x86/monitor: add get_capabilities to monitor_op domctl
Add option to monitor_op domctl to determine the monitor capabilities of the
system.

Signed-off-by: Tamas K Lengyel <tlengyel@novetta.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
2015-07-10 12:38:09 +02:00
Jan Beulich 84d6add559 x86/MSI: fix guest unmasking when handling IRQ via event channel
Rather than assuming only PV guests need special treatment (and
dealing with that directly when an IRQ gets set up), keep all guest MSI
IRQs masked until either the (HVM) guest unmasks them via vMSI or the
(PV, PVHVM, or PVH) guest sets up an event channel for it.

To not further clutter the common evtchn_bind_pirq() with x86-specific
code, introduce an arch_evtchn_bind_pirq() hook instead.

Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Sander Eikelenboom <linux@eikelenboom.it>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2015-07-10 12:36:24 +02:00
Paul Durrant e101123463 x86/hvm: track large memory mapped accesses by buffer offset
The code in hvmemul_do_io() that tracks large reads or writes, to avoid
re-issue of component I/O, is defeated by accesses across a page boundary
because it uses physical address. The code is also only relevant to memory
mapped I/O to or from a buffer.

This patch re-factors the code and moves it into hvmemul_phys_mmio_access()
where it is relevant and tracks using buffer offset rather than address.
Separate I/O emulations (of which there may be up to three per instruction)
are distinguished by linear address.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2015-07-10 10:22:08 +02:00