diff mbox series

[v1,24/29] plugins: Fix physical address calculation for IO regions

Message ID 20210720232703.10650-25-alex.bennee@linaro.org
State Superseded
Headers show
Series various fixes pre-PR (metadata, docs, plugins, testing) | expand

Commit Message

Alex Bennée July 20, 2021, 11:26 p.m. UTC
From: Aaron Lindsay <aaron@os.amperecomputing.com>


The address calculation for IO regions introduced by

commit 787148bf928a54b5cc86f5b434f9399e9737679c
Author: Aaron Lindsay <aaron@os.amperecomputing.com>
    plugins: Expose physical addresses instead of device offsets

is not always accurate. Use the more correct
MemoryRegionSection.offset_within_address_space.

Signed-off-by: Aaron Lindsay <aaron@os.amperecomputing.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Message-Id: <20210720195735.3934473-1-aaron@os.amperecomputing.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

---
 plugins/api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.32.0.264.g75ae10bc75
diff mbox series

Patch

diff --git a/plugins/api.c b/plugins/api.c
index 78b563c5c5..2d521e6ba8 100644
--- a/plugins/api.c
+++ b/plugins/api.c
@@ -319,7 +319,7 @@  uint64_t qemu_plugin_hwaddr_phys_addr(const struct qemu_plugin_hwaddr *haddr)
             return block->offset + offset + block->mr->addr;
         } else {
             MemoryRegionSection *mrs = haddr->v.io.section;
-            return haddr->v.io.offset + mrs->mr->addr;
+            return mrs->offset_within_address_space + haddr->v.io.offset;
         }
     }
 #endif