All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: Mark Rutland <mark.rutland@arm.com>,
	linux-arm-kernel@lists.infradead.org
Cc: catalin.marinas@arm.com, robin.murphy@arm.com, hch@lst.de,
	will@kernel.org
Subject: Re: [PATCH 03/13] arm64: head.S: always initialize PSTATE
Date: Wed, 30 Sep 2020 17:09:47 +0100	[thread overview]
Message-ID: <ec708d49-0ddf-6cfd-f1f5-100210549318@arm.com> (raw)
In-Reply-To: <20200925160722.27155-4-mark.rutland@arm.com>

Hi Mark,

On 25/09/2020 17:07, Mark Rutland wrote:
> As with SCTLR_ELx and other control registers, some PSTATE bits are
> UNKNOWN out-of-reset, and we may not be able to rely on hardware of
> firmware

(hardware or firmware)


> to initialize them to our liking prior to entry to the kernel,
> e.g. in the primary/secondary boot paths and return from idle/suspend.
> 
> It would be more robust (and easier to reason about) if we consistently
> initialized PSTATE to a default value, as we do with control registers.
> This will ensure that the kernel is not adversely affected by bits it is
> not aware of, e.g. when support for a feature such as PAN/UAO is
> disabled.
> 
> This patch ensures that PSTATE is consistently initialized at boot time
> via an ERET. This is not intended to relax the existing requirements
> (e.g. DAIF bits must still be set prior to entering the kernel). For
> features detected dynamically (which may require system-wide support),
> it is still necessary to subsequently modify PSTATE.


> diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
> index 9bb07be45249a..b8ee9a62c9b61 100644
> --- a/arch/arm64/kernel/head.S
> +++ b/arch/arm64/kernel/head.S
> @@ -494,17 +494,22 @@ EXPORT_SYMBOL(kimage_vaddr)
>   * booted in EL1 or EL2 respectively.
>   */
>  SYM_FUNC_START(init_kernel_el)
> -	msr	SPsel, #1			// We want to use SP_EL{1,2}
>  	mrs	x0, CurrentEL
>  	cmp	x0, #CurrentEL_EL2
> -	b.eq	1f
> +	b.eq	init_el2
> +
> +SYM_INNER_LABEL(init_el1, SYM_L_LOCAL)
>  	mov_q	x0, INIT_SCTLR_EL1_MMU_OFF
>  	msr	sctlr_el1, x0
> -	mov	w0, #BOOT_CPU_MODE_EL1		// This cpu booted in EL1

>  	isb

Could you add a comment covering why this ISB isn't rolled into the ERET?
I'm guessing its in case SCTLR_EL1 previously had v8.5s EOS 'Exception Exit is Context
Synchronizing' clear.


> -	ret
> +	mov_q	x0, INIT_PSTATE_EL1
> +	msr	spsr_el1, x0
> +	msr	elr_el1, lr
> +	mov	w0, #BOOT_CPU_MODE_EL1
> +	eret


Thanks,

James

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

  reply	other threads:[~2020-09-30 16:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-25 16:07 [PATCH 00/13] arm64: remove set_fs() and friends Mark Rutland
2020-09-25 16:07 ` [PATCH 01/13] arm64: head.S: rename el2_setup -> init_kernel_el Mark Rutland
2020-09-25 16:07 ` [PATCH 02/13] arm64: head.S: cleanup SCTLR_ELx initialization Mark Rutland
2020-09-25 16:07 ` [PATCH 03/13] arm64: head.S: always initialize PSTATE Mark Rutland
2020-09-30 16:09   ` James Morse [this message]
2020-10-01 11:01     ` Mark Rutland
2020-09-25 16:07 ` [PATCH 04/13] arm64: sdei: move uaccess logic to arch/arm64/ Mark Rutland
2020-09-25 16:07 ` [PATCH 05/13] arm64: uaccess: move uao_* alternatives to asm-uaccess.h Mark Rutland
2020-09-25 16:07 ` [PATCH 06/13] arm64: uaccess: rename privileged uaccess routines Mark Rutland
2020-09-25 16:07 ` [PATCH 07/13] arm64: uaccess: simplify __copy_user_flushcache() Mark Rutland
2020-09-25 16:07 ` [PATCH 08/13] arm64: uaccess: refactor __{get,put}_user Mark Rutland
2020-09-25 16:07 ` [PATCH 09/13] arm64: uaccess: split user/kernel routines Mark Rutland
2020-09-25 16:07 ` [PATCH 10/13] arm64: uaccess cleanup macro naming Mark Rutland
2020-09-25 16:07 ` [PATCH 11/13] arm64: uaccess: remove set_fs() Mark Rutland
2020-09-28  7:04   ` Christoph Hellwig
2020-09-28  9:02     ` Mark Rutland
2020-09-28 15:29       ` Mark Rutland
2020-09-25 16:07 ` [PATCH 12/13] arm64: uaccess: remove addr_limit_user_check() Mark Rutland
2020-09-28  7:05   ` Christoph Hellwig
2020-09-28  9:06     ` Mark Rutland
2020-09-25 16:07 ` [PATCH 13/13] arm64: uaccess: remove redundant PAN toggling Mark Rutland
2020-09-28  7:16 ` [PATCH 00/13] arm64: remove set_fs() and friends Christoph Hellwig
2020-09-28  7:23   ` Christoph Hellwig
2020-09-28  9:18     ` Mark Rutland

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=ec708d49-0ddf-6cfd-f1f5-100210549318@arm.com \
    --to=james.morse@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=hch@lst.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=robin.murphy@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.