public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>, kvm@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Subject: [PATCH v2 09/11] KVM: Expose the architectural performance monitoring CPUID leaf
Date: Mon, 13 Jun 2011 16:35:04 +0300	[thread overview]
Message-ID: <1307972106-2468-10-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1307972106-2468-1-git-send-email-avi@redhat.com>

Provide a CPUID leaf that describes the emulated PMU.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/x86.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 7bc5e56..7e1a02b 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2442,6 +2442,25 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 	}
 	case 9:
 		break;
+	case 0xA: { /* Architectural Performance Monitoring */
+		unsigned version = entry->eax & 0xff;
+		unsigned gp_nr = (entry->eax >> 8) & 0xff;
+		unsigned gp_width = (entry->eax >> 16) & 0xff;
+
+		if (version < 1) {
+			gp_nr = 2;
+			gp_width = 40;
+		}
+
+		entry->eax = 0x01             /* version */
+			| (gp_nr << 8)
+			| (gp_width << 16)
+			| (7 << 24);   /* supported counters bitmask length */
+		entry->ebx &= (1 << 7) - 1;
+		entry->ecx = 0;
+		entry->edx = 0;
+		break;
+	}
 	/* function 0xb has additional index. */
 	case 0xb: {
 		int i, level_type;
@@ -2532,7 +2551,6 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
 	case 3: /* Processor serial number */
 	case 5: /* MONITOR/MWAIT */
 	case 6: /* Thermal management */
-	case 0xA: /* Architectural Performance Monitoring */
 	case 0x80000007: /* Advanced power management */
 	case 0xC0000002:
 	case 0xC0000003:
-- 
1.7.5.3


  parent reply	other threads:[~2011-06-13 13:35 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-13 13:34 [PATCH v2 00/11] KVM in-guest performance monitoring Avi Kivity
2011-06-13 13:34 ` [PATCH v2 01/11] perf: add context field to perf_event Avi Kivity
2011-06-13 13:34 ` [PATCH v2 02/11] x86, perf: add constraints for architectural PMU v1 Avi Kivity
2011-06-13 13:34 ` [PATCH v2 03/11] perf: export perf_event_refresh() to modules Avi Kivity
2011-06-13 13:34 ` [PATCH v2 04/11] KVM: Expose kvm_lapic_local_deliver() Avi Kivity
2011-06-13 13:35 ` [PATCH v2 05/11] KVM: Expose a version 1 architectural PMU to guests Avi Kivity
2011-06-13 18:10   ` David Ahern
2011-06-14  8:33     ` Avi Kivity
2011-06-27 14:10   ` lidong chen
2011-06-27 14:13     ` Avi Kivity
2011-06-28  2:54       ` lidong chen
2011-06-28  8:15         ` Avi Kivity
2011-06-13 13:35 ` [PATCH v2 06/11] KVM: Add generic RDPMC support Avi Kivity
2011-06-13 13:35 ` [PATCH v2 07/11] KVM: SVM: Intercept RDPMC Avi Kivity
2011-06-13 13:35 ` [PATCH v2 08/11] KVM: VMX: " Avi Kivity
2011-06-13 16:17   ` David Ahern
2011-06-13 16:29     ` Avi Kivity
2011-06-13 16:59       ` David Ahern
2011-06-13 17:38         ` Ingo Molnar
2011-06-13 18:09           ` David Ahern
2011-06-14  8:34           ` Avi Kivity
2011-06-14  9:27             ` Ingo Molnar
2011-06-13 13:35 ` Avi Kivity [this message]
2011-06-13 13:35 ` [PATCH v2 10/11] KVM: x86 emulator: fix RDPMC privilege check Avi Kivity
2011-06-13 13:35 ` [PATCH v2 11/11] KVM: x86 emulator: implement RDPMC (0F 33) Avi Kivity
2011-06-13 19:55 ` [PATCH v2 00/11] KVM in-guest performance monitoring David Ahern
2011-06-14  8:36   ` Avi Kivity
2011-06-14 17:15     ` David Ahern
2011-06-14 17:24       ` Jan Kiszka
2011-06-14 17:33         ` David Ahern
2011-06-14 17:48           ` David Ahern
2011-06-14 18:11             ` David Ahern
2011-06-15  8:57               ` Avi Kivity
2011-06-15 12:40                 ` David Ahern
2011-06-15 13:22                   ` Avi Kivity
2011-06-15 16:08                     ` David Ahern
2011-06-15 16:27                       ` Avi Kivity
2011-06-15 16:51                         ` David Ahern
2011-06-16 13:53                           ` Avi Kivity
2011-06-16 14:08                             ` David Ahern
2011-06-16 14:19                               ` David Ahern
2011-06-16 14:20                                 ` Avi Kivity
2011-06-16 14:32                                   ` David Ahern
2011-06-16 14:36                                     ` Avi Kivity
2011-06-16 15:04                                       ` David Ahern
2011-06-16 15:08                               ` Peter Zijlstra
2011-06-16 15:18                                 ` David Ahern
2011-06-16 15:19                                 ` David Ahern
2011-06-16 15:27                                   ` Peter Zijlstra
2011-06-16 15:34                                     ` David Ahern
2011-06-16 15:59                                       ` Avi Kivity
2011-06-16 16:04                                         ` David Ahern
2011-06-16 16:31                                           ` Avi Kivity
2011-06-16 17:16                                             ` David Ahern
2011-06-29  7:52 ` Avi Kivity
2011-06-29  8:38   ` Peter Zijlstra
2011-06-29  9:26     ` 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=1307972106-2468-10-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=kvm@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