From: Gleb Natapov <gleb@redhat.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, avi@redhat.com,
mtosatti@redhat.com, mingo@elte.hu, a.p.zijlstra@chello.nl,
acme@ghostprotocols.net
Subject: [PATCHv3 04/10] KVM: SVM: Intercept RDPMC
Date: Thu, 10 Nov 2011 14:57:24 +0200 [thread overview]
Message-ID: <1320929850-10480-5-git-send-email-gleb@redhat.com> (raw)
In-Reply-To: <1320929850-10480-1-git-send-email-gleb@redhat.com>
From: Avi Kivity <avi@redhat.com>
Intercept RDPMC and forward it to the PMU emulation code.
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
arch/x86/kvm/svm.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index e32243e..5fa553b 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1014,6 +1014,7 @@ static void init_vmcb(struct vcpu_svm *svm)
set_intercept(svm, INTERCEPT_NMI);
set_intercept(svm, INTERCEPT_SMI);
set_intercept(svm, INTERCEPT_SELECTIVE_CR0);
+ set_intercept(svm, INTERCEPT_RDPMC);
set_intercept(svm, INTERCEPT_CPUID);
set_intercept(svm, INTERCEPT_INVD);
set_intercept(svm, INTERCEPT_HLT);
@@ -2770,6 +2771,19 @@ static int emulate_on_interception(struct vcpu_svm *svm)
return emulate_instruction(&svm->vcpu, 0) == EMULATE_DONE;
}
+static int rdpmc_interception(struct vcpu_svm *svm)
+{
+ int err;
+
+ if (!static_cpu_has(X86_FEATURE_NRIPS))
+ return emulate_on_interception(svm);
+
+ err = kvm_rdpmc(&svm->vcpu);
+ kvm_complete_insn_gp(&svm->vcpu, err);
+
+ return 1;
+}
+
bool check_selective_cr0_intercepted(struct vcpu_svm *svm, unsigned long val)
{
unsigned long cr0 = svm->vcpu.arch.cr0;
@@ -3190,6 +3204,7 @@ static int (*svm_exit_handlers[])(struct vcpu_svm *svm) = {
[SVM_EXIT_SMI] = nop_on_interception,
[SVM_EXIT_INIT] = nop_on_interception,
[SVM_EXIT_VINTR] = interrupt_window_interception,
+ [SVM_EXIT_RDPMC] = rdpmc_interception,
[SVM_EXIT_CPUID] = cpuid_interception,
[SVM_EXIT_IRET] = iret_interception,
[SVM_EXIT_INVD] = emulate_on_interception,
--
1.7.7.1
next prev parent reply other threads:[~2011-11-10 13:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-10 12:57 [PATCHv3 00/10] KVM in-guest performance monitoring Gleb Natapov
2011-11-10 12:57 ` [PATCHv3 01/10] KVM: Expose kvm_lapic_local_deliver() Gleb Natapov
2011-11-10 12:57 ` [PATCHv3 02/10] KVM: Expose a version 2 architectural PMU to a guests Gleb Natapov
2011-11-10 12:57 ` [PATCHv3 03/10] KVM: Add generic RDPMC support Gleb Natapov
2011-11-10 12:57 ` Gleb Natapov [this message]
2011-11-10 12:57 ` [PATCHv3 05/10] KVM: VMX: Intercept RDPMC Gleb Natapov
2011-11-10 12:57 ` [PATCHv3 06/10] x86, perf: disable non available architectural events Gleb Natapov
2011-11-17 9:29 ` Peter Zijlstra
2011-12-06 20:17 ` [tip:perf/core] x86, perf: Disable " tip-bot for Gleb Natapov
2011-11-10 12:57 ` [PATCHv3 07/10] perf, x86: expose perf capability to other modules Gleb Natapov
2011-12-06 20:18 ` [tip:perf/core] perf, x86: Expose " tip-bot for Gleb Natapov
2011-11-10 12:57 ` [PATCHv3 08/10] KVM: Expose the architectural performance monitoring CPUID leaf Gleb Natapov
2011-11-10 12:57 ` [PATCHv3 09/10] KVM: x86 emulator: fix RDPMC privilege check Gleb Natapov
2011-11-10 12:57 ` [PATCHv3 10/10] KVM: x86 emulator: implement RDPMC (0F 33) Gleb Natapov
2011-11-17 9:30 ` [PATCHv3 00/10] KVM in-guest performance monitoring Peter Zijlstra
2011-12-11 14:05 ` Avi Kivity
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=1320929850-10480-5-git-send-email-gleb@redhat.com \
--to=gleb@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mtosatti@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).