From: Wanpeng Li <kernellwp@gmail.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>
Subject: [PATCH v2 4/5] KVM: VMX: Add get/set residency msrs logic
Date: Tue, 11 Jun 2019 15:34:10 +0800 [thread overview]
Message-ID: <1560238451-19495-5-git-send-email-wanpengli@tencent.com> (raw)
In-Reply-To: <1560238451-19495-1-git-send-email-wanpengli@tencent.com>
From: Wanpeng Li <wanpengli@tencent.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@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Wanpeng Li <wanpengli@tencent.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
next prev parent reply other threads:[~2019-06-11 7:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-11 7:34 [PATCH v2 0/5] KVM: X86: Add virtual C-states residency msrs support Wanpeng Li
2019-06-11 7:34 ` [PATCH v2 1/5] KVM: X86: Dynamic allocate core residency msr state Wanpeng Li
2019-06-12 16:01 ` Sean Christopherson
2019-06-13 0:43 ` Wanpeng Li
2019-06-11 7:34 ` [PATCH v2 2/5] KVM: X86: Introduce residency msrs read/write operations Wanpeng Li
2019-06-11 7:34 ` [PATCH v2 3/5] KVM: X86: setup residency msrs during vCPU creation Wanpeng Li
2019-06-11 7:34 ` Wanpeng Li [this message]
2019-06-11 7:34 ` [PATCH v2 5/5] KVM: X86: Save/restore residency values when vCPU migrations Wanpeng Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1560238451-19495-5-git-send-email-wanpengli@tencent.com \
--to=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).