* [Qemu-devel] [PATCH] qxl: create slots on post_load in vga state
@ 2011-10-25 13:05 Alon Levy
2011-10-25 13:37 ` Alon Levy
0 siblings, 1 reply; 4+ messages in thread
From: Alon Levy @ 2011-10-25 13:05 UTC (permalink / raw)
To: kraxel; +Cc: qemu-devel
RHBZ 740547
If we migrate when the device is in vga state the guest
still believes the slots are created, and will cause operations
that reference the slots, causing a "panic: virtual address out of range"
on the first of them. Easy to see by migrating in vga mode with
a driver loaded, for instance windows cmd window in full screen mode,
and then exiting vga mode back to native mode will cause said panic.
Fixed by doing the slot recreation in post_load for vga mode as well.
Note that compat does not require any changes because it creates it's
only slot by a side effect of QXL_IO_SET_MODE.
Signed-off-by: Alon Levy <alevy@redhat.com>
---
v3:
no need to create slots in compat mode, they are created by qxl_set_mode.
hw/qxl.c | 27 ++++++++++++++++++++-------
1 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/hw/qxl.c b/hw/qxl.c
index 03848ed..ab088a9 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1662,12 +1662,26 @@ static int qxl_pre_load(void *opaque)
return 0;
}
+static void qxl_create_memslots(PCIQXLDevice *d)
+{
+ int i;
+
+ for (i = 0; i < NUM_MEMSLOTS; i++) {
+ if (!d->guest_slots[i].active) {
+ continue;
+ }
+ dprint(d, 1, "%s: restoring guest slot %d delta %"PRIu64"\n",
+ __func__, i, d->guest_slots[i].delta);
+ qxl_add_memslot(d, i, 0, QXL_SYNC);
+ }
+}
+
static int qxl_post_load(void *opaque, int version)
{
PCIQXLDevice* d = opaque;
uint8_t *ram_start = d->vga.vram_ptr;
QXLCommandExt *cmds;
- int in, out, i, newmode;
+ int in, out, newmode;
dprint(d, 1, "%s: start\n", __FUNCTION__);
@@ -1684,19 +1698,16 @@ static int qxl_post_load(void *opaque, int version)
qxl_mode_to_string(d->mode));
newmode = d->mode;
d->mode = QXL_MODE_UNDEFINED;
+
switch (newmode) {
case QXL_MODE_UNDEFINED:
break;
case QXL_MODE_VGA:
+ qxl_create_memslots(d);
qxl_enter_vga_mode(d);
break;
case QXL_MODE_NATIVE:
- for (i = 0; i < NUM_MEMSLOTS; i++) {
- if (!d->guest_slots[i].active) {
- continue;
- }
- qxl_add_memslot(d, i, 0, QXL_SYNC);
- }
+ qxl_create_memslots(d);
qxl_create_guest_primary(d, 1, QXL_SYNC);
/* replay surface-create and cursor-set commands */
@@ -1719,6 +1730,8 @@ static int qxl_post_load(void *opaque, int version)
break;
case QXL_MODE_COMPAT:
+ /* note: no need to call qxl_create_memslots, qxl_set_mode
+ * creates the mem slot. */
qxl_set_mode(d, d->shadow_rom.mode, 1);
break;
}
--
1.7.7
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] qxl: create slots on post_load in vga state
2011-10-25 13:05 [Qemu-devel] [PATCH] qxl: create slots on post_load in vga state Alon Levy
@ 2011-10-25 13:37 ` Alon Levy
0 siblings, 0 replies; 4+ messages in thread
From: Alon Levy @ 2011-10-25 13:37 UTC (permalink / raw)
To: kraxel; +Cc: qemu-devel
On Tue, Oct 25, 2011 at 03:05:08PM +0200, Alon Levy wrote:
> RHBZ 740547
>
NACK self, dprint contains delta that isn't being used, will resend.
> If we migrate when the device is in vga state the guest
> still believes the slots are created, and will cause operations
> that reference the slots, causing a "panic: virtual address out of range"
> on the first of them. Easy to see by migrating in vga mode with
> a driver loaded, for instance windows cmd window in full screen mode,
> and then exiting vga mode back to native mode will cause said panic.
>
> Fixed by doing the slot recreation in post_load for vga mode as well.
> Note that compat does not require any changes because it creates it's
> only slot by a side effect of QXL_IO_SET_MODE.
>
> Signed-off-by: Alon Levy <alevy@redhat.com>
> ---
> v3:
> no need to create slots in compat mode, they are created by qxl_set_mode.
>
> hw/qxl.c | 27 ++++++++++++++++++++-------
> 1 files changed, 20 insertions(+), 7 deletions(-)
>
> diff --git a/hw/qxl.c b/hw/qxl.c
> index 03848ed..ab088a9 100644
> --- a/hw/qxl.c
> +++ b/hw/qxl.c
> @@ -1662,12 +1662,26 @@ static int qxl_pre_load(void *opaque)
> return 0;
> }
>
> +static void qxl_create_memslots(PCIQXLDevice *d)
> +{
> + int i;
> +
> + for (i = 0; i < NUM_MEMSLOTS; i++) {
> + if (!d->guest_slots[i].active) {
> + continue;
> + }
> + dprint(d, 1, "%s: restoring guest slot %d delta %"PRIu64"\n",
> + __func__, i, d->guest_slots[i].delta);
> + qxl_add_memslot(d, i, 0, QXL_SYNC);
> + }
> +}
> +
> static int qxl_post_load(void *opaque, int version)
> {
> PCIQXLDevice* d = opaque;
> uint8_t *ram_start = d->vga.vram_ptr;
> QXLCommandExt *cmds;
> - int in, out, i, newmode;
> + int in, out, newmode;
>
> dprint(d, 1, "%s: start\n", __FUNCTION__);
>
> @@ -1684,19 +1698,16 @@ static int qxl_post_load(void *opaque, int version)
> qxl_mode_to_string(d->mode));
> newmode = d->mode;
> d->mode = QXL_MODE_UNDEFINED;
> +
> switch (newmode) {
> case QXL_MODE_UNDEFINED:
> break;
> case QXL_MODE_VGA:
> + qxl_create_memslots(d);
> qxl_enter_vga_mode(d);
> break;
> case QXL_MODE_NATIVE:
> - for (i = 0; i < NUM_MEMSLOTS; i++) {
> - if (!d->guest_slots[i].active) {
> - continue;
> - }
> - qxl_add_memslot(d, i, 0, QXL_SYNC);
> - }
> + qxl_create_memslots(d);
> qxl_create_guest_primary(d, 1, QXL_SYNC);
>
> /* replay surface-create and cursor-set commands */
> @@ -1719,6 +1730,8 @@ static int qxl_post_load(void *opaque, int version)
>
> break;
> case QXL_MODE_COMPAT:
> + /* note: no need to call qxl_create_memslots, qxl_set_mode
> + * creates the mem slot. */
> qxl_set_mode(d, d->shadow_rom.mode, 1);
> break;
> }
> --
> 1.7.7
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH] qxl: create slots on post_load in vga state
@ 2011-10-25 13:39 Alon Levy
2011-10-27 11:56 ` Gerd Hoffmann
0 siblings, 1 reply; 4+ messages in thread
From: Alon Levy @ 2011-10-25 13:39 UTC (permalink / raw)
To: kraxel; +Cc: qemu-devel
RHBZ 740547
If we migrate when the device is in vga state the guest
still believes the slots are created, and will cause operations
that reference the slots, causing a "panic: virtual address out of range"
on the first of them. Easy to see by migrating in vga mode with
a driver loaded, for instance windows cmd window in full screen mode,
and then exiting vga mode back to native mode will cause said panic.
Fixed by doing the slot recreation in post_load for vga mode as well.
Note that compat does not require any changes because it creates it's
only slot by a side effect of QXL_IO_SET_MODE.
Signed-off-by: Alon Levy <alevy@redhat.com>
---
v4:
don't print unused delta in qxl_create_memslots
v3:
no need to create slots in compat mode, they are created by qxl_set_mode.
hw/qxl.c | 26 +++++++++++++++++++-------
1 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/hw/qxl.c b/hw/qxl.c
index 03848ed..f332dbf 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1662,12 +1662,25 @@ static int qxl_pre_load(void *opaque)
return 0;
}
+static void qxl_create_memslots(PCIQXLDevice *d)
+{
+ int i;
+
+ for (i = 0; i < NUM_MEMSLOTS; i++) {
+ if (!d->guest_slots[i].active) {
+ continue;
+ }
+ dprint(d, 1, "%s: restoring guest slot %d\n", __func__, i);
+ qxl_add_memslot(d, i, 0, QXL_SYNC);
+ }
+}
+
static int qxl_post_load(void *opaque, int version)
{
PCIQXLDevice* d = opaque;
uint8_t *ram_start = d->vga.vram_ptr;
QXLCommandExt *cmds;
- int in, out, i, newmode;
+ int in, out, newmode;
dprint(d, 1, "%s: start\n", __FUNCTION__);
@@ -1684,19 +1697,16 @@ static int qxl_post_load(void *opaque, int version)
qxl_mode_to_string(d->mode));
newmode = d->mode;
d->mode = QXL_MODE_UNDEFINED;
+
switch (newmode) {
case QXL_MODE_UNDEFINED:
break;
case QXL_MODE_VGA:
+ qxl_create_memslots(d);
qxl_enter_vga_mode(d);
break;
case QXL_MODE_NATIVE:
- for (i = 0; i < NUM_MEMSLOTS; i++) {
- if (!d->guest_slots[i].active) {
- continue;
- }
- qxl_add_memslot(d, i, 0, QXL_SYNC);
- }
+ qxl_create_memslots(d);
qxl_create_guest_primary(d, 1, QXL_SYNC);
/* replay surface-create and cursor-set commands */
@@ -1719,6 +1729,8 @@ static int qxl_post_load(void *opaque, int version)
break;
case QXL_MODE_COMPAT:
+ /* note: no need to call qxl_create_memslots, qxl_set_mode
+ * creates the mem slot. */
qxl_set_mode(d, d->shadow_rom.mode, 1);
break;
}
--
1.7.7
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] qxl: create slots on post_load in vga state
2011-10-25 13:39 Alon Levy
@ 2011-10-27 11:56 ` Gerd Hoffmann
0 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2011-10-27 11:56 UTC (permalink / raw)
To: Alon Levy; +Cc: qemu-devel
On 10/25/11 15:39, Alon Levy wrote:
> RHBZ 740547
>
> If we migrate when the device is in vga state the guest
> still believes the slots are created, and will cause operations
> that reference the slots, causing a "panic: virtual address out of range"
> on the first of them. Easy to see by migrating in vga mode with
> a driver loaded, for instance windows cmd window in full screen mode,
> and then exiting vga mode back to native mode will cause said panic.
>
> Fixed by doing the slot recreation in post_load for vga mode as well.
> Note that compat does not require any changes because it creates it's
> only slot by a side effect of QXL_IO_SET_MODE.
>
> Signed-off-by: Alon Levy <alevy@redhat.com>
> ---
> v4:
> don't print unused delta in qxl_create_memslots
> v3:
> no need to create slots in compat mode, they are created by qxl_set_mode.
>
Patch added to spice patch queue.
thanks,
Gerd
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-10-27 11:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-25 13:05 [Qemu-devel] [PATCH] qxl: create slots on post_load in vga state Alon Levy
2011-10-25 13:37 ` Alon Levy
-- strict thread matches above, loose matches on Subject: below --
2011-10-25 13:39 Alon Levy
2011-10-27 11:56 ` Gerd Hoffmann
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).