If offset_within_address_space falls in a page, then we register a subpage. So check offset_within_address_space rather than offset_within_region.
Cc: Paolo Bonzini <pbonz...@redhat.com> Cc: Richard Henderson <r...@twiddle.net> Cc: "Andreas Färber" <afaer...@suse.de> Cc: Peter Maydell <peter.mayd...@linaro.org> Cc: Blue Swirl <blauwir...@gmail.com> Signed-off-by: Hu Tao <hu...@cn.fujitsu.com> --- exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 3ca9381..f1f9151 100644 --- a/exec.c +++ b/exec.c @@ -869,7 +869,7 @@ static void mem_add(MemoryListener *listener, MemoryRegionSection *section) now = remain; if (int128_lt(remain.size, page_size)) { register_subpage(d, &now); - } else if (remain.offset_within_region & ~TARGET_PAGE_MASK) { + } else if (remain.offset_within_address_space & ~TARGET_PAGE_MASK) { now.size = page_size; register_subpage(d, &now); } else { -- 1.8.1.4