[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/40] memory: limit sections in the radix tree to t
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 08/40] memory: limit sections in the radix tree to the actual address space size |
Date: |
Tue, 7 May 2013 16:16:46 +0200 |
From: Avi Kivity <address@hidden>
The radix tree is statically sized to fit TARGET_PHYS_ADDR_SPACE_BITS.
If a larger memory region is registered, it will overflow.
Fix by limiting any section in the radix tree to the supported size.
This problem was not observed earlier since artificial regions (containers
and aliases) are eliminated by the memory core, leaving only device regions
which have reasonable sizes. An IOMMU however cannot be eliminated by the
memory core, and may have an artificial size.
Signed-off-by: Avi Kivity <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
exec.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/exec.c b/exec.c
index 2e5b89a..fccecf6 100644
--- a/exec.c
+++ b/exec.c
@@ -777,10 +777,23 @@ static void register_multipage(AddressSpaceDispatch *d,
MemoryRegionSection *sec
section_index);
}
+static MemoryRegionSection limit(MemoryRegionSection section)
+{
+ unsigned practical_as_bits = MIN(TARGET_PHYS_ADDR_SPACE_BITS, 62);
+ hwaddr as_limit;
+
+ as_limit = (hwaddr)1 << practical_as_bits;
+
+ section.size = MIN(section.offset_within_address_space + section.size,
as_limit)
+ - section.offset_within_address_space;
+
+ return section;
+}
+
static void mem_add(MemoryListener *listener, MemoryRegionSection *section)
{
AddressSpaceDispatch *d = container_of(listener, AddressSpaceDispatch,
listener);
- MemoryRegionSection now = *section, remain = *section;
+ MemoryRegionSection now = limit(*section), remain = limit(*section);
if ((now.offset_within_address_space & ~TARGET_PAGE_MASK)
|| (now.size < TARGET_PAGE_SIZE)) {
--
1.7.1
- [Qemu-devel] [PATCH 29/40] acpi: add memory_region_set_owner calls, (continued)
- [Qemu-devel] [PATCH 29/40] acpi: add memory_region_set_owner calls, Paolo Bonzini, 2013/05/07
- [Qemu-devel] [PATCH 16/40] spapr: convert TCE API to use an opaque type, Paolo Bonzini, 2013/05/07
- [Qemu-devel] [PATCH 25/40] memory: add ref/unref, Paolo Bonzini, 2013/05/07
- [Qemu-devel] [PATCH 23/40] memory: give name to every AddressSpace, Paolo Bonzini, 2013/05/07
- [Qemu-devel] [PATCH 04/40] memory: Rename readable flag to romd_mode, Paolo Bonzini, 2013/05/07
[Qemu-devel] [PATCH 06/40] memory: make memory_global_sync_dirty_bitmap take an AddressSpace, Paolo Bonzini, 2013/05/07
[Qemu-devel] [PATCH 08/40] memory: limit sections in the radix tree to the actual address space size,
Paolo Bonzini <=
[Qemu-devel] [PATCH 15/40] vfio: abort if an emulated iommu is used, Paolo Bonzini, 2013/05/07
[Qemu-devel] [PATCH 05/40] memory: do not duplicate memory_region_destructor_none, Paolo Bonzini, 2013/05/07
[Qemu-devel] [PATCH 30/40] misc: add memory_region_set_owner calls, Paolo Bonzini, 2013/05/07
[Qemu-devel] [PATCH 22/40] dma: eliminate DMAContext, Paolo Bonzini, 2013/05/07
[Qemu-devel] [PATCH 32/40] vga: add memory_region_set_owner calls, Paolo Bonzini, 2013/05/07
[Qemu-devel] [PATCH 02/40] memory: allow memory_region_find() to run on non-root memory regions, Paolo Bonzini, 2013/05/07