public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Joey Gouly <joey.gouly@arm.com>
To: Eric Auger <eric.auger@redhat.com>
Cc: kvm@vger.kernel.org, alexandru.elisei@arm.com,
	andrew.jones@linux.dev, kvmarm@lists.linux.dev,
	Marc Zyngier <maz@kernel.org>,
	Oliver Upton <oliver.upton@linux.dev>
Subject: Re: [kvm-unit-tests PATCH v3 00/10] arm64: EL2 support
Date: Thu, 27 Nov 2025 14:52:07 +0000	[thread overview]
Message-ID: <20251127145207.GA3265987@e124191.cambridge.arm.com> (raw)
In-Reply-To: <3a39738e-ed33-49fa-9f1c-0bbba6979038@redhat.com>

On Thu, Nov 27, 2025 at 01:04:08PM +0100, Eric Auger wrote:
> Hi Joey,
> 
> On 11/27/25 12:08 PM, Joey Gouly wrote:
> > On Thu, Nov 27, 2025 at 11:04:43AM +0100, Eric Auger wrote:
> >> Hi Joey,
> >>
> >> On 9/25/25 4:19 PM, Joey Gouly wrote:
> >>> Hi all,
> >>>
> >>> This series is for adding support to running the kvm-unit-tests at EL2. These
> >>> have been tested with Linux 6.17-rc6 KVM nested virt.
> >>>
> >>> This latest round I also tested using the run_tests.sh script with QEMU TCG,
> >>> running at EL2.
> >>>
> >>> The goal is to later extend and add new tests for Nested Virtualisation,
> >>> however they should also work with bare metal as well.
> >>>
> >>> Changes since v2[1]:
> >>> 	- Move the sctlr setup in EFI to a function.
> >>> 	- Decided to not re-use el2_setup.h from Linux, looked more
> >>> 	  complicated to use than needed for KUT.
> >>> 	- Add EL2 env variable for testing, open to feedback for that.
> >>> 	  This was untested with kvmtool as my testing setup only has
> >>> 	  busybox ash currently, and the run_tests.sh script needs bash.
> >>>
> >>> Issues (that I think are fine to investigate/fix later):
> >>> 	- Some of the debug tests fail with QEMU at EL2 and kvmtool.
> >>> 	- The gic ipi test times out with QEMU at EL2, but works with kvmtool.
> >> Have you noticed any failure with migration tests. On my end, as soon as
> >> I set EL2=1 migration tests do fail.
> > Yes migration also fails here, forgot to mention that.
> >
> > Seems like migration completes, but then something bad happens on the first
> > interrupt. I will investigate a bit now and see if it's an easy fix.
> 
> while you do that I will go through the series. My apologies for the delay

Thanks!

I found the issue, and I thought it was one I had solved before, but maybe I lost the fix somehow:

diff --git a/arm/cstart64.S b/arm/cstart64.S
index af7c81c1..fd8b6690 100644
--- a/arm/cstart64.S
+++ b/arm/cstart64.S
@@ -235,6 +235,11 @@ get_mmu_off:
 .globl secondary_entry
 secondary_entry:
        init_el x0
+
+       /* set SCTLR_EL1 to a known value */
+       ldr     x4, =INIT_SCTLR_EL1_MMU_OFF
+       msr     sctlr_el1, x4
+       isb
+
        /* enable FP/ASIMD and SVE */
        mov     x0, #(3 << 20)
        orr     x0, x0, #(3 << 16)

The secondary core code doesn't fully initialise SCTLR_ELx, which means that
SCTLR_ELx.SPAN=0. That's why there was a data abort after the IRQ.

This doesn't affect EL1 (only) because KVM has a different reset value for
SCTLR_EL1 and SCTLR_EL2.

I will send out a new version with this fix, missing sob/reviews/acks, after you've had a look!

Thanks,
Joey

