From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Laurent Vivier" <laurent@vivier.eu>,
"Riku Voipio" <riku.voipio@iki.fi>,
"Kyle Evans" <kevans@freebsd.org>, "Warner Losh" <imp@bsdimp.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v3 1/3] bsd-user: Always use mmap_find_vma_aligned() in target_mmap()
Date: Fri, 7 Mar 2025 14:09:49 +0100 [thread overview]
Message-ID: <20250307130951.4816-2-philmd@linaro.org> (raw)
In-Reply-To: <20250307130951.4816-1-philmd@linaro.org>
Massage target_mmap(): calculate alignment once, then
unconditionally call mmap_find_vma_aligned().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
bsd-user/mmap.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c
index 346f2cefd32..28d7e387a20 100644
--- a/bsd-user/mmap.c
+++ b/bsd-user/mmap.c
@@ -489,13 +489,14 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
* before we truncate the length for mapping files below.
*/
if (!(flags & MAP_FIXED)) {
+ abi_ulong alignment = 0;
+
host_len = len + offset - host_offset;
host_len = HOST_PAGE_ALIGN(host_len);
- if ((flags & MAP_ALIGNMENT_MASK) != 0)
- start = mmap_find_vma_aligned(real_start, host_len,
- (flags & MAP_ALIGNMENT_MASK) >> MAP_ALIGNMENT_SHIFT);
- else
- start = mmap_find_vma(real_start, host_len);
+ if ((flags & MAP_ALIGNMENT_MASK) != 0) {
+ alignment = (flags & MAP_ALIGNMENT_MASK) >> MAP_ALIGNMENT_SHIFT;
+ }
+ start = mmap_find_vma_aligned(real_start, host_len, alignment);
if (start == (abi_ulong)-1) {
errno = ENOMEM;
goto fail;
--
2.47.1
next prev parent reply other threads:[~2025-03-07 13:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 13:09 [PATCH v3 0/3] user: Extract common MMAP API to 'user/mmap.h' Philippe Mathieu-Daudé
2025-03-07 13:09 ` Philippe Mathieu-Daudé [this message]
2025-03-07 16:03 ` [PATCH v3 1/3] bsd-user: Always use mmap_find_vma_aligned() in target_mmap() Richard Henderson
2025-03-09 23:21 ` Warner Losh
2025-03-07 13:09 ` [PATCH v3 2/3] bsd-user: Propagate alignment argument to mmap_find_vma() Philippe Mathieu-Daudé
2025-03-07 16:08 ` Richard Henderson
2025-03-07 16:17 ` Philippe Mathieu-Daudé
2025-03-09 23:20 ` Warner Losh
2025-03-07 13:09 ` [PATCH v3 3/3] user: Extract common MMAP API to 'user/mmap.h' Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250307130951.4816-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=imp@bsdimp.com \
--cc=kevans@freebsd.org \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).