From: Mark Rutland <mark.rutland@arm.com>
To: Andre Przywara <andre.przywara@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, akos.denke@arm.com,
luca.fancellu@arm.com, maz@kernel.org
Subject: Re: [BOOT-WRAPPER 01/11] Always enter AArch32 kernels in ARM mode
Date: Sat, 3 Aug 2024 11:53:08 +0100 [thread overview]
Message-ID: <Zq4MFPQqYGnKELAK@J2N7QTR9R3> (raw)
In-Reply-To: <20240802122639.30aebecb@donnerap.manchester.arm.com>
On Fri, Aug 02, 2024 at 12:26:39PM +0100, Andre Przywara wrote:
> On Mon, 29 Jul 2024 17:14:51 +0100
> Mark Rutland <mark.rutland@arm.com> wrote:
>
> > Currnetly we try to support entering AArch32 kernels, but this is
>
> I think you are missing "in Thumb mode" here? The read is a bit confusing
> otherwise.
>
> > unnecessary, and the code is never exercised.
> >
> > Per Linux's Documentation/arch/arm/booting.txt, AArch32 kernels
> > supported by the AArch64 boot-wrapper should always be entered in ARM
> > mode:
> >
> > | The boot loader is expected to call the kernel image by jumping
> > | directly to the first instruction of the kernel image.
> > |
> > | On CPUs supporting the ARM instruction set, the entry must be
> > | made in ARM state, even for a Thumb-2 kernel.
> > |
> > | On CPUs supporting only the Thumb instruction set such as
> > | Cortex-M class CPUs, the entry must be made in Thumb state.
> >
> > Additionally, the kernel__start symbol that we use as the kernel
> > entrypoint is always PHYS_OFFSET + KERNEL_OFFSET, which doesn't take
> > into account any ARM/Thumb distinction in the AArch32 kernel image, and
> > hence we'll never try to set the Thumb bit in the SPSR.
>
> Is that true? I see the first_spin code path for CPU 0 using those values,
> which indeed never have bit 0 set, but the address could come from *mbox
> as well, given by the live kernel in the PSCI code path, and we don't have
> any control over that.
> Or do I miss anything here?
You're right, and PSCI explicitly describes that bit 0 in the entry
address results in the T bit being set in CPSR.
I will drop this patch, and adjust subsequent paqtches accordingly.
Mark.
> I think the patch is still valid, but we might need to relax the commit
> message here a bit?
>
> Cheers,
> Andre
>
> >
> > Remove the redundant code.
> >
> > Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> > Cc: Akos Denke <akos.denke@arm.com>
> > Cc: Andre Przywara <andre.przywara@arm.com>
> > Cc: Luca Fancellu <luca.fancellu@arm.com>
> > Cc: Marc Zyngier <maz@kernel.org>
> > ---
> > arch/aarch32/boot.S | 4 ----
> > arch/aarch64/boot.S | 7 -------
> > 2 files changed, 11 deletions(-)
> >
> > diff --git a/arch/aarch32/boot.S b/arch/aarch32/boot.S
> > index 4d16c9c..5c2a183 100644
> > --- a/arch/aarch32/boot.S
> > +++ b/arch/aarch32/boot.S
> > @@ -105,10 +105,6 @@ ASM_FUNC(jump_kernel)
> > bxeq lr @ no EL3
> >
> > ldr r4, =SPSR_KERNEL
> > - /* Return in thumb2 mode when bit 0 of address is 1 */
> > - tst lr, #1
> > - orrne r4, #PSR_T
> > -
> > msr spsr_cxf, r4
> > movs pc, lr
> >
> > diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S
> > index da5fa65..b889137 100644
> > --- a/arch/aarch64/boot.S
> > +++ b/arch/aarch64/boot.S
> > @@ -136,13 +136,6 @@ ASM_FUNC(jump_kernel)
> > br x19 // No EL3
> >
> > 1: mov x4, #SPSR_KERNEL
> > -
> > - /*
> > - * If bit 0 of the kernel address is set, we're entering in AArch32
> > - * thumb mode. Set SPSR.T accordingly.
> > - */
> > - bfi x4, x19, #5, #1
> > -
> > msr elr_el3, x19
> > msr spsr_el3, x4
> > eret
>
next prev parent reply other threads:[~2024-08-03 10:53 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-29 16:14 [BOOT-WRAPPER 00/11] Cleanup initialization Mark Rutland
2024-07-29 16:14 ` [BOOT-WRAPPER 01/11] Always enter AArch32 kernels in ARM mode Mark Rutland
2024-08-02 11:26 ` Andre Przywara
2024-08-03 10:53 ` Mark Rutland [this message]
2024-07-29 16:14 ` [BOOT-WRAPPER 02/11] aarch64: Remove redundant EL1 entry logic Mark Rutland
2024-07-29 16:14 ` [BOOT-WRAPPER 03/11] aarch64: Implement cpu_init_arch() Mark Rutland
2024-08-02 9:29 ` Marc Zyngier
2024-08-02 9:38 ` Mark Rutland
2024-07-29 16:14 ` [BOOT-WRAPPER 04/11] aarch64: Always enter kernel via exception return Mark Rutland
2024-07-29 16:14 ` [BOOT-WRAPPER 05/11] aarch32: Refactor inital entry Mark Rutland
2024-07-29 16:14 ` [BOOT-WRAPPER 06/11] aarch32: Implement cpu_init_arch() Mark Rutland
2024-07-29 16:14 ` [BOOT-WRAPPER 07/11] aarch32: Always enter kernel via exception return Mark Rutland
2024-07-29 16:14 ` [BOOT-WRAPPER 08/11] Unify assembly setup paths Mark Rutland
2024-07-29 16:14 ` [BOOT-WRAPPER 09/11] Simplify spin logic Mark Rutland
2024-07-29 16:15 ` [BOOT-WRAPPER 10/11] Add printing functions Mark Rutland
2024-07-29 16:15 ` [BOOT-WRAPPER 11/11] Boot CPUs sequentially Mark Rutland
2024-07-31 9:57 ` Luca Fancellu
2024-08-03 10:57 ` Mark Rutland
2024-08-02 10:18 ` [BOOT-WRAPPER 00/11] Cleanup initialization Marc Zyngier
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=Zq4MFPQqYGnKELAK@J2N7QTR9R3 \
--to=mark.rutland@arm.com \
--cc=akos.denke@arm.com \
--cc=andre.przywara@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=luca.fancellu@arm.com \
--cc=maz@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