[PATCH 03/14] KVM: arm64: Mark HCR.EL2.E2H RES0 when ID_AA64MMFR1_EL1.VH is zero
Aneesh Kumar K.V
aneesh.kumar at kernel.org
Sun Feb 23 23:39:30 PST 2025
Marc Zyngier <maz at kernel.org> writes:
> Enforce HCR_EL2.E2H being RES0 when VHE is disabled, so that we can
> actually rely on that bit never being flipped behind our back.
>
> Signed-off-by: Marc Zyngier <maz at kernel.org>
> ---
> arch/arm64/kvm/nested.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c
> index 0c9387d2f5070..ed3add7d32f66 100644
> --- a/arch/arm64/kvm/nested.c
> +++ b/arch/arm64/kvm/nested.c
> @@ -1034,6 +1034,8 @@ int kvm_init_nv_sysregs(struct kvm_vcpu *vcpu)
> res0 |= (HCR_TEA | HCR_TERR);
> if (!kvm_has_feat(kvm, ID_AA64MMFR1_EL1, LO, IMP))
> res0 |= HCR_TLOR;
> + if (!kvm_has_feat(kvm, ID_AA64MMFR1_EL1, VH, IMP))
> + res0 |= HCR_E2H;
> if (!kvm_has_feat(kvm, ID_AA64MMFR4_EL1, E2H0, IMP))
> res1 |= HCR_E2H;
>
Does it make sense to check for E2H0 if MMFR1_EL1.VH == 0 ?
Should the above check be
if (!kvm_has_feat(kvm, ID_AA64MMFR1_EL1, VH, IMP))
res0 |= HCR_E2H;
else if (!kvm_has_feat(kvm, ID_AA64MMFR4_EL1, E2H0, IMP))
res1 |= HCR_E2H;
> set_sysreg_masks(kvm, HCR_EL2, res0, res1);
> --
> 2.39.2
More information about the linux-arm-kernel
mailing list