[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] exec.c: Allow memory region start_addr and region_o
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PATCH] exec.c: Allow memory region start_addr and region_offset to vary in low bits |
Date: |
Mon, 5 Dec 2011 11:01:37 +0000 |
Fix a long-standing deficiency of cpu_register_physical_memory_log()
where the start address and region offset had to have the same low
bits (otherwise the IO functions would be passed an incorrect address
offset). This was most likely to bite when registering memory regions
which started at a non-page-boundary.
Signed-off-by: Peter Maydell <address@hidden>
---
This is such a small change to correct this issue that I'm kind of
suspicious of it :-)
exec.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/exec.c b/exec.c
index 6b92198..7030cea 100644
--- a/exec.c
+++ b/exec.c
@@ -2655,10 +2655,7 @@ static subpage_t *subpage_init (target_phys_addr_t base,
ram_addr_t *phys,
For RAM, 'size' must be a multiple of the target page size.
If (phys_offset & ~TARGET_PAGE_MASK) != 0, then it is an
io memory page. The address used when calling the IO function is
- the offset from the start of the region, plus region_offset. Both
- start_addr and region_offset are rounded down to a page boundary
- before calculating this offset. This should not be a problem unless
- the low bits of start_addr and region_offset differ. */
+ the offset from the start of the region, plus region_offset. */
void cpu_register_physical_memory_log(target_phys_addr_t start_addr,
ram_addr_t size,
ram_addr_t phys_offset,
@@ -2677,7 +2674,11 @@ void cpu_register_physical_memory_log(target_phys_addr_t
start_addr,
if (phys_offset == IO_MEM_UNASSIGNED) {
region_offset = start_addr;
}
- region_offset &= TARGET_PAGE_MASK;
+ /* Adjust the region offset to account for the start_addr possibly
+ * not being page aligned, so we end up passing the IO functions
+ * the true offset from the start of the region.
+ */
+ region_offset -= (start_addr & ~TARGET_PAGE_MASK);
size = (size + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
end_addr = start_addr + (target_phys_addr_t)size;
--
1.7.1
- [Qemu-devel] [PATCH] exec.c: Allow memory region start_addr and region_offset to vary in low bits,
Peter Maydell <=