From: Yeoreum Yun <yeoreum.yun@arm.com>
To: Marc Zyngier <maz@kernel.org>
Cc: catalin.marinas@arm.com, will@kernel.org, broonie@kernel.org,
oliver.upton@linux.dev, anshuman.khandual@arm.com,
robh@kernel.org, james.morse@arm.com, mark.rutland@arm.com,
joey.gouly@arm.com, Dave.Martin@arm.com, ahmed.genidi@arm.com,
kevin.brodsky@arm.com, scott@os.amperecomputing.com,
mbenes@suse.cz, james.clark@linaro.org, frederic@kernel.org,
rafael@kernel.org, pavel@kernel.org, ryan.roberts@arm.com,
suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
kvmarm@lists.linux.dev
Subject: Re: [PATCH v2 2/6] arm64: initialise SCTLR2_ELx register at boot time
Date: Mon, 11 Aug 2025 20:23:47 +0100 [thread overview]
Message-ID: <aJpDQ71/f9zdwXbf@e129823.arm.com> (raw)
In-Reply-To: <86pld190l2.wl-maz@kernel.org>
Hi Marc,
> [dropping ry111@xry111.site, which bounces]
>
> On Mon, 11 Aug 2025 17:33:36 +0100,
> Yeoreum Yun <yeoreum.yun@arm.com> wrote:
> >
> > add initialisation for SCTRL2_ELx register at boot time.
>
> Again, please expand.
Okay.
[...]
> >
> > +.macro __init_el2_sctlr2
>
> Writing this as __init_sctlr2_el2 would read vastly better (yes, I
> know most macros in this file are similarly braindead).
>
> > + .macro init_sctlr2_elx, el, tmp
> > + mrs_s \tmp, SYS_ID_AA64MMFR3_EL1
> > + ubfx \tmp, \tmp, #ID_AA64MMFR3_EL1_SCTLRX_SHIFT, #4
> > + cbz \tmp, .Lskip_sctlr2_\@
> > + .if \el == 2
> > + mov_q \tmp, INIT_SCTLR2_EL2
> > + msr_s SYS_SCTLR_EL2, \tmp
> > + .else
> > + mov_q \tmp, INIT_SCTLR2_EL1
> > + .if \el == 12
> > + msr_s SYS_SCTLR_EL12, \tmp
> > + .else
> > + msr_s SYS_SCTLR_EL1, \tmp
> > + .endif
>
> I don't think this is the correct place for this macro.
> asm/assembler.h seems more suitable, and already has that sort of
> things.
Thanks for letting me know the proper place.
I'll rewrite it on there.
>
> > + .endif
> > +.Lskip_sctlr2_\@:
> > + .endm
> > #else
> >
> > #include <linux/bitfield.h>
> > diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
> > index ca04b338cb0d..0dff7593e50b 100644
> > --- a/arch/arm64/kernel/head.S
> > +++ b/arch/arm64/kernel/head.S
> > @@ -276,6 +276,7 @@ SYM_INNER_LABEL(init_el1, SYM_L_LOCAL)
> > mov_q x0, INIT_SCTLR_EL1_MMU_OFF
> > pre_disable_mmu_workaround
> > msr sctlr_el1, x0
> > + init_sctlr2_elx 1, x0
> > isb
> > mov_q x0, INIT_PSTATE_EL1
> > msr spsr_el1, x0
> > @@ -298,7 +299,6 @@ SYM_INNER_LABEL(init_el2, SYM_L_LOCAL)
> > msr sctlr_el2, x0
> > isb
> > 0:
> > -
> > init_el2_hcr HCR_HOST_NVHE_FLAGS
> > init_el2_state
> >
> > @@ -315,12 +315,15 @@ SYM_INNER_LABEL(init_el2, SYM_L_LOCAL)
> >
> > /* Set a sane SCTLR_EL1, the VHE way */
> > msr_s SYS_SCTLR_EL12, x1
> > + init_sctlr2_elx 12, x2
> > mov x2, #BOOT_CPU_FLAG_E2H
> > b 3f
> >
> > 2:
> > msr sctlr_el1, x1
> > + init_sctlr2_elx 1, x2
> > mov x2, xzr
> > +
> > 3:
> > mov x0, #INIT_PSTATE_EL1
> > msr spsr_el2, x0
>
> This is missing something: you should resynchronise SCTLR2_EL2 from
> SCTLR2_EL1 in __finalise_el2, rather than relying on whatever you've
> set in __init_el2_sctlr2.
Thanks. I'll add missing on enter_vhe().
--
Sincerely,
Yeoreum Yun
next prev parent reply other threads:[~2025-08-11 19:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-11 16:33 [PATCH v2 0/6] initialize SCTRL2_ELx Yeoreum Yun
2025-08-11 16:33 ` [PATCH v2 1/6] arm64: make SCTLR2_EL1 accessible Yeoreum Yun
2025-08-11 17:46 ` Marc Zyngier
2025-08-12 6:50 ` Yeoreum Yun
2025-08-11 16:33 ` [PATCH v2 2/6] arm64: initialise SCTLR2_ELx register at boot time Yeoreum Yun
2025-08-11 18:26 ` Marc Zyngier
2025-08-11 19:23 ` Yeoreum Yun [this message]
2025-08-11 16:33 ` [PATCH v2 3/6] arm64: save/restore SCTLR2_EL1 when cpu_suspend()/resume() Yeoreum Yun
2025-08-11 16:33 ` [PATCH v2 4/6] arm64: init SCTLR2_EL1 at cpu_soft_restart() Yeoreum Yun
2025-08-11 16:33 ` [PATCH v2 5/6] arm64: make the per-task SCTLR2_EL1 Yeoreum Yun
2025-08-11 16:33 ` [PATCH v2 6/6] KVM: arm64: initialise SCTLR2_EL1 at __kvm_host_psci_cpu_entry() Yeoreum Yun
2025-08-11 17:51 ` Marc Zyngier
2025-08-11 19:43 ` Yeoreum Yun
2025-08-12 10:06 ` Marc Zyngier
2025-08-12 10:29 ` Yeoreum Yun
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=aJpDQ71/f9zdwXbf@e129823.arm.com \
--to=yeoreum.yun@arm.com \
--cc=Dave.Martin@arm.com \
--cc=ahmed.genidi@arm.com \
--cc=anshuman.khandual@arm.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=frederic@kernel.org \
--cc=james.clark@linaro.org \
--cc=james.morse@arm.com \
--cc=joey.gouly@arm.com \
--cc=kevin.brodsky@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=mbenes@suse.cz \
--cc=oliver.upton@linux.dev \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=scott@os.amperecomputing.com \
--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