Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: Daniel Kiss <daniel.kiss@arm.com>
Cc: Catalin.Marinas@arm.com, pcc@google.com, Ard.Biesheuvel@arm.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 2/2] arm64: Do not configure kernel's PTR_AUTH key when it not needed.
Date: Tue, 26 Jan 2021 13:32:01 +0000	[thread overview]
Message-ID: <20210126133200.GG29702@willie-the-truck> (raw)
In-Reply-To: <20201218115632.59067-3-daniel.kiss@arm.com>

On Fri, Dec 18, 2020 at 12:56:32PM +0100, Daniel Kiss wrote:
> If the kernel is not compiled with CONFIG_ARM64_PTR_AUTH_KERNEL,
> then no need to install dedicated key for the kernel, user's key
> could be left enabled because no PACI/AUTI instructions are expected..

(same comment as before re commit message)

> Signed-off-by: Daniel Kiss <daniel.kiss@arm.com>
> ---
>  arch/arm64/include/asm/asm_pointer_auth.h | 53 +++++++++++++----------
>  arch/arm64/include/asm/pointer_auth.h     | 20 ++++++---
>  arch/arm64/include/asm/processor.h        |  2 +
>  arch/arm64/kernel/asm-offsets.c           |  4 ++
>  4 files changed, 51 insertions(+), 28 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/asm_pointer_auth.h b/arch/arm64/include/asm/asm_pointer_auth.h
> index 52dead2a8640..b2572a943f59 100644
> --- a/arch/arm64/include/asm/asm_pointer_auth.h
> +++ b/arch/arm64/include/asm/asm_pointer_auth.h
> @@ -39,27 +39,6 @@ alternative_if ARM64_HAS_GENERIC_AUTH
>  alternative_else_nop_endif
>  	.endm
>  
> -	.macro __ptrauth_keys_install_kernel_nosync tsk, tmp1, tmp2, tmp3
> -	mov	\tmp1, #THREAD_KEYS_KERNEL
> -	add	\tmp1, \tsk, \tmp1
> -	ldp	\tmp2, \tmp3, [\tmp1, #PTRAUTH_KERNEL_KEY_APIA]
> -	msr_s	SYS_APIAKEYLO_EL1, \tmp2
> -	msr_s	SYS_APIAKEYHI_EL1, \tmp3
> -	.endm
> -
> -	.macro ptrauth_keys_install_kernel_nosync tsk, tmp1, tmp2, tmp3
> -alternative_if ARM64_HAS_ADDRESS_AUTH
> -	__ptrauth_keys_install_kernel_nosync \tsk, \tmp1, \tmp2, \tmp3
> -alternative_else_nop_endif
> -	.endm
> -
> -	.macro ptrauth_keys_install_kernel tsk, tmp1, tmp2, tmp3
> -alternative_if ARM64_HAS_ADDRESS_AUTH
> -	__ptrauth_keys_install_kernel_nosync \tsk, \tmp1, \tmp2, \tmp3
> -	isb
> -alternative_else_nop_endif
> -	.endm
> -
>  	.macro __ptrauth_keys_init_cpu tsk, tmp1, tmp2, tmp3
>  	mrs	\tmp1, id_aa64isar1_el1
>  	ubfx	\tmp1, \tmp1, #ID_AA64ISAR1_APA_SHIFT, #8
> @@ -69,7 +48,9 @@ alternative_else_nop_endif
>  	mrs	\tmp2, sctlr_el1
>  	orr	\tmp2, \tmp2, \tmp1
>  	msr	sctlr_el1, \tmp2
> +#ifdef CONFIG_ARM64_PTR_AUTH_KERNEL
>  	__ptrauth_keys_install_kernel_nosync \tsk, \tmp1, \tmp2, \tmp3
> +#endif
>  	isb
>  .Lno_addr_auth\@:
>  	.endm
> @@ -82,17 +63,43 @@ alternative_else_nop_endif
>  .Lno_addr_auth\@:
>  	.endm
>  
> -#else /* CONFIG_ARM64_PTR_AUTH */
> +#else /* !CONFIG_ARM64_PTR_AUTH */
>  
>  	.macro ptrauth_keys_install_user tsk, tmp1, tmp2, tmp3
>  	.endm
>  
> +#endif /* CONFIG_ARM64_PTR_AUTH */
> +
> +#ifdef CONFIG_ARM64_PTR_AUTH_KERNEL
> +	.macro __ptrauth_keys_install_kernel_nosync tsk, tmp1, tmp2, tmp3
> +	mov	\tmp1, #THREAD_KEYS_KERNEL
> +	add	\tmp1, \tsk, \tmp1
> +	ldp	\tmp2, \tmp3, [\tmp1, #PTRAUTH_KERNEL_KEY_APIA]
> +	msr_s	SYS_APIAKEYLO_EL1, \tmp2
> +	msr_s	SYS_APIAKEYHI_EL1, \tmp3
> +	.endm
> +

nit: can you please define these macros at the top of the file, so that
they are defined before the macros which use them?

Will

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

  reply	other threads:[~2021-01-26 13:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07 22:46 arm64: split ARM64_PTR_AUTH option to userspace and kernel configs Daniel Kiss
2020-12-07 22:46 ` [PATCH 1/2] arm64: Add ARM64_PTR_AUTH_KERNEL config option Daniel Kiss
2020-12-07 22:46 ` [PATCH 2/2] arm64: Configure kernel's PTR_AUTH key when it is built with PTR_AUTH Daniel Kiss
2020-12-07 23:07   ` Peter Collingbourne
2020-12-08 11:00     ` Catalin Marinas
2020-12-08 19:33       ` Peter Collingbourne
2020-12-09 10:51         ` Will Deacon
2020-12-09 11:56           ` Daniel Kiss
2020-12-18 11:56             ` arm64: split ARM64_PTR_AUTH option to userspace and kernel Daniel Kiss
2020-12-18 11:56               ` [PATCH v2 1/2] arm64: Add ARM64_PTR_AUTH_KERNEL config option Daniel Kiss
2021-01-26 13:27                 ` Will Deacon
2021-02-08 14:39                   ` Daniel Kiss
2020-12-18 11:56               ` [PATCH v2 2/2] arm64: Do not configure kernel's PTR_AUTH key when it not needed Daniel Kiss
2021-01-26 13:32                 ` Will Deacon [this message]
2021-01-26 13:17               ` arm64: split ARM64_PTR_AUTH option to userspace and kernel Will Deacon

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=20210126133200.GG29702@willie-the-truck \
    --to=will@kernel.org \
    --cc=Ard.Biesheuvel@arm.com \
    --cc=Catalin.Marinas@arm.com \
    --cc=daniel.kiss@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=pcc@google.com \
    /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