From: Avi Kivity <a...@redhat.com>

Last qemu merge broke extboot completely.  Instead of reading the command,
extboot corrupted the stack.  Instead of writing back the geometry, extboot
wrote nothing.

Fix by reading the command correctly and writing back the results.

Signed-off-by: Avi Kivity <a...@redhat.com>

diff --git a/hw/extboot.c b/hw/extboot.c
index f66b6c5..b91d54f 100644
--- a/hw/extboot.c
+++ b/hw/extboot.c
@@ -81,8 +81,8 @@ static void extboot_write_cmd(void *opaque, uint32_t addr, 
uint32_t value)
     int blen = 0;
     void *buf = NULL;
 
-    cpu_physical_memory_read((value & 0xFFFF) << 4, (uint8_t *)&buf,
-                             sizeof(buf));
+    cpu_physical_memory_read((value & 0xFFFF) << 4, (uint8_t *)&cmd,
+                             sizeof(cmd));
 
     if (cmd.type == 0x01 || cmd.type == 0x02) {
        pa = cmd.xfer.segment * 16 + cmd.xfer.offset;
@@ -98,7 +98,6 @@ static void extboot_write_cmd(void *opaque, uint32_t addr, 
uint32_t value)
        cmd.query_geometry.heads = heads;
        cmd.query_geometry.sectors = sectors;
        cmd.query_geometry.nb_sectors = nb_sectors;
-       cpu_physical_memory_set_dirty((value & 0xFFFF) << 4);
        break;
     case 0x01:
        err = bdrv_read(bs, cmd.xfer.sector, buf, cmd.xfer.nb_sectors);
@@ -118,6 +117,8 @@ static void extboot_write_cmd(void *opaque, uint32_t addr, 
uint32_t value)
        break;
     }
 
+    cpu_physical_memory_write((value & 0xFFFF) << 4, (uint8_t *)&cmd,
+                              sizeof(cmd));
     if (buf)
         qemu_free(buf);
 }
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to