From ffe81d439812b2858065bb1410551027eafe938b Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 6 Jan 2022 20:25:59 -0800 Subject: linux-user/arm: Move target_oabi_flock64 out of target_structs.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Place it next to copy_from/to_user_oabi_flock64, the only users, inside the existing target-specific ifdef. This leaves only generic ipc structs in target_structs.h. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-Id: <20220107042600.149852-2-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'linux-user/syscall.c') diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ce9d64896c..ca6e0b8fb0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6927,6 +6927,14 @@ typedef abi_long from_flock64_fn(struct flock64 *fl, abi_ulong target_addr); typedef abi_long to_flock64_fn(abi_ulong target_addr, const struct flock64 *fl); #if defined(TARGET_ARM) && TARGET_ABI_BITS == 32 +struct target_oabi_flock64 { + abi_short l_type; + abi_short l_whence; + abi_llong l_start; + abi_llong l_len; + abi_int l_pid; +} QEMU_PACKED; + static inline abi_long copy_from_user_oabi_flock64(struct flock64 *fl, abi_ulong target_flock_addr) { -- cgit 1.4.1 From 08f5f973491b7e575231afbb1fa5c96f39c257b2 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 6 Jan 2022 14:57:35 -0800 Subject: linux-user: Do not special-case NULL for PR_GET_PDEATHSIG The kernel does not special-case arg2 != NULL, so neither should we. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220106225738.103012-2-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux-user/syscall.c') diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ca6e0b8fb0..eff107b8bc 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6444,7 +6444,7 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, int deathsig; ret = get_errno(prctl(PR_GET_PDEATHSIG, &deathsig, arg3, arg4, arg5)); - if (!is_error(ret) && arg2 && put_user_s32(deathsig, arg2)) { + if (!is_error(ret) && put_user_s32(deathsig, arg2)) { return -TARGET_EFAULT; } return ret; -- cgit 1.4.1 From 1edebb36ea1809c7882a7be9654260adbbfdcb35 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 6 Jan 2022 14:57:36 -0800 Subject: linux-user: Map signal number in PR_GET_PDEATHSIG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert the host signal number to guest signal number before returning the value to the guest. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20220106225738.103012-3-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'linux-user/syscall.c') diff --git a/linux-user/syscall.c b/linux-user/syscall.c index eff107b8bc..b17cfe31c8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6444,7 +6444,8 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, int deathsig; ret = get_errno(prctl(PR_GET_PDEATHSIG, &deathsig, arg3, arg4, arg5)); - if (!is_error(ret) && put_user_s32(deathsig, arg2)) { + if (!is_error(ret) && + put_user_s32(host_to_target_signal(deathsig), arg2)) { return -TARGET_EFAULT; } return ret; -- cgit 1.4.1 From f746c65909ee6df4b560804bc152cdb3e9ad9bf8 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 6 Jan 2022 14:57:37 -0800 Subject: linux-user: Implement PR_SET_PDEATHSIG Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220106225738.103012-4-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'linux-user/syscall.c') diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b17cfe31c8..f9ae6328b5 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6450,6 +6450,9 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, } return ret; } + case PR_SET_PDEATHSIG: + return get_errno(prctl(PR_SET_PDEATHSIG, target_to_host_signal(arg2), + arg3, arg4, arg5)); case PR_GET_NAME: { void *name = lock_user(VERIFY_WRITE, arg2, 16, 1); -- cgit 1.4.1 From 4f4e5567f856d9b841494b3b5216a37d2952ee54 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 6 Jan 2022 14:57:38 -0800 Subject: linux-user: Implement capability prctls This is PR_CAPBSET_READ, PR_CAPBSET_DROP and the "legacy" PR_CAP_AMBIENT PR_GET_SECUREBITS, PR_SET_SECUREBITS. All of these arguments are integer values only, and do not require mapping of values between host and guest. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20220106225738.103012-5-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'linux-user/syscall.c') diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f9ae6328b5..5950222a77 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6504,10 +6504,15 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, case PR_SET_UNALIGN: return do_prctl_set_unalign(env, arg2); + case PR_CAP_AMBIENT: + case PR_CAPBSET_READ: + case PR_CAPBSET_DROP: case PR_GET_DUMPABLE: case PR_SET_DUMPABLE: case PR_GET_KEEPCAPS: case PR_SET_KEEPCAPS: + case PR_GET_SECUREBITS: + case PR_SET_SECUREBITS: case PR_GET_TIMING: case PR_SET_TIMING: case PR_GET_TIMERSLACK: -- cgit 1.4.1