Skip to contentSkip to conversation

hw/pc.c: Fix converting of ioport_register* to MemoryRegion

PATCH Applied Julien Grall 3 participants 3 messages Jan 10, 2013 – Jan 11, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/pc.c: Fix converting of ioport_register* to MemoryRegion

The commit 258711 introduced MemoryRegion to replace ioport_region* for ioport 80h and F0h.
A MemoryRegion needs to have both read and write callback otherwise a segfault will occur when an access is made.

The previous behaviour of this both ioport is to return 0xffffffffffffffff. So keep this behaviour.

---
 hw/pc.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
hw/pc.c +12 -0
index df0c48e..90b1bf7 100644
@@ -103,6 +103,11 @@ static void ioport80_write(void *opaque, hwaddr addr, uint64_t data,
 {
 }
 
+static uint64_t ioport80_read(void *opaque, hwaddr addr, unsigned size)
+{
+    return 0xffffffffffffffff;
+}
+
 /* MSDOS compatibility mode FPU exception support */
 static qemu_irq ferr_irq;
 
@@ -123,6 +128,11 @@ static void ioportF0_write(void *opaque, hwaddr addr, uint64_t data,
     qemu_irq_lower(ferr_irq);
 }
 
+static uint64_t ioportF0_read(void *opaque, hwaddr addr, unsigned size)
+{
+    return 0xffffffffffffffff;
+}
+
 /* TSC handling */
 uint64_t cpu_get_tsc(CPUX86State *env)
 {
@@ -960,6 +970,7 @@ static void cpu_request_exit(void *opaque, int irq, int level)
 
 static const MemoryRegionOps ioport80_io_ops = {
     .write = ioport80_write,
+    .read = ioport80_read,
     .endianness = DEVICE_NATIVE_ENDIAN,
     .impl = {
         .min_access_size = 1,
@@ -969,6 +980,7 @@ static const MemoryRegionOps ioport80_io_ops = {
 
 static const MemoryRegionOps ioportF0_io_ops = {
     .write = ioportF0_write,
+    .read = ioportF0_read,
     .endianness = DEVICE_NATIVE_ENDIAN,
     .impl = {
         .min_access_size = 1,
Signature · 1 line
Julien Grall
Tested-by on v1 1/1
#1 lore raw
Quoted 7 lines · Julien Grall

The commit 258711 introduced MemoryRegion to replace ioport_region* for ioport 80h and F0h.
A MemoryRegion needs to have both read and write callback otherwise a segfault will occur when an access is made.

The previous behaviour of this both ioport is to return 0xffffffffffffffff. So keep this behaviour.

Thanks, confirmed.

Quoted 2 lines
Quoted 51 lines
---
 hw/pc.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
hw/pc.c +12 -0
index df0c48e..90b1bf7 100644
@@ -103,6 +103,11 @@ static void ioport80_write(void *opaque, hwaddr addr, uint64_t data,
 {
 }
 
+static uint64_t ioport80_read(void *opaque, hwaddr addr, unsigned size)
+{
+    return 0xffffffffffffffff;
+}
+
 /* MSDOS compatibility mode FPU exception support */
 static qemu_irq ferr_irq;
 
@@ -123,6 +128,11 @@ static void ioportF0_write(void *opaque, hwaddr addr, uint64_t data,
     qemu_irq_lower(ferr_irq);
 }
 
+static uint64_t ioportF0_read(void *opaque, hwaddr addr, unsigned size)
+{
+    return 0xffffffffffffffff;
+}
+
 /* TSC handling */
 uint64_t cpu_get_tsc(CPUX86State *env)
 {
@@ -960,6 +970,7 @@ static void cpu_request_exit(void *opaque, int irq, int level)
 
 static const MemoryRegionOps ioport80_io_ops = {
     .write = ioport80_write,
+    .read = ioport80_read,
     .endianness = DEVICE_NATIVE_ENDIAN,
     .impl = {
         .min_access_size = 1,
@@ -969,6 +980,7 @@ static const MemoryRegionOps ioport80_io_ops = {
 
 static const MemoryRegionOps ioportF0_io_ops = {
     .write = ioportF0_write,
+    .read = ioportF0_read,
     .endianness = DEVICE_NATIVE_ENDIAN,
     .impl = {
         .min_access_size = 1,
Signature · 1 line
Julien Grall

Adam

Signature · 2 lines
Adam                 [email protected]
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/
#2 lore raw
In reply to Julien Grall
Quoted 5 lines · Julien Grall

The commit 258711 introduced MemoryRegion to replace ioport_region* for ioport 80h and F0h.
A MemoryRegion needs to have both read and write callback otherwise a segfault will occur when an access is made.

Quoted 8 lines

The previous behaviour of this both ioport is to return 0xffffffffffffffff. So keep this behaviour.

---
 hw/pc.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches

Stefan