linux-user: Add missing includes
PATCH 1/1 linux-user: Add missing includes
We're getting errors about this:linux-user/elfload.c:2770:36: error: use of undeclared identifier 'MAP_FIXED_NOREPLACE'
--- linux-user/elfload.c | 1 + linux-user/mmap.c | 1 + linux-user/syscall.c | 1 + 3 files changed, 3 insertions(+)
linux-user/elfload.c +1 -0
@@ -5,6 +5,7 @@#include <sys/prctl.h> #include <sys/resource.h> #include <sys/shm.h> +#include <linux/mman.h> #include "qemu.h" #include "user/tswap-target.h"
linux-user/mmap.c +1 -0
@@ -18,6 +18,7 @@*/ #include "qemu/osdep.h" #include <sys/shm.h> +#include <linux/mman.h> #include "trace.h" #include "exec/log.h" #include "exec/page-protection.h"
linux-user/syscall.c +1 -0
@@ -101,6 +101,7 @@#include <linux/soundcard.h> #include <linux/kd.h> #include <linux/mtio.h> +#include <linux/mman.h> #include <linux/fs.h> #include <linux/fd.h> #if defined(CONFIG_FIEMAP )
---
base-commit: baa79455fa92984ff0f4b9ae94bed66823177a27
change-id: 20250904-includes-19d9afaed67a
Best regards,
Signature · 1 line
Peter Foley <[email protected]>
Paolo Bonzini
AppliedQuoted 2 lines · Peter Foley
We're getting errors about this:
linux-user/elfload.c:2770:36: error: use of undeclared identifier 'MAP_FIXED_NOREPLACE'
Queued, thanks.
Paolo
Quoted 50 lines
Signed-off-by Peter Foley <[email protected]>--- linux-user/elfload.c | 1 + linux-user/mmap.c | 1 + linux-user/syscall.c | 1 + 3 files changed, 3 insertions(+)linux-user/elfload.c +1
-0@@ -5,6 +5,7 @@#include <sys/prctl.h> #include <sys/resource.h> #include <sys/shm.h> +#include <linux/mman.h> #include "qemu.h" #include "user/tswap-target.h" linux-user/mmap.c +1
-0@@ -18,6 +18,7 @@*/ #include "qemu/osdep.h" #include <sys/shm.h> +#include <linux/mman.h> #include "trace.h" #include "exec/log.h" #include "exec/page-protection.h" linux-user/syscall.c +1
-1@@ -101,6 +101,7 @@#include <linux/soundcard.h> #include <linux/kd.h> #include <linux/mtio.h> +#include <linux/mman.h> #include <linux/fs.h> #include <linux/fd.h> #if defined(CONFIG_FIEMAP ) ---base-commit:
baa79455fa92984ff0f4b9ae94bed66823177a27
change-id: 20250904-includes-19d9afaed67aBest regards,
Quoted 16 lines · Paolo Bonzini
Quoted 2 lines · Peter Foley
We're getting errors about this:
linux-user/elfload.c:2770:36: error: use of undeclared identifier 'MAP_FIXED_NOREPLACE'Queued, thanks.
Paolo
Quoted 8 lines
Signed-off-by Peter Foley <[email protected]>---
linux-user/elfload.c| 1 +
linux-user/mmap.c | 1 +
linux-user/syscall.c| 1 +3 files changed, 3 insertions(+)
Quoted 9 lines
linux-user/elfload.c line 8
Quoted 9 lines
linux-user/elfload.c +1
-0@@ -5,6 +5,7 @@ #include <sys/prctl.h> #include <sys/resource.h> #include <sys/shm.h> +#include <linux/mman.h>
There's no reason to include <linux/mman.h>.
This value is provided by <sys/mman.h> directly for musl and by <sys/mman.h> via <bits/mman-map-flags*> for glibc.
Are you using some other libc? You're solidly in non-standard territory there. Perhaps that other libc needs updating.
r~
Quoted 33 lines · Richard Henderson
Quoted 3 lines · Paolo Bonzini
Quoted 2 lines · Peter Foley
We're getting errors about this:
linux-user/elfload.c:2770:36: error: use of undeclared identifier'
MAP_FIXED_NOREPLACE'Quoted 13 lines
Queued, thanks.
Paolo
Quoted 8 lines
Signed-off-by Peter Foley <[email protected]>--- linux-user/elfload.c | 1 + linux-user/mmap.c | 1 + linux-user/syscall.c | 1 + 3 files changed, 3 insertions(+)Quoted 2 lines
Quoted 2 lines
linux-user/elfload.c +0
-0index
26c090c95d3e90ad4a23a927267e4106f68975b0..edbacf041f25d88472c95efb4eb9bdccd81e9902Quoted 8 lines
linux-user/elfload.c line 8
Quoted 8 lines
100644
linux-user/elfload.c +1
-0@@ -5,6 +5,7 @@#include <sys/prctl.h> #include <sys/resource.h> #include <sys/shm.h> +#include <linux/mman.h> There's no reason to include <
linux/mman.h>.
Quoted 8 lines
This value is provided by <
sys/mman.h> directly for musl and by <sys/mman.h> via
<bits/mman-map-flags*> for glibc.Are you using some other libc? You're solidly in non-standard territory there.
Perhaps that other libc needs updating.
We're using glibc 2.27.
I definitely saw build failures earlier without this patch, but I'm now unable to reproduce them at head.
So maybe there was an issue with our headers at an earlier point that has since been fixed?
I'll revert this patch from our local fork and you should probably drop it upstream as well.
Quoted 3 lines
r~
Quoted 47 lines · Peter Foley
Quoted 33 lines · Richard Henderson
Quoted 3 lines · Paolo Bonzini
Quoted 2 lines · Peter Foley
We're getting errors about this:
linux-user/elfload.c:2770:36: error: use of undeclared identifier'
MAP_FIXED_NOREPLACE'Quoted 13 lines
Queued, thanks.
Paolo
Quoted 8 lines
Signed-off-by Peter Foley <[email protected]>--- linux-user/elfload.c | 1 + linux-user/mmap.c | 1 + linux-user/syscall.c | 1 + 3 files changed, 3 insertions(+)Quoted 2 lines
Quoted 2 lines
linux-user/elfload.c +0
-0index
26c090c95d3e90ad4a23a927267e4106f68975b0..edbacf041f25d88472c95efb4eb9bdccd81e9902Quoted 8 lines
linux-user/elfload.c line 8
Quoted 8 lines
100644
linux-user/elfload.c +1
-0@@ -5,6 +5,7 @@#include <sys/prctl.h> #include <sys/resource.h> #include <sys/shm.h> +#include <linux/mman.h> There's no reason to include <
linux/mman.h>.Quoted 8 lines
This value is provided by <
sys/mman.h> directly for musl and by <sys/mman.h> via
<bits/mman-map-flags*> for glibc.Are you using some other libc? You're solidly in non-standard territory there.
Perhaps that other libc needs updating.
Quoted 9 lines
We're using glibc 2.27.
I definitely saw build failures earlier without this patch, but I'm now unable to reproduce them at head.
So maybe there was an issue with our headers at an earlier point that has since been fixed?
I'll revert this patch from our local fork and you should probably drop it upstream as well.
Oh, I figured out why I couldn't reproduce the issue.
We had a separate patch we were carrying that added linux/mman.h to linux-user/user-mmap.h.
If I revert both patches, I see this:third_party/qemu/linux-user/mmap.c:602:40: error: use of undeclared identifier 'MAP_FIXED_NOREPLACE'
602 | if (start || (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) {
Quoted 5 lines
Quoted 4 lines
r~
Quoted 1 line · Peter Foley
We're using glibc 2.27.
That's just too old.
commit c42e77a90d9244c8caf76fe0e54f84200430a4e1
Author: Richard Henderson <[email protected]> Date: Tue Aug 8 09:44:18 2023 -0700
qemu/osdep: Remove fallback for MAP_FIXED_NOREPLACE
In order for our emulation of MAP_FIXED_NOREPLACE to succeed within linux-user target_mmap, we require a non-zero value. This does not require host kernel support, merely the bit being defined.
MAP_FIXED_NOREPLACE was added with glibc 2.28. From repology.org:
Fedora 36: 2.35
CentOS 8 (RHEL-8): 2.28
Debian 11: 2.31
OpenSUSE Leap 15.4: 2.31
Ubuntu LTS 20.04: 2.31
Message-Id: <[email protected]>
r~
Quoted 5 lines · Richard Henderson
Quoted 1 line · Peter Foley
We're using glibc 2.27.
That's just too old.
Yeah, I'm picking up on that.
So it looks like short of back-porting support for MAP_FIXED_NOREPLACE to our "grte" fork of glibc, we should just keep carrying a local patch. Sorry for the noise.
Quoted 29 lines
commit
c42e77a90d9244c8caf76fe0e54f84200430a4e1Author: Richard Henderson <[email protected]> Date: Tue Aug 8 09:44:18 2023 -0700qemu/osdep: Remove fallback for
MAP_FIXED_NOREPLACEIn order for our emulation of
MAP_FIXED_NOREPLACEto succeed within linux-usertarget_mmap, we require a non-zero value. This does not require host kernel support, merely the bit being defined.
MAP_FIXED_NOREPLACEwas added with glibc 2.28. From repology.org:Fedora 36: 2.35
CentOS 8 (RHEL-8): 2.28
Debian 11: 2.31
OpenSUSE Leap 15.4: 2.31
Ubuntu LTS 20.04: 2.31Reported-by Akihiko Odaki <[email protected]>Reviewed-by Akihiko Odaki <[email protected]>Reviewed-by Alex Bennée <[email protected]>Signed-off-by Richard Henderson <[email protected]>Message-Id: <[email protected]>
r~