Skip to content

Commit f3c6efc

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: Treat PMCR_EL1.LC as RES1 on asymmetric systems
KVM does not support AArch32 on asymmetric systems. To that end, enforce AArch64-only behavior on PMCR_EL1.LC when on an asymmetric system. Fixes: 2122a83 ("arm64: Allow mismatched 32-bit EL0 support") Signed-off-by: Oliver Upton <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ae3b1da commit f3c6efc

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,10 @@ bool kvm_arm_vcpu_is_finalized(struct kvm_vcpu *vcpu);
929929
(system_supports_mte() && \
930930
test_bit(KVM_ARCH_FLAG_MTE_ENABLED, &(kvm)->arch.flags))
931931

932+
#define kvm_supports_32bit_el0() \
933+
(system_supports_32bit_el0() && \
934+
!static_branch_unlikely(&arm64_mismatched_32bit_el0))
935+
932936
int kvm_trng_call(struct kvm_vcpu *vcpu);
933937
#ifdef CONFIG_KVM
934938
extern phys_addr_t hyp_mem_base;

arch/arm64/kvm/arm.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,7 @@ static bool vcpu_mode_is_bad_32bit(struct kvm_vcpu *vcpu)
757757
if (likely(!vcpu_mode_is_32bit(vcpu)))
758758
return false;
759759

760-
return !system_supports_32bit_el0() ||
761-
static_branch_unlikely(&arm64_mismatched_32bit_el0);
760+
return !kvm_supports_32bit_el0();
762761
}
763762

764763
/**

arch/arm64/kvm/sys_regs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ static void reset_pmcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
652652
*/
653653
val = ((pmcr & ~ARMV8_PMU_PMCR_MASK)
654654
| (ARMV8_PMU_PMCR_MASK & 0xdecafbad)) & (~ARMV8_PMU_PMCR_E);
655-
if (!system_supports_32bit_el0())
655+
if (!kvm_supports_32bit_el0())
656656
val |= ARMV8_PMU_PMCR_LC;
657657
__vcpu_sys_reg(vcpu, r->reg) = val;
658658
}
@@ -701,7 +701,7 @@ static bool access_pmcr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
701701
val = __vcpu_sys_reg(vcpu, PMCR_EL0);
702702
val &= ~ARMV8_PMU_PMCR_MASK;
703703
val |= p->regval & ARMV8_PMU_PMCR_MASK;
704-
if (!system_supports_32bit_el0())
704+
if (!kvm_supports_32bit_el0())
705705
val |= ARMV8_PMU_PMCR_LC;
706706
__vcpu_sys_reg(vcpu, PMCR_EL0) = val;
707707
kvm_pmu_handle_pmcr(vcpu, val);

0 commit comments

Comments
 (0)