Skip to content

Commit a443c3e

Browse files
agrafbonzini
authored andcommitted
hvf: Avoid mapping regions < PAGE_SIZE as ram
HVF has generic memory listener code that adds all RAM regions as HVF RAM regions. However, HVF can only handle page aligned, page granule regions. So let's ignore regions that are not page aligned and sized. They will be trapped as MMIO instead. Signed-off-by: Alexander Graf <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent ff66ee5 commit a443c3e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

accel/hvf/hvf-accel-ops.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
122122
MemoryRegion *area = section->mr;
123123
bool writeable = !area->readonly && !area->rom_device;
124124
hv_memory_flags_t flags;
125+
uint64_t page_size = qemu_real_host_page_size;
125126

126127
if (!memory_region_is_ram(area)) {
127128
if (writeable) {
@@ -135,6 +136,12 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
135136
}
136137
}
137138

139+
if (!QEMU_IS_ALIGNED(int128_get64(section->size), page_size) ||
140+
!QEMU_IS_ALIGNED(section->offset_within_address_space, page_size)) {
141+
/* Not page aligned, so we can not map as RAM */
142+
add = false;
143+
}
144+
138145
mem = hvf_find_overlap_slot(
139146
section->offset_within_address_space,
140147
int128_get64(section->size));

0 commit comments

Comments
 (0)