[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yqw6TP3MhEqnQ+2o@FVFF77S0Q05N>
Date: Fri, 17 Jun 2022 09:24:44 +0100
From: Mark Rutland <mark.rutland@....com>
To: Tong Tiangen <tongtiangen@...wei.com>
Cc: James Morse <james.morse@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Robin Murphy <robin.murphy@....com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Michael Ellerman <mpe@...erman.id.au>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>, x86@...nel.org,
"H . Peter Anvin" <hpa@...or.com>, linuxppc-dev@...ts.ozlabs.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, Kefeng Wang <wangkefeng.wang@...wei.com>,
Xie XiuQi <xiexiuqi@...wei.com>,
Guohanjun <guohanjun@...wei.com>
Subject: Re: [PATCH -next v5 2/8] arm64: extable: make uaaccess helper use
extable type EX_TYPE_UACCESS_ERR_ZERO
On Sat, May 28, 2022 at 06:50:50AM +0000, Tong Tiangen wrote:
> Currnetly, the extable type used by __arch_copy_from/to_user() is
> EX_TYPE_FIXUP. In fact, It is more clearly to use meaningful
> EX_TYPE_UACCESS_*.
>
> Suggested-by: Mark Rutland <mark.rutland@....com>
> Signed-off-by: Tong Tiangen <tongtiangen@...wei.com>
> ---
> arch/arm64/include/asm/asm-extable.h | 8 ++++++++
> arch/arm64/include/asm/asm-uaccess.h | 12 ++++++------
> 2 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm64/include/asm/asm-extable.h b/arch/arm64/include/asm/asm-extable.h
> index 56ebe183e78b..9c94ac1f082c 100644
> --- a/arch/arm64/include/asm/asm-extable.h
> +++ b/arch/arm64/include/asm/asm-extable.h
> @@ -28,6 +28,14 @@
> __ASM_EXTABLE_RAW(\insn, \fixup, EX_TYPE_FIXUP, 0)
> .endm
>
> +/*
> + * Create an exception table entry for uaccess `insn`, which will branch to `fixup`
> + * when an unhandled fault is taken.
> + * ex->data = ~0 means both reg_err and reg_zero is set to wzr(x31).
> + */
> + .macro _asm_extable_uaccess, insn, fixup
> + __ASM_EXTABLE_RAW(\insn, \fixup, EX_TYPE_UACCESS_ERR_ZERO, ~0)
> + .endm
I'm not too keen on using `~0` here, since that also sets other bits in the
data field, and its somewhat opaque.
How painful is it to generate the data fields as with the C version of this
macro, so that we can pass in wzr explciitly for the two sub-fields?
Other than that, this looks good to me.
Thanks,
Mark.
> /*
> * Create an exception table entry for `insn` if `fixup` is provided. Otherwise
> * do nothing.
> diff --git a/arch/arm64/include/asm/asm-uaccess.h b/arch/arm64/include/asm/asm-uaccess.h
> index 0557af834e03..75b211c98dea 100644
> --- a/arch/arm64/include/asm/asm-uaccess.h
> +++ b/arch/arm64/include/asm/asm-uaccess.h
> @@ -61,7 +61,7 @@ alternative_else_nop_endif
>
> #define USER(l, x...) \
> 9999: x; \
> - _asm_extable 9999b, l
> + _asm_extable_uaccess 9999b, l
>
> /*
> * Generate the assembly for LDTR/STTR with exception table entries.
> @@ -73,8 +73,8 @@ alternative_else_nop_endif
> 8889: ldtr \reg2, [\addr, #8];
> add \addr, \addr, \post_inc;
>
> - _asm_extable 8888b,\l;
> - _asm_extable 8889b,\l;
> + _asm_extable_uaccess 8888b, \l;
> + _asm_extable_uaccess 8889b, \l;
> .endm
>
> .macro user_stp l, reg1, reg2, addr, post_inc
> @@ -82,14 +82,14 @@ alternative_else_nop_endif
> 8889: sttr \reg2, [\addr, #8];
> add \addr, \addr, \post_inc;
>
> - _asm_extable 8888b,\l;
> - _asm_extable 8889b,\l;
> + _asm_extable_uaccess 8888b,\l;
> + _asm_extable_uaccess 8889b,\l;
> .endm
>
> .macro user_ldst l, inst, reg, addr, post_inc
> 8888: \inst \reg, [\addr];
> add \addr, \addr, \post_inc;
>
> - _asm_extable 8888b,\l;
> + _asm_extable_uaccess 8888b, \l;
> .endm
> #endif
> --
> 2.25.1
>
Powered by blists - more mailing lists