Skip to content

Commit 59d67fc

Browse files
committed
KVM: nSVM: Use KVM-governed feature framework to track "Pause Filter enabled"
Track "Pause Filtering is exposed to L1" via governed feature flags instead of using dedicated bits/flags in vcpu_svm. No functional change intended. Reviewed-by: Yuan Yao <yuan.yao@intel.com> Link: https://lore.kernel.org/r/20230815203653.519297-13-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent e183d17 commit 59d67fc

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

arch/x86/kvm/governed_features.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ KVM_GOVERNED_X86_FEATURE(NRIPS)
1212
KVM_GOVERNED_X86_FEATURE(TSCRATEMSR)
1313
KVM_GOVERNED_X86_FEATURE(V_VMSAVE_VMLOAD)
1414
KVM_GOVERNED_X86_FEATURE(LBRV)
15+
KVM_GOVERNED_X86_FEATURE(PAUSEFILTER)
16+
KVM_GOVERNED_X86_FEATURE(PFTHRESHOLD)
1517

1618
#undef KVM_GOVERNED_X86_FEATURE
1719
#undef KVM_GOVERNED_FEATURE

arch/x86/kvm/svm/nested.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,14 @@ static void nested_vmcb02_prepare_control(struct vcpu_svm *svm,
743743
if (!nested_vmcb_needs_vls_intercept(svm))
744744
vmcb02->control.virt_ext |= VIRTUAL_VMLOAD_VMSAVE_ENABLE_MASK;
745745

746-
pause_count12 = svm->pause_filter_enabled ? svm->nested.ctl.pause_filter_count : 0;
747-
pause_thresh12 = svm->pause_threshold_enabled ? svm->nested.ctl.pause_filter_thresh : 0;
746+
if (guest_can_use(vcpu, X86_FEATURE_PAUSEFILTER))
747+
pause_count12 = svm->nested.ctl.pause_filter_count;
748+
else
749+
pause_count12 = 0;
750+
if (guest_can_use(vcpu, X86_FEATURE_PFTHRESHOLD))
751+
pause_thresh12 = svm->nested.ctl.pause_filter_thresh;
752+
else
753+
pause_thresh12 = 0;
748754
if (kvm_pause_in_guest(svm->vcpu.kvm)) {
749755
/* use guest values since host doesn't intercept PAUSE */
750756
vmcb02->control.pause_filter_count = pause_count12;

arch/x86/kvm/svm/svm.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4271,11 +4271,8 @@ static void svm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
42714271
if (!guest_cpuid_is_intel(vcpu))
42724272
kvm_governed_feature_check_and_set(vcpu, X86_FEATURE_V_VMSAVE_VMLOAD);
42734273

4274-
svm->pause_filter_enabled = kvm_cpu_cap_has(X86_FEATURE_PAUSEFILTER) &&
4275-
guest_cpuid_has(vcpu, X86_FEATURE_PAUSEFILTER);
4276-
4277-
svm->pause_threshold_enabled = kvm_cpu_cap_has(X86_FEATURE_PFTHRESHOLD) &&
4278-
guest_cpuid_has(vcpu, X86_FEATURE_PFTHRESHOLD);
4274+
kvm_governed_feature_check_and_set(vcpu, X86_FEATURE_PAUSEFILTER);
4275+
kvm_governed_feature_check_and_set(vcpu, X86_FEATURE_PFTHRESHOLD);
42794276

42804277
svm->vgif_enabled = vgif && guest_cpuid_has(vcpu, X86_FEATURE_VGIF);
42814278

arch/x86/kvm/svm/svm.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ struct vcpu_svm {
259259
bool soft_int_injected;
260260

261261
/* optional nested SVM features that are enabled for this guest */
262-
bool pause_filter_enabled : 1;
263-
bool pause_threshold_enabled : 1;
264262
bool vgif_enabled : 1;
265263
bool vnmi_enabled : 1;
266264

0 commit comments

Comments
 (0)