[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1560238451-19495-5-git-send-email-wanpengli@tencent.com>
Date: Tue, 11 Jun 2019 15:34:10 +0800
From: Wanpeng Li <kernellwp@...il.com>
To: linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Cc: Paolo Bonzini <pbonzini@...hat.com>,
Radim Krčmář <rkrcmar@...hat.com>
Subject: [PATCH v2 4/5] KVM: VMX: Add get/set residency msrs logic
From: Wanpeng Li <wanpengli@...cent.com>
Add logic to get/set the residency msrs. Then current idle
power-state residency statistics can be consult by guest, and
be save/restore during live migration.
Cc: Paolo Bonzini <pbonzini@...hat.com>
Cc: Radim Krčmář <rkrcmar@...hat.com>
Signed-off-by: Wanpeng Li <wanpengli@...cent.com>
---
arch/x86/kvm/vmx/vmx.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 2ebaa90..852f51e 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -1715,6 +1715,9 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
case MSR_IA32_FEATURE_CONTROL:
msr_info->data = vmx->msr_ia32_feature_control;
break;
+ case MSR_CORE_C3_RESIDENCY ... MSR_CORE_C7_RESIDENCY:
+ msr_info->data = kvm_residency_read(vcpu, msr_info->index);
+ break;
case MSR_IA32_VMX_BASIC ... MSR_IA32_VMX_VMFUNC:
if (!nested_vmx_allowed(vcpu))
return 1;
@@ -1928,6 +1931,11 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
if (msr_info->host_initiated && data == 0)
vmx_leave_nested(vcpu);
break;
+ case MSR_CORE_C3_RESIDENCY ... MSR_CORE_C7_RESIDENCY:
+ if (!msr_info->host_initiated)
+ return 1;
+ kvm_residency_write(vcpu, msr_info->index, data);
+ break;
case MSR_IA32_VMX_BASIC ... MSR_IA32_VMX_VMFUNC:
if (!msr_info->host_initiated)
return 1; /* they are read-only */
--
2.7.4
Powered by blists - more mailing lists