summaryrefslogtreecommitdiffstats
path: root/linux-user/syscall.c
diff options
context:
space:
mode:
authorPeter Maydell2021-05-18 17:17:22 +0200
committerPeter Maydell2021-05-18 17:17:22 +0200
commitc313e52e6459de2e9064767083a0c949c476e32b (patch)
tree9bf8c4a6927fe0c714c06c5e4967e0501a1ca335 /linux-user/syscall.c
parentMerge remote-tracking branch 'remotes/nvme/tags/nvme-next-pull-request' into ... (diff)
parentlinux-user/elfload: add s390x core dumping support (diff)
downloadqemu-c313e52e6459de2e9064767083a0c949c476e32b.tar.gz
qemu-c313e52e6459de2e9064767083a0c949c476e32b.tar.xz
qemu-c313e52e6459de2e9064767083a0c949c476e32b.zip
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-6.1-pull-request' into staging
linux-user pull request 20210517 - alpha sigaction fixes/cleanups - s390x sigaction fixes/cleanup - sparc sigaction fixes/cleanup - s390x core dumping support - core dump fix (app name) - arm fpa11 fix and cleanup - strace fixes (unshare(), llseek()) - fix copy_file_range() - use GDateTime - Remove dead code # gpg: Signature made Tue 18 May 2021 06:31:12 BST # gpg: using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C # gpg: issuer "laurent@vivier.eu" # gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full] # gpg: aka "Laurent Vivier <laurent@vivier.eu>" [full] # gpg: aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full] # Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F 5173 F30C 38BD 3F2F BE3C * remotes/vivier2/tags/linux-user-for-6.1-pull-request: (59 commits) linux-user/elfload: add s390x core dumping support linux-user/elfload: fix filling psinfo->pr_psargs linux-user: Tidy TARGET_NR_rt_sigaction linux-user/alpha: Share code for TARGET_NR_sigaction linux-user/alpha: Define TARGET_ARCH_HAS_KA_RESTORER linux-user: Honor TARGET_ARCH_HAS_SA_RESTORER in do_syscall linux-user: Pass ka_restorer to do_sigaction linux-user/alpha: Rename the sigaction restorer field linux-user/alpha: Fix rt sigframe return linux-user: use GDateTime for formatting timestamp for core file linux-user: Fix erroneous conversion in copy_file_range linux-user: Add copy_file_range to strace.list linux-user/s390x: Handle vector regs in signal stack linux-user/s390x: Clean up signal.c linux-user/s390x: Add build asserts for sigset sizes linux-user/s390x: Fix frame_addr corruption in setup_frame linux-user/s390x: Add stub sigframe argument for last_break linux-user/s390x: Set psw.mask properly for the signal handler linux-user/s390x: Clean up single-use gotos in signal.c linux-user/s390x: Tidy save_sigregs ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'linux-user/syscall.c')
-rw-r--r--linux-user/syscall.c113
1 files changed, 29 insertions, 84 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 95d79ddc43..c9f812091c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8980,29 +8980,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
#ifdef TARGET_NR_sigaction
case TARGET_NR_sigaction:
{
-#if defined(TARGET_ALPHA)
- struct target_sigaction act, oact, *pact = 0;
- struct target_old_sigaction *old_act;
- if (arg2) {
- if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
- return -TARGET_EFAULT;
- act._sa_handler = old_act->_sa_handler;
- target_siginitset(&act.sa_mask, old_act->sa_mask);
- act.sa_flags = old_act->sa_flags;
- act.sa_restorer = 0;
- unlock_user_struct(old_act, arg2, 0);
- pact = &act;
- }
- ret = get_errno(do_sigaction(arg1, pact, &oact));
- if (!is_error(ret) && arg3) {
- if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
- return -TARGET_EFAULT;
- old_act->_sa_handler = oact._sa_handler;
- old_act->sa_mask = oact.sa_mask.sig[0];
- old_act->sa_flags = oact.sa_flags;
- unlock_user_struct(old_act, arg3, 1);
- }
-#elif defined(TARGET_MIPS)
+#if defined(TARGET_MIPS)
struct target_sigaction act, oact, *pact, *old_act;
if (arg2) {
@@ -9017,7 +8995,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
pact = NULL;
}
- ret = get_errno(do_sigaction(arg1, pact, &oact));
+ ret = get_errno(do_sigaction(arg1, pact, &oact, 0));
if (!is_error(ret) && arg3) {
if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
@@ -9039,23 +9017,24 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
act._sa_handler = old_act->_sa_handler;
target_siginitset(&act.sa_mask, old_act->sa_mask);
act.sa_flags = old_act->sa_flags;
+#ifdef TARGET_ARCH_HAS_SA_RESTORER
act.sa_restorer = old_act->sa_restorer;
-#ifdef TARGET_ARCH_HAS_KA_RESTORER
- act.ka_restorer = 0;
#endif
unlock_user_struct(old_act, arg2, 0);
pact = &act;
} else {
pact = NULL;
}
- ret = get_errno(do_sigaction(arg1, pact, &oact));
+ ret = get_errno(do_sigaction(arg1, pact, &oact, 0));
if (!is_error(ret) && arg3) {
if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
return -TARGET_EFAULT;
old_act->_sa_handler = oact._sa_handler;
old_act->sa_mask = oact.sa_mask.sig[0];
old_act->sa_flags = oact.sa_flags;
+#ifdef TARGET_ARCH_HAS_SA_RESTORER
old_act->sa_restorer = oact.sa_restorer;
+#endif
unlock_user_struct(old_act, arg3, 1);
}
#endif
@@ -9064,77 +9043,43 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
#endif
case TARGET_NR_rt_sigaction:
{
-#if defined(TARGET_ALPHA)
- /* For Alpha and SPARC this is a 5 argument syscall, with
+ /*
+ * 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)) {
- return -TARGET_EINVAL;
- }
- if (arg2) {
- if (!lock_user_struct(VERIFY_READ, rt_act, arg2, 1))
- return -TARGET_EFAULT;
- act._sa_handler = rt_act->_sa_handler;
- act.sa_mask = rt_act->sa_mask;
- act.sa_flags = rt_act->sa_flags;
- act.sa_restorer = arg5;
- unlock_user_struct(rt_act, arg2, 0);
- pact = &act;
- }
- ret = get_errno(do_sigaction(arg1, pact, &oact));
- if (!is_error(ret) && arg3) {
- if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0))
- return -TARGET_EFAULT;
- rt_act->_sa_handler = oact._sa_handler;
- rt_act->sa_mask = oact.sa_mask;
- rt_act->sa_flags = oact.sa_flags;
- unlock_user_struct(rt_act, arg3, 1);
- }
-#else
-#ifdef TARGET_SPARC
+#if defined(TARGET_ALPHA)
+ target_ulong sigsetsize = arg4;
+ target_ulong restorer = arg5;
+#elif defined(TARGET_SPARC)
target_ulong restorer = arg4;
target_ulong sigsetsize = arg5;
#else
target_ulong sigsetsize = arg4;
+ target_ulong restorer = 0;
#endif
- struct target_sigaction *act;
- struct target_sigaction *oact;
+ struct target_sigaction *act = NULL;
+ struct target_sigaction *oact = NULL;
if (sigsetsize != sizeof(target_sigset_t)) {
return -TARGET_EINVAL;
}
- if (arg2) {
- if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) {
- return -TARGET_EFAULT;
- }
-#ifdef TARGET_ARCH_HAS_KA_RESTORER
- act->ka_restorer = restorer;
-#endif
- } else {
- act = NULL;
+ if (arg2 && !lock_user_struct(VERIFY_READ, act, arg2, 1)) {
+ return -TARGET_EFAULT;
}
- if (arg3) {
- if (!lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) {
- ret = -TARGET_EFAULT;
- goto rt_sigaction_fail;
+ if (arg3 && !lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) {
+ ret = -TARGET_EFAULT;
+ } else {
+ ret = get_errno(do_sigaction(arg1, act, oact, restorer));
+ if (oact) {
+ unlock_user_struct(oact, arg3, 1);
}
- } else
- oact = NULL;
- ret = get_errno(do_sigaction(arg1, act, oact));
- rt_sigaction_fail:
- if (act)
+ }
+ if (act) {
unlock_user_struct(act, arg2, 0);
- if (oact)
- unlock_user_struct(oact, arg3, 1);
-#endif
+ }
}
return ret;
#ifdef TARGET_NR_sgetmask /* not on alpha */
@@ -11195,8 +11140,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
return ret;
}
case TARGET_NR_sigaltstack:
- return do_sigaltstack(arg1, arg2,
- get_sp_from_cpustate((CPUArchState *)cpu_env));
+ return do_sigaltstack(arg1, arg2, cpu_env);
#ifdef CONFIG_SENDFILE
#ifdef TARGET_NR_sendfile
@@ -13245,8 +13189,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
}
poutoff = &outoff;
}
+ /* Do not sign-extend the count parameter. */
ret = get_errno(safe_copy_file_range(arg1, pinoff, arg3, poutoff,
- arg5, arg6));
+ (abi_ulong)arg5, arg6));
if (!is_error(ret) && ret > 0) {
if (arg2) {
if (put_user_u64(inoff, arg2)) {