linux-user/aarch64: Implement prctls for GCS

This is PR_GET_SHADOW_STACK_STATUS, PR_SET_SHADOW_STACK_STATUS,
and PR_LOCK_SHADOW_STACK_STATUS.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20251008215613.300150-64-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Richard Henderson 2025-10-08 14:56:03 -07:00 committed by Peter Maydell
parent 9c5dfe8b56
commit d0e16dcad9
4 changed files with 168 additions and 0 deletions

View file

@ -6353,6 +6353,11 @@ abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr)
# define PR_SME_VL_LEN_MASK 0xffff
# define PR_SME_VL_INHERIT (1 << 17)
#endif
#ifndef PR_GET_SHADOW_STACK_STATUS
# define PR_GET_SHADOW_STACK_STATUS 74
# define PR_SET_SHADOW_STACK_STATUS 75
# define PR_LOCK_SHADOW_STACK_STATUS 76
#endif
#include "target_prctl.h"
@ -6399,6 +6404,15 @@ static abi_long do_prctl_inval1(CPUArchState *env, abi_long arg2)
#ifndef do_prctl_sme_set_vl
#define do_prctl_sme_set_vl do_prctl_inval1
#endif
#ifndef do_prctl_get_shadow_stack_status
#define do_prctl_get_shadow_stack_status do_prctl_inval1
#endif
#ifndef do_prctl_set_shadow_stack_status
#define do_prctl_set_shadow_stack_status do_prctl_inval1
#endif
#ifndef do_prctl_lock_shadow_stack_status
#define do_prctl_lock_shadow_stack_status do_prctl_inval1
#endif
static abi_long do_prctl_syscall_user_dispatch(CPUArchState *env,
abi_ulong arg2, abi_ulong arg3,
@ -6499,6 +6513,21 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,
return -TARGET_EINVAL;
}
return do_prctl_get_tagged_addr_ctrl(env);
case PR_GET_SHADOW_STACK_STATUS:
if (arg3 || arg4 || arg5) {
return -TARGET_EINVAL;
}
return do_prctl_get_shadow_stack_status(env, arg2);
case PR_SET_SHADOW_STACK_STATUS:
if (arg3 || arg4 || arg5) {
return -TARGET_EINVAL;
}
return do_prctl_set_shadow_stack_status(env, arg2);
case PR_LOCK_SHADOW_STACK_STATUS:
if (arg3 || arg4 || arg5) {
return -TARGET_EINVAL;
}
return do_prctl_lock_shadow_stack_status(env, arg2);
case PR_GET_UNALIGN:
return do_prctl_get_unalign(env, arg2);