kvmtool enables SVE whenever it is supported by the KVM.
However, Realm VMs may want controlled features, which gets
measured during the creation. Thus, provide an option to disable
the SVE, to preserve the current behavior of SVE on by default.
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
arm/aarch64/include/kvm/kvm-config-arch.h | 4 +++-
arm/aarch64/kvm-cpu.c | 8 +++++---
arm/include/arm-common/kvm-config-arch.h | 1 +
3 files changed, 9 insertions(+), 4 deletions(-)
@@ -19,7 +19,9 @@ int vcpu_affinity_parser(const struct option *opt, const char *arg, int unset);
"Specify random seed for Kernel Address Space " \
"Layout Randomization (KASLR)"), \
OPT_BOOLEAN('\0', "no-pvtime", &(cfg)->no_pvtime, "Disable" \
- " stolen time"),
+ " stolen time"), \
+ OPT_BOOLEAN('\0', "disable-sve", &(cfg)->disable_sve, \
+ "Disable SVE"),
#include "arm-common/kvm-config-arch.h"
#endif /* KVM__KVM_CONFIG_ARCH_H */
@@ -149,8 +149,9 @@ void kvm_cpu__select_features(struct kvm *kvm, struct kvm_vcpu_init *init)
init->features[0] |= 1UL << KVM_ARM_VCPU_PTRAUTH_GENERIC;
}
- /* Enable SVE if available */
- if (kvm__supports_vm_extension(kvm, KVM_CAP_ARM_SVE))
+ /* If SVE is not disabled explicitly, enable if available */
+ if (!kvm->cfg.arch.disable_sve &&
+ kvm__supports_vm_extension(kvm, KVM_CAP_ARM_SVE))
init->features[0] |= 1UL << KVM_ARM_VCPU_SVE;
}
@@ -158,7 +159,8 @@ int kvm_cpu__configure_features(struct kvm_cpu *vcpu)
{
struct kvm *kvm = vcpu->kvm;
- if (kvm__supports_vm_extension(kvm, KVM_CAP_ARM_SVE)) {
+ if (!kvm->cfg.arch.disable_sve &&
+ kvm__supports_vm_extension(kvm, KVM_CAP_ARM_SVE)) {
int feature = KVM_ARM_VCPU_SVE;
if (ioctl(vcpu->vcpu_fd, KVM_ARM_VCPU_FINALIZE, &feature)) {
@@ -15,6 +15,7 @@ struct kvm_config_arch {
enum irqchip_type irqchip;
u64 fw_addr;
bool no_pvtime;
+ bool disable_sve;
};
int irqchip_parser(const struct option *opt, const char *arg, int unset);