Skip to contentSkip to conversation

linux-user: Tell guest about big host page sizes

PATCH In review Alexander Graf 2 participants 2 messages Jun 5, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: Tell guest about big host page sizes

We tell the guest its page size via AUX vectors. The guest process then uses this page size as information on which boundaries it can mmap() things.

However, if the host has a bigger page size granularity than the guest, it can not fulfill these mmap() requests - which falls apart when MAP_FIXED is passed to mmap.

So in that case, let the guest know that we're running on a bigger page size granularity than the target would require.

This fixes running qemu-ppc (TARGET_PAGE_SIZE=4k) on a 64k page size ppc64 host for me.

---
 linux-user/elfload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/elfload.c +1 -1
index 0af6292..127c565 100644
@@ -1545,7 +1545,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
     NEW_AUX_ENT(AT_PHDR, (abi_ulong)(info->load_addr + exec->e_phoff));
     NEW_AUX_ENT(AT_PHENT, (abi_ulong)(sizeof (struct elf_phdr)));
     NEW_AUX_ENT(AT_PHNUM, (abi_ulong)(exec->e_phnum));
-    NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(TARGET_PAGE_SIZE));
+    NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(MAX(TARGET_PAGE_SIZE, getpagesize())));
     NEW_AUX_ENT(AT_BASE, (abi_ulong)(interp_info ? interp_info->load_addr : 0));
     NEW_AUX_ENT(AT_FLAGS, (abi_ulong)0);
     NEW_AUX_ENT(AT_ENTRY, info->entry);
Signature · 1 line
1.8.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Alexander Graf

We tell the guest its page size via AUX vectors. The guest process then uses this page size as information on which boundaries it can mmap() things.

However, if the host has a bigger page size granularity than the guest, it can not fulfill these mmap() requests - which falls apart when MAP_FIXED is passed to mmap.

So in that case, let the guest know that we're running on a bigger page size granularity than the target would require.

Quoted 7 lines

This fixes running qemu-ppc (TARGET_PAGE_SIZE=4k) on a 64k page size ppc64 host for me.

---
 linux-user/elfload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Woot. Obviously this won't fix all guests, only those that expect a variable page size to begin. But it's certainly a step forward.

r~