linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Joey Gouly <joey.gouly@arm.com>
To: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com,
	james.morse@arm.com, maz@kernel.org, will@kernel.org, nd@arm.com
Subject: Re: [PATCH 3/4] arm64: entry: move bulk of ret_to_user to C
Date: Tue, 3 Aug 2021 13:06:10 +0100	[thread overview]
Message-ID: <20210803120610.GB52119@e124191.cambridge.arm.com> (raw)
In-Reply-To: <20210802140733.52716-4-mark.rutland@arm.com>

On Mon, Aug 02, 2021 at 03:07:32PM +0100, Mark Rutland wrote:
> In `ret_to_user` we perform some conditional work depending on the
> thread flags, then perform some IRQ/context tracking which is intended
> to balance with the IRQ/context tracking performed in the entry C code.
> 
> For simplicity and consistency, it would be preferable to move this all
> to C. As a step towards that, this patch moves the conditional work and
> IRQ/context tracking into a C helper function. To aid bisectability,
> this is called from the `ret_to_user` assembly, and a subsequent patch
> will move the call to C code.
> 

[..]

> diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
> index 863d44f73028..fe0a9bcc3e1f 100644
> --- a/arch/arm64/kernel/entry.S
> +++ b/arch/arm64/kernel/entry.S
> @@ -29,16 +29,6 @@
>  #include <asm/asm-uaccess.h>
>  #include <asm/unistd.h>
>  
> -/*
> - * Context tracking and irqflag tracing need to instrument transitions between
> - * user and kernel mode.
> - */
> -	.macro user_enter_irqoff
> -#if defined(CONFIG_CONTEXT_TRACKING) || defined(CONFIG_TRACE_IRQFLAGS)
> -	bl	exit_to_user_mode
> -#endif
> -	.endm
> -
>  	.macro	clear_gp_regs
>  	.irp	n,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29
>  	mov	x\n, xzr
> @@ -585,37 +575,17 @@ SYM_CODE_START_LOCAL(ret_to_kernel)
>  	kernel_exit 1
>  SYM_CODE_END(ret_to_kernel)
>  
> -/*
> - * "slow" syscall return path.
> - */
>  SYM_CODE_START_LOCAL(ret_to_user)
> -	disable_daif
> -	gic_prio_kentry_setup tmp=x3

The `gic_prio_kentry_setup` macro is now unused too!

> -#ifdef CONFIG_TRACE_IRQFLAGS
> -	bl	trace_hardirqs_off
> -#endif
> -	ldr	x19, [tsk, #TSK_TI_FLAGS]
> -	and	x2, x19, #_TIF_WORK_MASK
> -	cbnz	x2, work_pending
> -finish_ret_to_user:
> -	user_enter_irqoff
> +	mov	x0, sp
> +	bl	asm_exit_to_user_mode
>  	/* Ignore asynchronous tag check faults in the uaccess routines */
>  	clear_mte_async_tcf
> +	ldr	x19, [tsk, #TSK_TI_FLAGS]	// re-check for single-step
>  	enable_step_tsk x19, x2
>  #ifdef CONFIG_GCC_PLUGIN_STACKLEAK
>  	bl	stackleak_erase
>  #endif
>  	kernel_exit 0
> -
> -/*
> - * Ok, we need to do extra processing, enter the slow path.
> - */
> -work_pending:
> -	mov	x0, sp				// 'regs'
> -	mov	x1, x19
> -	bl	do_notify_resume
> -	ldr	x19, [tsk, #TSK_TI_FLAGS]	// re-check for single-step
> -	b	finish_ret_to_user
>  SYM_CODE_END(ret_to_user)
>  
>  	.popsection				// .entry.text

Reviewed-by: Joey Gouly <joey.gouly@arm.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-08-03 12:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02 14:07 [PATCH 0/4] arm64: entry: rework user return handling Mark Rutland
2021-08-02 14:07 ` [PATCH 1/4] arm64: entry: consolidate entry/exit helpers Mark Rutland
2021-08-03 12:07   ` Joey Gouly
2021-08-02 14:07 ` [PATCH 2/4] arm64: entry: clarify " Mark Rutland
2021-08-03 11:53   ` Joey Gouly
2021-08-02 14:07 ` [PATCH 3/4] arm64: entry: move bulk of ret_to_user to C Mark Rutland
2021-08-03 12:06   ` Joey Gouly [this message]
2021-08-02 14:07 ` [PATCH 4/4] arm64: entry: call exit_to_user_mode() from C Mark Rutland
2021-08-03 12:17   ` Joey Gouly
2021-08-05 13:38 ` [PATCH 0/4] arm64: entry: rework user return handling Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210803120610.GB52119@e124191.cambridge.arm.com \
    --to=joey.gouly@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=james.morse@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=nd@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).