Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2231952/?format=api
{ "id": 2231952, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2231952/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260501161106.818373-1-mohamedaymanworkspace@gmail.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/1.1/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20260501161106.818373-1-mohamedaymanworkspace@gmail.com>", "date": "2026-05-01T16:11:06", "name": "[v2] bsd-user: remove cached host page size and rely on qemu_real_host_page_size()", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "7defe9f82c5f2b1ee553d9bc10b77f0a941e149a", "submitter": { "id": 92749, "url": "http://patchwork.ozlabs.org/api/1.1/people/92749/?format=api", "name": "MOHAMED AYMAN", "email": "mohamedaymanworkspace@gmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260501161106.818373-1-mohamedaymanworkspace@gmail.com/mbox/", "series": [ { "id": 502480, "url": "http://patchwork.ozlabs.org/api/1.1/series/502480/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=502480", "date": "2026-05-01T16:11:06", "name": "[v2] bsd-user: remove cached host page size and rely on qemu_real_host_page_size()", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/502480/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2231952/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2231952/checks/", "tags": {}, "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=ovKndJjV;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g6bf30HkFz1xqf\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 02 May 2026 02:12:09 +1000 (AEST)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wIqSW-0005Na-G8; Fri, 01 May 2026 12:11:20 -0400", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <mohamedaymanworkspace@gmail.com>)\n id 1wIqST-0005NL-C9\n for qemu-devel@nongnu.org; Fri, 01 May 2026 12:11:17 -0400", "from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <mohamedaymanworkspace@gmail.com>)\n id 1wIqSQ-0002al-O7\n for qemu-devel@nongnu.org; Fri, 01 May 2026 12:11:17 -0400", "by mail-wm1-x32c.google.com with SMTP id\n 5b1f17b1804b1-48909558b3aso21435115e9.0\n for <qemu-devel@nongnu.org>; Fri, 01 May 2026 09:11:14 -0700 (PDT)", "from ST.. ([196.221.137.242]) by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-48a8eb3427fsm109156315e9.0.2026.05.01.09.11.10\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 01 May 2026 09:11:11 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1777651873; x=1778256673; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=tMEWKSQ/RSCozoHhOpqRI+VRHQvtonijjlfJLhN4XF4=;\n b=ovKndJjVgUZaMOg564zx+CFQMlsAPFIge4vk4uaud9cKahDJ9t1Zo7kjbrRTbKyCrt\n AChtJM45bPaPMoqDUKvGju+v0V4Wn3g3X/ke8Vwadr8/K+sc38C9N1TXd7JXl5xABxnB\n 0b8PbIyS618gW/A0R7ouuZ+pyDm27UxMdDKf7oRkEisV6BUm8AvFax88mBIv6bGkZIm5\n pBXtMT4CV6NAOBqQe4uCY9cprMvexvalc2ByhpJPJXA8AOylQHf9jrkn2VIUUi7W+k5x\n nIR5AeEmV88ev5L3jooMsx95o57COh/D33B+U0qwU4U89SUCNyD7Rn5Ouz8vyhP9I8TG\n 6XvQ==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777651873; x=1778256673;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=tMEWKSQ/RSCozoHhOpqRI+VRHQvtonijjlfJLhN4XF4=;\n b=injgRaA7uic4yX/eWCf/UWzSztueGxhHiSiv4aEZly0F0ktRp7dw442W2dscr0l5nZ\n +6uQvuZ7T2LCuOJrsd2tpaRwCZFjSYvXKFp1nFNiuoWf0p0/t6uN53I2Qd+f4Bnauq8I\n /RCvkTbKgolSgfa/joaurqR4rs0G2yIHW2q4rTSw7joSGxMzKxEvA8Tw7+jYXn31j4KW\n GRjMEI516octz2FdHx/kBenEkjf0xlomUe1v/PmTpWYZMLLJGIidJkJRhIIYO8AHhgAH\n bG+JHw1xuUzH1PqRKK5CXwO0J6y4nxcGM4WSBTdGmMZIPGy9TL6PQ7Y56d2U2xDamv8D\n t8rw==", "X-Forwarded-Encrypted": "i=1;\n AFNElJ/8pDOEEVRg0gMiZjGiuDRza9pYCTtttJZKdpLrPdmG5E1wYUWpyHE9RauWEQsDiMtVjHvKLFQs6vHY@nongnu.org", "X-Gm-Message-State": "AOJu0YyHaFn4mYyK7vry7EcNhOVy21W1qCHSMC6ZQ3218kH3OR/XZlLJ\n 5PpRm2hlGCiriR61wBMO99Ot4DFPnKpL/R2ojeP1OBsWx75/UQ+ch4bB", "X-Gm-Gg": "AeBDieufly32OyqSH4UNx2m7Q2b629TewjxyBYToTR6l+JcrwLHDk0VSsAjdku1YQYU\n r+opJ41a/XjKcT8cweG3Tb3lZ5F5ccsSQvEcoibKGM0w/gLR7SdClSC0VrWNv/dmw9Tn4AJzKJN\n UVVLxfaeQkX0Vqteo00lUFTloMSyC4W3YVMzlFsWUVtXwrDaJ2lw0nCSdR14xqI1VD1ranhssUM\n yvjr5zCbAseH7HI7DBUICCk/47TIuk4WcuuzaeSg9RlOJyZ4sa4z0vCLVxFxMhXP1s212lvpe4E\n +g+5Cxk4MTKTIkxPlm0c0UGvDIt/ny+MBq5BSDv0b/T/yy85Pov6CVHQwJPsEQ5Z6NOuQIvjvTM\n 1hepNbxRP7mP/7QBRQn7deh44Hmr+icKkDsO0bPaYJZyBP2zOGDBVqrMwupJK8b5VjhM4lRSx/3\n Xlx+dVB4dLUr6jyVl7P0lsvfbluxrBQLwLBU2EeShjwfssXcpm+w4QbysYRGlR592Sj2YThbJR", "X-Received": "by 2002:a05:600c:4a9f:b0:48a:9562:7a30 with SMTP id\n 5b1f17b1804b1-48a95627aa2mr13849645e9.24.1777651872701;\n Fri, 01 May 2026 09:11:12 -0700 (PDT)", "From": "Mohamed Ayman <mohamedaymanworkspace@gmail.com>", "To": "Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>,\n qemu-devel@nongnu.org (open list:All patches CC here)", "Cc": "Mohamed Ayman <mohamedaymanworkspace@gmail.com>,\n qemu-devel@nongnu.org (open list:All patches CC here)", "Subject": "[PATCH v2] bsd-user: remove cached host page size and rely on\n qemu_real_host_page_size()", "Date": "Fri, 1 May 2026 19:11:06 +0300", "Message-Id": "<20260501161106.818373-1-mohamedaymanworkspace@gmail.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20260430162941.584960-1-mohamedaymanworkspace@gmail.com>", "References": "<20260430162941.584960-1-mohamedaymanworkspace@gmail.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=2a00:1450:4864:20::32c;\n envelope-from=mohamedaymanworkspace@gmail.com; helo=mail-wm1-x32c.google.com", "X-Spam_score_int": "-20", "X-Spam_score": "-2.1", "X-Spam_bar": "--", "X-Spam_report": "(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no", "X-Spam_action": "no action", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "qemu development <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "The bsd-user implementation previously cached host page size and mask\nin global variables (qemu_host_page_size and qemu_host_page_mask),\nwhich duplicated information already available through\nqemu_real_host_page_size().\n\nThis introduced unnecessary global state and potential inconsistencies\nif the host page size is queried or changes during initialization.\n\nReplace all usages of qemu_host_page_size and qemu_host_page_mask with\nHOST_PAGE_SIZE and HOST_PAGE_MASK macros defined as:\n\n MAX(qemu_real_host_page_size(), TARGET_PAGE_SIZE)\n\nThis preserves the original behavior where the effective host page size\nis the maximum of the real host page size and the target page size,\nwhich matters on targets like aarch64 with 16K pages running on an\namd64 host with 4K pages.\n\nThis also opens the way for renaming qemu_real_host_page_size() to\nqemu_host_page_size() now that the bsd-user globals no longer occupy\nthat name.\n\nSigned-off-by: Mohamed Ayman <mohamedaymanworkspace@gmail.com>\n---\n bsd-user/elfload.c | 25 ++---------\n bsd-user/main.c | 14 ++-----\n bsd-user/mmap.c | 102 ++++++++++++++++-----------------------------\n bsd-user/qemu.h | 10 ++---\n 4 files changed, 46 insertions(+), 105 deletions(-)", "diff": "diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c\nindex 3bca0cc9ed..00250fc3c1 100644\n--- a/bsd-user/elfload.c\n+++ b/bsd-user/elfload.c\n@@ -192,14 +192,14 @@ static void setup_arg_pages(struct bsd_binprm *bprm, struct image_info *info,\n */\n size = target_dflssiz;\n stack_base = TARGET_USRSTACK - size;\n- addr = target_mmap(stack_base , size + qemu_host_page_size,\n+ addr = target_mmap(stack_base , size + HOST_PAGE_SIZE,\n PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);\n if (addr == -1) {\n perror(\"stk mmap\");\n exit(-1);\n }\n /* we reserve one extra page at the top of the stack as guard */\n- target_mprotect(addr + size, qemu_host_page_size, PROT_NONE);\n+ target_mprotect(addr + size, HOST_PAGE_SIZE, PROT_NONE);\n \n target_stksiz = size;\n target_stkbas = addr;\n@@ -239,27 +239,10 @@ static void padzero(abi_ulong elf_bss, abi_ulong last_bss)\n return;\n }\n \n- /*\n- * XXX: this is really a hack : if the real host page size is\n- * smaller than the target page size, some pages after the end\n- * of the file may not be mapped. A better fix would be to\n- * patch target_mmap(), but it is more complicated as the file\n- * size must be known.\n- */\n- if (qemu_real_host_page_size() < qemu_host_page_size) {\n- abi_ulong end_addr, end_addr1;\n- end_addr1 = REAL_HOST_PAGE_ALIGN(elf_bss);\n- end_addr = HOST_PAGE_ALIGN(elf_bss);\n- if (end_addr1 < end_addr) {\n- mmap((void *)g2h_untagged(end_addr1), end_addr - end_addr1,\n- PROT_READ | PROT_WRITE | PROT_EXEC,\n- MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0);\n- }\n- }\n \n- nbyte = elf_bss & (qemu_host_page_size - 1);\n+ nbyte = elf_bss & (HOST_PAGE_SIZE - 1);\n if (nbyte) {\n- nbyte = qemu_host_page_size - nbyte;\n+ nbyte = HOST_PAGE_SIZE - nbyte;\n do {\n /* FIXME - what to do if put_user() fails? */\n put_user_u8(0, elf_bss);\ndiff --git a/bsd-user/main.c b/bsd-user/main.c\nindex 73aae8c327..3f5141e794 100644\n--- a/bsd-user/main.c\n+++ b/bsd-user/main.c\n@@ -54,11 +54,6 @@\n #include \"target_arch_cpu.h\"\n \n \n-/*\n- * TODO: Remove these and rely only on qemu_real_host_page_size().\n- */\n-uintptr_t qemu_host_page_size;\n-intptr_t qemu_host_page_mask;\n \n static bool opt_one_insn_per_tb;\n static unsigned long opt_tb_size;\n@@ -302,8 +297,6 @@ int main(int argc, char **argv)\n (void) envlist_setenv(envlist, *wrk);\n }\n \n- qemu_host_page_size = getpagesize();\n- qemu_host_page_size = MAX(qemu_host_page_size, TARGET_PAGE_SIZE);\n \n cpu_model = NULL;\n \n@@ -405,7 +398,6 @@ int main(int argc, char **argv)\n }\n }\n \n- qemu_host_page_mask = -qemu_host_page_size;\n \n /* init debug */\n {\n@@ -452,7 +444,7 @@ int main(int argc, char **argv)\n \n cpu_type = parse_cpu_option(cpu_model);\n \n- /* init tcg before creating CPUs and to get qemu_host_page_size */\n+ /* init tcg before creating CPUs */\n {\n AccelState *accel = current_accel();\n AccelClass *ac = ACCEL_GET_CLASS(accel);\n@@ -534,7 +526,7 @@ int main(int argc, char **argv)\n * proper page alignment for guest_base.\n */\n if (have_guest_base) {\n- if (guest_base & ~qemu_host_page_mask) {\n+ if (guest_base & ~HOST_PAGE_MASK) {\n error_report(\"Selected guest base not host page aligned\");\n exit(1);\n }\n@@ -573,7 +565,7 @@ int main(int argc, char **argv)\n /* Ensure that mmap_next_start is within range. */\n if (reserved_va <= mmap_next_start) {\n mmap_next_start = (reserved_va / 4 * 3)\n- & TARGET_PAGE_MASK & qemu_host_page_mask;\n+ & TARGET_PAGE_MASK & HOST_PAGE_MASK;\n }\n }\n \ndiff --git a/bsd-user/mmap.c b/bsd-user/mmap.c\nindex fe77eceb48..59c70083a4 100644\n--- a/bsd-user/mmap.c\n+++ b/bsd-user/mmap.c\n@@ -84,7 +84,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int prot)\n return 0;\n \n mmap_lock();\n- host_start = start & qemu_host_page_mask;\n+ host_start = start & HOST_PAGE_MASK;\n host_end = HOST_PAGE_ALIGN(end);\n if (start > host_start) {\n /* handle host page containing start */\n@@ -92,28 +92,28 @@ int target_mprotect(abi_ulong start, abi_ulong len, int prot)\n for (addr = host_start; addr < start; addr += TARGET_PAGE_SIZE) {\n prot1 |= page_get_flags(addr);\n }\n- if (host_end == host_start + qemu_host_page_size) {\n+ if (host_end == host_start + HOST_PAGE_SIZE) {\n for (addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) {\n prot1 |= page_get_flags(addr);\n }\n end = host_end;\n }\n ret = mprotect(g2h_untagged(host_start),\n- qemu_host_page_size, prot1 & PAGE_RWX);\n+ HOST_PAGE_SIZE, prot1 & PAGE_RWX);\n if (ret != 0)\n goto error;\n- host_start += qemu_host_page_size;\n+ host_start += HOST_PAGE_SIZE;\n }\n if (end < host_end) {\n prot1 = prot;\n for (addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) {\n prot1 |= page_get_flags(addr);\n }\n- ret = mprotect(g2h_untagged(host_end - qemu_host_page_size),\n- qemu_host_page_size, prot1 & PAGE_RWX);\n+ ret = mprotect(g2h_untagged(host_end - HOST_PAGE_SIZE),\n+ HOST_PAGE_SIZE, prot1 & PAGE_RWX);\n if (ret != 0)\n goto error;\n- host_end -= qemu_host_page_size;\n+ host_end -= HOST_PAGE_SIZE;\n }\n \n /* handle the pages in the middle */\n@@ -193,7 +193,7 @@ static int mmap_frag(abi_ulong real_start,\n void *host_start;\n int prot1, prot_new;\n \n- real_end = real_start + qemu_host_page_size;\n+ real_end = real_start + HOST_PAGE_SIZE;\n host_start = g2h_untagged(real_start);\n \n /* get the protection of the target pages outside the mapping */\n@@ -205,7 +205,7 @@ static int mmap_frag(abi_ulong real_start,\n \n if (prot1 == 0) {\n /* no page was there, so we allocate one. See also above. */\n- void *p = mmap(host_start, qemu_host_page_size, prot,\n+ void *p = mmap(host_start, HOST_PAGE_SIZE, prot,\n flags | ((fd != -1) ? MAP_ANON : 0), -1, 0);\n if (p == MAP_FAILED)\n return -1;\n@@ -223,7 +223,7 @@ static int mmap_frag(abi_ulong real_start,\n \n /* adjust protection to be able to read */\n if (!(prot1 & PROT_WRITE))\n- mprotect(host_start, qemu_host_page_size, prot1 | PROT_WRITE);\n+ mprotect(host_start, HOST_PAGE_SIZE, prot1 | PROT_WRITE);\n \n /* read the corresponding file data */\n if (!mmap_pread(fd, g2h_untagged(start), end - start, offset, true)) {\n@@ -232,10 +232,10 @@ static int mmap_frag(abi_ulong real_start,\n \n /* put final protection */\n if (prot_new != (prot1 | PROT_WRITE))\n- mprotect(host_start, qemu_host_page_size, prot_new);\n+ mprotect(host_start, HOST_PAGE_SIZE, prot_new);\n } else {\n if (prot_new != prot1) {\n- mprotect(host_start, qemu_host_page_size, prot_new);\n+ mprotect(host_start, HOST_PAGE_SIZE, prot_new);\n }\n if (prot_new & PROT_WRITE) {\n memset(g2h_untagged(start), 0, end - start);\n@@ -289,7 +289,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong alignment)\n if (start == 0) {\n start = mmap_next_start;\n } else {\n- start &= qemu_host_page_mask;\n+ start &= HOST_PAGE_MASK;\n }\n \n size = HOST_PAGE_ALIGN(size);\n@@ -297,7 +297,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong alignment)\n if (reserved_va) {\n return mmap_find_vma_reserved(start, size,\n (alignment != 0 ? 1 << alignment :\n- MAX(qemu_host_page_size, TARGET_PAGE_SIZE)));\n+ MAX(HOST_PAGE_SIZE, TARGET_PAGE_SIZE)));\n }\n \n addr = start;\n@@ -478,8 +478,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,\n goto fail;\n }\n \n- real_start = start & qemu_host_page_mask;\n- host_offset = offset & qemu_host_page_mask;\n+ real_start = start & HOST_PAGE_MASK;\n+ host_offset = offset & HOST_PAGE_MASK;\n \n /*\n * If the user is asking for the kernel to find a location, do that\n@@ -498,38 +498,6 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,\n }\n }\n \n- /*\n- * When mapping files into a memory area larger than the file, accesses\n- * to pages beyond the file size will cause a SIGBUS.\n- *\n- * For example, if mmaping a file of 100 bytes on a host with 4K pages\n- * emulating a target with 8K pages, the target expects to be able to\n- * access the first 8K. But the host will trap us on any access beyond\n- * 4K.\n- *\n- * When emulating a target with a larger page-size than the hosts, we\n- * may need to truncate file maps at EOF and add extra anonymous pages\n- * up to the targets page boundary.\n- */\n-\n- if ((qemu_real_host_page_size() < qemu_host_page_size) && fd != -1) {\n- struct stat sb;\n-\n- if (fstat(fd, &sb) == -1) {\n- goto fail;\n- }\n-\n- /* Are we trying to create a map beyond EOF?. */\n- if (offset + len > sb.st_size) {\n- /*\n- * If so, truncate the file map at eof aligned with\n- * the hosts real pagesize. Additional anonymous maps\n- * will be created beyond EOF.\n- */\n- len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset);\n- }\n- }\n-\n if (!(flags & MAP_FIXED)) {\n unsigned long host_start;\n void *p;\n@@ -539,8 +507,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,\n \n /*\n * Note: we prefer to control the mapping address. It is\n- * especially important if qemu_host_page_size >\n- * qemu_real_host_page_size\n+ * especially important if HOST_PAGE_SIZE >\n+ * TARGET_PAGE_SIZE\n */\n p = mmap(g2h_untagged(start), host_len, prot,\n flags | MAP_FIXED | ((fd != -1) ? MAP_ANON : 0), -1, 0);\n@@ -581,7 +549,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,\n * aligned, so we read it\n */\n if (fd != -1 &&\n- (offset & ~qemu_host_page_mask) != (start & ~qemu_host_page_mask)) {\n+ (offset & ~HOST_PAGE_MASK) != (start & ~HOST_PAGE_MASK)) {\n /*\n * msync() won't work here, so we return an error if write is\n * possible while it is a shared mapping\n@@ -614,7 +582,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,\n \n /* handle the start of the mapping */\n if (start > real_start) {\n- if (real_end == real_start + qemu_host_page_size) {\n+ if (real_end == real_start + HOST_PAGE_SIZE) {\n /* one single host page */\n ret = mmap_frag(real_start, start, end,\n prot, flags, fd, offset);\n@@ -622,21 +590,21 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,\n goto fail;\n goto the_end1;\n }\n- ret = mmap_frag(real_start, start, real_start + qemu_host_page_size,\n+ ret = mmap_frag(real_start, start, real_start + HOST_PAGE_SIZE,\n prot, flags, fd, offset);\n if (ret == -1)\n goto fail;\n- real_start += qemu_host_page_size;\n+ real_start += HOST_PAGE_SIZE;\n }\n /* handle the end of the mapping */\n if (end < real_end) {\n- ret = mmap_frag(real_end - qemu_host_page_size,\n- real_end - qemu_host_page_size, end,\n+ ret = mmap_frag(real_end - HOST_PAGE_SIZE,\n+ real_end - HOST_PAGE_SIZE, end,\n prot, flags, fd,\n- offset + real_end - qemu_host_page_size - start);\n+ offset + real_end - HOST_PAGE_SIZE - start);\n if (ret == -1)\n goto fail;\n- real_end -= qemu_host_page_size;\n+ real_end -= HOST_PAGE_SIZE;\n }\n \n /* map the middle (easier) */\n@@ -676,7 +644,7 @@ void mmap_reserve(abi_ulong start, abi_ulong size)\n abi_ulong end;\n int prot;\n \n- real_start = start & qemu_host_page_mask;\n+ real_start = start & HOST_PAGE_MASK;\n real_end = HOST_PAGE_ALIGN(start + size);\n end = start + size;\n if (start > real_start) {\n@@ -685,14 +653,14 @@ void mmap_reserve(abi_ulong start, abi_ulong size)\n for (addr = real_start; addr < start; addr += TARGET_PAGE_SIZE) {\n prot |= page_get_flags(addr);\n }\n- if (real_end == real_start + qemu_host_page_size) {\n+ if (real_end == real_start + HOST_PAGE_SIZE) {\n for (addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) {\n prot |= page_get_flags(addr);\n }\n end = real_end;\n }\n if (prot != 0) {\n- real_start += qemu_host_page_size;\n+ real_start += HOST_PAGE_SIZE;\n }\n }\n if (end < real_end) {\n@@ -701,7 +669,7 @@ void mmap_reserve(abi_ulong start, abi_ulong size)\n prot |= page_get_flags(addr);\n }\n if (prot != 0) {\n- real_end -= qemu_host_page_size;\n+ real_end -= HOST_PAGE_SIZE;\n }\n }\n if (real_start != real_end) {\n@@ -727,7 +695,7 @@ int target_munmap(abi_ulong start, abi_ulong len)\n return -EINVAL;\n mmap_lock();\n end = start + len;\n- real_start = start & qemu_host_page_mask;\n+ real_start = start & HOST_PAGE_MASK;\n real_end = HOST_PAGE_ALIGN(end);\n \n if (start > real_start) {\n@@ -736,14 +704,14 @@ int target_munmap(abi_ulong start, abi_ulong len)\n for (addr = real_start; addr < start; addr += TARGET_PAGE_SIZE) {\n prot |= page_get_flags(addr);\n }\n- if (real_end == real_start + qemu_host_page_size) {\n+ if (real_end == real_start + HOST_PAGE_SIZE) {\n for (addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) {\n prot |= page_get_flags(addr);\n }\n end = real_end;\n }\n if (prot != 0)\n- real_start += qemu_host_page_size;\n+ real_start += HOST_PAGE_SIZE;\n }\n if (end < real_end) {\n prot = 0;\n@@ -751,7 +719,7 @@ int target_munmap(abi_ulong start, abi_ulong len)\n prot |= page_get_flags(addr);\n }\n if (prot != 0)\n- real_end -= qemu_host_page_size;\n+ real_end -= HOST_PAGE_SIZE;\n }\n \n ret = 0;\n@@ -784,6 +752,6 @@ int target_msync(abi_ulong start, abi_ulong len, int flags)\n if (end == start)\n return 0;\n \n- start &= qemu_host_page_mask;\n+ start &= HOST_PAGE_MASK;\n return msync(g2h_untagged(start), end - start, flags);\n }\ndiff --git a/bsd-user/qemu.h b/bsd-user/qemu.h\nindex b0b2c249fb..7553ac154c 100644\n--- a/bsd-user/qemu.h\n+++ b/bsd-user/qemu.h\n@@ -44,12 +44,10 @@ extern char **environ;\n #include \"accel/tcg/vcpu-state.h\"\n \n #include \"qemu-os.h\"\n-/*\n- * TODO: Remove these and rely only on qemu_real_host_page_size().\n- */\n-extern uintptr_t qemu_host_page_size;\n-extern intptr_t qemu_host_page_mask;\n-#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size)\n+\n+#define HOST_PAGE_SIZE MAX(qemu_real_host_page_size(), TARGET_PAGE_SIZE)\n+#define HOST_PAGE_MASK ((intptr_t)~(HOST_PAGE_SIZE - 1))\n+#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), HOST_PAGE_SIZE)\n \n /*\n * This struct is used to hold certain information about the image. Basically,\n", "prefixes": [ "v2" ] }