[PATCHv2 05/11] arm64: entry: prepare ret_to_user for function call
Guenter Roeck
linux at roeck-us.net
Thu Dec 17 12:57:40 EST 2020
Hi,
On Mon, Nov 30, 2020 at 11:59:44AM +0000, Mark Rutland wrote:
> In a subsequent patch ret_to_user will need to make a C function call
> (in some configurations) which may clobber x0-x18 at the start of the
> finish_ret_to_user block, before enable_step_tsk consumes the flags
> loaded into x1.
>
> In preparation for this, let's load the flags into x19, which is
> preserved across C function calls. This avoids a redundant reload of the
> flags and ensures we operate on a consistent shapshot regardless.
>
> There should be no functional change as a result of this patch. At this
> point of the entry/exit paths we only need to preserve x28 (tsk) and the
> sp, and x19 is free for this use.
>
> Signed-off-by: Mark Rutland <mark.rutland at arm.com>
> Cc: Catalin Marinas <catalin.marinas at arm.com>
> Cc: James Morse <james.morse at arm.com>
> Cc: Will Deacon <will at kernel.org>
This patch results in:
arch/arm64/kernel/entry.S: Assembler messages:
arch/arm64/kernel/entry.S:774: Error: immediate out of range at operand 3 -- `and x2,x19,#((1<<1)|(1<<0)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<7))'
This is with gcc 9.3.0 and binutils 2.34. Do I need a special compiler
and/or binutils version to make it compile ?
Thanks,
Guenter
> ---
> arch/arm64/kernel/entry.S | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
> index b295fb912b12..84aec600eeed 100644
> --- a/arch/arm64/kernel/entry.S
> +++ b/arch/arm64/kernel/entry.S
> @@ -774,13 +774,13 @@ SYM_CODE_END(el0_error)
> SYM_CODE_START_LOCAL(ret_to_user)
> disable_daif
> gic_prio_kentry_setup tmp=x3
> - ldr x1, [tsk, #TSK_TI_FLAGS]
> - and x2, x1, #_TIF_WORK_MASK
> + ldr x19, [tsk, #TSK_TI_FLAGS]
> + and x2, x19, #_TIF_WORK_MASK
> cbnz x2, work_pending
> finish_ret_to_user:
> /* Ignore asynchronous tag check faults in the uaccess routines */
> clear_mte_async_tcf
> - enable_step_tsk x1, x2
> + enable_step_tsk x19, x2
> #ifdef CONFIG_GCC_PLUGIN_STACKLEAK
> bl stackleak_erase
> #endif
> @@ -791,11 +791,12 @@ finish_ret_to_user:
> */
> work_pending:
> mov x0, sp // 'regs'
> + mov x1, x19
> bl do_notify_resume
> #ifdef CONFIG_TRACE_IRQFLAGS
> bl trace_hardirqs_on // enabled while in userspace
> #endif
> - ldr x1, [tsk, #TSK_TI_FLAGS] // re-check for single-step
> + ldr x19, [tsk, #TSK_TI_FLAGS] // re-check for single-step
> b finish_ret_to_user
> SYM_CODE_END(ret_to_user)
>
> --
> 2.11.0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
More information about the linux-arm-kernel
mailing list