aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Elisei <alexandru.elisei@arm.com>2022-04-12 14:32:24 +0100
committerWill Deacon <will@kernel.org>2022-05-06 14:21:16 +0100
commit412ee1375de8fcfae2feece5db9c859eedb3cdba (patch)
treea70864d98c928518c44d4c232ecb95140a57ef94
parent5898515dc727c8fa595a25dac640202bec2440eb (diff)
downloadkvmtool-412ee1375de8fcfae2feece5db9c859eedb3cdba.tar.gz
arm: Move arch specific VCPU features to the arch specific function
KVM_CAP_ARM_EL1_32BIT and KVM_CAP_ARM_PMU_V3 are arm64 specific features. They are set based on arm64 specific command line options and they target arm64 hardware features. It makes little sense for kvmtool to set the features in the code that is shared between arm and arm64. Move the logic to set the feature bits to the arch specific function kvm_cpu__select_features(), which is already used by arm64 to set other arm64 specific features. Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20220412133231.35355-5-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--arm/aarch64/include/kvm/kvm-cpu-arch.h4
-rw-r--r--arm/aarch64/kvm-cpu.c12
-rw-r--r--arm/kvm-cpu.c8
3 files changed, 13 insertions, 11 deletions
diff --git a/arm/aarch64/include/kvm/kvm-cpu-arch.h b/arm/aarch64/include/kvm/kvm-cpu-arch.h
index 35996dc0..4cbadf91 100644
--- a/arm/aarch64/include/kvm/kvm-cpu-arch.h
+++ b/arm/aarch64/include/kvm/kvm-cpu-arch.h
@@ -6,9 +6,7 @@
#include "arm-common/kvm-cpu-arch.h"
#define ARM_VCPU_FEATURE_FLAGS(kvm, cpuid) { \
- [0] = ((!!(cpuid) << KVM_ARM_VCPU_POWER_OFF) | \
- (!!(kvm)->cfg.arch.aarch32_guest << KVM_ARM_VCPU_EL1_32BIT) | \
- (!!(kvm)->cfg.arch.has_pmuv3 << KVM_ARM_VCPU_PMU_V3)) \
+ [0] = (!!(cpuid) << KVM_ARM_VCPU_POWER_OFF), \
}
#define ARM_MPIDR_HWID_BITMASK 0xFF00FFFFFFUL
diff --git a/arm/aarch64/kvm-cpu.c b/arm/aarch64/kvm-cpu.c
index 9f3e8586..3b6224a5 100644
--- a/arm/aarch64/kvm-cpu.c
+++ b/arm/aarch64/kvm-cpu.c
@@ -130,6 +130,18 @@ static void reset_vcpu_aarch64(struct kvm_cpu *vcpu)
void kvm_cpu__select_features(struct kvm *kvm, struct kvm_vcpu_init *init)
{
+ if (kvm->cfg.arch.aarch32_guest) {
+ if (!kvm__supports_extension(kvm, KVM_CAP_ARM_EL1_32BIT))
+ die("32bit guests are not supported\n");
+ init->features[0] |= 1UL << KVM_ARM_VCPU_EL1_32BIT;
+ }
+
+ if (kvm->cfg.arch.has_pmuv3) {
+ if (!kvm__supports_extension(kvm, KVM_CAP_ARM_PMU_V3))
+ die("PMUv3 is not supported");
+ init->features[0] |= 1UL << KVM_ARM_VCPU_PMU_V3;
+ }
+
/* Enable pointer authentication if available */
if (kvm__supports_extension(kvm, KVM_CAP_ARM_PTRAUTH_ADDRESS) &&
kvm__supports_extension(kvm, KVM_CAP_ARM_PTRAUTH_GENERIC)) {
diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c
index 00660d6e..3a5c8a5a 100644
--- a/arm/kvm-cpu.c
+++ b/arm/kvm-cpu.c
@@ -46,14 +46,6 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
.features = ARM_VCPU_FEATURE_FLAGS(kvm, cpu_id)
};
- if (kvm->cfg.arch.aarch32_guest &&
- !kvm__supports_extension(kvm, KVM_CAP_ARM_EL1_32BIT))
- die("32bit guests are not supported\n");
-
- if (kvm->cfg.arch.has_pmuv3 &&
- !kvm__supports_extension(kvm, KVM_CAP_ARM_PMU_V3))
- die("PMUv3 is not supported");
-
vcpu = calloc(1, sizeof(struct kvm_cpu));
if (!vcpu)
return NULL;