1From 4517e2046610722879761bcdb60edbb2b929c848 Mon Sep 17 00:00:00 2001 2From: Richard Henderson <richard.henderson@linaro.org> 3Date: Wed, 28 Feb 2024 10:25:14 -1000 4Subject: [PATCH 1/5] linux-user/x86_64: Handle the vsyscall page in 5 open_self_maps_{2,4} 6 7This is the only case in which we expect to have no host memory backing 8for a guest memory page, because in general linux user processes cannot 9map any pages in the top half of the 64-bit address space. 10 11Upstream-Status: Submitted [https://www.mail-archive.com/qemu-devel@nongnu.org/msg1026793.html] 12 13Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2170 14Signed-off-by: Richard Henderson <richard.henderson@linaro.org> 15Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> 16--- 17 linux-user/syscall.c | 16 ++++++++++++++++ 18 1 file changed, 16 insertions(+) 19 20diff --git a/linux-user/syscall.c b/linux-user/syscall.c 21index a114f29a8..8307a8a61 100644 22--- a/linux-user/syscall.c 23+++ b/linux-user/syscall.c 24@@ -7922,6 +7922,10 @@ static void open_self_maps_4(const struct open_self_maps_data *d, 25 path = "[heap]"; 26 } else if (start == info->vdso) { 27 path = "[vdso]"; 28+#ifdef TARGET_X86_64 29+ } else if (start == TARGET_VSYSCALL_PAGE) { 30+ path = "[vsyscall]"; 31+#endif 32 } 33 34 /* Except null device (MAP_ANON), adjust offset for this fragment. */ 35@@ -8010,6 +8014,18 @@ static int open_self_maps_2(void *opaque, target_ulong guest_start, 36 uintptr_t host_start = (uintptr_t)g2h_untagged(guest_start); 37 uintptr_t host_last = (uintptr_t)g2h_untagged(guest_end - 1); 38 39+#ifdef TARGET_X86_64 40+ /* 41+ * Because of the extremely high position of the page within the guest 42+ * virtual address space, this is not backed by host memory at all. 43+ * Therefore the loop below would fail. This is the only instance 44+ * of not having host backing memory. 45+ */ 46+ if (guest_start == TARGET_VSYSCALL_PAGE) { 47+ return open_self_maps_3(opaque, guest_start, guest_end, flags); 48+ } 49+#endif 50+ 51 while (1) { 52 IntervalTreeNode *n = 53 interval_tree_iter_first(d->host_maps, host_start, host_start); 54-- 552.34.1 56 57