get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2231405/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2231405,
    "url": "http://patchwork.ozlabs.org/api/patches/2231405/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260430162941.584960-1-mohamedaymanworkspace@gmail.com/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/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": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260430162941.584960-1-mohamedaymanworkspace@gmail.com>",
    "list_archive_url": null,
    "date": "2026-04-30T16:29:41",
    "name": "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": "20765dff93ed81107a13d9b5a68bb2b50a695009",
    "submitter": {
        "id": 92749,
        "url": "http://patchwork.ozlabs.org/api/people/92749/?format=api",
        "name": "Mohamed Ayman",
        "email": "mohamedaymanworkspace@gmail.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260430162941.584960-1-mohamedaymanworkspace@gmail.com/mbox/",
    "series": [
        {
            "id": 502345,
            "url": "http://patchwork.ozlabs.org/api/series/502345/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=502345",
            "date": "2026-04-30T16:29:41",
            "name": "bsd-user: remove cached host page size and rely on qemu_real_host_page_size()",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/502345/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2231405/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2231405/checks/",
    "tags": {},
    "related": [],
    "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=UDuzl7zb;\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 4g60xl1WLPz1xqf\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 03:08:43 +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 1wIUry-0001Ng-2K; Thu, 30 Apr 2026 13:08:11 -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 1wIUGw-0008QK-3D\n for qemu-devel@nongnu.org; Thu, 30 Apr 2026 12:29:54 -0400",
            "from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d])\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 1wIUGt-0006Dt-M0\n for qemu-devel@nongnu.org; Thu, 30 Apr 2026 12:29:53 -0400",
            "by mail-wm1-x32d.google.com with SMTP id\n 5b1f17b1804b1-4838c15e3cbso10031375e9.3\n for <qemu-devel@nongnu.org>; Thu, 30 Apr 2026 09:29:49 -0700 (PDT)",
            "from ST.. ([196.221.137.242]) by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-48a8d1723fbsm20315e9.8.2026.04.30.09.29.46\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 30 Apr 2026 09:29:47 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1777566589; x=1778171389; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=IqLLBmJlIHN7BtOC5QVKL16tdRtU/MN1TR4NvWc4koU=;\n b=UDuzl7zbecL4n8O1GMGCfd2qft5vD/gWZ8ABUiynEtavNwlpF08eGwcWc8QRHmLie9\n F59GEgPmRLxT4tCi7pcWq+ob7KWWd40NF02r7rh4dr1iFfDsnDJeTFkdHA8I5Muwz3MV\n 7zumcEE7VBnvnM8zchMKXg75E6udR1EXxztKu9Blk9l8jeEXUL72XMqMl7WiEupZOsG2\n WEysjQRsdIYfCbiXrgFGjOSUwFHhZ7Y8gpEVCXDFPLOI5kkhtBy74U2GMLMU3eseQUou\n 6ydrYYgFXZMYKfkvMbHjcB0kb1cIBuo6gmvuWiQU1Hw2dx6enWSMZJuaD7b2JWLEClzO\n Tedw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777566589; x=1778171389;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=IqLLBmJlIHN7BtOC5QVKL16tdRtU/MN1TR4NvWc4koU=;\n b=a92jJMmyCqHxTAu40fqc48uN9DpdEHqTgUrHsu6fMjuP8yuxH2mpgM6llpGAtzT0fC\n EHcC/pF7To2xyMA70CWR0V2n5QCiCnjU4A6ohmw2lQes4syxXMnMmsNLm1Ro40kkch4b\n xATPklH8yJOMz0W8EVFWYEpBS2jPtGn2OG1CMcpGdup53aiDukY35Wo6xsjqVzyihU2G\n 4/Ay3IHJf+71im9rRa+YqwWp+pCuOlxBXsWD1+WLs376hxOVi2YaT6qbCo1U3Ur2+sfH\n knUFRNEm4qc0xyS4emRhfhcv1BagTdrwgeCFBeCfoYXjgO8xxik5uA2UySTmr/MmDve+\n Xpdg==",
        "X-Forwarded-Encrypted": "i=1;\n AFNElJ8IOtEBlyLMdx9NQ44uUJFawXKGxEF0OEKIi3LJeLNQkOOSu58zEnUi29Ro1+Eh8TX5gxLgrbj7q6mW@nongnu.org",
        "X-Gm-Message-State": "AOJu0YyKHiPtEIdSNasMfTF7QBa9rQH6Aq9hNWBFglvotqKhoku7MYB0\n vussuHp1Q/DGM3ZVmlhUBySGZLlHyP5vKpw7V1G40EeQkGDlh/U2AAr9",
        "X-Gm-Gg": "AeBDietAZMugpS7d8oKJ/bct+/UVka9mVn3666W6XpRwucrakoEmsZ4GoMEYJqdWMV1\n RJsv4GFvkyDl90YJY7BW1/S3ymM1Pg6smv0j4w+n2gUaagLnoW6lCI7gcy/0FPz/6r05hSq4g/Y\n D5biI5cB5vT7jrn4DQ8M3TObxfvIm6ya7pkptUAGEpaJ/TaXTd57ixvBQlYB4H72Krz5P1kQJYv\n 0tyPpG7ZX/EROrlwVbDoUSGhx1ZWof0kDaMMmfyPpQ0XfhJyUiF1cqFdkDCPH/4h0gs7r1gKXzi\n +IviPmO9pQZOy9/QK0xHqO+WUU79KOb3Me2iQPtXjARKQUbY8G8e/equ2LFG99eMxQ6pysyZXKX\n VQtLx9U/8pMkCJyk7KqvQHb8a/tFEYU+nDo9+KERyJolOiUvkYOXHqwJwSe6ckzvE1fh1PCf84N\n pWIMTr9Hndy42xuvan/HQvyE2CqiNcL4QQGrYLZBIMm0jLIkmVJFU6jgsIqgGlfIsiu2q2QBaU",
        "X-Received": "by 2002:a05:600c:4f81:b0:489:1c2d:211e with SMTP id\n 5b1f17b1804b1-48a83d62fc3mr53231995e9.5.1777566588399;\n Thu, 30 Apr 2026 09:29:48 -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] bsd-user: remove cached host page size and rely on\n qemu_real_host_page_size()",
        "Date": "Thu, 30 Apr 2026 19:29:41 +0300",
        "Message-Id": "<20260430162941.584960-1-mohamedaymanworkspace@gmail.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Received-SPF": "pass client-ip=2a00:1450:4864:20::32d;\n envelope-from=mohamedaymanworkspace@gmail.com; helo=mail-wm1-x32d.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-Mailman-Approved-At": "Thu, 30 Apr 2026 13:08:01 -0400",
        "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 introduces 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\nqemu_real_host_page_size() and derived expressions, and update all\nalignment and masking logic accordingly.\n\nThis simplifies the code and ensures a single source of truth for host\npage size handling across bsd-user memory management paths.\n\nNo functional change intended.\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..41ac5e3eab 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        qemu_real_host_page_size()\n+#define HOST_PAGE_MASK        (~(HOST_PAGE_SIZE - 1))\n+#define HOST_PAGE_MASK  ((intptr_t)~(HOST_PAGE_SIZE - 1))\n \n /*\n  * This struct is used to hold certain information about the image.  Basically,\n",
    "prefixes": []
}