* [PATCH for-8.1] linux-user: Define real MAP_FIXED_NOREPLACE value
@ 2023-08-08 11:52 Akihiko Odaki
2023-08-08 14:42 ` Richard Henderson
0 siblings, 1 reply; 4+ messages in thread
From: Akihiko Odaki @ 2023-08-08 11:52 UTC (permalink / raw)
Cc: Alex Bennée, Richard Henderson, pbonzini, philmd, laurent,
deller, qemu-devel, Akihiko Odaki
do_brk() assumes target_mmap() emulates MAP_FIXED_NOREPLACE even when
the host does not support it. However, such emulation is not possible
if MAP_FIXED_NOREPLACE is defined as zero.
Define MAP_FIXED_NOREPLACE with the real value instead of zero if it is
not defined.
Fixes: e69e032d1a ("linux-user: Use MAP_FIXED_NOREPLACE for do_brk()")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
include/qemu/osdep.h | 8 ++++++--
linux-user/elfload.c | 1 -
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index cc61b00ba9..1aac17ec2f 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -289,8 +289,12 @@ void QEMU_ERROR("code path is reachable")
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif
-#ifndef MAP_FIXED_NOREPLACE
-#define MAP_FIXED_NOREPLACE 0
+#if defined(__linux__) && !defined(MAP_FIXED_NOREPLACE)
+#if HOST_ALPHA
+#define MAP_FIXED_NOREPLACE 0x200000
+#else
+#define MAP_FIXED_NOREPLACE 0x100000
+#endif
#endif
#ifndef MAP_NORESERVE
#define MAP_NORESERVE 0
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 36e4026f05..9d9c79a653 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2807,7 +2807,6 @@ static void pgb_reserved_va(const char *image_name, abi_ulong guest_loaddr,
/* Widen the "image" to the entire reserved address space. */
pgb_static(image_name, 0, reserved_va, align);
- /* osdep.h defines this as 0 if it's missing */
flags |= MAP_FIXED_NOREPLACE;
/* Reserve the memory on the host. */
--
2.41.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH for-8.1] linux-user: Define real MAP_FIXED_NOREPLACE value
2023-08-08 11:52 [PATCH for-8.1] linux-user: Define real MAP_FIXED_NOREPLACE value Akihiko Odaki
@ 2023-08-08 14:42 ` Richard Henderson
2023-08-08 15:16 ` Akihiko Odaki
0 siblings, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2023-08-08 14:42 UTC (permalink / raw)
To: Akihiko Odaki
Cc: Alex Bennée, pbonzini, philmd, laurent, deller, qemu-devel
On 8/8/23 04:52, Akihiko Odaki wrote:
> do_brk() assumes target_mmap() emulates MAP_FIXED_NOREPLACE even when
> the host does not support it. However, such emulation is not possible
> if MAP_FIXED_NOREPLACE is defined as zero.
>
> Define MAP_FIXED_NOREPLACE with the real value instead of zero if it is
> not defined.
>
> Fixes: e69e032d1a ("linux-user: Use MAP_FIXED_NOREPLACE for do_brk()")
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
> include/qemu/osdep.h | 8 ++++++--
> linux-user/elfload.c | 1 -
> 2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
> index cc61b00ba9..1aac17ec2f 100644
> --- a/include/qemu/osdep.h
> +++ b/include/qemu/osdep.h
> @@ -289,8 +289,12 @@ void QEMU_ERROR("code path is reachable")
> #ifndef MAP_ANONYMOUS
> #define MAP_ANONYMOUS MAP_ANON
> #endif
> -#ifndef MAP_FIXED_NOREPLACE
> -#define MAP_FIXED_NOREPLACE 0
> +#if defined(__linux__) && !defined(MAP_FIXED_NOREPLACE)
> +#if HOST_ALPHA
HOST_ALPHA is not a thing. Also, see
https://lore.kernel.org/qemu-devel/20230808120303.585509-3-pbonzini@redhat.com/
where host support for Alpha is completely removed.
> +#define MAP_FIXED_NOREPLACE 0x200000
> +#else
> +#define MAP_FIXED_NOREPLACE 0x100000
> +#endif
Which supported hosts do not define this value? Can we simply remove the fallback?
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH for-8.1] linux-user: Define real MAP_FIXED_NOREPLACE value
2023-08-08 14:42 ` Richard Henderson
@ 2023-08-08 15:16 ` Akihiko Odaki
2023-08-08 16:19 ` Richard Henderson
0 siblings, 1 reply; 4+ messages in thread
From: Akihiko Odaki @ 2023-08-08 15:16 UTC (permalink / raw)
To: Richard Henderson
Cc: Alex Bennée, pbonzini, philmd, laurent, deller, qemu-devel
On 2023/08/08 23:42, Richard Henderson wrote:
> On 8/8/23 04:52, Akihiko Odaki wrote:
>> do_brk() assumes target_mmap() emulates MAP_FIXED_NOREPLACE even when
>> the host does not support it. However, such emulation is not possible
>> if MAP_FIXED_NOREPLACE is defined as zero.
>>
>> Define MAP_FIXED_NOREPLACE with the real value instead of zero if it is
>> not defined.
>>
>> Fixes: e69e032d1a ("linux-user: Use MAP_FIXED_NOREPLACE for do_brk()")
>> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>> ---
>> include/qemu/osdep.h | 8 ++++++--
>> linux-user/elfload.c | 1 -
>> 2 files changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
>> index cc61b00ba9..1aac17ec2f 100644
>> --- a/include/qemu/osdep.h
>> +++ b/include/qemu/osdep.h
>> @@ -289,8 +289,12 @@ void QEMU_ERROR("code path is reachable")
>> #ifndef MAP_ANONYMOUS
>> #define MAP_ANONYMOUS MAP_ANON
>> #endif
>> -#ifndef MAP_FIXED_NOREPLACE
>> -#define MAP_FIXED_NOREPLACE 0
>> +#if defined(__linux__) && !defined(MAP_FIXED_NOREPLACE)
>> +#if HOST_ALPHA
>
> HOST_ALPHA is not a thing. Also, see
>
> https://lore.kernel.org/qemu-devel/20230808120303.585509-3-pbonzini@redhat.com/
>
> where host support for Alpha is completely removed.
I sent v2 with the condition HOST_ALPHA replaced with
MAP_HUGETLB == 0x100000.
While Alpha is no longer supported, and linux-user will not work on
Alpha, code outside linux-user also refers to osdep.h and the build
script does not actively block building QEMU on an unsupported host so I
left the definition for Alpha just in case.
>
>
>> +#define MAP_FIXED_NOREPLACE 0x200000
>> +#else
>> +#define MAP_FIXED_NOREPLACE 0x100000
>> +#endif
>
> Which supported hosts do not define this value? Can we simply remove
> the fallback?
glibc didn't have this defined until 2.28. The older releases still
maintained are 2.26, and 2.27, according to:
https://sourceware.org/glibc/wiki/Release
The page says ALT Linux p9 and Ubuntu 18.04 LTS (Bionic Beaver) has
glibc 2.27.
>
>
> r~
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH for-8.1] linux-user: Define real MAP_FIXED_NOREPLACE value
2023-08-08 15:16 ` Akihiko Odaki
@ 2023-08-08 16:19 ` Richard Henderson
0 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2023-08-08 16:19 UTC (permalink / raw)
To: Akihiko Odaki
Cc: Alex Bennée, pbonzini, philmd, laurent, deller, qemu-devel
On 8/8/23 08:16, Akihiko Odaki wrote:
>> Which supported hosts do not define this value? Can we simply remove the fallback?
>
> glibc didn't have this defined until 2.28. The older releases still maintained are 2.26,
> and 2.27, according to:
> https://sourceware.org/glibc/wiki/Release
Thanks for digging into glibc versions.
> The page says ALT Linux p9 and Ubuntu 18.04 LTS (Bionic Beaver) has glibc 2.27.
QEMU says
# Support for the previous major version will be dropped 2 years
# after the new major version is released or when the vendor itself
# drops support, whichever comes first.
Ubuntu 22.04 is the current major version, so 20.04 is still supported until 2024, but
18.04 is unsupported.
Similarly, ALT 10.0 was released in 2021, so ALT 9 is now unsupported.
I have just run a patch to remove the fallback through gitlab CI and it has passed:
https://gitlab.com/rth7680/qemu/-/pipelines/959680899/
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-08 16:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-08 11:52 [PATCH for-8.1] linux-user: Define real MAP_FIXED_NOREPLACE value Akihiko Odaki
2023-08-08 14:42 ` Richard Henderson
2023-08-08 15:16 ` Akihiko Odaki
2023-08-08 16:19 ` Richard Henderson
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).