Skip to content

Commit 92ff25b

Browse files
committed
[x86_64][Virtualization] Switch to HCF or VP_RUNTIME counters
1 parent 85b1e62 commit 92ff25b

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
COREFREQ_MAJOR = 1
66
COREFREQ_MINOR = 98
7-
COREFREQ_REV = 3
7+
COREFREQ_REV = 4
88
HW = $(shell uname -m)
99
CC ?= cc
1010
WARNING = -Wall -Wfatal-errors

x86_64/corefreqk.c

+20-6
Original file line numberDiff line numberDiff line change
@@ -14925,11 +14925,22 @@ static void AMD_Core_Counters_Clear(union SAVE_AREA_CORE *Save, CORE_RO *Core)
1492514925

1492614926
#define Counters_VirtualMachine(Core, T) \
1492714927
({ \
14928-
if (!PUBLIC(RO(Proc))->Features.AdvPower.EDX.Inv_TSC) { \
14929-
RDTSC64(Core->Counter[T].TSC); \
14930-
} else { \
14931-
RDTSCP64(Core->Counter[T].TSC); \
14932-
} \
14928+
if (!PUBLIC(RO(Proc))->Features.AdvPower.EDX.Inv_TSC) { \
14929+
RDTSC64(Core->Counter[T].TSC); \
14930+
} else { \
14931+
RDTSCP64(Core->Counter[T].TSC); \
14932+
} \
14933+
switch (PUBLIC(RO(Proc))->Features.Info.Hypervisor.CRC) { \
14934+
HCF_MSR: \
14935+
case CRC_VBOX: \
14936+
case CRC_KBOX: \
14937+
default: \
14938+
RDCOUNTER(Core->Counter[T].C0.UCC, MSR_CORE_PERF_UCC); \
14939+
RDCOUNTER(Core->Counter[T].C0.URC, MSR_CORE_PERF_URC); \
14940+
break; \
14941+
case CRC_KVM: \
14942+
case CRC_VMWARE: \
14943+
case CRC_HYPERV: \
1493314944
/* HV_PARTITION_PRIVILEGE_MASK: AccessVpRunTimeReg */ \
1493414945
if (BITVAL(Core->CpuID[ \
1493514946
CPUID_40000003_00000000_HYPERVISOR_FEATURES \
@@ -14941,7 +14952,10 @@ static void AMD_Core_Counters_Clear(union SAVE_AREA_CORE *Save, CORE_RO *Core)
1494114952
* PUBLIC(RO(Proc))->Features.Factory.Ratio * 10; \
1494214953
\
1494314954
Core->Counter[T].C0.UCC = Core->Counter[T].C0.URC; \
14944-
} \
14955+
} else \
14956+
goto HCF_MSR; \
14957+
break; \
14958+
} \
1494514959
/* Derive C1: */ \
1494614960
Core->Counter[T].C1 = \
1494714961
(Core->Counter[T].TSC > Core->Counter[T].C0.URC) ? \

0 commit comments

Comments
 (0)