x86/cpu/vpmu: Add Hygon Dhyana and AMD Zen support for vPMU

As Hygon Dhyana CPU share similar PMU architecture with AMD family
17h one, so add Hygon Dhyana support in vpmu_arch_initialise() and
vpmu_init() by sharing AMD code path.

Split the common part in amd_vpmu_init() to a static function
_vpmu_init(), making AMD and Hygon to call the shared function to
initialize vPMU.

As current vPMU still not support AMD Zen(family 17h), add 0x17 support
to amd_vpmu_init().

Also create a function hygon_vpmu_init() for Hygon vPMU initialization.

Both of AMD 17h and Hygon 18h have the same performance event select
and counter MSRs as AMD 15h has, so reuse the 15h definitions for them.

Signed-off-by: Pu Wen <puwen@hygon.cn>
Acked-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Pu Wen authored and Andrew Cooper committed 2019-06-06 15:28:21 +01:00
1 parent 1c07b0135a
commit 4d94642626
3 files changed
+51 -18

No files matched your search

+8
View File
@@ -456,6 +456,7 @@ static int vpmu_arch_initialise(struct vcpu *v)
switch ( vendor )
{
case X86_VENDOR_AMD:
case X86_VENDOR_HYGON:
ret = svm_vpmu_initialise(v);
break;
@@ -876,10 +877,17 @@ static int __init vpmu_init(void)
if ( amd_vpmu_init() )
vpmu_mode = XENPMU_MODE_OFF;
break;
case X86_VENDOR_HYGON:
if ( hygon_vpmu_init() )
vpmu_mode = XENPMU_MODE_OFF;
break;
case X86_VENDOR_INTEL:
if ( core2_vpmu_init() )
vpmu_mode = XENPMU_MODE_OFF;
break;
default:
printk(XENLOG_WARNING "VPMU: Unknown CPU vendor: %d. "
"Turning VPMU off.\n", vendor);
+42 -18
View File
@@ -538,28 +538,12 @@ int svm_vpmu_initialise(struct vcpu *v)
return 0;
}
int __init amd_vpmu_init(void)
static int __init common_init(void)
{
unsigned int i;
switch ( current_cpu_data.x86 )
if ( !num_counters )
{
case 0x15:
num_counters = F15H_NUM_COUNTERS;
counters = AMD_F15H_COUNTERS;
ctrls = AMD_F15H_CTRLS;
k7_counters_mirrored = 1;
break;
case 0x10:
case 0x12:
case 0x14:
case 0x16:
num_counters = F10H_NUM_COUNTERS;
counters = AMD_F10H_COUNTERS;
ctrls = AMD_F10H_CTRLS;
k7_counters_mirrored = 0;
break;
default:
printk(XENLOG_WARNING "VPMU: Unsupported CPU family %#x\n",
current_cpu_data.x86);
return -EINVAL;
@@ -586,3 +570,43 @@ int __init amd_vpmu_init(void)
return 0;
}
int __init amd_vpmu_init(void)
{
switch ( current_cpu_data.x86 )
{
case 0x15:
case 0x17:
num_counters = F15H_NUM_COUNTERS;
counters = AMD_F15H_COUNTERS;
ctrls = AMD_F15H_CTRLS;
k7_counters_mirrored = 1;
break;
case 0x10:
case 0x12:
case 0x14:
case 0x16:
num_counters = F10H_NUM_COUNTERS;
counters = AMD_F10H_COUNTERS;
ctrls = AMD_F10H_CTRLS;
k7_counters_mirrored = 0;
break;
}
return common_init();
}
int __init hygon_vpmu_init(void)
{
switch ( current_cpu_data.x86 )
{
case 0x18:
num_counters = F15H_NUM_COUNTERS;
counters = AMD_F15H_COUNTERS;
ctrls = AMD_F15H_CTRLS;
k7_counters_mirrored = 1;
break;
}
return common_init();
}
+1
View File
@@ -52,6 +52,7 @@ struct arch_vpmu_ops {
int core2_vpmu_init(void);
int vmx_vpmu_initialise(struct vcpu *);
int amd_vpmu_init(void);
int hygon_vpmu_init(void);
int svm_vpmu_initialise(struct vcpu *);
struct vpmu_struct {
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.