> 
> Eric
> >
> > Thanks,
> > Joey
> >
> >> Eric
> >>> Thanks,
> >>> Joey
> >>>
> >>> [1] https://lore.kernel.org/kvmarm/20250529135557.2439500-1-joey.gouly@arm.com/
> >>>
> >>> Alexandru Elisei (2):
> >>>   arm64: micro-bench: use smc when at EL2
> >>>   arm64: selftest: update test for running at EL2
> >>>
> >>> Joey Gouly (8):
> >>>   arm64: drop to EL1 if booted at EL2
> >>>   arm64: efi: initialise SCTLR_ELx fully
> >>>   arm64: efi: initialise the EL
> >>>   arm64: timer: use hypervisor timers when at EL2
> >>>   arm64: micro-bench: fix timer IRQ
> >>>   arm64: pmu: count EL2 cycles
> >>>   arm64: run at EL2 if supported
> >>>   arm64: add EL2 environment variable
> >>>
> >>>  arm/cstart64.S             | 56 ++++++++++++++++++++++++++++++++++++--
> >>>  arm/efi/crt0-efi-aarch64.S |  5 ++++
> >>>  arm/micro-bench.c          | 26 ++++++++++++++++--
> >>>  arm/pmu.c                  | 13 ++++++---
> >>>  arm/run                    |  7 +++++
> >>>  arm/selftest.c             | 18 ++++++++----
> >>>  arm/timer.c                | 10 +++++--
> >>>  lib/acpi.h                 |  2 ++
> >>>  lib/arm/asm/setup.h        |  8 ++++++
> >>>  lib/arm/asm/timer.h        | 11 ++++++++
> >>>  lib/arm/setup.c            |  4 +++
> >>>  lib/arm/timer.c            | 19 +++++++++++--
> >>>  lib/arm64/asm/sysreg.h     | 19 +++++++++++++
> >>>  lib/arm64/processor.c      | 12 ++++++++
> >>>  14 files changed, 191 insertions(+), 19 deletions(-)
> >>>
> 

  reply	other threads:[~2025-11-27 14:52 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-25 14:19 [kvm-unit-tests PATCH v3 00/10] arm64: EL2 support Joey Gouly
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 01/10] arm64: drop to EL1 if booted at EL2 Joey Gouly
2025-11-27 17:07   ` Eric Auger
2025-11-28 15:11     ` Joey Gouly
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 02/10] arm64: efi: initialise SCTLR_ELx fully Joey Gouly
2025-11-27 16:49   ` Eric Auger
2025-11-28 15:18     ` Joey Gouly
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 03/10] arm64: efi: initialise the EL Joey Gouly
2025-11-27 17:08   ` Eric Auger
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 04/10] arm64: timer: use hypervisor timers when at EL2 Joey Gouly
2025-12-02  8:36   ` Eric Auger
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 05/10] arm64: micro-bench: fix timer IRQ Joey Gouly
2025-12-02  8:36   ` Eric Auger
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 06/10] arm64: micro-bench: use smc when at EL2 Joey Gouly
2025-12-02  9:11   ` Eric Auger
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 07/10] arm64: selftest: update test for running " Joey Gouly
2025-12-02  9:16   ` Eric Auger
2025-12-02 12:21     ` Joey Gouly
2025-12-02 12:30       ` Eric Auger
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 08/10] arm64: pmu: count EL2 cycles Joey Gouly
2025-12-02 10:31   ` Eric Auger
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 09/10] arm64: run at EL2 if supported Joey Gouly
2025-12-02 10:35   ` Eric Auger
2025-09-25 14:19 ` [kvm-unit-tests PATCH v3 10/10] arm64: add EL2 environment variable Joey Gouly
2025-11-27 10:34   ` Eric Auger
2025-11-27 10:40     ` Joey Gouly
2025-12-01 23:34   ` Andrew Jones
2025-11-19 13:18 ` [kvm-unit-tests PATCH v3 00/10] arm64: EL2 support Joey Gouly
2025-11-19 13:48   ` Nadav Amit
2025-11-19 14:02     ` Joey Gouly
2025-11-19 15:34       ` Andrew Jones
2025-11-19 15:34 ` Marc Zyngier
2025-11-27 10:04 ` Eric Auger
2025-11-27 11:08   ` Joey Gouly
2025-11-27 12:04     ` Eric Auger
2025-11-27 14:52       ` Joey Gouly [this message]
2025-12-01 23:16         ` Andrew Jones
2025-12-02 14:22           ` Joey Gouly

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=20251127145207.GA3265987@e124191.cambridge.arm.com \
    --to=joey.gouly@arm.com \
    --cc=alexandru.elisei@arm.com \
    --cc=andrew.jones@linux.dev \
    --cc=eric.auger@redhat.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