@@ -39,7 +39,7 @@
#define KVM_MAX_VCPUS VGIC_V3_MAX_CPUS
-#define KVM_VCPU_MAX_FEATURES 7
+#define KVM_VCPU_MAX_FEATURES 8
#define KVM_REQ_SLEEP \
KVM_ARCH_REQ_FLAGS(0, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
@@ -1178,8 +1178,12 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu,
val = cpuid_feature_cap_perfmon_field(val,
ID_AA64DFR0_PMUVER_SHIFT,
ID_AA64DFR0_PMUVER_8_1);
- /* Don't advertise SPE to guests */
- val &= ~(0xfUL << ID_AA64DFR0_PMSVER_SHIFT);
+ /*
+ * Don't advertise SPE to guests without SPE. Otherwise, allow
+ * the guest to detect the hardware SPE version.
+ */
+ if (!vcpu_has_spe(vcpu))
+ val &= ~(0xfUL << ID_AA64DFR0_PMSVER_SHIFT);
} else if (id == SYS_ID_DFR0_EL1) {
/* Limit guests to PMUv3 for ARMv8.1 */
val = cpuid_feature_cap_perfmon_field(val,
We have all the bits in place to expose SPE to guests, allow userspace to set the feature and advertise the presence of SPE in the ID_AA64DFR0_EL1 register. Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> --- arch/arm64/include/asm/kvm_host.h | 2 +- arch/arm64/kvm/sys_regs.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-)