{
struct amd_vpmu_context *ctxt = NULL;
struct vpmu_struct *vpmu = vcpu_vpmu(v);
- __u8 family = current_cpu_data.x86;
+ uint8_t family = current_cpu_data.x86;
if ( vpmu->flags & VPMU_CONTEXT_ALLOCATED )
return;
.arch_vpmu_save = amd_vpmu_save,
.arch_vpmu_load = amd_vpmu_restore
};
+
+int svm_vpmu_initialise(struct vcpu *v)
+{
+ struct vpmu_struct *vpmu = vcpu_vpmu(v);
+ uint8_t family = current_cpu_data.x86;
+
+ switch ( family )
+ {
+ case 0x10:
+ case 0x12:
+ case 0x14:
+ case 0x15:
+ vpmu->arch_vpmu_ops = &amd_vpmu_ops;
+ return 0;
+ }
+
+ printk("VPMU: Initialization failed. "
+ "AMD processor family %d has not "
+ "been supported\n", family);
+ return -EINVAL;
+}
+
.arch_vpmu_save = core2_vpmu_save,
.arch_vpmu_load = core2_vpmu_load
};
+
+int vmx_vpmu_initialise(struct vcpu *v)
+{
+ struct vpmu_struct *vpmu = vcpu_vpmu(v);
+ uint8_t family = current_cpu_data.x86;
+ uint8_t cpu_model = current_cpu_data.x86_model;
+
+ if ( family == 6 )
+ {
+ switch ( cpu_model )
+ {
+ case 15:
+ case 23:
+ case 26:
+ case 29:
+ case 42:
+ case 46:
+ case 47:
+ vpmu->arch_vpmu_ops = &core2_vpmu_ops;
+ return 0;
+ }
+ }
+
+ printk("VPMU: Initialization failed. "
+ "Intel processor family %d model %d has not "
+ "been supported\n", family, cpu_model);
+ return -EINVAL;
+}
+
void vpmu_initialise(struct vcpu *v)
{
struct vpmu_struct *vpmu = vcpu_vpmu(v);
- __u8 vendor = current_cpu_data.x86_vendor;
- __u8 family = current_cpu_data.x86;
- __u8 cpu_model = current_cpu_data.x86_model;
+ uint8_t vendor = current_cpu_data.x86_vendor;
if ( !opt_vpmu_enabled )
return;
switch ( vendor )
{
case X86_VENDOR_AMD:
- switch ( family )
- {
- case 0x10:
- case 0x12:
- case 0x14:
- case 0x15:
- vpmu->arch_vpmu_ops = &amd_vpmu_ops;
- break;
- default:
- printk("VPMU: Initialization failed. "
- "AMD processor family %d has not "
- "been supported\n", family);
- return;
- }
+ if ( svm_vpmu_initialise(v) != 0 )
+ opt_vpmu_enabled = 0;
break;
case X86_VENDOR_INTEL:
- if ( family == 6 )
- {
- switch ( cpu_model )
- {
- case 15:
- case 23:
- case 26:
- case 29:
- case 42:
- case 46:
- case 47:
- vpmu->arch_vpmu_ops = &core2_vpmu_ops;
- break;
- }
- }
- if ( vpmu->arch_vpmu_ops == NULL )
- printk("VPMU: Initialization failed. "
- "Intel processor family %d model %d has not "
- "been supported\n", family, cpu_model);
+ if ( vmx_vpmu_initialise(v) != 0 )
+ opt_vpmu_enabled = 0;
break;
default:
printk("VPMU: Initialization failed. "
"Unknown CPU vendor %d\n", vendor);
+ opt_vpmu_enabled = 0;
break;
}
void (*arch_vpmu_load)(struct vcpu *v);
};
-extern struct arch_vpmu_ops core2_vpmu_ops;
-extern struct arch_vpmu_ops amd_vpmu_ops;
+int vmx_vpmu_initialise(struct vcpu *v);
+int svm_vpmu_initialise(struct vcpu *v);
struct vpmu_struct {
u32 flags;