2024-02-03 12:11:16

by Zhao Liu

[permalink] [raw]
Subject: [RFC 17/26] KVM: VMX: Allow to inject thermal interrupt without HFI update

From: Zhao Liu <[email protected]>

When the HFI table memory address is set by MSR_IA32_HW_FEEDBACK_PTR or
when MSR_IA32_HW_FEEDBACK_CONFIG enables the HFI feature, the hardware
sends an initial HFI notification via thermal interrupt and sets the
thermal status bit.

To prepare for the above cases, extend vmx_update_hfi_table() to allow
the forced thermal interrupt injection (with the thermal status bit set)
regardless of whether there is the HFI table change to be updated.

Tested-by: Yanting Jiang <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
---
arch/x86/kvm/vmx/vmx.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 44c09c995120..97bb7b304213 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -1616,7 +1616,7 @@ static int vmx_build_hfi_table(struct kvm *kvm)
return 1;
}

-static void vmx_update_hfi_table(struct kvm *kvm)
+static void vmx_update_hfi_table(struct kvm *kvm, bool forced_int)
{
struct kvm_vmx *kvm_vmx = to_kvm_vmx(kvm);
struct hfi_desc *kvm_vmx_hfi = &kvm_vmx->pkg_therm.hfi_desc;
@@ -1635,7 +1635,7 @@ static void vmx_update_hfi_table(struct kvm *kvm)
}

ret = vmx_build_hfi_table(kvm);
- if (ret <= 0)
+ if (ret < 0 || (!ret && !forced_int))
return;

kvm_vmx_hfi->hfi_update_status = true;
@@ -1731,7 +1731,7 @@ static void vmx_dynamic_update_hfi_table(struct kvm_vcpu *vcpu)
* of the same VM are sharing the one HFI table. Therefore, one
* vCPU can update the HFI table for the whole VM.
*/
- vmx_update_hfi_table(vcpu->kvm);
+ vmx_update_hfi_table(vcpu->kvm, false);
mutex_unlock(&kvm_vmx->pkg_therm.pkg_therm_lock);
}

--
2.34.1