From: Eric Auger <eric.auger@redhat.com>
To: Joey Gouly <joey.gouly@arm.com>, kvm@vger.kernel.org
Cc: 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 07/10] arm64: selftest: update test for running at EL2
Date: Tue, 2 Dec 2025 10:16:42 +0100 [thread overview]
Message-ID: <5160dadb-1ff3-487e-bd0b-9f643c3d9ec3@redhat.com> (raw)
In-Reply-To: <20250925141958.468311-8-joey.gouly@arm.com>
On 9/25/25 4:19 PM, Joey Gouly wrote:
> From: Alexandru Elisei <alexandru.elisei@arm.com>
>
> Remove some hard-coded assumptions that this test is running at EL1.
>
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> Signed-off-by: Joey Gouly <joey.gouly@arm.com>
> ---
> arm/selftest.c | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/arm/selftest.c b/arm/selftest.c
> index 1553ed8e..01691389 100644
> --- a/arm/selftest.c
> +++ b/arm/selftest.c
> @@ -232,6 +232,7 @@ static void user_psci_system_off(struct pt_regs *regs)
> __user_psci_system_off();
> }
> #elif defined(__aarch64__)
> +static unsigned long expected_level;
>
> /*
> * Capture the current register state and execute an instruction
> @@ -276,8 +277,7 @@ static bool check_regs(struct pt_regs *regs)
> {
> unsigned i;
>
> - /* exception handlers should always run in EL1 */
> - if (current_level() != CurrentEL_EL1)
> + if (current_level() != expected_level)
> return false;
>
> for (i = 0; i < ARRAY_SIZE(regs->regs); ++i) {
> @@ -301,7 +301,11 @@ static enum vector check_vector_prep(void)
> return EL0_SYNC_64;
>
> asm volatile("mrs %0, daif" : "=r" (daif) ::);
> - expected_regs.pstate = daif | PSR_MODE_EL1h;
> + expected_regs.pstate = daif;
> + if (current_level() == CurrentEL_EL1)
> + expected_regs.pstate |= PSR_MODE_EL1h;
> + else
> + expected_regs.pstate |= PSR_MODE_EL2h;
> return EL1H_SYNC;
> }
>
> @@ -317,8 +321,8 @@ static bool check_und(void)
>
> install_exception_handler(v, ESR_EL1_EC_UNKNOWN, unknown_handler);
>
> - /* try to read an el2 sysreg from el0/1 */
> - test_exception("", "mrs x0, sctlr_el2", "", "x0");
> + /* try to read an el3 sysreg from el0/1/2 */
> + test_exception("", "mrs x0, sctlr_el3", "", "x0");
>
> install_exception_handler(v, ESR_EL1_EC_UNKNOWN, NULL);
>
> @@ -429,6 +433,10 @@ int main(int argc, char **argv)
> if (argc < 2)
> report_abort("no test specified");
>
> +#if defined(__aarch64__)
> + expected_level = current_level();
nit I would directly use current_level() in the calling function,
check_regs() to avoid that #ifdef
Eric
> +#endif
> +
> report_prefix_push(argv[1]);
>
> if (strcmp(argv[1], "setup") == 0) {
next prev parent reply other threads:[~2025-12-02 9:16 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 [this message]
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
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=5160dadb-1ff3-487e-bd0b-9f643c3d9ec3@redhat.com \
--to=eric.auger@redhat.com \
--cc=alexandru.elisei@arm.com \
--cc=andrew.jones@linux.dev \
--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