Patchwork [12/25] memory: Fix old portio word accesses

login
register
mail settings
Submitter Avi Kivity
Date Oct. 6, 2011, 10:23 a.m.
Message ID <1317896615-25202-13-git-send-email-avi@redhat.com>
Download mbox | patch
Permalink /patch/118061/
State New
Headers show

Comments

Avi Kivity - Oct. 6, 2011, 10:23 a.m.
From: Jan Kiszka <jan.kiszka@siemens.com>

As we register old portio regions via ioport_register, we are also
responsible for providing the word access wrapper.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 memory.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

Patch

diff --git a/memory.c b/memory.c
index 528e5fb..a8359b1 100644
--- a/memory.c
+++ b/memory.c
@@ -404,6 +404,11 @@  static void memory_region_iorange_read(IORange *iorange,
         *data = ((uint64_t)1 << (width * 8)) - 1;
         if (mrp) {
             *data = mrp->read(mr->opaque, offset + mr->offset);
+        } else if (width == 2) {
+            mrp = find_portio(mr, offset, 1, false);
+            assert(mrp);
+            *data = mrp->read(mr->opaque, offset + mr->offset) |
+                    (mrp->read(mr->opaque, offset + mr->offset + 1) << 8);
         }
         return;
     }
@@ -426,6 +431,11 @@  static void memory_region_iorange_write(IORange *iorange,
 
         if (mrp) {
             mrp->write(mr->opaque, offset + mr->offset, data);
+        } else if (width == 2) {
+            mrp = find_portio(mr, offset, 1, false);
+            assert(mrp);
+            mrp->write(mr->opaque, offset + mr->offset, data & 0xff);
+            mrp->write(mr->opaque, offset + mr->offset + 1, data >> 8);
         }
         return;
     }