Message ID | 20200605041733.415188-10-richard.henderson@linaro.org |
---|---|
State | New |
Headers | show |
Series | target-arm: Implement ARMv8.5-MemTag, user mode | expand |
On Fri, 5 Jun 2020 at 05:17, Richard Henderson <richard.henderson@linaro.org> wrote: > > This is the prctl bit that controls whether syscalls accept tagged > addresses. See Documentation/arm64/tagged-address-abi.rst in the > linux kernel. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > linux-user/aarch64/target_syscall.h | 4 ++++ > linux-user/syscall.c | 23 +++++++++++++++++++++++ > 2 files changed, 27 insertions(+) > > + case TARGET_PR_SET_TAGGED_ADDR_CTRL: > + { > + abi_ulong valid_mask = TARGET_PR_TAGGED_ADDR_ENABLE; > + > + if ((arg2 & ~valid_mask) || arg3 || arg4 || arg5) { > + return -TARGET_EINVAL; > + } > + untagged_addr_mask = (arg2 & TARGET_PR_TAGGED_ADDR_ENABLE > + ? MAKE_64BIT_MASK(0, 56) : -1); > + return 0; > + } The spec says the tagged-address control is thread-scoped, not process-wide. thanks -- PMM
diff --git a/linux-user/aarch64/target_syscall.h b/linux-user/aarch64/target_syscall.h index 995e475c73..5fb0bf4a5d 100644 --- a/linux-user/aarch64/target_syscall.h +++ b/linux-user/aarch64/target_syscall.h @@ -29,4 +29,8 @@ struct target_pt_regs { # define TARGET_PR_PAC_APDBKEY (1 << 3) # define TARGET_PR_PAC_APGAKEY (1 << 4) +#define TARGET_PR_SET_TAGGED_ADDR_CTRL 55 +#define TARGET_PR_GET_TAGGED_ADDR_CTRL 56 +# define TARGET_PR_TAGGED_ADDR_ENABLE (1UL << 0) + #endif /* AARCH64_TARGET_SYSCALL_H */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d190fb1122..e4da53c5b3 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -10460,6 +10460,29 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } return -TARGET_EINVAL; + case TARGET_PR_SET_TAGGED_ADDR_CTRL: + { + abi_ulong valid_mask = TARGET_PR_TAGGED_ADDR_ENABLE; + + if ((arg2 & ~valid_mask) || arg3 || arg4 || arg5) { + return -TARGET_EINVAL; + } + untagged_addr_mask = (arg2 & TARGET_PR_TAGGED_ADDR_ENABLE + ? MAKE_64BIT_MASK(0, 56) : -1); + return 0; + } + case TARGET_PR_GET_TAGGED_ADDR_CTRL: + { + abi_long ret = 0; + + if (arg2 || arg3 || arg4 || arg5) { + return -TARGET_EINVAL; + } + if (~untagged_addr_mask != 0) { + ret |= TARGET_PR_TAGGED_ADDR_ENABLE; + } + return ret; + } #endif /* AARCH64 */ case PR_GET_SECCOMP: case PR_SET_SECCOMP:
This is the prctl bit that controls whether syscalls accept tagged addresses. See Documentation/arm64/tagged-address-abi.rst in the linux kernel. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- linux-user/aarch64/target_syscall.h | 4 ++++ linux-user/syscall.c | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) -- 2.25.1