From: Gleb Natapov <gleb@redhat.com>
To: kvm@vger.kernel.org
Cc: avi@redhat.com, mtosatti@redhat.com,
linux-kernel@vger.kernel.org, mingo@elte.hu,
a.p.zijlstra@chello.nl, acme@ghostprotocols.net
Subject: [PATCHv2 0/9] KVM in-guest performance monitoring
Date: Thu, 3 Nov 2011 14:33:29 +0200 [thread overview]
Message-ID: <1320323618-10375-1-git-send-email-gleb@redhat.com> (raw)
This patchset exposes an emulated version 2 architectural performance
monitoring unit to KVM guests. The PMU is emulated using perf_events,
so the host kernel can multiplex host-wide, host-user, and the
guest on available resources.
The patches are against next branch on kvm.git.
If you want to try running perf in a guest you need to apply the patch
below to qemu-kvm and use -cpu host on qemu command line. But DO NOT
TRY those patches without applying [1][2] to the host kernel first.
Don't tell me I didn't warn you!
[1] https://lkml.org/lkml/2011/10/18/390
[2] https://lkml.org/lkml/2011/10/23/163
Changelog:
v1->v2
- put index into struct kvm_pmc instead of calculating it
- use locked version of bitops
- inject pmi from irq work if vcpu was not in a guest mode during NMI
- providing stub for perf_get_x86_pmu_capability() for !PERF_EVENTS
Avi Kivity (6):
KVM: Expose kvm_lapic_local_deliver()
KVM: Add generic RDPMC support
KVM: SVM: Intercept RDPMC
KVM: VMX: Intercept RDPMC
KVM: x86 emulator: fix RDPMC privilege check
KVM: x86 emulator: implement RDPMC (0F 33)
Gleb Natapov (3):
KVM: Expose a version 2 architectural PMU to a guests
perf: expose perf capability to other modules.
KVM: Expose the architectural performance monitoring CPUID leaf
arch/x86/include/asm/kvm_emulate.h | 1 +
arch/x86/include/asm/kvm_host.h | 49 +++
arch/x86/include/asm/perf_event.h | 15 +
arch/x86/kernel/cpu/perf_event.c | 11 +
arch/x86/kernel/cpu/perf_event.h | 2 +
arch/x86/kernel/cpu/perf_event_intel.c | 3 +
arch/x86/kvm/Kconfig | 1 +
arch/x86/kvm/Makefile | 2 +-
arch/x86/kvm/emulate.c | 13 +-
arch/x86/kvm/lapic.c | 2 +-
arch/x86/kvm/lapic.h | 1 +
arch/x86/kvm/pmu.c | 529 ++++++++++++++++++++++++++++++++
arch/x86/kvm/svm.c | 15 +
arch/x86/kvm/vmx.c | 15 +-
arch/x86/kvm/x86.c | 69 ++++-
include/linux/kvm_host.h | 2 +
16 files changed, 716 insertions(+), 14 deletions(-)
create mode 100644 arch/x86/kvm/pmu.c
diff --git a/roms/seabios b/roms/seabios
index 8e30147..e0f87ce 160000
--- a/roms/seabios
+++ b/roms/seabios
@@ -1 +1 @@
-Subproject commit 8e301472e324b6d6496d8b4ffc66863e99d7a505
+Subproject commit e0f87ce6610a0f341ff79c2c40ddc29f26932353-dirty
diff --git a/roms/vgabios b/roms/vgabios
index ca056d8..19ea12c 160000
--- a/roms/vgabios
+++ b/roms/vgabios
@@ -1 +1 @@
-Subproject commit ca056d8e77a534f4f90548bc8cee166a378c1454
+Subproject commit 19ea12c230ded95928ecaef0db47a82231c2e485-dirty
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index f179999..ff2a0ca 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -1178,11 +1178,20 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
*edx = 0;
break;
case 0xA:
- /* Architectural Performance Monitoring Leaf */
- *eax = 0;
- *ebx = 0;
- *ecx = 0;
- *edx = 0;
+ if (kvm_enabled()) {
+ KVMState *s = env->kvm_state;
+
+ *eax = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EAX);
+ *ebx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EBX);
+ *ecx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_ECX);
+ *edx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EDX);
+ } else {
+ /* Architectural Performance Monitoring Leaf */
+ *eax = 0; //0x07280402;
+ *ebx = 0;
+ *ecx = 0;
+ *edx = 0; //0x00000503;
+ }
break;
case 0xD:
/* Processor Extended State */
--
1.7.5.3
next reply other threads:[~2011-11-03 12:34 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-03 12:33 Gleb Natapov [this message]
2011-11-03 12:33 ` [PATCHv2 1/9] KVM: Expose kvm_lapic_local_deliver() Gleb Natapov
2011-11-03 12:33 ` [PATCHv2 2/9] KVM: Expose a version 2 architectural PMU to a guests Gleb Natapov
2011-11-07 14:22 ` Peter Zijlstra
2011-11-07 15:34 ` Gleb Natapov
2011-11-07 15:40 ` Avi Kivity
2011-11-07 14:34 ` Peter Zijlstra
2011-11-07 14:46 ` Avi Kivity
2011-11-07 14:59 ` Peter Zijlstra
2011-11-07 15:11 ` Gleb Natapov
2011-11-07 15:13 ` Avi Kivity
2011-11-07 15:19 ` Gleb Natapov
2011-11-07 15:25 ` Avi Kivity
2011-11-07 16:22 ` Peter Zijlstra
2011-11-07 16:26 ` Gleb Natapov
2011-11-07 14:36 ` Peter Zijlstra
2011-11-07 15:25 ` Gleb Natapov
2011-11-07 16:45 ` Peter Zijlstra
2011-11-07 17:17 ` Gleb Natapov
2011-11-03 12:33 ` [PATCHv2 3/9] KVM: Add generic RDPMC support Gleb Natapov
2011-11-03 12:33 ` [PATCHv2 4/9] KVM: SVM: Intercept RDPMC Gleb Natapov
2011-11-03 12:33 ` [PATCHv2 5/9] KVM: VMX: " Gleb Natapov
2011-11-03 12:33 ` [PATCHv2 6/9] perf: expose perf capability to other modules Gleb Natapov
2011-11-07 14:07 ` Peter Zijlstra
2011-11-07 15:53 ` Gleb Natapov
2011-11-07 16:01 ` Peter Zijlstra
2011-11-07 16:22 ` Gleb Natapov
2011-11-07 16:25 ` Peter Zijlstra
2011-11-08 12:49 ` Gleb Natapov
2011-11-08 13:26 ` Peter Zijlstra
2011-11-08 13:54 ` Gleb Natapov
2011-11-08 14:12 ` Peter Zijlstra
2011-11-08 14:18 ` Gleb Natapov
2011-11-08 14:31 ` Peter Zijlstra
2011-11-10 11:56 ` Gleb Natapov
2011-11-03 12:33 ` [PATCHv2 7/9] KVM: Expose the architectural performance monitoring CPUID leaf Gleb Natapov
2011-11-07 14:09 ` Peter Zijlstra
2011-11-07 15:41 ` Gleb Natapov
2011-11-07 15:45 ` Peter Zijlstra
2011-11-07 15:54 ` Gleb Natapov
2011-11-03 12:33 ` [PATCHv2 8/9] KVM: x86 emulator: fix RDPMC privilege check Gleb Natapov
2011-11-03 12:33 ` [PATCHv2 9/9] KVM: x86 emulator: implement RDPMC (0F 33) Gleb Natapov
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=1320323618-10375-1-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
Powered by JetHome