From nobody Mon May 25 03:55:47 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1777962700; cv=none; d=zohomail.com; s=zohoarc; b=MGP56s4gRZwnsFrXDNdUdhyJE6/dQRFRj4ovyJb70g7NLJiy6w/QwosknkBnGHMikdu9LjaK+bwkD2X8AvJEfYqhduSXSGPrlgtBKPqRiZnH7FU2DGe5/ECg8VreG45BM/vTTIkk5+7Km6L04m/uIgJI+PzfRXYuChhHSHdac2k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777962700; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NRS8c+FSQpT+P23sIdLHqdspzXwKvOg9KSkLozX8Jjw=; b=G0vgZWs6zEOZ2N+C0o8LUWJ+S+Jufq5ym2a6lPMG4gYAjdth98kUtqqkgX8L/gOjoRNEz715Il3cNSgz3HjTCpQ42Yt8kKIKoLA+XbdCPeQTkvFfrUzNPFJWqBa40SAMO8g4Vsp7HbQ9aoLEvQH+2ZpAFnlzHMzDHxWPVI3aWWU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1777962700350466.5191566812955; Mon, 4 May 2026 23:31:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wK9JC-0006G8-Hx; Tue, 05 May 2026 02:31:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wK9JB-0006Fz-D6 for qemu-devel@nongnu.org; Tue, 05 May 2026 02:31:05 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wK9J8-0003kD-SS for qemu-devel@nongnu.org; Tue, 05 May 2026 02:31:05 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-488a88aeec9so54510785e9.2 for ; Mon, 04 May 2026 23:31:02 -0700 (PDT) Received: from ST.. ([196.221.137.242]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48d14c1ef96sm11154255e9.11.2026.05.04.23.30.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 23:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777962659; x=1778567459; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NRS8c+FSQpT+P23sIdLHqdspzXwKvOg9KSkLozX8Jjw=; b=R7bxMUwi0mqPjzhlFExzyuz8rQd4j2NZl4rwImNOdoUm4816Rg+Glj6rTVBDs/YXgZ LgJbzBO6ZpP+rIfbf+RgsCf6rB0PhFX8aaRbPMm28jBbawuOlb35Il4HlUvGMPBJjDKa Q/ENgFpuEahE0PG/XjCROVDDFemkq6KcrL8rp27bLJqLXgztyLVYy5Da2KTVCWT+R6aB ev7Zp7knJBsjGk6BzW8eJFvC8nrAmeweHaXNHAWGOeg0yOAtQfWn5hG3V1wxyYfScWl7 wTmtS45JA3//iEX0eb2V90yL8+0FFOgmcXUvGjm1mhj4PygD2/iXqu6SGOgYGhiW5/oU rKzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777962659; x=1778567459; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=NRS8c+FSQpT+P23sIdLHqdspzXwKvOg9KSkLozX8Jjw=; b=GhljNr+z3BDtAS8ok/gqcaeg4y8/DfOPVA3cbyhlHsC/AJ5PFQfvPYCR5gJQjeQnFz 1WcYueQtXBfAfouOA9dr+q9ZcKY9WGKjajtR0zCNs8iQNQiCVvgQfLoJ5deSHSzXXkAh UNI6qpoM+eEwsosLXbUqHbHTpFEV7gFhrdDqrusnq0nnemnWu6YcWSbPbIhdNMBdeVcD 5ZlDBPdef2krX7pAbkros9sZXsQLlmUUnd/oqkHCmGb2916XkwAsoAUuqjmeCoCwTPzP nmtqbQXuT+F5UL+2O6NsRywUwZdMSxAdgvLA3AHDSQUKwyOSOl8R0uKzOVeGdlMaX0zf ntjw== X-Gm-Message-State: AOJu0YyDfRNHMNizXprNVbTZht0lypWNm7Q8Krqjh3UHMbcIUhKomNgj 1WuKz3FqsWjsJHm9Kq6PTwP5bl05RSoOjJidKG+NvJytzUtE7jbfFNMxm9lx/Qzg X-Gm-Gg: AeBDieuNavnjiZ9+wzN4gyapS3rpJXvOwJ3hgNCkRAdJx+0F7pLdiAxjOv1CHEBS5tD 58Aml2Q4I/QLBGogw6Ly5TcochfnuW3ckTIjOCcPm4CMZGF6O+8xfw6tv8ELePjXZCBZv+U3Qvj NuItgXH4orQ6oXwEx3g9rk9YWMxJOgrT+fXfLrnAOKk+lmg2k+sR8eliAL3bR9w2s6XkcklrZiJ osNXiGRBaK2BIIIn+5+fH1mAAERLCP2CEV5EIdsCXe9bEIxChb0cwOkr/o/XVZ9ZJbeFTznBR6a E/vUcjUx9GEo1s6RCHu4jcNEKJZ8zJCDepxsKA7W8mFpTkp22S/DllKZFaQeQFz8q5e9suPLjxS 6N2hXc8WHwXKtyBgdU097cDcM4yS/+ByAFl5WwIzeTp2lQi5dYBU0OgG1JwWSONhguUKEneZZhW ZhFjlxHfDK4E/8hshvdSgQk1n8rJoD6V6Wt78GNHl0az6vPD7vqopAJweAcKMTS1Yim5g36CPM X-Received: by 2002:a05:600c:4e43:b0:480:1d0b:2d32 with SMTP id 5b1f17b1804b1-48a98638227mr219705785e9.12.1777962659063; Mon, 04 May 2026 23:30:59 -0700 (PDT) From: Mohamed Ayman To: qemu-devel@nongnu.org Cc: imp@bsdimp.com, kevans@freebsd.org, Mohamed Ayman Subject: [PATCH v3] bsd-user: remove cached host page size and rely on qemu_real_host_page_size() Date: Tue, 5 May 2026 09:30:48 +0300 Message-Id: <20260505063048.230226-1-mohamedaymanworkspace@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260501161106.818373-1-mohamedaymanworkspace@gmail.com> References: <20260501161106.818373-1-mohamedaymanworkspace@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=mohamedaymanworkspace@gmail.com; helo=mail-wm1-x334.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, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1777962702308158500 Content-Type: text/plain; charset="utf-8" Fix duplicate HOST_PAGE_MASK definition and replace all remaining uses of qemu_host_page_size/qemu_host_page_mask with HOST_PAGE_SIZE/HOST_PAGE_MA= SK. HOST_PAGE_SIZE is now defined as: MAX(qemu_real_host_page_size(), TARGET_PAGE_SIZE) This preserves correct behavior when the target page size exceeds the host page size (e.g. aarch64 16K pages on a 4K amd64 host). Signed-off-by: Mohamed Ayman --- bsd-user/elfload.c | 25 ++--------- bsd-user/main.c | 14 ++----- bsd-user/mmap.c | 102 ++++++++++++++++----------------------------- bsd-user/qemu.h | 10 ++--- 4 files changed, 46 insertions(+), 105 deletions(-) diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c index 3bca0cc9ed..00250fc3c1 100644 --- a/bsd-user/elfload.c +++ b/bsd-user/elfload.c @@ -192,14 +192,14 @@ static void setup_arg_pages(struct bsd_binprm *bprm, = struct image_info *info, */ size =3D target_dflssiz; stack_base =3D TARGET_USRSTACK - size; - addr =3D target_mmap(stack_base , size + qemu_host_page_size, + addr =3D target_mmap(stack_base , size + HOST_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); if (addr =3D=3D -1) { perror("stk mmap"); exit(-1); } /* we reserve one extra page at the top of the stack as guard */ - target_mprotect(addr + size, qemu_host_page_size, PROT_NONE); + target_mprotect(addr + size, HOST_PAGE_SIZE, PROT_NONE); =20 target_stksiz =3D size; target_stkbas =3D addr; @@ -239,27 +239,10 @@ static void padzero(abi_ulong elf_bss, abi_ulong last= _bss) return; } =20 - /* - * XXX: this is really a hack : if the real host page size is - * smaller than the target page size, some pages after the end - * of the file may not be mapped. A better fix would be to - * patch target_mmap(), but it is more complicated as the file - * size must be known. - */ - if (qemu_real_host_page_size() < qemu_host_page_size) { - abi_ulong end_addr, end_addr1; - end_addr1 =3D REAL_HOST_PAGE_ALIGN(elf_bss); - end_addr =3D HOST_PAGE_ALIGN(elf_bss); - if (end_addr1 < end_addr) { - mmap((void *)g2h_untagged(end_addr1), end_addr - end_addr1, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0); - } - } =20 - nbyte =3D elf_bss & (qemu_host_page_size - 1); + nbyte =3D elf_bss & (HOST_PAGE_SIZE - 1); if (nbyte) { - nbyte =3D qemu_host_page_size - nbyte; + nbyte =3D HOST_PAGE_SIZE - nbyte; do { /* FIXME - what to do if put_user() fails? */ put_user_u8(0, elf_bss); diff --git a/bsd-user/main.c b/bsd-user/main.c index 73aae8c327..3f5141e794 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -54,11 +54,6 @@ #include "target_arch_cpu.h" =20 =20 -/* - * TODO: Remove these and rely only on qemu_real_host_page_size(). - */ -uintptr_t qemu_host_page_size; -intptr_t qemu_host_page_mask; =20 static bool opt_one_insn_per_tb; static unsigned long opt_tb_size; @@ -302,8 +297,6 @@ int main(int argc, char **argv) (void) envlist_setenv(envlist, *wrk); } =20 - qemu_host_page_size =3D getpagesize(); - qemu_host_page_size =3D MAX(qemu_host_page_size, TARGET_PAGE_SIZE); =20 cpu_model =3D NULL; =20 @@ -405,7 +398,6 @@ int main(int argc, char **argv) } } =20 - qemu_host_page_mask =3D -qemu_host_page_size; =20 /* init debug */ { @@ -452,7 +444,7 @@ int main(int argc, char **argv) =20 cpu_type =3D parse_cpu_option(cpu_model); =20 - /* init tcg before creating CPUs and to get qemu_host_page_size */ + /* init tcg before creating CPUs */ { AccelState *accel =3D current_accel(); AccelClass *ac =3D ACCEL_GET_CLASS(accel); @@ -534,7 +526,7 @@ int main(int argc, char **argv) * proper page alignment for guest_base. */ if (have_guest_base) { - if (guest_base & ~qemu_host_page_mask) { + if (guest_base & ~HOST_PAGE_MASK) { error_report("Selected guest base not host page aligned"); exit(1); } @@ -573,7 +565,7 @@ int main(int argc, char **argv) /* Ensure that mmap_next_start is within range. */ if (reserved_va <=3D mmap_next_start) { mmap_next_start =3D (reserved_va / 4 * 3) - & TARGET_PAGE_MASK & qemu_host_page_mask; + & TARGET_PAGE_MASK & HOST_PAGE_MASK; } } =20 diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index fe77eceb48..59c70083a4 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -84,7 +84,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int p= rot) return 0; =20 mmap_lock(); - host_start =3D start & qemu_host_page_mask; + host_start =3D start & HOST_PAGE_MASK; host_end =3D HOST_PAGE_ALIGN(end); if (start > host_start) { /* handle host page containing start */ @@ -92,28 +92,28 @@ int target_mprotect(abi_ulong start, abi_ulong len, int= prot) for (addr =3D host_start; addr < start; addr +=3D TARGET_PAGE_SIZE= ) { prot1 |=3D page_get_flags(addr); } - if (host_end =3D=3D host_start + qemu_host_page_size) { + if (host_end =3D=3D host_start + HOST_PAGE_SIZE) { for (addr =3D end; addr < host_end; addr +=3D TARGET_PAGE_SIZE= ) { prot1 |=3D page_get_flags(addr); } end =3D host_end; } ret =3D mprotect(g2h_untagged(host_start), - qemu_host_page_size, prot1 & PAGE_RWX); + HOST_PAGE_SIZE, prot1 & PAGE_RWX); if (ret !=3D 0) goto error; - host_start +=3D qemu_host_page_size; + host_start +=3D HOST_PAGE_SIZE; } if (end < host_end) { prot1 =3D prot; for (addr =3D end; addr < host_end; addr +=3D TARGET_PAGE_SIZE) { prot1 |=3D page_get_flags(addr); } - ret =3D mprotect(g2h_untagged(host_end - qemu_host_page_size), - qemu_host_page_size, prot1 & PAGE_RWX); + ret =3D mprotect(g2h_untagged(host_end - HOST_PAGE_SIZE), + HOST_PAGE_SIZE, prot1 & PAGE_RWX); if (ret !=3D 0) goto error; - host_end -=3D qemu_host_page_size; + host_end -=3D HOST_PAGE_SIZE; } =20 /* handle the pages in the middle */ @@ -193,7 +193,7 @@ static int mmap_frag(abi_ulong real_start, void *host_start; int prot1, prot_new; =20 - real_end =3D real_start + qemu_host_page_size; + real_end =3D real_start + HOST_PAGE_SIZE; host_start =3D g2h_untagged(real_start); =20 /* get the protection of the target pages outside the mapping */ @@ -205,7 +205,7 @@ static int mmap_frag(abi_ulong real_start, =20 if (prot1 =3D=3D 0) { /* no page was there, so we allocate one. See also above. */ - void *p =3D mmap(host_start, qemu_host_page_size, prot, + void *p =3D mmap(host_start, HOST_PAGE_SIZE, prot, flags | ((fd !=3D -1) ? MAP_ANON : 0), -1, 0); if (p =3D=3D MAP_FAILED) return -1; @@ -223,7 +223,7 @@ static int mmap_frag(abi_ulong real_start, =20 /* adjust protection to be able to read */ if (!(prot1 & PROT_WRITE)) - mprotect(host_start, qemu_host_page_size, prot1 | PROT_WRITE); + mprotect(host_start, HOST_PAGE_SIZE, prot1 | PROT_WRITE); =20 /* read the corresponding file data */ if (!mmap_pread(fd, g2h_untagged(start), end - start, offset, true= )) { @@ -232,10 +232,10 @@ static int mmap_frag(abi_ulong real_start, =20 /* put final protection */ if (prot_new !=3D (prot1 | PROT_WRITE)) - mprotect(host_start, qemu_host_page_size, prot_new); + mprotect(host_start, HOST_PAGE_SIZE, prot_new); } else { if (prot_new !=3D prot1) { - mprotect(host_start, qemu_host_page_size, prot_new); + mprotect(host_start, HOST_PAGE_SIZE, prot_new); } if (prot_new & PROT_WRITE) { memset(g2h_untagged(start), 0, end - start); @@ -289,7 +289,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size= , abi_ulong alignment) if (start =3D=3D 0) { start =3D mmap_next_start; } else { - start &=3D qemu_host_page_mask; + start &=3D HOST_PAGE_MASK; } =20 size =3D HOST_PAGE_ALIGN(size); @@ -297,7 +297,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size= , abi_ulong alignment) if (reserved_va) { return mmap_find_vma_reserved(start, size, (alignment !=3D 0 ? 1 << alignment : - MAX(qemu_host_page_size, TARGET_PAGE_SIZE))); + MAX(HOST_PAGE_SIZE, TARGET_PAGE_SIZE))); } =20 addr =3D start; @@ -478,8 +478,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, goto fail; } =20 - real_start =3D start & qemu_host_page_mask; - host_offset =3D offset & qemu_host_page_mask; + real_start =3D start & HOST_PAGE_MASK; + host_offset =3D offset & HOST_PAGE_MASK; =20 /* * If the user is asking for the kernel to find a location, do that @@ -498,38 +498,6 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, i= nt prot, } } =20 - /* - * When mapping files into a memory area larger than the file, accesses - * to pages beyond the file size will cause a SIGBUS. - * - * For example, if mmaping a file of 100 bytes on a host with 4K pages - * emulating a target with 8K pages, the target expects to be able to - * access the first 8K. But the host will trap us on any access beyond - * 4K. - * - * When emulating a target with a larger page-size than the hosts, we - * may need to truncate file maps at EOF and add extra anonymous pages - * up to the targets page boundary. - */ - - if ((qemu_real_host_page_size() < qemu_host_page_size) && fd !=3D -1) { - struct stat sb; - - if (fstat(fd, &sb) =3D=3D -1) { - goto fail; - } - - /* Are we trying to create a map beyond EOF?. */ - if (offset + len > sb.st_size) { - /* - * If so, truncate the file map at eof aligned with - * the hosts real pagesize. Additional anonymous maps - * will be created beyond EOF. - */ - len =3D REAL_HOST_PAGE_ALIGN(sb.st_size - offset); - } - } - if (!(flags & MAP_FIXED)) { unsigned long host_start; void *p; @@ -539,8 +507,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, =20 /* * Note: we prefer to control the mapping address. It is - * especially important if qemu_host_page_size > - * qemu_real_host_page_size + * especially important if HOST_PAGE_SIZE > + * TARGET_PAGE_SIZE */ p =3D mmap(g2h_untagged(start), host_len, prot, flags | MAP_FIXED | ((fd !=3D -1) ? MAP_ANON : 0), -1, 0); @@ -581,7 +549,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, * aligned, so we read it */ if (fd !=3D -1 && - (offset & ~qemu_host_page_mask) !=3D (start & ~qemu_host_page_= mask)) { + (offset & ~HOST_PAGE_MASK) !=3D (start & ~HOST_PAGE_MASK)) { /* * msync() won't work here, so we return an error if write is * possible while it is a shared mapping @@ -614,7 +582,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t prot, =20 /* handle the start of the mapping */ if (start > real_start) { - if (real_end =3D=3D real_start + qemu_host_page_size) { + if (real_end =3D=3D real_start + HOST_PAGE_SIZE) { /* one single host page */ ret =3D mmap_frag(real_start, start, end, prot, flags, fd, offset); @@ -622,21 +590,21 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int prot, goto fail; goto the_end1; } - ret =3D mmap_frag(real_start, start, real_start + qemu_host_pa= ge_size, + ret =3D mmap_frag(real_start, start, real_start + HOST_PAGE_SI= ZE, prot, flags, fd, offset); if (ret =3D=3D -1) goto fail; - real_start +=3D qemu_host_page_size; + real_start +=3D HOST_PAGE_SIZE; } /* handle the end of the mapping */ if (end < real_end) { - ret =3D mmap_frag(real_end - qemu_host_page_size, - real_end - qemu_host_page_size, end, + ret =3D mmap_frag(real_end - HOST_PAGE_SIZE, + real_end - HOST_PAGE_SIZE, end, prot, flags, fd, - offset + real_end - qemu_host_page_size - star= t); + offset + real_end - HOST_PAGE_SIZE - start); if (ret =3D=3D -1) goto fail; - real_end -=3D qemu_host_page_size; + real_end -=3D HOST_PAGE_SIZE; } =20 /* map the middle (easier) */ @@ -676,7 +644,7 @@ void mmap_reserve(abi_ulong start, abi_ulong size) abi_ulong end; int prot; =20 - real_start =3D start & qemu_host_page_mask; + real_start =3D start & HOST_PAGE_MASK; real_end =3D HOST_PAGE_ALIGN(start + size); end =3D start + size; if (start > real_start) { @@ -685,14 +653,14 @@ void mmap_reserve(abi_ulong start, abi_ulong size) for (addr =3D real_start; addr < start; addr +=3D TARGET_PAGE_SIZE= ) { prot |=3D page_get_flags(addr); } - if (real_end =3D=3D real_start + qemu_host_page_size) { + if (real_end =3D=3D real_start + HOST_PAGE_SIZE) { for (addr =3D end; addr < real_end; addr +=3D TARGET_PAGE_SIZE= ) { prot |=3D page_get_flags(addr); } end =3D real_end; } if (prot !=3D 0) { - real_start +=3D qemu_host_page_size; + real_start +=3D HOST_PAGE_SIZE; } } if (end < real_end) { @@ -701,7 +669,7 @@ void mmap_reserve(abi_ulong start, abi_ulong size) prot |=3D page_get_flags(addr); } if (prot !=3D 0) { - real_end -=3D qemu_host_page_size; + real_end -=3D HOST_PAGE_SIZE; } } if (real_start !=3D real_end) { @@ -727,7 +695,7 @@ int target_munmap(abi_ulong start, abi_ulong len) return -EINVAL; mmap_lock(); end =3D start + len; - real_start =3D start & qemu_host_page_mask; + real_start =3D start & HOST_PAGE_MASK; real_end =3D HOST_PAGE_ALIGN(end); =20 if (start > real_start) { @@ -736,14 +704,14 @@ int target_munmap(abi_ulong start, abi_ulong len) for (addr =3D real_start; addr < start; addr +=3D TARGET_PAGE_SIZE= ) { prot |=3D page_get_flags(addr); } - if (real_end =3D=3D real_start + qemu_host_page_size) { + if (real_end =3D=3D real_start + HOST_PAGE_SIZE) { for (addr =3D end; addr < real_end; addr +=3D TARGET_PAGE_SIZE= ) { prot |=3D page_get_flags(addr); } end =3D real_end; } if (prot !=3D 0) - real_start +=3D qemu_host_page_size; + real_start +=3D HOST_PAGE_SIZE; } if (end < real_end) { prot =3D 0; @@ -751,7 +719,7 @@ int target_munmap(abi_ulong start, abi_ulong len) prot |=3D page_get_flags(addr); } if (prot !=3D 0) - real_end -=3D qemu_host_page_size; + real_end -=3D HOST_PAGE_SIZE; } =20 ret =3D 0; @@ -784,6 +752,6 @@ int target_msync(abi_ulong start, abi_ulong len, int fl= ags) if (end =3D=3D start) return 0; =20 - start &=3D qemu_host_page_mask; + start &=3D HOST_PAGE_MASK; return msync(g2h_untagged(start), end - start, flags); } diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index b0b2c249fb..7553ac154c 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -44,12 +44,10 @@ extern char **environ; #include "accel/tcg/vcpu-state.h" =20 #include "qemu-os.h" -/* - * TODO: Remove these and rely only on qemu_real_host_page_size(). - */ -extern uintptr_t qemu_host_page_size; -extern intptr_t qemu_host_page_mask; -#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size) + +#define HOST_PAGE_SIZE MAX(qemu_real_host_page_size(), TARGET_PAGE_= SIZE) +#define HOST_PAGE_MASK ((intptr_t)~(HOST_PAGE_SIZE - 1)) +#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), HOST_PAGE_SIZE) =20 /* * This struct is used to hold certain information about the image. Basic= ally, --=20 2.34.1