From: Anthony PERARD <anthony.perard@citrix.com>
To: QEMU-devel <qemu-devel@nongnu.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
Xen Devel <xen-devel@lists.xensource.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [Qemu-devel] [PATCH 2/5] xen mapcache: Check if a memory space has moved.
Date: Thu, 24 Nov 2011 16:08:10 +0000 [thread overview]
Message-ID: <1322150893-887-3-git-send-email-anthony.perard@citrix.com> (raw)
In-Reply-To: <1322150893-887-1-git-send-email-anthony.perard@citrix.com>
This patch change the xen_map_cache behavior. Before trying to map a guest
addr, mapcache will look into the list of range of address that have been moved
(physmap/set_memory). There is currently one memory space like this, the vram,
"moved" from were it's allocated to were the guest will look into.
This help to have a succefull migration.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
xen-all.c | 19 +++++++++++++++++++
xen-mapcache.c | 8 ++++++--
xen-mapcache.h | 1 +
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/xen-all.c b/xen-all.c
index b5e28ab..40e8869 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -83,6 +83,8 @@ typedef struct XenIOState {
Notifier exit;
} XenIOState;
+XenIOState *xen_io_state = NULL;
+
/* Xen specific function for piix pci */
int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
@@ -218,6 +220,22 @@ static XenPhysmap *get_physmapping(XenIOState *state,
return NULL;
}
+target_phys_addr_t xen_addr_actually_is(target_phys_addr_t start_addr, ram_addr_t size)
+{
+ if (xen_io_state) {
+ target_phys_addr_t addr = start_addr & TARGET_PAGE_MASK;
+ XenPhysmap *physmap = NULL;
+
+ QLIST_FOREACH(physmap, &xen_io_state->physmap, list) {
+ if (range_covers_byte(physmap->phys_offset, physmap->size, addr)) {
+ return physmap->start_addr;
+ }
+ }
+ }
+
+ return start_addr;
+}
+
#if CONFIG_XEN_CTRL_INTERFACE_VERSION >= 340
static int xen_add_to_physmap(XenIOState *state,
target_phys_addr_t start_addr,
@@ -891,6 +909,7 @@ int xen_hvm_init(void)
XenIOState *state;
state = g_malloc0(sizeof (XenIOState));
+ xen_io_state = state;
state->xce_handle = xen_xc_evtchn_open(NULL, 0);
if (state->xce_handle == XC_HANDLER_INITIAL_VALUE) {
diff --git a/xen-mapcache.c b/xen-mapcache.c
index 7bcb86e..73927ab 100644
--- a/xen-mapcache.c
+++ b/xen-mapcache.c
@@ -191,10 +191,14 @@ uint8_t *xen_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size,
uint8_t lock)
{
MapCacheEntry *entry, *pentry = NULL;
- target_phys_addr_t address_index = phys_addr >> MCACHE_BUCKET_SHIFT;
- target_phys_addr_t address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1);
+ target_phys_addr_t address_index;
+ target_phys_addr_t address_offset;
target_phys_addr_t __size = size;
+ phys_addr = xen_addr_actually_is(phys_addr, size);
+ address_index = phys_addr >> MCACHE_BUCKET_SHIFT;
+ address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1);
+
trace_xen_map_cache(phys_addr);
if (address_index == mapcache->last_address_index && !lock && !__size) {
diff --git a/xen-mapcache.h b/xen-mapcache.h
index da874ca..5e561c5 100644
--- a/xen-mapcache.h
+++ b/xen-mapcache.h
@@ -19,6 +19,7 @@ uint8_t *xen_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size,
ram_addr_t xen_ram_addr_from_mapcache(void *ptr);
void xen_invalidate_map_cache_entry(uint8_t *buffer);
void xen_invalidate_map_cache(void);
+target_phys_addr_t xen_addr_actually_is(target_phys_addr_t start_addr, ram_addr_t size);
#else
--
Anthony PERARD
next prev parent reply other threads:[~2011-11-24 16:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-24 16:08 [Qemu-devel] [PATCH 0/5] Have a working migration with Xen Anthony PERARD
2011-11-24 16:08 ` [Qemu-devel] [PATCH 1/5] vl.c: Do not save RAM state when Xen is used Anthony PERARD
2011-11-24 17:23 ` Stefano Stabellini
2011-11-24 18:06 ` Anthony PERARD
2011-11-24 16:08 ` Anthony PERARD [this message]
2011-11-24 17:40 ` [Qemu-devel] [PATCH 2/5] xen mapcache: Check if a memory space has moved Stefano Stabellini
2011-11-24 17:57 ` Stefano Stabellini
2011-11-24 16:08 ` [Qemu-devel] [PATCH 3/5] Introduce premigrate RunState Anthony PERARD
2011-11-24 16:08 ` [Qemu-devel] [PATCH 4/5] xen: Change memory access behavior during migration Anthony PERARD
2011-11-24 16:08 ` [Qemu-devel] [PATCH 5/5] vga-cirrus: Workaround during restore when using Xen Anthony PERARD
2011-11-24 18:30 ` Stefano Stabellini
2011-11-24 18:49 ` Anthony PERARD
2011-11-25 11:51 ` Stefano Stabellini
2011-11-25 12:33 ` Anthony PERARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1322150893-887-3-git-send-email-anthony.perard@citrix.com \
--to=anthony.perard@citrix.com \
--cc=qemu-devel@nongnu.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).