Skip to contentSkip to conversation

megasas: Add write function to handle write access to PCI BAR 3

PATCH Applied Salva Peiró 3 participants 3 messages Jul 27, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 megasas: Add write function to handle write access to PCI BAR 3

This patch fixes a QEMU SEGFAULT when a write operation is performed on the memory region of the PCI BAR 3 (base address space). When a writeb(0xe0000000) is performed the .write function is invoked to handle the write access, however, since the .write is not initialised, the call to 0, causes QEMU to SEGFAULT.

---
 hw/scsi/megasas.c | 7 +++++++
 1 file changed, 7 insertions(+)
hw/scsi/megasas.c +7 -0
index 51ba9e0..a04369c 100644
@@ -2202,8 +2202,15 @@ static uint64_t megasas_queue_read(void *opaque, hwaddr addr,
     return 0;
 }
 
+static void megasas_queue_write(void *opaque, hwaddr addr,
+                               uint64_t val, unsigned size)
+{
+    return;
+}
+
 static const MemoryRegionOps megasas_queue_ops = {
     .read = megasas_queue_read,
+    .write = megasas_queue_write,
     .endianness = DEVICE_LITTLE_ENDIAN,
     .impl = {
         .min_access_size = 8,
Signature · 1 line
2.1.4
Acked-by on v1 1/1
#1 lore raw
Quoted 22 lines · Salva Peiró

This patch fixes a QEMU SEGFAULT when a write operation is performed on the memory region of the PCI BAR 3 (base address space). When a writeb(0xe0000000) is performed the .write function is invoked to handle the write access, however, since the .write is not initialised, the call to 0, causes QEMU to SEGFAULT.

---
 hw/scsi/megasas.c | 7 +++++++
 1 file changed, 7 insertions(+)
hw/scsi/megasas.c +2 -0
index 51ba9e0..a04369c 100644
@@ -2202,8 +2202,15 @@ static uint64_t megasas_queue_read(void *opaque, hwaddr addr,
     return 0;
 }
 
+static void megasas_queue_write(void *opaque, hwaddr addr,
+                               uint64_t val, unsigned size)

hw/scsi/megasas.c static uint64_t megasas_queue_read(void *opaque, hwaddr addr, · line 2216

Quoted 10 lines
hw/scsi/megasas.c +5 -0
+{
+    return;
+}
+
 static const MemoryRegionOps megasas_queue_ops = {
     .read = megasas_queue_read,
+    .write = megasas_queue_write,
     .endianness = DEVICE_LITTLE_ENDIAN,
     .impl = {
         .min_access_size = 8,

Yep, that's the correct fix.

Cheers,

Hannes

Signature · 5 lines
Dr. Hannes Reinecke		               zSeries & Storage
[email protected]			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)