Skip to contentSkip to conversation

pmu emulation fixes

PATCH Applied Gleb Natapov 2 participants 6 messages Feb 26, 2012 – Mar 5, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover pmu emulation fixes

Gleb Natapov (3):
KVM: x86 emulator: warn when pin control is set in eventsel msr
KVM: x86 emulator: Fix raw event check
KVM: x86 emulator: add proper support for fixed counter 2

 arch/x86/include/asm/perf_event.h |    1 +
 arch/x86/kvm/pmu.c                |    8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.7.3
#1 lore raw

PATCH 1/3 KVM: x86 emulator: warn when pin control is set in eventsel msr

Print warning once if pin control bit is set in eventsel msr since emulation does not support it yet.

---
 arch/x86/include/asm/perf_event.h |    1 +
 arch/x86/kvm/pmu.c                |    3 +++
 2 files changed, 4 insertions(+), 0 deletions(-)
arch/x86/include/asm/perf_event.h +1 -0
index 096c975..f1f7182 100644
@@ -23,6 +23,7 @@
 #define ARCH_PERFMON_EVENTSEL_USR			(1ULL << 16)
 #define ARCH_PERFMON_EVENTSEL_OS			(1ULL << 17)
 #define ARCH_PERFMON_EVENTSEL_EDGE			(1ULL << 18)
+#define ARCH_PERFMON_EVENTSEL_PIN_CONTROL		(1ULL << 19)
 #define ARCH_PERFMON_EVENTSEL_INT			(1ULL << 20)
 #define ARCH_PERFMON_EVENTSEL_ANY			(1ULL << 21)
 #define ARCH_PERFMON_EVENTSEL_ENABLE			(1ULL << 22)
arch/x86/kvm/pmu.c +3 -0
index 3e48c1d..6af9a54 100644
@@ -210,6 +210,9 @@ static void reprogram_gp_counter(struct kvm_pmc *pmc, u64 eventsel)
 	unsigned config, type = PERF_TYPE_RAW;
 	u8 event_select, unit_mask;
 
+	if (eventsel & ARCH_PERFMON_EVENTSEL_PIN_CONTROL)
+		printk_once("kvm pmu: pin control bit is ignored\n");
+
 	pmc->eventsel = eventsel;
 
 	stop_counter(pmc);
Signature · 1 line
1.7.7.3
#2 lore raw

PATCH 2/3 KVM: x86 emulator: Fix raw event check

In reply to Gleb Natapov

If eventsel has EDGE, INV or CMASK set we should create raw counter for it, but the check is done on a wrong variable. Fix it.

---
 arch/x86/kvm/pmu.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kvm/pmu.c +1 -1
index 6af9a54..b52a8ed 100644
@@ -223,7 +223,7 @@ static void reprogram_gp_counter(struct kvm_pmc *pmc, u64 eventsel)
 	event_select = eventsel & ARCH_PERFMON_EVENTSEL_EVENT;
 	unit_mask = (eventsel & ARCH_PERFMON_EVENTSEL_UMASK) >> 8;
 
-	if (!(event_select & (ARCH_PERFMON_EVENTSEL_EDGE |
+	if (!(eventsel & (ARCH_PERFMON_EVENTSEL_EDGE |
 				ARCH_PERFMON_EVENTSEL_INV |
 				ARCH_PERFMON_EVENTSEL_CMASK))) {
 		config = find_arch_event(&pmc->vcpu->arch.pmu, event_select,
Signature · 1 line
1.7.7.3
#3 lore raw

PATCH 3/3 KVM: x86 emulator: add proper support for fixed counter 2

In reply to Gleb Natapov

Currently pmu emulation emulates fixed counter 2 as bus cycles architectural counter, but since commit 9c1497ea591b25d perf has pseudo encoding for it. Use it.

---
 arch/x86/kvm/pmu.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
arch/x86/kvm/pmu.c +2 -1
index b52a8ed..a73f0c1 100644
@@ -33,10 +33,11 @@ static struct kvm_arch_event_perf_mapping {
 	[4] = { 0x2e, 0x41, PERF_COUNT_HW_CACHE_MISSES },
 	[5] = { 0xc4, 0x00, PERF_COUNT_HW_BRANCH_INSTRUCTIONS },
 	[6] = { 0xc5, 0x00, PERF_COUNT_HW_BRANCH_MISSES },
+	[7] = { 0x00, 0x30, PERF_COUNT_HW_REF_CPU_CYCLES },
 };
 
 /* mapping between fixed pmc index and arch_events array */
-int fixed_pmc_events[] = {1, 0, 2};
+int fixed_pmc_events[] = {1, 0, 7};
 
 static bool pmc_is_gp(struct kvm_pmc *pmc)
 {
Signature · 1 line
1.7.7.3
Applied
#4 lore raw
In reply to Gleb Natapov
Quoted 5 lines · Gleb Natapov

Gleb Natapov (3):
KVM: x86 emulator: warn when pin control is set in eventsel msr
KVM: x86 emulator: Fix raw event check
KVM: x86 emulator: add proper support for fixed counter 2

Thanks, applied (s/emulator/pmu/...)

Signature · 1 line
error compiling committee.c: too many arguments to function
#5 lore raw
Quoted 9 lines · Avi Kivity
Quoted 5 lines · Gleb Natapov

Gleb Natapov (3):
KVM: x86 emulator: warn when pin control is set in eventsel msr
KVM: x86 emulator: Fix raw event check
KVM: x86 emulator: add proper support for fixed counter 2

Thanks, applied (s/emulator/pmu/...)

You, maintainers, are hard to please! My previous fix to PMU ee3f9f114bdc8b315eed7b1c651ca6c9b8251cf7 was prefixed "KVM: x86 emulator:" so I followed suit :)

--
Gleb.