Skip to content

Commit be9c0c0

Browse files
committed
KVM: arm64: Hoist SVE check into KVM_ARM_VCPU_INIT ioctl handler
Test that the system supports SVE before ever getting to kvm_reset_vcpu(). Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 9116db1 commit be9c0c0

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

arch/arm64/kvm/arm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,9 @@ static unsigned long system_supported_vcpu_features(void)
12001200
if (!kvm_arm_support_pmu_v3())
12011201
clear_bit(KVM_ARM_VCPU_PMU_V3, &features);
12021202

1203+
if (!system_supports_sve())
1204+
clear_bit(KVM_ARM_VCPU_SVE, &features);
1205+
12031206
return features;
12041207
}
12051208

arch/arm64/kvm/reset.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,8 @@ int __init kvm_arm_init_sve(void)
7373
return 0;
7474
}
7575

76-
static int kvm_vcpu_enable_sve(struct kvm_vcpu *vcpu)
76+
static void kvm_vcpu_enable_sve(struct kvm_vcpu *vcpu)
7777
{
78-
if (!system_supports_sve())
79-
return -EINVAL;
80-
8178
vcpu->arch.sve_max_vl = kvm_sve_max_vl;
8279

8380
/*
@@ -86,8 +83,6 @@ static int kvm_vcpu_enable_sve(struct kvm_vcpu *vcpu)
8683
* kvm_arm_vcpu_finalize(), which freezes the configuration.
8784
*/
8885
vcpu_set_flag(vcpu, GUEST_HAS_SVE);
89-
90-
return 0;
9186
}
9287

9388
/*
@@ -231,11 +226,8 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
231226
}
232227

233228
if (!kvm_arm_vcpu_sve_finalized(vcpu)) {
234-
if (test_bit(KVM_ARM_VCPU_SVE, vcpu->arch.features)) {
235-
ret = kvm_vcpu_enable_sve(vcpu);
236-
if (ret)
237-
goto out;
238-
}
229+
if (test_bit(KVM_ARM_VCPU_SVE, vcpu->arch.features))
230+
kvm_vcpu_enable_sve(vcpu);
239231
} else {
240232
kvm_vcpu_reset_sve(vcpu);
241233
}

0 commit comments

Comments
 (0)