From: Alexandru Elisei <alexandru.elisei@arm.com>
To: Joey Gouly <joey.gouly@arm.com>
Cc: kvm@vger.kernel.org, drjones@redhat.com, kvmarm@lists.linux.dev,
Marc Zyngier <maz@kernel.org>,
Oliver Upton <oliver.upton@linux.dev>
Subject: Re: [kvm-unit-tests PATCH v1 1/7] arm64: drop to EL1 if booted at EL2
Date: Thu, 6 Mar 2025 15:52:31 +0000 [thread overview]
Message-ID: <Z8nEv17KEXFCHoAi@raptor> (raw)
In-Reply-To: <20250304170213.GB1553498@e124191.cambridge.arm.com>
Hi Joey,
On Tue, Mar 04, 2025 at 05:02:13PM +0000, Joey Gouly wrote:
> Hi,
>
> On Thu, Feb 27, 2025 at 04:53:15PM +0000, Alexandru Elisei wrote:
> > Hi Joey,
> >
> > On Thu, Feb 20, 2025 at 02:13:48PM +0000, Joey Gouly wrote:
> > > EL2 is not currently supported, drop to EL1 to conitnue booting.
> > >
> > > Signed-off-by: Joey Gouly <joey.gouly@arm.com>
> > > ---
> > > arm/cstart64.S | 27 +++++++++++++++++++++++++--
> > > 1 file changed, 25 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/arm/cstart64.S b/arm/cstart64.S
> > > index b480a552..3a305ad0 100644
> > > --- a/arm/cstart64.S
> > > +++ b/arm/cstart64.S
> > > @@ -57,14 +57,25 @@ start:
> > > add x6, x6, :lo12:reloc_end
> > > 1:
> > > cmp x5, x6
> > > - b.hs 1f
> > > + b.hs reloc_done
> > > ldr x7, [x5] // r_offset
> > > ldr x8, [x5, #16] // r_addend
> > > add x8, x8, x4 // val = base + r_addend
> > > str x8, [x4, x7] // base[r_offset] = val
> > > add x5, x5, #24
> > > b 1b
> > > -
> > > +reloc_done:
> > > + mrs x4, CurrentEL
> > > + cmp x4, CurrentEL_EL2
> > > + b.ne 1f
> > > +drop_to_el1:
> > > + mov x4, 4
> > > + msr spsr_el2, x4
> > > + adrp x4, 1f
> > > + add x4, x4, :lo12:1f
> > > + msr elr_el2, x4
> >
> > I'm going to assume this works because KVM is nice enough to initialise the
> > EL2 registers that affect execution at EL1 to some sane defaults. Is that
> > something that can be relied on going forward?
>
> I was just trying to keep the changes minimal.
Sure, I appreciate that, and the series looks nice and small because of it, but
in the absence of an ABI from KVM, the reset values for the EL2 registers that
affect execution at EL1 are just an implemention choice that KVM made at a
particular point in time. I don't think robust software should rely on it.
>
> >
> > What about UEFI?
>
> Haven't tested it yet.
Ok, I saw you made changes to the UEFI code so I had assumed to tested them.
>
> >
> > I was expecting some kind of initialization of the registers that affect
> > EL1.
>
> I'll look into it.
Great, thanks. I think arch/arm64/incluse/asm/el2_setup.h might be a useful
starting point. You can put the initialization code in a macro and use it
for the primary and secondaries CPUs, like Marc suggested.
Thanks,
Alex
next prev parent reply other threads:[~2025-03-06 15:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 14:13 [kvm-unit-tests PATCH v1 0/7] arm64: support EL2 Joey Gouly
2025-02-20 14:13 ` [kvm-unit-tests PATCH v1 1/7] arm64: drop to EL1 if booted at EL2 Joey Gouly
2025-02-20 15:23 ` Marc Zyngier
2025-02-27 16:53 ` Alexandru Elisei
2025-03-04 17:02 ` Joey Gouly
2025-03-06 15:52 ` Alexandru Elisei [this message]
2025-02-20 14:13 ` [kvm-unit-tests PATCH v1 2/7] arm64: timer: use hypervisor timers when " Joey Gouly
2025-02-27 16:55 ` Alexandru Elisei
2025-03-04 17:05 ` Joey Gouly
2025-03-06 15:52 ` Alexandru Elisei
2025-02-20 14:13 ` [kvm-unit-tests PATCH v1 3/7] arm64: micro-bench: fix timer IRQ Joey Gouly
2025-02-27 16:58 ` Alexandru Elisei
2025-02-20 14:13 ` [kvm-unit-tests PATCH v1 4/7] arm64: micro-bench: use smc when at EL2 Joey Gouly
2025-02-20 14:13 ` [kvm-unit-tests PATCH v1 5/7] arm64: selftest: update test for running " Joey Gouly
2025-02-27 16:58 ` Alexandru Elisei
2025-02-20 14:13 ` [kvm-unit-tests PATCH v1 6/7] arm64: pmu: count EL2 cycles Joey Gouly
2025-02-27 17:01 ` Alexandru Elisei
2025-03-04 16:56 ` Joey Gouly
2025-03-06 15:58 ` Alexandru Elisei
2025-02-20 14:13 ` [kvm-unit-tests PATCH v1 7/7] arm64: run at EL2 if supported Joey Gouly
2025-02-20 15:34 ` 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=Z8nEv17KEXFCHoAi@raptor \
--to=alexandru.elisei@arm.com \
--cc=drjones@redhat.com \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
/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