Commit 69b67646 authored by Tyler Hall's avatar Tyler Hall Committed by Stefan Hajnoczi
Browse files

exec.c: Use subpages for large unaligned mappings

Registering a multi-page memory region that is non-page-aligned results
in a subpage from the start to the page boundary, some number of full
pages, and possibly another subpage from the last page boundary to the
end. The full pages will have a value for offset_within_region that is
not a multiple of TARGET_PAGE_SIZE. Accesses through softmmu are unable
to handle this and will segfault.

Handling full pages through subpages is not optimal, but only
non-page-aligned mappings take the penalty.
Signed-off-by: default avatarTyler Hall <>
Reviewed-by: default avatarPeter Maydell <>
Reviewed-by: default avatarAvi Kivity <>
Signed-off-by: default avatarStefan Hajnoczi <>
parent adb2a9b5
......@@ -2305,10 +2305,15 @@ void cpu_register_physical_memory_log(MemoryRegionSection *section,
remain.offset_within_address_space += now.size;
remain.offset_within_region += now.size;
now = remain;
now.size &= TARGET_PAGE_MASK;
if (now.size) {
while (remain.size >= TARGET_PAGE_SIZE) {
now = remain;
if (remain.offset_within_region & ~TARGET_PAGE_MASK) {
now.size = TARGET_PAGE_SIZE;
} else {
now.size &= TARGET_PAGE_MASK;
remain.size -= now.size;
remain.offset_within_address_space += now.size;
remain.offset_within_region += now.size;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment