qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw/arm/boot: Set SCR_EL3.FGTEn when booting kernel
@ 2023-09-13 11:57 Fabian Vogt
  2023-09-15 14:28 ` Peter Maydell
  2023-10-21 12:30 ` Michael Tokarev
  0 siblings, 2 replies; 4+ messages in thread
From: Fabian Vogt @ 2023-09-13 11:57 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, qemu-arm

Just like d7ef5e16a17c sets SCR_EL3.HXEn for FEAT_HCX, this commit
handles SCR_EL3.FGTEn for FEAT_FGT:

When we direct boot a kernel on a CPU which emulates EL3, we need to
set up the EL3 system registers as the Linux kernel documentation
specifies:
    https://www.kernel.org/doc/Documentation/arm64/booting.rst

> For CPUs with the Fine Grained Traps (FEAT_FGT) extension present:
> - If EL3 is present and the kernel is entered at EL2:
>   - SCR_EL3.FGTEn (bit 27) must be initialised to 0b1.

Signed-off-by: Fabian Vogt <fvogt@suse.de>
---
 hw/arm/boot.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 720f22531a..24fa169060 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -761,6 +761,10 @@ static void do_cpu_reset(void *opaque)
                     if (cpu_isar_feature(aa64_hcx, cpu)) {
                         env->cp15.scr_el3 |= SCR_HXEN;
                     }
+                    if (cpu_isar_feature(aa64_fgt, cpu)) {
+                        env->cp15.scr_el3 |= SCR_FGTEN;
+                    }
+
                     /* AArch64 kernels never boot in secure mode */
                     assert(!info->secure_boot);
                     /* This hook is only supported for AArch32 currently:
-- 
2.41.0






^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] hw/arm/boot: Set SCR_EL3.FGTEn when booting kernel
  2023-09-13 11:57 [PATCH] hw/arm/boot: Set SCR_EL3.FGTEn when booting kernel Fabian Vogt
@ 2023-09-15 14:28 ` Peter Maydell
  2023-10-21 12:30 ` Michael Tokarev
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2023-09-15 14:28 UTC (permalink / raw)
  To: Fabian Vogt; +Cc: qemu-devel, qemu-arm

On Wed, 13 Sept 2023 at 12:58, Fabian Vogt <fvogt@suse.de> wrote:
>
> Just like d7ef5e16a17c sets SCR_EL3.HXEn for FEAT_HCX, this commit
> handles SCR_EL3.FGTEn for FEAT_FGT:
>
> When we direct boot a kernel on a CPU which emulates EL3, we need to
> set up the EL3 system registers as the Linux kernel documentation
> specifies:
>     https://www.kernel.org/doc/Documentation/arm64/booting.rst
>
> > For CPUs with the Fine Grained Traps (FEAT_FGT) extension present:
> > - If EL3 is present and the kernel is entered at EL2:
> >   - SCR_EL3.FGTEn (bit 27) must be initialised to 0b1.
>
> Signed-off-by: Fabian Vogt <fvogt@suse.de>
> ---

Applied to target-arm.next, thanks.
(We seem to have a habit of forgetting these...)

-- PMM


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] hw/arm/boot: Set SCR_EL3.FGTEn when booting kernel
  2023-09-13 11:57 [PATCH] hw/arm/boot: Set SCR_EL3.FGTEn when booting kernel Fabian Vogt
  2023-09-15 14:28 ` Peter Maydell
@ 2023-10-21 12:30 ` Michael Tokarev
  2023-10-23 10:12   ` Peter Maydell
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Tokarev @ 2023-10-21 12:30 UTC (permalink / raw)
  To: Fabian Vogt, Peter Maydell; +Cc: qemu-devel, qemu-arm, qemu-stable

13.09.2023 14:57, Fabian Vogt :
> Just like d7ef5e16a17c sets SCR_EL3.HXEn for FEAT_HCX, this commit
> handles SCR_EL3.FGTEn for FEAT_FGT:
> 
> When we direct boot a kernel on a CPU which emulates EL3, we need to
> set up the EL3 system registers as the Linux kernel documentation
> specifies:
>      https://www.kernel.org/doc/Documentation/arm64/booting.rst
> 
>> For CPUs with the Fine Grained Traps (FEAT_FGT) extension present:
>> - If EL3 is present and the kernel is entered at EL2:
>>    - SCR_EL3.FGTEn (bit 27) must be initialised to 0b1.

Am I right assuming this makes no sense to pick up for stable-7.2 since
it doesn't even have aa64_fgt definitions (commit 15126d9ce2
"target/arm: Define the FEAT_FGT registers"), or should this commit
be picked up too?

This and subsequent change in this area, "target/arm: Fix CNTPCT_EL0
trapping from EL0 when HCR_EL2.E2H is 0"

Thanks,

/mjt


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] hw/arm/boot: Set SCR_EL3.FGTEn when booting kernel
  2023-10-21 12:30 ` Michael Tokarev
@ 2023-10-23 10:12   ` Peter Maydell
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2023-10-23 10:12 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: Fabian Vogt, qemu-devel, qemu-arm, qemu-stable

On Sat, 21 Oct 2023 at 13:30, Michael Tokarev <mjt@tls.msk.ru> wrote:
>
> 13.09.2023 14:57, Fabian Vogt :
> > Just like d7ef5e16a17c sets SCR_EL3.HXEn for FEAT_HCX, this commit
> > handles SCR_EL3.FGTEn for FEAT_FGT:
> >
> > When we direct boot a kernel on a CPU which emulates EL3, we need to
> > set up the EL3 system registers as the Linux kernel documentation
> > specifies:
> >      https://www.kernel.org/doc/Documentation/arm64/booting.rst
> >
> >> For CPUs with the Fine Grained Traps (FEAT_FGT) extension present:
> >> - If EL3 is present and the kernel is entered at EL2:
> >>    - SCR_EL3.FGTEn (bit 27) must be initialised to 0b1.
>
> Am I right assuming this makes no sense to pick up for stable-7.2 since
> it doesn't even have aa64_fgt definitions (commit 15126d9ce2
> "target/arm: Define the FEAT_FGT registers"), or should this commit
> be picked up too?

Correct. stable-7.2 doesn't implement FEAT_FGT, so it doesn't
need this fix for that feature's implementation.

> This and subsequent change in this area, "target/arm: Fix CNTPCT_EL0
> trapping from EL0 when HCR_EL2.E2H is 0"

That's a safe bugfix back to any QEMU that has the code that it's
patching, but it's also not super high priority, since the code has
been that way since 2020 and we only just noticed :-) (Affects
running Xen in emulation under QEMU.)

thanks
-- PMM


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-23 10:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-13 11:57 [PATCH] hw/arm/boot: Set SCR_EL3.FGTEn when booting kernel Fabian Vogt
2023-09-15 14:28 ` Peter Maydell
2023-10-21 12:30 ` Michael Tokarev
2023-10-23 10:12   ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).