* [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11
@ 2017-11-20 21:21 riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 01/15] linux-user: Restrict usage of sa_restorer riku.voipio
` (17 more replies)
0 siblings, 18 replies; 19+ messages in thread
From: riku.voipio @ 2017-11-20 21:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio
From: Riku Voipio <riku.voipio@linaro.org>
The following changes since commit b0fbe46ad82982b289a44ee2495b59b0bad8a842:
Update version for v2.11.0-rc0 release (2017-11-07 16:05:28 +0000)
are available in the git repository at:
git://git.linaro.org/people/riku.voipio/qemu.git tags/pull-linux-user-20171120
for you to fetch changes up to f516511ea84d8bb3395d6ea95a7c7b80dc2a05e9:
linux-user: Fix calculation of auxv length (2017-11-20 16:15:41 +0200)
----------------------------------------------------------------
late linux-user fixes for Qemu 2.11
----------------------------------------------------------------
Emilio G. Cota (1):
linux-user: fix 'finshed' typo in comment
Helge Deller (5):
linux-user/hppa: Fix TARGET_SA_* defines
linux-user/hppa: Fix typo for TARGET_NR_epoll_wait
linux-user/hppa: Fix TARGET_MAP_TYPE
linux-user/hppa: Fix TARGET_F_RDLCK, TARGET_F_WRLCK, TARGET_F_UNLCK
linux-user: Handle TARGET_MAP_STACK and TARGET_MAP_HUGETLB
James Clarke (1):
linux-user/syscall.c: Handle SH4's exceptional alignment for p{read, write}64
James Cowgill (1):
linux-user: return EINVAL from prctl(PR_*_SECCOMP)
Peter Maydell (5):
linux-user/s390x: Mask si_addr for SIGSEGV
linux-user/ppc: Report correct fault address for data faults
linux-user/sparc: Put address for data faults where linux-user expects it
linux-user: Handle rt_sigaction correctly for SPARC
linux-user: Fix calculation of auxv length
Richard Henderson (2):
linux-user: Restrict usage of sa_restorer
linux-user/hppa: Fix cpu_clone_regs
linux-user/elfload.c | 11 +++++++--
linux-user/hppa/syscall_nr.h | 2 +-
linux-user/hppa/target_cpu.h | 4 ++++
linux-user/main.c | 8 +++++--
linux-user/signal.c | 4 ++--
linux-user/syscall.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------
linux-user/syscall_defs.h | 40 ++++++++++++++++++++++++++++++++-
target/sparc/mmu_helper.c | 8 +++++++
8 files changed, 144 insertions(+), 35 deletions(-)
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Qemu-devel] [PULL 01/15] linux-user: Restrict usage of sa_restorer
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
@ 2017-11-20 21:21 ` riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 02/15] linux-user/hppa: Fix TARGET_SA_* defines riku.voipio
` (16 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: riku.voipio @ 2017-11-20 21:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson
From: Richard Henderson <rth@twiddle.net>
Reading and writing to an sa_restorer member that isn't supposed to
exist corrupts user memory. Introduce TARGET_ARCH_HAS_SA_RESTORER,
similar to the kernel's __ARCH_HAS_SA_RESTORER.
Reported-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/signal.c | 4 ++--
linux-user/syscall_defs.h | 13 +++++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 7a238aaea1..cf35473671 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -777,7 +777,7 @@ int do_sigaction(int sig, const struct target_sigaction *act,
if (oact) {
__put_user(k->_sa_handler, &oact->_sa_handler);
__put_user(k->sa_flags, &oact->sa_flags);
-#if !defined(TARGET_MIPS)
+#ifdef TARGET_ARCH_HAS_SA_RESTORER
__put_user(k->sa_restorer, &oact->sa_restorer);
#endif
/* Not swapped. */
@@ -787,7 +787,7 @@ int do_sigaction(int sig, const struct target_sigaction *act,
/* FIXME: This is not threadsafe. */
__get_user(k->_sa_handler, &act->_sa_handler);
__get_user(k->sa_flags, &act->sa_flags);
-#if !defined(TARGET_MIPS)
+#ifdef TARGET_ARCH_HAS_SA_RESTORER
__get_user(k->sa_restorer, &act->sa_restorer);
#endif
/* To be swapped in target_to_host_sigset. */
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 450960bb54..e366183419 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -445,6 +445,7 @@ int do_sigaction(int sig, const struct target_sigaction *act,
#define TARGET_SA_RESTART 2u
#define TARGET_SA_NODEFER 0x20u
#define TARGET_SA_RESETHAND 4u
+#define TARGET_ARCH_HAS_SA_RESTORER 1
#elif defined(TARGET_MIPS)
#define TARGET_SA_NOCLDSTOP 0x00000001
#define TARGET_SA_NOCLDWAIT 0x00010000
@@ -483,6 +484,10 @@ int do_sigaction(int sig, const struct target_sigaction *act,
#define TARGET_SA_RESTORER 0x04000000
#endif
+#ifdef TARGET_SA_RESTORER
+#define TARGET_ARCH_HAS_SA_RESTORER 1
+#endif
+
#if defined(TARGET_ALPHA)
#define TARGET_SIGHUP 1
@@ -718,19 +723,27 @@ struct target_sigaction {
abi_ulong _sa_handler;
#endif
target_sigset_t sa_mask;
+#ifdef TARGET_ARCH_HAS_SA_RESTORER
+ /* ??? This is always present, but ignored unless O32. */
+ abi_ulong sa_restorer;
+#endif
};
#else
struct target_old_sigaction {
abi_ulong _sa_handler;
abi_ulong sa_mask;
abi_ulong sa_flags;
+#ifdef TARGET_ARCH_HAS_SA_RESTORER
abi_ulong sa_restorer;
+#endif
};
struct target_sigaction {
abi_ulong _sa_handler;
abi_ulong sa_flags;
+#ifdef TARGET_ARCH_HAS_SA_RESTORER
abi_ulong sa_restorer;
+#endif
target_sigset_t sa_mask;
};
#endif
--
2.14.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PULL 02/15] linux-user/hppa: Fix TARGET_SA_* defines
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 01/15] linux-user: Restrict usage of sa_restorer riku.voipio
@ 2017-11-20 21:21 ` riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 03/15] linux-user/hppa: Fix cpu_clone_regs riku.voipio
` (15 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: riku.voipio @ 2017-11-20 21:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Helge Deller
From: Helge Deller <deller@gmx.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall_defs.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index e366183419..38339ecb9a 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -473,6 +473,14 @@ int do_sigaction(int sig, const struct target_sigaction *act,
#define TARGET_SA_RESETHAND 0x00000010
#define TARGET_SA_NOCLDWAIT 0x00000020 /* not supported yet */
#define TARGET_SA_SIGINFO 0x00000040
+#elif defined(TARGET_HPPA)
+#define TARGET_SA_ONSTACK 0x00000001
+#define TARGET_SA_RESETHAND 0x00000004
+#define TARGET_SA_NOCLDSTOP 0x00000008
+#define TARGET_SA_SIGINFO 0x00000010
+#define TARGET_SA_NODEFER 0x00000020
+#define TARGET_SA_RESTART 0x00000040
+#define TARGET_SA_NOCLDWAIT 0x00000080
#else
#define TARGET_SA_NOCLDSTOP 0x00000001
#define TARGET_SA_NOCLDWAIT 0x00000002 /* not supported yet */
--
2.14.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PULL 03/15] linux-user/hppa: Fix cpu_clone_regs
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 01/15] linux-user: Restrict usage of sa_restorer riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 02/15] linux-user/hppa: Fix TARGET_SA_* defines riku.voipio
@ 2017-11-20 21:21 ` riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 04/15] linux-user/hppa: Fix typo for TARGET_NR_epoll_wait riku.voipio
` (14 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: riku.voipio @ 2017-11-20 21:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Richard Henderson
From: Richard Henderson <rth@twiddle.net>
By failing to return from the syscall in the child, the child
issues another clone syscall and hilarity ensues.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/hppa/target_cpu.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/linux-user/hppa/target_cpu.h b/linux-user/hppa/target_cpu.h
index 1a5cecad3c..e50522eae9 100644
--- a/linux-user/hppa/target_cpu.h
+++ b/linux-user/hppa/target_cpu.h
@@ -24,7 +24,11 @@ static inline void cpu_clone_regs(CPUHPPAState *env, target_ulong newsp)
if (newsp) {
env->gr[30] = newsp;
}
+ /* Indicate child in return value. */
env->gr[28] = 0;
+ /* Return from the syscall. */
+ env->iaoq_f = env->gr[31];
+ env->iaoq_b = env->gr[31] + 4;
}
static inline void cpu_set_tls(CPUHPPAState *env, target_ulong newtls)
--
2.14.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PULL 04/15] linux-user/hppa: Fix typo for TARGET_NR_epoll_wait
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
` (2 preceding siblings ...)
2017-11-20 21:21 ` [Qemu-devel] [PULL 03/15] linux-user/hppa: Fix cpu_clone_regs riku.voipio
@ 2017-11-20 21:21 ` riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 05/15] linux-user/hppa: Fix TARGET_MAP_TYPE riku.voipio
` (13 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: riku.voipio @ 2017-11-20 21:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Helge Deller
From: Helge Deller <deller@gmx.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Helge Deller <deller@gmx.de>
Message-Id: <20170311100543.GA29669@ls3530.fritz.box>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/hppa/syscall_nr.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/linux-user/hppa/syscall_nr.h b/linux-user/hppa/syscall_nr.h
index 0f396fa1e2..55bdf71d50 100644
--- a/linux-user/hppa/syscall_nr.h
+++ b/linux-user/hppa/syscall_nr.h
@@ -228,7 +228,7 @@
#define TARGET_NR_lookup_dcookie 223
#define TARGET_NR_epoll_create 224
#define TARGET_NR_epoll_ctl 225
-#define TARGET_NR_epill_wait 226
+#define TARGET_NR_epoll_wait 226
#define TARGET_NR_remap_file_pages 227
#define TARGET_NR_semtimedop 228
#define TARGET_NR_mq_open 229
--
2.14.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PULL 05/15] linux-user/hppa: Fix TARGET_MAP_TYPE
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
` (3 preceding siblings ...)
2017-11-20 21:21 ` [Qemu-devel] [PULL 04/15] linux-user/hppa: Fix typo for TARGET_NR_epoll_wait riku.voipio
@ 2017-11-20 21:21 ` riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 06/15] linux-user/hppa: Fix TARGET_F_RDLCK, TARGET_F_WRLCK, TARGET_F_UNLCK riku.voipio
` (12 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: riku.voipio @ 2017-11-20 21:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Helge Deller
From: Helge Deller <deller@gmx.de>
TARGET_MAP_TYPE needs to be 0x03 instead of 0x0f on the hppa
architecture, otherwise it conflicts with MAP_FIXED which is 0x04.
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Message-ID: <20170311175019.GA7195@ls3530.fritz.box>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall_defs.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 38339ecb9a..a6ed30d70e 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -1336,7 +1336,11 @@ struct target_winsize {
/* Common */
#define TARGET_MAP_SHARED 0x01 /* Share changes */
#define TARGET_MAP_PRIVATE 0x02 /* Changes are private */
-#define TARGET_MAP_TYPE 0x0f /* Mask for type of mapping */
+#if defined(TARGET_HPPA)
+#define TARGET_MAP_TYPE 0x03 /* Mask for type of mapping */
+#else
+#define TARGET_MAP_TYPE 0x0f /* Mask for type of mapping */
+#endif
/* Target specific */
#if defined(TARGET_MIPS)
--
2.14.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PULL 06/15] linux-user/hppa: Fix TARGET_F_RDLCK, TARGET_F_WRLCK, TARGET_F_UNLCK
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
` (4 preceding siblings ...)
2017-11-20 21:21 ` [Qemu-devel] [PULL 05/15] linux-user/hppa: Fix TARGET_MAP_TYPE riku.voipio
@ 2017-11-20 21:21 ` riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 07/15] linux-user: Handle TARGET_MAP_STACK and TARGET_MAP_HUGETLB riku.voipio
` (11 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: riku.voipio @ 2017-11-20 21:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Helge Deller
From: Helge Deller <deller@gmx.de>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Message-ID: <20170311175019.GA7195@ls3530.fritz.box>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall_defs.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index a6ed30d70e..daa2a57398 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -2361,6 +2361,9 @@ struct target_statfs64 {
#define TARGET_F_SETOWN 24 /* for sockets. */
#define TARGET_F_GETOWN 23 /* for sockets. */
#elif defined(TARGET_HPPA)
+#define TARGET_F_RDLCK 1
+#define TARGET_F_WRLCK 2
+#define TARGET_F_UNLCK 3
#define TARGET_F_GETLK 5
#define TARGET_F_SETLK 6
#define TARGET_F_SETLKW 7
--
2.14.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PULL 07/15] linux-user: Handle TARGET_MAP_STACK and TARGET_MAP_HUGETLB
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
` (5 preceding siblings ...)
2017-11-20 21:21 ` [Qemu-devel] [PULL 06/15] linux-user/hppa: Fix TARGET_F_RDLCK, TARGET_F_WRLCK, TARGET_F_UNLCK riku.voipio
@ 2017-11-20 21:21 ` riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 08/15] linux-user/syscall.c: Handle SH4's exceptional alignment for p{read, write}64 riku.voipio
` (10 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: riku.voipio @ 2017-11-20 21:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Helge Deller
From: Helge Deller <deller@gmx.de>
Add the missing defines and for TARGET_MAP_STACK and TARGET_MAP_HUGETLB
for alpha, mips, ppc, x86, hppa. Fix the mmap_flags translation table
to translate MAP_HUGETLB between host and target architecture, and to
drop MAP_STACK.
Signed-off-by: Helge Deller <deller@gmx.de>
Message-Id: <20170311183016.GA20514@ls3530.fritz.box>
[rth: Drop MAP_STACK instead of translating it, since it is ignored
in the kernel anyway. Fix tabs to spaces.]
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 31 ++++++++++++++++++++-----------
linux-user/syscall_defs.h | 10 ++++++++++
2 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d4497dec5d..8047bf3aac 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5872,17 +5872,26 @@ static const StructEntry struct_termios_def = {
};
static bitmask_transtbl mmap_flags_tbl[] = {
- { TARGET_MAP_SHARED, TARGET_MAP_SHARED, MAP_SHARED, MAP_SHARED },
- { TARGET_MAP_PRIVATE, TARGET_MAP_PRIVATE, MAP_PRIVATE, MAP_PRIVATE },
- { TARGET_MAP_FIXED, TARGET_MAP_FIXED, MAP_FIXED, MAP_FIXED },
- { TARGET_MAP_ANONYMOUS, TARGET_MAP_ANONYMOUS, MAP_ANONYMOUS, MAP_ANONYMOUS },
- { TARGET_MAP_GROWSDOWN, TARGET_MAP_GROWSDOWN, MAP_GROWSDOWN, MAP_GROWSDOWN },
- { TARGET_MAP_DENYWRITE, TARGET_MAP_DENYWRITE, MAP_DENYWRITE, MAP_DENYWRITE },
- { TARGET_MAP_EXECUTABLE, TARGET_MAP_EXECUTABLE, MAP_EXECUTABLE, MAP_EXECUTABLE },
- { TARGET_MAP_LOCKED, TARGET_MAP_LOCKED, MAP_LOCKED, MAP_LOCKED },
- { TARGET_MAP_NORESERVE, TARGET_MAP_NORESERVE, MAP_NORESERVE,
- MAP_NORESERVE },
- { 0, 0, 0, 0 }
+ { TARGET_MAP_SHARED, TARGET_MAP_SHARED, MAP_SHARED, MAP_SHARED },
+ { TARGET_MAP_PRIVATE, TARGET_MAP_PRIVATE, MAP_PRIVATE, MAP_PRIVATE },
+ { TARGET_MAP_FIXED, TARGET_MAP_FIXED, MAP_FIXED, MAP_FIXED },
+ { TARGET_MAP_ANONYMOUS, TARGET_MAP_ANONYMOUS,
+ MAP_ANONYMOUS, MAP_ANONYMOUS },
+ { TARGET_MAP_GROWSDOWN, TARGET_MAP_GROWSDOWN,
+ MAP_GROWSDOWN, MAP_GROWSDOWN },
+ { TARGET_MAP_DENYWRITE, TARGET_MAP_DENYWRITE,
+ MAP_DENYWRITE, MAP_DENYWRITE },
+ { TARGET_MAP_EXECUTABLE, TARGET_MAP_EXECUTABLE,
+ MAP_EXECUTABLE, MAP_EXECUTABLE },
+ { TARGET_MAP_LOCKED, TARGET_MAP_LOCKED, MAP_LOCKED, MAP_LOCKED },
+ { TARGET_MAP_NORESERVE, TARGET_MAP_NORESERVE,
+ MAP_NORESERVE, MAP_NORESERVE },
+ { TARGET_MAP_HUGETLB, TARGET_MAP_HUGETLB, MAP_HUGETLB, MAP_HUGETLB },
+ /* MAP_STACK had been ignored by the kernel for quite some time.
+ Recognize it for the target insofar as we do not want to pass
+ it through to the host. */
+ { TARGET_MAP_STACK, TARGET_MAP_STACK, 0, 0 },
+ { 0, 0, 0, 0 }
};
#if defined(TARGET_I386)
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index daa2a57398..bec3680b94 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -1353,6 +1353,8 @@ struct target_winsize {
#define TARGET_MAP_NORESERVE 0x0400 /* don't check for reservations */
#define TARGET_MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
#define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
+#define TARGET_MAP_STACK 0x40000 /* ignored */
+#define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
#elif defined(TARGET_PPC)
#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
#define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
@@ -1363,6 +1365,8 @@ struct target_winsize {
#define TARGET_MAP_NORESERVE 0x0040 /* don't check for reservations */
#define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
#define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */
+#define TARGET_MAP_STACK 0x20000 /* ignored */
+#define TARGET_MAP_HUGETLB 0x40000 /* create a huge page mapping */
#elif defined(TARGET_ALPHA)
#define TARGET_MAP_ANONYMOUS 0x10 /* don't use a file */
#define TARGET_MAP_FIXED 0x100 /* Interpret addr exactly */
@@ -1373,6 +1377,8 @@ struct target_winsize {
#define TARGET_MAP_NORESERVE 0x10000 /* no check for reservations */
#define TARGET_MAP_POPULATE 0x20000 /* pop (prefault) pagetables */
#define TARGET_MAP_NONBLOCK 0x40000 /* do not block on IO */
+#define TARGET_MAP_STACK 0x80000 /* ignored */
+#define TARGET_MAP_HUGETLB 0x100000 /* create a huge page mapping */
#elif defined(TARGET_HPPA)
#define TARGET_MAP_ANONYMOUS 0x10 /* don't use a file */
#define TARGET_MAP_FIXED 0x04 /* Interpret addr exactly */
@@ -1383,6 +1389,8 @@ struct target_winsize {
#define TARGET_MAP_NORESERVE 0x04000 /* no check for reservations */
#define TARGET_MAP_POPULATE 0x10000 /* pop (prefault) pagetables */
#define TARGET_MAP_NONBLOCK 0x20000 /* do not block on IO */
+#define TARGET_MAP_STACK 0x40000 /* ignored */
+#define TARGET_MAP_HUGETLB 0x80000 /* create a huge page mapping */
#else
#define TARGET_MAP_FIXED 0x10 /* Interpret addr exactly */
#define TARGET_MAP_ANONYMOUS 0x20 /* don't use a file */
@@ -1393,6 +1401,8 @@ struct target_winsize {
#define TARGET_MAP_NORESERVE 0x4000 /* don't check for reservations */
#define TARGET_MAP_POPULATE 0x8000 /* populate (prefault) pagetables */
#define TARGET_MAP_NONBLOCK 0x10000 /* do not block on IO */
+#define TARGET_MAP_STACK 0x20000 /* ignored */
+#define TARGET_MAP_HUGETLB 0x40000 /* create a huge page mapping */
#define TARGET_MAP_UNINITIALIZED 0x4000000 /* for anonymous mmap, memory could be uninitialized */
#endif
--
2.14.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PULL 08/15] linux-user/syscall.c: Handle SH4's exceptional alignment for p{read, write}64
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
` (6 preceding siblings ...)
2017-11-20 21:21 ` [Qemu-devel] [PULL 07/15] linux-user: Handle TARGET_MAP_STACK and TARGET_MAP_HUGETLB riku.voipio
@ 2017-11-20 21:21 ` riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 09/15] linux-user: fix 'finshed' typo in comment riku.voipio
` (9 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: riku.voipio @ 2017-11-20 21:21 UTC (permalink / raw)
To: qemu-devel; +Cc: James Clarke
From: James Clarke <jrtc27@jrtc27.com>
Fixes: https://bugs.launchpad.net/qemu/+bug/1716767
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-By: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 36 +++++++++++++++++++++++++-----------
1 file changed, 25 insertions(+), 11 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8047bf3aac..9268c3ef69 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -671,18 +671,32 @@ static inline int next_free_host_timer(void)
/* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */
#ifdef TARGET_ARM
-static inline int regpairs_aligned(void *cpu_env) {
+static inline int regpairs_aligned(void *cpu_env, int num)
+{
return ((((CPUARMState *)cpu_env)->eabi) == 1) ;
}
#elif defined(TARGET_MIPS) && (TARGET_ABI_BITS == 32)
-static inline int regpairs_aligned(void *cpu_env) { return 1; }
+static inline int regpairs_aligned(void *cpu_env, int num) { return 1; }
#elif defined(TARGET_PPC) && !defined(TARGET_PPC64)
/* SysV AVI for PPC32 expects 64bit parameters to be passed on odd/even pairs
* of registers which translates to the same as ARM/MIPS, because we start with
* r3 as arg1 */
-static inline int regpairs_aligned(void *cpu_env) { return 1; }
+static inline int regpairs_aligned(void *cpu_env, int num) { return 1; }
+#elif defined(TARGET_SH4)
+/* SH4 doesn't align register pairs, except for p{read,write}64 */
+static inline int regpairs_aligned(void *cpu_env, int num)
+{
+ switch (num) {
+ case TARGET_NR_pread64:
+ case TARGET_NR_pwrite64:
+ return 1;
+
+ default:
+ return 0;
+ }
+}
#else
-static inline int regpairs_aligned(void *cpu_env) { return 0; }
+static inline int regpairs_aligned(void *cpu_env, int num) { return 0; }
#endif
#define ERRNO_TABLE_SIZE 1200
@@ -6870,7 +6884,7 @@ static inline abi_long target_truncate64(void *cpu_env, const char *arg1,
abi_long arg3,
abi_long arg4)
{
- if (regpairs_aligned(cpu_env)) {
+ if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) {
arg2 = arg3;
arg3 = arg4;
}
@@ -6884,7 +6898,7 @@ static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1,
abi_long arg3,
abi_long arg4)
{
- if (regpairs_aligned(cpu_env)) {
+ if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) {
arg2 = arg3;
arg3 = arg4;
}
@@ -10508,7 +10522,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#endif
#ifdef TARGET_NR_pread64
case TARGET_NR_pread64:
- if (regpairs_aligned(cpu_env)) {
+ if (regpairs_aligned(cpu_env, num)) {
arg4 = arg5;
arg5 = arg6;
}
@@ -10518,7 +10532,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
unlock_user(p, arg2, ret);
break;
case TARGET_NR_pwrite64:
- if (regpairs_aligned(cpu_env)) {
+ if (regpairs_aligned(cpu_env, num)) {
arg4 = arg5;
arg5 = arg6;
}
@@ -11288,7 +11302,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
arg6 = ret;
#else
/* 6 args: fd, offset (high, low), len (high, low), advice */
- if (regpairs_aligned(cpu_env)) {
+ if (regpairs_aligned(cpu_env, num)) {
/* offset is in (3,4), len in (5,6) and advice in 7 */
arg2 = arg3;
arg3 = arg4;
@@ -11307,7 +11321,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#ifdef TARGET_NR_fadvise64
case TARGET_NR_fadvise64:
/* 5 args: fd, offset (high, low), len, advice */
- if (regpairs_aligned(cpu_env)) {
+ if (regpairs_aligned(cpu_env, num)) {
/* offset is in (3,4), len in 5 and advice in 6 */
arg2 = arg3;
arg3 = arg4;
@@ -11420,7 +11434,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#ifdef TARGET_NR_readahead
case TARGET_NR_readahead:
#if TARGET_ABI_BITS == 32
- if (regpairs_aligned(cpu_env)) {
+ if (regpairs_aligned(cpu_env, num)) {
arg2 = arg3;
arg3 = arg4;
arg4 = arg5;
--
2.14.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PULL 09/15] linux-user: fix 'finshed' typo in comment
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
` (7 preceding siblings ...)
2017-11-20 21:21 ` [Qemu-devel] [PULL 08/15] linux-user/syscall.c: Handle SH4's exceptional alignment for p{read, write}64 riku.voipio
@ 2017-11-20 21:21 ` riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 10/15] linux-user: return EINVAL from prctl(PR_*_SECCOMP) riku.voipio
` (8 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: riku.voipio @ 2017-11-20 21:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Emilio G. Cota
From: "Emilio G. Cota" <cota@braap.org>
Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 9268c3ef69..84e123b67b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6258,7 +6258,7 @@ static void *clone_func(void *arg)
pthread_mutex_lock(&info->mutex);
pthread_cond_broadcast(&info->cond);
pthread_mutex_unlock(&info->mutex);
- /* Wait until the parent has finshed initializing the tls state. */
+ /* Wait until the parent has finished initializing the tls state. */
pthread_mutex_lock(&clone_lock);
pthread_mutex_unlock(&clone_lock);
cpu_loop(env);
--
2.14.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PULL 10/15] linux-user: return EINVAL from prctl(PR_*_SECCOMP)
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
` (8 preceding siblings ...)
2017-11-20 21:21 ` [Qemu-devel] [PULL 09/15] linux-user: fix 'finshed' typo in comment riku.voipio
@ 2017-11-20 21:21 ` riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 11/15] linux-user/s390x: Mask si_addr for SIGSEGV riku.voipio
` (7 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: riku.voipio @ 2017-11-20 21:21 UTC (permalink / raw)
To: qemu-devel; +Cc: James Cowgill
From: James Cowgill <james.cowgill@mips.com>
If an application tries to install a seccomp filter using
prctl(PR_SET_SECCOMP), the filter is likely for the target instead of the host
architecture. This will probably cause qemu to be immediately killed when it
executes another syscall.
Prevent this from happening by returning EINVAL from both seccomp prctl
calls. This is the error returned by the kernel when seccomp support is
disabled.
Fixes: https://bugs.launchpad.net/qemu/+bug/1726394
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: James Cowgill <james.cowgill@mips.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 84e123b67b..f31b853bb7 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -10505,6 +10505,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
break;
}
#endif
+ case PR_GET_SECCOMP:
+ case PR_SET_SECCOMP:
+ /* Disable seccomp to prevent the target disabling syscalls we
+ * need. */
+ ret = -TARGET_EINVAL;
+ break;
default:
/* Most prctl options have no pointer arguments */
ret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5));
--
2.14.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PULL 11/15] linux-user/s390x: Mask si_addr for SIGSEGV
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
` (9 preceding siblings ...)
2017-11-20 21:21 ` [Qemu-devel] [PULL 10/15] linux-user: return EINVAL from prctl(PR_*_SECCOMP) riku.voipio
@ 2017-11-20 21:21 ` riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 12/15] linux-user/ppc: Report correct fault address for data faults riku.voipio
` (6 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: riku.voipio @ 2017-11-20 21:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell
From: Peter Maydell <peter.maydell@linaro.org>
For s390x, the address passed to a signal handler in the
siginfo_t si_addr field is masked (in the kernel this is done in
do_sigbus() and do_sigsegv() in arch/s390/mm/fault.c). Implement
this architecture-specific oddity in linux-user.
This is one of the issues described in
https://bugs.launchpad.net/qemu/+bug/1705118
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/main.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index aa02f25b85..b6dd9efd2d 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3238,6 +3238,10 @@ void cpu_loop(CPUAlphaState *env)
#endif /* TARGET_ALPHA */
#ifdef TARGET_S390X
+
+/* s390x masks the fault address it reports in si_addr for SIGSEGV and SIGBUS */
+#define S390X_FAIL_ADDR_MASK -4096LL
+
void cpu_loop(CPUS390XState *env)
{
CPUState *cs = CPU(s390_env_get_cpu(env));
@@ -3294,7 +3298,7 @@ void cpu_loop(CPUS390XState *env)
sig = TARGET_SIGSEGV;
/* XXX: check env->error_code */
n = TARGET_SEGV_MAPERR;
- addr = env->__excp_addr;
+ addr = env->__excp_addr & S390X_FAIL_ADDR_MASK;
goto do_signal;
case PGM_EXECUTE:
case PGM_SPECIFICATION:
--
2.14.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PULL 12/15] linux-user/ppc: Report correct fault address for data faults
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
` (10 preceding siblings ...)
2017-11-20 21:21 ` [Qemu-devel] [PULL 11/15] linux-user/s390x: Mask si_addr for SIGSEGV riku.voipio
@ 2017-11-20 21:21 ` riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 13/15] linux-user/sparc: Put address for data faults where linux-user expects it riku.voipio
` (5 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: riku.voipio @ 2017-11-20 21:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell
From: Peter Maydell <peter.maydell@linaro.org>
For faults on loads and stores, ppc_cpu_handle_mmu_fault() in
target/ppc/user_only_helper.c stores the offending address
in env->spr[SPR_DAR]. Report this correctly to the guest
in si_addr, rather than incorrectly using the address of the
instruction that caused the fault.
This fixes the test case in
https://bugs.launchpad.net/qemu/+bug/1077116
for ppc, ppc64 and ppc64le.
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index b6dd9efd2d..6286661bd3 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -1420,7 +1420,7 @@ void cpu_loop(CPUPPCState *env)
info.si_code = TARGET_SEGV_MAPERR;
break;
}
- info._sifields._sigfault._addr = env->nip;
+ info._sifields._sigfault._addr = env->spr[SPR_DAR];
queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
break;
case POWERPC_EXCP_ISI: /* Instruction storage exception */
--
2.14.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PULL 13/15] linux-user/sparc: Put address for data faults where linux-user expects it
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
` (11 preceding siblings ...)
2017-11-20 21:21 ` [Qemu-devel] [PULL 12/15] linux-user/ppc: Report correct fault address for data faults riku.voipio
@ 2017-11-20 21:21 ` riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 14/15] linux-user: Handle rt_sigaction correctly for SPARC riku.voipio
` (4 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: riku.voipio @ 2017-11-20 21:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell
From: Peter Maydell <peter.maydell@linaro.org>
In the user-mode-only version of sparc_cpu_handle_mmu_fault(),
we must save the fault address for a data fault into the CPU
state's mmu registers, because the code in linux-user/main.c
expects to find it there in order to populate the si_addr
field of the guest siginfo.
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
target/sparc/mmu_helper.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c
index 126ea5e3ee..d5b6c1e48c 100644
--- a/target/sparc/mmu_helper.c
+++ b/target/sparc/mmu_helper.c
@@ -30,10 +30,18 @@
int sparc_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int rw,
int mmu_idx)
{
+ SPARCCPU *cpu = SPARC_CPU(cs);
+ CPUSPARCState *env = &cpu->env;
+
if (rw & 2) {
cs->exception_index = TT_TFAULT;
} else {
cs->exception_index = TT_DFAULT;
+#ifdef TARGET_SPARC64
+ env->dmmu.mmuregs[4] = address;
+#else
+ env->mmuregs[4] = address;
+#endif
}
return 1;
}
--
2.14.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PULL 14/15] linux-user: Handle rt_sigaction correctly for SPARC
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
` (12 preceding siblings ...)
2017-11-20 21:21 ` [Qemu-devel] [PULL 13/15] linux-user/sparc: Put address for data faults where linux-user expects it riku.voipio
@ 2017-11-20 21:21 ` riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 15/15] linux-user: Fix calculation of auxv length riku.voipio
` (3 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: riku.voipio @ 2017-11-20 21:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell
From: Peter Maydell <peter.maydell@linaro.org>
SPARC is like Alpha in its handling of the rt_sigaction syscall:
it takes an extra parameter 'restorer' which needs to be copied
into the sa_restorer field of the sigaction struct. The order
of the arguments differs slightly between SPARC and Alpha but
the implementation is otherwise the same. (Compare the
rt_sigaction() functions in arch/sparc/kernel/sys_sparc_64.c
and arch/alpha/kernel/signal.c.)
Note that this change is somewhat moot until SPARC acquires
support for actually delivering RT signals.
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f31b853bb7..11c9116c4a 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8579,8 +8579,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
case TARGET_NR_rt_sigaction:
{
#if defined(TARGET_ALPHA)
- struct target_sigaction act, oact, *pact = 0;
+ /* For Alpha and SPARC this is a 5 argument syscall, with
+ * a 'restorer' parameter which must be copied into the
+ * sa_restorer field of the sigaction struct.
+ * For Alpha that 'restorer' is arg5; for SPARC it is arg4,
+ * and arg5 is the sigsetsize.
+ * Alpha also has a separate rt_sigaction struct that it uses
+ * here; SPARC uses the usual sigaction struct.
+ */
struct target_rt_sigaction *rt_act;
+ struct target_sigaction act, oact, *pact = 0;
if (arg4 != sizeof(target_sigset_t)) {
ret = -TARGET_EINVAL;
@@ -8606,18 +8614,29 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
unlock_user_struct(rt_act, arg3, 1);
}
#else
+#ifdef TARGET_SPARC
+ target_ulong restorer = arg4;
+ target_ulong sigsetsize = arg5;
+#else
+ target_ulong sigsetsize = arg4;
+#endif
struct target_sigaction *act;
struct target_sigaction *oact;
- if (arg4 != sizeof(target_sigset_t)) {
+ if (sigsetsize != sizeof(target_sigset_t)) {
ret = -TARGET_EINVAL;
break;
}
if (arg2) {
- if (!lock_user_struct(VERIFY_READ, act, arg2, 1))
+ if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) {
goto efault;
- } else
+ }
+#ifdef TARGET_SPARC
+ act->sa_restorer = restorer;
+#endif
+ } else {
act = NULL;
+ }
if (arg3) {
if (!lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) {
ret = -TARGET_EFAULT;
--
2.14.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PULL 15/15] linux-user: Fix calculation of auxv length
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
` (13 preceding siblings ...)
2017-11-20 21:21 ` [Qemu-devel] [PULL 14/15] linux-user: Handle rt_sigaction correctly for SPARC riku.voipio
@ 2017-11-20 21:21 ` riku.voipio
2017-11-20 21:36 ` [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 no-reply
` (2 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: riku.voipio @ 2017-11-20 21:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell
From: Peter Maydell <peter.maydell@linaro.org>
In commit 7c4ee5bcc82e643 we changed the order in which we construct
the AUXV, but forgot to adjust the calculation of the length. The
result is that we set info->auxv_len to a bogus and negative value,
and then later on the code in open_self_auxv() gets confused and
ends up presenting the guest with an empty file.
Since we now have to calculate the auxv length up-front as part
of figuring out how much we're going to put on the stack, set
info->auxv_len then; this allows us to assert that we put the
same number of entries into auxv as we pre-calculated, rather
than merely having a comment saying we need to do that.
Fixes: https://bugs.launchpad.net/qemu/+bug/1728116
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/elfload.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 3b857fbc9c..20f3d8c2c3 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1732,6 +1732,8 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
#ifdef ELF_HWCAP2
size += 2;
#endif
+ info->auxv_len = size * n;
+
size += envc + argc + 2;
size += 1; /* argc itself */
size *= n;
@@ -1760,7 +1762,6 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
put_user_ual(val, u_auxv); u_auxv += n; \
} while(0)
- /* There must be exactly DLINFO_ITEMS entries here. */
#ifdef ARCH_DLINFO
/*
* ARCH_DLINFO must come first so platform specific code can enforce
@@ -1768,6 +1769,9 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
*/
ARCH_DLINFO;
#endif
+ /* There must be exactly DLINFO_ITEMS entries here, or the assert
+ * on info->auxv_len will trigger.
+ */
NEW_AUX_ENT(AT_PHDR, (abi_ulong)(info->load_addr + exec->e_phoff));
NEW_AUX_ENT(AT_PHENT, (abi_ulong)(sizeof (struct elf_phdr)));
NEW_AUX_ENT(AT_PHNUM, (abi_ulong)(exec->e_phnum));
@@ -1793,7 +1797,10 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
NEW_AUX_ENT (AT_NULL, 0);
#undef NEW_AUX_ENT
- info->auxv_len = u_argv - info->saved_auxv;
+ /* Check that our initial calculation of the auxv length matches how much
+ * we actually put into it.
+ */
+ assert(info->auxv_len == u_auxv - info->saved_auxv);
put_user_ual(argc, u_argc);
--
2.14.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
` (14 preceding siblings ...)
2017-11-20 21:21 ` [Qemu-devel] [PULL 15/15] linux-user: Fix calculation of auxv length riku.voipio
@ 2017-11-20 21:36 ` no-reply
2017-11-20 21:36 ` no-reply
2017-11-21 11:19 ` Peter Maydell
17 siblings, 0 replies; 19+ messages in thread
From: no-reply @ 2017-11-20 21:36 UTC (permalink / raw)
To: riku.voipio; +Cc: famz, qemu-devel
Hi,
This series seems to have some coding style problems. See output below for
more information:
Subject: [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11
Type: series
Message-id: cover.1511212753.git.riku.voipio@linaro.org
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))
done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
t [tag update] patchew/1511201308-23580-1-git-send-email-peter.maydell@linaro.org -> patchew/1511201308-23580-1-git-send-email-peter.maydell@linaro.org
t [tag update] patchew/20171117190422.23626-1-eblake@redhat.com -> patchew/20171117190422.23626-1-eblake@redhat.com
* [new tag] patchew/cover.1511212753.git.riku.voipio@linaro.org -> patchew/cover.1511212753.git.riku.voipio@linaro.org
Switched to a new branch 'test'
788f1bba45 linux-user: Fix calculation of auxv length
052a0df24b linux-user: Handle rt_sigaction correctly for SPARC
f604e7242e linux-user/sparc: Put address for data faults where linux-user expects it
72147cb49c linux-user/ppc: Report correct fault address for data faults
e463bfe01b linux-user/s390x: Mask si_addr for SIGSEGV
453566e577 linux-user: return EINVAL from prctl(PR_*_SECCOMP)
fa4841c61b linux-user: fix 'finshed' typo in comment
8c79f00a62 linux-user/syscall.c: Handle SH4's exceptional alignment for p{read, write}64
00aa6fca9b linux-user: Handle TARGET_MAP_STACK and TARGET_MAP_HUGETLB
0404230a13 linux-user/hppa: Fix TARGET_F_RDLCK, TARGET_F_WRLCK, TARGET_F_UNLCK
843644155e linux-user/hppa: Fix TARGET_MAP_TYPE
928786ff34 linux-user/hppa: Fix typo for TARGET_NR_epoll_wait
244abacff6 linux-user/hppa: Fix cpu_clone_regs
63e9a64d06 linux-user/hppa: Fix TARGET_SA_* defines
46e4119671 linux-user: Restrict usage of sa_restorer
=== OUTPUT BEGIN ===
Checking PATCH 1/15: linux-user: Restrict usage of sa_restorer...
Checking PATCH 2/15: linux-user/hppa: Fix TARGET_SA_* defines...
Checking PATCH 3/15: linux-user/hppa: Fix cpu_clone_regs...
Checking PATCH 4/15: linux-user/hppa: Fix typo for TARGET_NR_epoll_wait...
Checking PATCH 5/15: linux-user/hppa: Fix TARGET_MAP_TYPE...
ERROR: code indent should never use tabs
#25: FILE: linux-user/syscall_defs.h:1340:
+#define TARGET_MAP_TYPE 0x03^I^I/* Mask for type of mapping */$
ERROR: code indent should never use tabs
#27: FILE: linux-user/syscall_defs.h:1342:
+#define TARGET_MAP_TYPE 0x0f^I^I/* Mask for type of mapping */$
total: 2 errors, 0 warnings, 12 lines checked
Your patch has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 6/15: linux-user/hppa: Fix TARGET_F_RDLCK, TARGET_F_WRLCK, TARGET_F_UNLCK...
Checking PATCH 7/15: linux-user: Handle TARGET_MAP_STACK and TARGET_MAP_HUGETLB...
Checking PATCH 8/15: linux-user/syscall.c: Handle SH4's exceptional alignment for p{read, write}64...
Checking PATCH 9/15: linux-user: fix 'finshed' typo in comment...
Checking PATCH 10/15: linux-user: return EINVAL from prctl(PR_*_SECCOMP)...
Checking PATCH 11/15: linux-user/s390x: Mask si_addr for SIGSEGV...
Checking PATCH 12/15: linux-user/ppc: Report correct fault address for data faults...
Checking PATCH 13/15: linux-user/sparc: Put address for data faults where linux-user expects it...
Checking PATCH 14/15: linux-user: Handle rt_sigaction correctly for SPARC...
Checking PATCH 15/15: linux-user: Fix calculation of auxv length...
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
` (15 preceding siblings ...)
2017-11-20 21:36 ` [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 no-reply
@ 2017-11-20 21:36 ` no-reply
2017-11-21 11:19 ` Peter Maydell
17 siblings, 0 replies; 19+ messages in thread
From: no-reply @ 2017-11-20 21:36 UTC (permalink / raw)
To: riku.voipio; +Cc: famz, qemu-devel
Hi,
This series failed build test on ppc host. Please find the details below.
Type: series
Subject: [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11
Message-id: cover.1511212753.git.riku.voipio@linaro.org
=== TEST SCRIPT BEGIN ===
#!/bin/bash
# Testing script will be invoked under the git checkout with
# HEAD pointing to a commit that has the patches applied on top of "base"
# branch
set -e
echo "=== ENV ==="
env
echo "=== PACKAGES ==="
rpm -qa
echo "=== TEST BEGIN ==="
INSTALL=$PWD/install
BUILD=$PWD/build
mkdir -p $BUILD $INSTALL
SRC=$PWD
cd $BUILD
$SRC/configure --prefix=$INSTALL
make -j100
# XXX: we need reliable clean up
# make check -j100 V=1
make install
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
error: RPC failed; result=18, HTTP code = 200
fatal: The remote end hung up unexpectedly
error: Could not fetch 3c8cf5a9c21ff8782164d1def7f44bd888713384
Traceback (most recent call last):
File "/home/patchew/patchew/patchew-cli", line 504, in test_one
git_clone_repo(clone, r["repo"], r["head"], logf)
File "/home/patchew/patchew/patchew-cli", line 48, in git_clone_repo
stdout=logf, stderr=logf)
File "/usr/lib64/python3.4/subprocess.py", line 558, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', 'remote', 'add', '-f', '--mirror=fetch', '3c8cf5a9c21ff8782164d1def7f44bd888713384', 'https://github.com/patchew-project/qemu']' returned non-zero exit status 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
` (16 preceding siblings ...)
2017-11-20 21:36 ` no-reply
@ 2017-11-21 11:19 ` Peter Maydell
17 siblings, 0 replies; 19+ messages in thread
From: Peter Maydell @ 2017-11-21 11:19 UTC (permalink / raw)
To: Riku Voipio; +Cc: QEMU Developers
On 20 November 2017 at 21:21, <riku.voipio@linaro.org> wrote:
> From: Riku Voipio <riku.voipio@linaro.org>
>
> The following changes since commit b0fbe46ad82982b289a44ee2495b59b0bad8a842:
>
> Update version for v2.11.0-rc0 release (2017-11-07 16:05:28 +0000)
>
> are available in the git repository at:
>
> git://git.linaro.org/people/riku.voipio/qemu.git tags/pull-linux-user-20171120
>
> for you to fetch changes up to f516511ea84d8bb3395d6ea95a7c7b80dc2a05e9:
>
> linux-user: Fix calculation of auxv length (2017-11-20 16:15:41 +0200)
>
> ----------------------------------------------------------------
> late linux-user fixes for Qemu 2.11
>
> ----------------------------------------------------------------
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2017-11-21 13:23 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-20 21:21 [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 01/15] linux-user: Restrict usage of sa_restorer riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 02/15] linux-user/hppa: Fix TARGET_SA_* defines riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 03/15] linux-user/hppa: Fix cpu_clone_regs riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 04/15] linux-user/hppa: Fix typo for TARGET_NR_epoll_wait riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 05/15] linux-user/hppa: Fix TARGET_MAP_TYPE riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 06/15] linux-user/hppa: Fix TARGET_F_RDLCK, TARGET_F_WRLCK, TARGET_F_UNLCK riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 07/15] linux-user: Handle TARGET_MAP_STACK and TARGET_MAP_HUGETLB riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 08/15] linux-user/syscall.c: Handle SH4's exceptional alignment for p{read, write}64 riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 09/15] linux-user: fix 'finshed' typo in comment riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 10/15] linux-user: return EINVAL from prctl(PR_*_SECCOMP) riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 11/15] linux-user/s390x: Mask si_addr for SIGSEGV riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 12/15] linux-user/ppc: Report correct fault address for data faults riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 13/15] linux-user/sparc: Put address for data faults where linux-user expects it riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 14/15] linux-user: Handle rt_sigaction correctly for SPARC riku.voipio
2017-11-20 21:21 ` [Qemu-devel] [PULL 15/15] linux-user: Fix calculation of auxv length riku.voipio
2017-11-20 21:36 ` [Qemu-devel] [PULL 00/15] late linux-user fixes for 2.11 no-reply
2017-11-20 21:36 ` no-reply
2017-11-21 11:19 ` Peter Maydell
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).