gitlab.arm.com will be in the maintainance mode on Wednesday June 29th 01:00 - 10:00 (UTC+1). Repositories is read only during the maintainance.

Commit 0eb79e44 authored by Dave Martin's avatar Dave Martin
Browse files

arm64: Add basic SVE support



This patch adds an --sve command line option to allow the Scalable
Vector Extension to be enabled when creating a guest.

This requires use of the new KVM_ARM_VCPU_FINALIZE ioctl before the
vcpu is runnable, so a new hook kvm_cpu__configure_features() is
added to provide an appropiate place to do this work.

The kernel does not enable SVE by default, and for now kvmtool
adopts the same policy: without --sve, SVE is not enabled for the
guest even if the host supports it.
Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
parent 4deb883e
...@@ -13,4 +13,9 @@ ...@@ -13,4 +13,9 @@
#define ARM_CPU_ID 0, 0, 0 #define ARM_CPU_ID 0, 0, 0
#define ARM_CPU_ID_MPIDR 5 #define ARM_CPU_ID_MPIDR 5
static inline int kvm_cpu__configure_features(struct kvm_cpu *vcpu)
{
return 0;
}
#endif /* KVM__KVM_CPU_ARCH_H */ #endif /* KVM__KVM_CPU_ARCH_H */
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
"Create PMUv3 device"), \ "Create PMUv3 device"), \
OPT_U64('\0', "kaslr-seed", &(cfg)->kaslr_seed, \ OPT_U64('\0', "kaslr-seed", &(cfg)->kaslr_seed, \
"Specify random seed for Kernel Address Space " \ "Specify random seed for Kernel Address Space " \
"Layout Randomization (KASLR)"), "Layout Randomization (KASLR)"), \
OPT_BOOLEAN('\0', "sve", &(cfg)->has_sve, \
"Enable SVE for the guest"),
#include "arm-common/kvm-config-arch.h" #include "arm-common/kvm-config-arch.h"
......
...@@ -8,13 +8,18 @@ ...@@ -8,13 +8,18 @@
#define ARM_VCPU_FEATURE_FLAGS(kvm, cpuid) { \ #define ARM_VCPU_FEATURE_FLAGS(kvm, cpuid) { \
[0] = ((!!(cpuid) << KVM_ARM_VCPU_POWER_OFF) | \ [0] = ((!!(cpuid) << KVM_ARM_VCPU_POWER_OFF) | \
(!!(kvm)->cfg.arch.aarch32_guest << KVM_ARM_VCPU_EL1_32BIT) | \ (!!(kvm)->cfg.arch.aarch32_guest << KVM_ARM_VCPU_EL1_32BIT) | \
(!!(kvm)->cfg.arch.has_pmuv3 << KVM_ARM_VCPU_PMU_V3)) \ (!!(kvm)->cfg.arch.has_pmuv3 << KVM_ARM_VCPU_PMU_V3) | \
(!!(kvm)->cfg.arch.has_sve << KVM_ARM_VCPU_SVE)) \
} }
#define ARM_MPIDR_HWID_BITMASK 0xFF00FFFFFFUL #define ARM_MPIDR_HWID_BITMASK 0xFF00FFFFFFUL
#define ARM_CPU_ID 3, 0, 0, 0 #define ARM_CPU_ID 3, 0, 0, 0
#define ARM_CPU_ID_MPIDR 5 #define ARM_CPU_ID_MPIDR 5
#define ARM_CPU_CTRL 3, 0, 1, 0 #define ARM_CPU_CTRL 3, 0, 1, 0
#define ARM_CPU_CTRL_SCTLR_EL1 0 #define ARM_CPU_CTRL_SCTLR_EL1 0
int kvm_cpu__configure_features(struct kvm_cpu *vcpu);
#endif /* KVM__KVM_CPU_ARCH_H */ #endif /* KVM__KVM_CPU_ARCH_H */
...@@ -128,6 +128,25 @@ static void reset_vcpu_aarch64(struct kvm_cpu *vcpu) ...@@ -128,6 +128,25 @@ static void reset_vcpu_aarch64(struct kvm_cpu *vcpu)
} }
} }
static int configure_sve(struct kvm_cpu *vcpu)
{
int feature = KVM_ARM_VCPU_SVE;
if (ioctl(vcpu->vcpu_fd, KVM_ARM_VCPU_FINALIZE, &feature))
return -1;
return 0;
}
int kvm_cpu__configure_features(struct kvm_cpu *vcpu)
{
if (vcpu->kvm->cfg.arch.has_sve)
if (configure_sve(vcpu))
return -1;
return 0;
}
void kvm_cpu__reset_vcpu(struct kvm_cpu *vcpu) void kvm_cpu__reset_vcpu(struct kvm_cpu *vcpu)
{ {
if (vcpu->kvm->cfg.arch.aarch32_guest) if (vcpu->kvm->cfg.arch.aarch32_guest)
......
...@@ -12,6 +12,7 @@ struct kvm_config_arch { ...@@ -12,6 +12,7 @@ struct kvm_config_arch {
u64 kaslr_seed; u64 kaslr_seed;
enum irqchip_type irqchip; enum irqchip_type irqchip;
u64 fw_addr; u64 fw_addr;
bool has_sve;
}; };
int irqchip_parser(const struct option *opt, const char *arg, int unset); int irqchip_parser(const struct option *opt, const char *arg, int unset);
......
...@@ -122,6 +122,9 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id) ...@@ -122,6 +122,9 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
vcpu->cpu_compatible = target->compatible; vcpu->cpu_compatible = target->compatible;
vcpu->is_running = true; vcpu->is_running = true;
if (kvm_cpu__configure_features(vcpu))
die("Unable to configure requested vcpu features");
return vcpu; return vcpu;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment