Re: [kvm-unit-tests PATCH v1 7/7] arm64: run at EL2 if supported

Marc Zyngier
2025-02-20T15:34:52Z

On Thu, 20 Feb 2025 14:13:54 +0000,
Joey Gouly <joey.gouly@arm.com> wrote:
>
> If VHE is supported, continue booting at EL2, otherwise continue booting at
> EL1.
>
> Signed-off-by: Joey Gouly <joey.gouly@arm.com>
> ---
> arm/cstart64.S | 28 ++++++++++++++++++++++++++++
> lib/arm64/asm/sysreg.h | 5 +++++
> 2 files changed, 33 insertions(+)
>
> diff --git a/arm/cstart64.S b/arm/cstart64.S
> index 3a305ad0..2a15c03d 100644
> --- a/arm/cstart64.S
> +++ b/arm/cstart64.S
> @@ -68,6 +68,20 @@ reloc_done:
> mrs x4, CurrentEL
> cmp x4, CurrentEL_EL2
> b.ne 1f
> + /* EL2 setup */
> + mrs x4, mpidr_el1
> + msr vmpidr_el2, x4
> + mrs x4, midr_el1
> + msr vpidr_el2, x4
> + /* check VHE is supported */
> + mrs x4, ID_AA64MMFR1_EL1
> + ubfx x4, x4, ID_AA64MMFR1_EL1_VH_SHIFT, #4
> + cmp x4, #0
> + b.eq drop_to_el1

nit: you can replace these cmp/b.eq with a cbz.

Thanks,

M.

--
Without deviation from the norm, progress is not possible.