* [PULL 0/4] Linux user for 7.2 patches
@ 2022-11-03 8:49 Laurent Vivier
2022-11-03 8:49 ` [PULL 1/4] linux-user/hppa: Detect glibc ABORT_INSTRUCTION and EXCP_BREAK handler Laurent Vivier
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Laurent Vivier @ 2022-11-03 8:49 UTC (permalink / raw)
To: qemu-devel; +Cc: Laurent Vivier
The following changes since commit a11f65ec1b8adcb012b89c92819cbda4dc25aaf1:
Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging (2022-11-01 13:49:33 -0400)
are available in the Git repository at:
https://gitlab.com/laurent_vivier/qemu.git tags/linux-user-for-7.2-pull-request
for you to fetch changes up to 16c81dd563b94e9392a578ccf5aa762d01e8f165:
linux-user: always translate cmsg when recvmsg (2022-11-02 17:29:17 +0100)
----------------------------------------------------------------
linux-user pull request 20221103
Fix recvmsg
Fix hppa exception handler
Add close_range
Add strace for timer_settime64
----------------------------------------------------------------
Helge Deller (3):
linux-user/hppa: Detect glibc ABORT_INSTRUCTION and EXCP_BREAK handler
linux-user: Add close_range() syscall
linux-user: Add strace output for timer_settime64() syscall
Icenowy Zheng (1):
linux-user: always translate cmsg when recvmsg
linux-user/hppa/cpu_loop.c | 19 ++++++++++++++-----
linux-user/strace.list | 8 +++++++-
linux-user/syscall.c | 22 +++++++++++++++++++++-
3 files changed, 42 insertions(+), 7 deletions(-)
--
2.37.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PULL 1/4] linux-user/hppa: Detect glibc ABORT_INSTRUCTION and EXCP_BREAK handler
2022-11-03 8:49 [PULL 0/4] Linux user for 7.2 patches Laurent Vivier
@ 2022-11-03 8:49 ` Laurent Vivier
2022-11-03 8:49 ` [PULL 2/4] linux-user: Add close_range() syscall Laurent Vivier
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Laurent Vivier @ 2022-11-03 8:49 UTC (permalink / raw)
To: qemu-devel; +Cc: Laurent Vivier, Helge Deller
From: Helge Deller <deller@gmx.de>
The glibc on the hppa platform uses the "iitlbp %r0,(%sr0, %r0)"
assembler instruction as ABORT_INSTRUCTION.
If this (in userspace context) illegal assembler statement is found,
dump the registers and report the failure to userspace the same way as
the Linux kernel on physical hardware.
For other illegal instructions report TARGET_ILL_ILLOPC instead of
TARGET_ILL_ILLOPN as si_code.
Additionally add the missing EXCP_BREAK exception handler which occurs
when the "break x,y" assembler instruction is executed and report
EXCP_ASSIST traps.
Signed-off-by: Helge Deller <deller@gmx.de>
Message-Id: <Y1osHVsylkuZNUnY@p100>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/hppa/cpu_loop.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c
index 1ef3b461911c..8ab133510602 100644
--- a/linux-user/hppa/cpu_loop.c
+++ b/linux-user/hppa/cpu_loop.c
@@ -147,15 +147,20 @@ void cpu_loop(CPUHPPAState *env)
force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, env->iaoq_f);
break;
case EXCP_ILL:
- EXCP_DUMP(env, "qemu: got CPU exception 0x%x - aborting\n", trapnr);
- force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, env->iaoq_f);
+ EXCP_DUMP(env, "qemu: EXCP_ILL exception %#x\n", trapnr);
+ force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC, env->iaoq_f);
break;
case EXCP_PRIV_OPR:
- EXCP_DUMP(env, "qemu: got CPU exception 0x%x - aborting\n", trapnr);
- force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVOPC, env->iaoq_f);
+ /* check for glibc ABORT_INSTRUCTION "iitlbp %r0,(%sr0, %r0)" */
+ EXCP_DUMP(env, "qemu: EXCP_PRIV_OPR exception %#x\n", trapnr);
+ if (env->cr[CR_IIR] == 0x04000000) {
+ force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC, env->iaoq_f);
+ } else {
+ force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVOPC, env->iaoq_f);
+ }
break;
case EXCP_PRIV_REG:
- EXCP_DUMP(env, "qemu: got CPU exception 0x%x - aborting\n", trapnr);
+ EXCP_DUMP(env, "qemu: EXCP_PRIV_REG exception %#x\n", trapnr);
force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVREG, env->iaoq_f);
break;
case EXCP_OVERFLOW:
@@ -167,6 +172,10 @@ void cpu_loop(CPUHPPAState *env)
case EXCP_ASSIST:
force_sig_fault(TARGET_SIGFPE, 0, env->iaoq_f);
break;
+ case EXCP_BREAK:
+ EXCP_DUMP(env, "qemu: EXCP_BREAK exception %#x\n", trapnr);
+ force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->iaoq_f & ~3);
+ break;
case EXCP_DEBUG:
force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->iaoq_f);
break;
--
2.37.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PULL 2/4] linux-user: Add close_range() syscall
2022-11-03 8:49 [PULL 0/4] Linux user for 7.2 patches Laurent Vivier
2022-11-03 8:49 ` [PULL 1/4] linux-user/hppa: Detect glibc ABORT_INSTRUCTION and EXCP_BREAK handler Laurent Vivier
@ 2022-11-03 8:49 ` Laurent Vivier
2022-11-03 8:49 ` [PULL 3/4] linux-user: Add strace output for timer_settime64() syscall Laurent Vivier
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Laurent Vivier @ 2022-11-03 8:49 UTC (permalink / raw)
To: qemu-devel; +Cc: Laurent Vivier, Helge Deller, Richard Henderson
From: Helge Deller <deller@gmx.de>
Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <Y1dLJoEDhJ2AAYDn@p100>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/strace.list | 3 +++
linux-user/syscall.c | 19 +++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/linux-user/strace.list b/linux-user/strace.list
index 3df2184580aa..cd995e5d56db 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -103,6 +103,9 @@
#ifdef TARGET_NR_close
{ TARGET_NR_close, "close" , "%s(%d)", NULL, NULL },
#endif
+#ifdef TARGET_NR_close_range
+{ TARGET_NR_close_range, "close_range" , "%s(%u,%u,%u)", NULL, NULL },
+#endif
#ifdef TARGET_NR_connect
{ TARGET_NR_connect, "connect" , "%s(%d,%#x,%d)", NULL, NULL },
#endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8402c1399d3c..8b18adfba894 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -364,6 +364,13 @@ _syscall3(int,sys_syslog,int,type,char*,bufp,int,len)
#ifdef __NR_exit_group
_syscall1(int,exit_group,int,error_code)
#endif
+#if defined(__NR_close_range) && defined(TARGET_NR_close_range)
+#define __NR_sys_close_range __NR_close_range
+_syscall3(int,sys_close_range,int,first,int,last,int,flags)
+#ifndef CLOSE_RANGE_CLOEXEC
+#define CLOSE_RANGE_CLOEXEC (1U << 2)
+#endif
+#endif
#if defined(__NR_futex)
_syscall6(int,sys_futex,int *,uaddr,int,op,int,val,
const struct timespec *,timeout,int *,uaddr2,int,val3)
@@ -8756,6 +8763,18 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
case TARGET_NR_close:
fd_trans_unregister(arg1);
return get_errno(close(arg1));
+#if defined(__NR_close_range) && defined(TARGET_NR_close_range)
+ case TARGET_NR_close_range:
+ ret = get_errno(sys_close_range(arg1, arg2, arg3));
+ if (ret == 0 && !(arg3 & CLOSE_RANGE_CLOEXEC)) {
+ abi_long fd, maxfd;
+ maxfd = MIN(arg2, target_fd_max);
+ for (fd = arg1; fd < maxfd; fd++) {
+ fd_trans_unregister(fd);
+ }
+ }
+ return ret;
+#endif
case TARGET_NR_brk:
return do_brk(arg1);
--
2.37.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PULL 3/4] linux-user: Add strace output for timer_settime64() syscall
2022-11-03 8:49 [PULL 0/4] Linux user for 7.2 patches Laurent Vivier
2022-11-03 8:49 ` [PULL 1/4] linux-user/hppa: Detect glibc ABORT_INSTRUCTION and EXCP_BREAK handler Laurent Vivier
2022-11-03 8:49 ` [PULL 2/4] linux-user: Add close_range() syscall Laurent Vivier
@ 2022-11-03 8:49 ` Laurent Vivier
2022-11-03 8:49 ` [PULL 4/4] linux-user: always translate cmsg when recvmsg Laurent Vivier
2022-11-03 21:27 ` [PULL 0/4] Linux user for 7.2 patches Stefan Hajnoczi
4 siblings, 0 replies; 6+ messages in thread
From: Laurent Vivier @ 2022-11-03 8:49 UTC (permalink / raw)
To: qemu-devel; +Cc: Laurent Vivier, Helge Deller
From: Helge Deller <deller@gmx.de>
Add missing timer_settime64() strace output and specify format for
timer_settime().
Signed-off-by: Helge Deller <deller@gmx.de>
Message-Id: <Y1b5eIXFoMRDcDL9@p100>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/strace.list | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/linux-user/strace.list b/linux-user/strace.list
index cd995e5d56db..3a898e2532d3 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -1534,7 +1534,10 @@
{ TARGET_NR_timer_gettime, "timer_gettime" , NULL, NULL, NULL },
#endif
#ifdef TARGET_NR_timer_settime
-{ TARGET_NR_timer_settime, "timer_settime" , NULL, NULL, NULL },
+{ TARGET_NR_timer_settime, "timer_settime" , "%s(%d,%d,%p,%p)", NULL, NULL },
+#endif
+#ifdef TARGET_NR_timer_settime64
+{ TARGET_NR_timer_settime64, "timer_settime64" , "%s(%d,%d,%p,%p)", NULL, NULL },
#endif
#ifdef TARGET_NR_timerfd
{ TARGET_NR_timerfd, "timerfd" , NULL, NULL, NULL },
--
2.37.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PULL 4/4] linux-user: always translate cmsg when recvmsg
2022-11-03 8:49 [PULL 0/4] Linux user for 7.2 patches Laurent Vivier
` (2 preceding siblings ...)
2022-11-03 8:49 ` [PULL 3/4] linux-user: Add strace output for timer_settime64() syscall Laurent Vivier
@ 2022-11-03 8:49 ` Laurent Vivier
2022-11-03 21:27 ` [PULL 0/4] Linux user for 7.2 patches Stefan Hajnoczi
4 siblings, 0 replies; 6+ messages in thread
From: Laurent Vivier @ 2022-11-03 8:49 UTC (permalink / raw)
To: qemu-devel; +Cc: Laurent Vivier, Icenowy Zheng
From: Icenowy Zheng <uwu@icenowy.me>
It's possible that a message contains both normal payload and ancillary
data in the same message, and even if no ancillary data is available
this information should be passed to the target, otherwise the target
cmsghdr will be left uninitialized and the target is going to access
uninitialized memory if it expects cmsg.
Always call the function that translate cmsg when recvmsg, because that
function should be empty-cmsg-safe (it creates an empty cmsg in the
target).
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20221028081220.1604244-1-uwu@icenowy.me>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/syscall.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8b18adfba894..24b25759beab 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3353,7 +3353,8 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
if (fd_trans_host_to_target_data(fd)) {
ret = fd_trans_host_to_target_data(fd)(msg.msg_iov->iov_base,
MIN(msg.msg_iov->iov_len, len));
- } else {
+ }
+ if (!is_error(ret)) {
ret = host_to_target_cmsg(msgp, &msg);
}
if (!is_error(ret)) {
--
2.37.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PULL 0/4] Linux user for 7.2 patches
2022-11-03 8:49 [PULL 0/4] Linux user for 7.2 patches Laurent Vivier
` (3 preceding siblings ...)
2022-11-03 8:49 ` [PULL 4/4] linux-user: always translate cmsg when recvmsg Laurent Vivier
@ 2022-11-03 21:27 ` Stefan Hajnoczi
4 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2022-11-03 21:27 UTC (permalink / raw)
To: Laurent Vivier; +Cc: qemu-devel, Laurent Vivier
[-- Attachment #1: Type: text/plain, Size: 115 bytes --]
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/7.2 for any user-visible changes.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-11-03 21:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-03 8:49 [PULL 0/4] Linux user for 7.2 patches Laurent Vivier
2022-11-03 8:49 ` [PULL 1/4] linux-user/hppa: Detect glibc ABORT_INSTRUCTION and EXCP_BREAK handler Laurent Vivier
2022-11-03 8:49 ` [PULL 2/4] linux-user: Add close_range() syscall Laurent Vivier
2022-11-03 8:49 ` [PULL 3/4] linux-user: Add strace output for timer_settime64() syscall Laurent Vivier
2022-11-03 8:49 ` [PULL 4/4] linux-user: always translate cmsg when recvmsg Laurent Vivier
2022-11-03 21:27 ` [PULL 0/4] Linux user for 7.2 patches Stefan Hajnoczi
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).