Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Mark Rutland <mark.rutland@arm.com>,
	linux-arm-kernel@lists.infradead.org
Cc: alexandru.elisei@arm.com, andrii@kernel.org, ardb@kernel.org,
	ast@kernel.org, broonie@kernel.org, catalin.marinas@arm.com,
	daniel@iogearbox.net, dvyukov@google.com, james.morse@arm.com,
	jean-philippe@linaro.org, jpoimboe@redhat.com, maz@kernel.org,
	peterz@infradead.org, suzuki.poulose@arm.com, will@kernel.org
Subject: Re: [PATCH 01/13] arm64: lib: __arch_clear_user(): fold fixups into body
Date: Wed, 13 Oct 2021 20:55:31 +0100	[thread overview]
Message-ID: <eaa77b0b-2340-a02b-fe82-8763bf79057f@arm.com> (raw)
In-Reply-To: <20211013110059.10324-2-mark.rutland@arm.com>

On 2021-10-13 12:00, Mark Rutland wrote:
> Like other functions, __arch_clear_user() places its exception fixups in
> the `.fixup` section without any clear association with
> __arch_clear_user() itself. If we backtrace the fixup code, it will be
> symbolized as an offset from the nearest prior symbol, which happens to
> be `__entry_tramp_text_end`. Further, since the PC adjustment for the
> fixup is akin to a direct branch rather than a function call,
> __arch_clear_user() itself will be missing from the backtrace.
> 
> This is confusing and hinders debugging. In general this pattern will
> also be problematic for CONFIG_LIVEPATCH, since fixups often return to
> their associated function, but this isn't accurately captured in the
> stacktrace.
> 
> To solve these issues for assembly functions, we must move fixups into
> the body of the functions themselves, after the usual fast-path returns.
> This patch does so for __arch_clear_user().
> 
> Inline assembly will be dealt with in subsequent patches.
> 
> Other than the improved backtracing, there should be no functional
> change as a result of this patch.

Oh, I always assumed the .fixup section might have some special 
significance of its own. If not, all the better - modulo one possible 
nit below, this is fine by me. Also it's led me to see that 
copy_in_user() has finally left us, hooray! Guess I've got no more 
excuses to put off that promised usercopy rewrite other than finding the 
time now...

> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: James Morse <james.morse@arm.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Robin Murphy <robin.murphy@arm.com>
> Cc: Will Deacon <will@kernel.org>
> ---
>   arch/arm64/lib/clear_user.S | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arm64/lib/clear_user.S b/arch/arm64/lib/clear_user.S
> index a7efb2ad2a1c..dac13df4a1ed 100644
> --- a/arch/arm64/lib/clear_user.S
> +++ b/arch/arm64/lib/clear_user.S
> @@ -45,13 +45,10 @@ USER(9f, sttrh	wzr, [x0])
>   USER(7f, sttrb	wzr, [x2, #-1])
>   5:	mov	x0, #0
>   	ret
> -SYM_FUNC_END(__arch_clear_user)
> -EXPORT_SYMBOL(__arch_clear_user)
>   
> -	.section .fixup,"ax"

The one useful purpose this did serve is to provide a handy visual cue - 
if you have any more concrete reason to respin the series, would you 
mind sticking in a little comment like "// Exception fixup" here and in 
the other two assembly routines, just so it's harder to overlook that 
the preceding ret is the normal exit path?

Either way, for patches 1-3,

Acked-by: Robin Murphy <robin.murphy@arm.com>

I got totally lost trying to follow the _ASM_EXTABLE_UACCESS_* business, 
but I don't think the rest of the series gets in the way of any 
outstanding plans either (and FWIW I always thought "fixup->fixup" was 
pretty awful so feel free to have an ack for patch #9 as well). Indeed, 
I guess the new type field should mean that we can implement "proper" 
address-aware fault handlers without the Itanium trick if we still need to.

Cheers,
Robin

> -	.align	2
>   7:	sub	x0, x2, #5	// Adjust for faulting on the final byte...
>   8:	add	x0, x0, #4	// ...or the second word of the 4-7 byte case
>   9:	sub	x0, x2, x0
>   	ret
> -	.previous
> +SYM_FUNC_END(__arch_clear_user)
> +EXPORT_SYMBOL(__arch_clear_user)
> 

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

  reply	other threads:[~2021-10-13 19:58 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-13 11:00 [PATCH 00/13] arm64: extable: remove anonymous out-of-line fixups Mark Rutland
2021-10-13 11:00 ` [PATCH 01/13] arm64: lib: __arch_clear_user(): fold fixups into body Mark Rutland
2021-10-13 19:55   ` Robin Murphy [this message]
2021-10-14 11:09     ` Mark Rutland
2021-10-13 11:00 ` [PATCH 02/13] arm64: lib: __arch_copy_from_user(): " Mark Rutland
2021-10-13 11:00 ` [PATCH 03/13] arm64: lib: __arch_copy_to_user(): " Mark Rutland
2021-10-13 11:00 ` [PATCH 04/13] arm64: kvm: use kvm_exception_table_entry Mark Rutland
2021-10-13 11:00 ` [PATCH 05/13] arm64: factor out GPR numbering helpers Mark Rutland
2021-10-13 11:00 ` [PATCH 06/13] arm64: gpr-num: support W registers Mark Rutland
2021-10-13 11:00 ` [PATCH 07/13] arm64: extable: consolidate definitions Mark Rutland
2021-10-13 11:00 ` [PATCH 08/13] arm64: extable: make fixup_exception() return bool Mark Rutland
2021-10-13 11:00 ` [PATCH 09/13] arm64: extable: use `ex` for `exception_table_entry` Mark Rutland
2021-10-13 11:00 ` [PATCH 10/13] arm64: extable: add `type` and `data` fields Mark Rutland
2021-10-19 11:29   ` Will Deacon
2021-10-19 11:50     ` Mark Rutland
2021-10-19 12:05       ` Will Deacon
2021-10-19 12:12         ` Ard Biesheuvel
2021-10-19 13:01         ` Mark Rutland
2021-10-13 11:00 ` [PATCH 11/13] arm64: extable: add a dedicated uaccess handler Mark Rutland
2021-10-13 11:00 ` [PATCH 12/13] arm64: extable: add load_unaligned_zeropad() handler Mark Rutland
2021-10-13 11:00 ` [PATCH 13/13] arm64: vmlinux.lds.S: remove `.fixup` section Mark Rutland
2021-10-17 13:50 ` [PATCH 00/13] arm64: extable: remove anonymous out-of-line fixups Ard Biesheuvel

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=eaa77b0b-2340-a02b-fe82-8763bf79057f@arm.com \
    --to=robin.murphy@arm.com \
    --cc=alexandru.elisei@arm.com \
    --cc=andrii@kernel.org \
    --cc=ardb@kernel.org \
    --cc=ast@kernel.org \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=daniel@iogearbox.net \
    --cc=dvyukov@google.com \
    --cc=james.morse@arm.com \
    --cc=jean-philippe@linaro.org \
    --cc=jpoimboe@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=peterz@infradead.org \
    --cc=suzuki.poulose@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