Re: [PATCH 06/13 v2] arc: define syscall_get_arch()
From: Vineet Gupta
Date: Fri Nov 09 2018 - 18:39:11 EST
On 11/9/18 3:33 PM, Dmitry V. Levin wrote:
> syscall_get_arch() is required to be implemented on all architectures
> that use tracehook_report_syscall_entry() in order to extend
> the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
>
> Signed-off-by: Dmitry V. Levin <ldv@xxxxxxxxxxxx>
> ---
> v2: define AUDIT_ARCH_ARCOMPACT, AUDIT_ARCH_ARCOMPACTLE, AUDIT_ARCH_ARCV2,
> and AUDIT_ARCH_ARCV2LE instead of AUDIT_ARCH_ARC, update
> syscall_get_arch() implementation accordingly.
>
> arch/arc/include/asm/syscall.h | 18 ++++++++++++++++++
> include/uapi/linux/audit.h | 4 ++++
> 2 files changed, 22 insertions(+)
>
> diff --git a/arch/arc/include/asm/syscall.h b/arch/arc/include/asm/syscall.h
> index 29de09804306..a1b698290778 100644
> --- a/arch/arc/include/asm/syscall.h
> +++ b/arch/arc/include/asm/syscall.h
> @@ -9,6 +9,7 @@
> #ifndef _ASM_ARC_SYSCALL_H
> #define _ASM_ARC_SYSCALL_H 1
>
> +#include <uapi/linux/audit.h>
> #include <linux/err.h>
> #include <linux/sched.h>
> #include <asm/unistd.h>
> @@ -68,4 +69,21 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
> }
> }
>
> +static inline int syscall_get_arch(void)
> +{
> +#ifdef CONFIG_ISA_ARCOMPACT
> +# ifdef CONFIG_CPU_BIG_ENDIAN
> + return AUDIT_ARCH_ARCOMPACT;
> +# else
> + return AUDIT_ARCH_ARCOMPACTLE;
> +# endif
> +#else /* CONFIG_ISA_ARCV2 */
> +# ifdef CONFIG_CPU_BIG_ENDIAN
> + return AUDIT_ARCH_ARCV2;
> +# else
> + return AUDIT_ARCH_ARCV2LE;
> +# endif
> +#endif
> +}
Bike shedding, but will using IS_ENABLED make the code any better.
> +
> #endif
> diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> index 818ae690ab79..8e70fb70b8f8 100644
> --- a/include/uapi/linux/audit.h
> +++ b/include/uapi/linux/audit.h
> @@ -375,6 +375,10 @@ enum {
>
> #define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> #define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> +#define AUDIT_ARCH_ARCOMPACT (EM_ARCOMPACT)
> +#define AUDIT_ARCH_ARCOMPACTLE (EM_ARCOMPACT|__AUDIT_ARCH_LE)
> +#define AUDIT_ARCH_ARCV2 (EM_ARCV2)
> +#define AUDIT_ARCH_ARCV2LE (EM_ARCV2|__AUDIT_ARCH_LE)
More Bike shedding, can we make LE as default and add BE suffixes variants please.