render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0022-memory-Provide-separate-handling-of-unassigned-io-po.patch

298366
From 7ab1044eb1ac2cbc7e65769edf44ced92b85b038 Mon Sep 17 00:00:00 2001
298366
From: Jan Kiszka <jan.kiszka@siemens.com>
298366
Date: Mon, 2 Sep 2013 18:43:30 +0200
298366
Subject: [PATCH] memory: Provide separate handling of unassigned io ports
298366
 accesses
298366
298366
Accesses to unassigned io ports shall return -1 on read and be ignored
298366
on write. Ensure these properties via dedicated ops, decoupling us from
298366
the memory core's handling of unassigned accesses.
298366
298366
Cc: qemu-stable@nongnu.org
298366
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
298366
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
298366
(cherry picked from commit 3bb28b7208b349e7a1b326e3c6ef9efac1d462bf)
298366
298366
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
298366
---
298366
 exec.c                |  3 ++-
298366
 include/exec/ioport.h |  4 ++++
298366
 ioport.c              | 16 ++++++++++++++++
298366
 3 files changed, 22 insertions(+), 1 deletion(-)
298366
298366
diff --git a/exec.c b/exec.c
298366
index 2ea8f04..08eecb3 100644
298366
--- a/exec.c
298366
+++ b/exec.c
298366
@@ -1821,7 +1821,8 @@ static void memory_map_init(void)
298366
     address_space_init(&address_space_memory, system_memory, "memory");
298366
 
298366
     system_io = g_malloc(sizeof(*system_io));
298366
-    memory_region_init(system_io, NULL, "io", 65536);
298366
+    memory_region_init_io(system_io, NULL, &unassigned_io_ops, NULL, "io",
298366
+                          65536);
298366
     address_space_init(&address_space_io, system_io, "I/O");
298366
 
298366
     memory_listener_register(&core_memory_listener, &address_space_memory);
298366
diff --git a/include/exec/ioport.h b/include/exec/ioport.h
298366
index bdd4e96..b3848be 100644
298366
--- a/include/exec/ioport.h
298366
+++ b/include/exec/ioport.h
298366
@@ -45,6 +45,10 @@ typedef struct MemoryRegionPortio {
298366
 
298366
 #define PORTIO_END_OF_LIST() { }
298366
 
298366
+#ifndef CONFIG_USER_ONLY
298366
+extern const MemoryRegionOps unassigned_io_ops;
298366
+#endif
298366
+
298366
 void cpu_outb(pio_addr_t addr, uint8_t val);
298366
 void cpu_outw(pio_addr_t addr, uint16_t val);
298366
 void cpu_outl(pio_addr_t addr, uint32_t val);
298366
diff --git a/ioport.c b/ioport.c
298366
index 79b7f1a..707cce8 100644
298366
--- a/ioport.c
298366
+++ b/ioport.c
298366
@@ -44,6 +44,22 @@ typedef struct MemoryRegionPortioList {
298366
     MemoryRegionPortio ports[];
298366
 } MemoryRegionPortioList;
298366
 
298366
+static uint64_t unassigned_io_read(void *opaque, hwaddr addr, unsigned size)
298366
+{
298366
+    return -1ULL;
298366
+}
298366
+
298366
+static void unassigned_io_write(void *opaque, hwaddr addr, uint64_t val,
298366
+                                unsigned size)
298366
+{
298366
+}
298366
+
298366
+const MemoryRegionOps unassigned_io_ops = {
298366
+    .read = unassigned_io_read,
298366
+    .write = unassigned_io_write,
298366
+    .endianness = DEVICE_NATIVE_ENDIAN,
298366
+};
298366
+
298366
 void cpu_outb(pio_addr_t addr, uint8_t val)
298366
 {
298366
     LOG_IOPORT("outb: %04"FMT_pioaddr" %02"PRIx8"\n", addr, val);