diff mbox series

[RFC,16/26] KVM: VMX: Update HFI table when vCPU migrates

Message ID 20240203091214.411862-17-zhao1.liu@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Intel Thread Director Virtualization | expand

Commit Message

Zhao Liu Feb. 3, 2024, 9:12 a.m. UTC
From: Zhuocheng Ding <zhuocheng.ding@intel.com>

When the vCPU migrates to a different pCPU, the virtual hfi data
corresponding to the vCPU's hfi index should be updated to the new
pCPU's data.

We don't need to re-register HFI notifier because currently ITD/HFI
virtualization is only supported for client platforms (with only one
HFI instance).

In this case, make the request to update the virtual hfi table.

Tested-by: Yanting Jiang <yanting.jiang@intel.com>
Signed-off-by: Zhuocheng Ding <zhuocheng.ding@intel.com>
Co-developed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
 arch/x86/kvm/vmx/vmx.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 0ad5e3473a28..44c09c995120 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -1735,6 +1735,17 @@  static void vmx_dynamic_update_hfi_table(struct kvm_vcpu *vcpu)
 	mutex_unlock(&kvm_vmx->pkg_therm.pkg_therm_lock);
 }
 
+static void vmx_vcpu_hfi_load(struct kvm_vcpu *vcpu, int cpu)
+{
+	if (!intel_hfi_enabled())
+		return;
+
+	if (!vmx_hfi_initialized(to_kvm_vmx(vcpu->kvm)))
+		return;
+
+	kvm_make_request(KVM_REQ_HFI_UPDATE, vcpu);
+}
+
 /*
  * Switches to specified vcpu, until a matching vcpu_put(), but assumes
  * vcpu mutex is already taken.
@@ -1748,6 +1759,9 @@  static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 	vmx_vcpu_pi_load(vcpu, cpu);
 
 	vmx->host_debugctlmsr = get_debugctlmsr();
+
+	if (unlikely(vcpu->cpu != cpu))
+		vmx_vcpu_hfi_load(vcpu, cpu);
 }
 
 static void vmx_vcpu_put(struct kvm_vcpu *vcpu)