void vpmu_initialise(struct vcpu *v) { struct vpmu_struct *vpmu = vcpu_vpmu(v); uint8_t vendor = current_cpu_data.x86_vendor; if ( is_pvh_vcpu(v) ) return; if ( vpmu_is_set(vpmu, VPMU_CONTEXT_ALLOCATED) ) vpmu_destroy(v); vpmu_clear(vpmu); vpmu->context = NULL; switch ( vendor ) { case X86_VENDOR_AMD: if ( svm_vpmu_initialise(v, opt_vpmu_enabled) != 0 ) opt_vpmu_enabled = 0; break; case X86_VENDOR_INTEL: if ( vmx_vpmu_initialise(v, opt_vpmu_enabled) != 0 ) opt_vpmu_enabled = 0; break; default: printk("VPMU: Initialization failed. " "Unknown CPU vendor %d\n", vendor); opt_vpmu_enabled = 0; break; } }
static int ppro_allocate_msr(struct vcpu *v) { struct vpmu_struct *vpmu = vcpu_vpmu(v); struct arch_msr_pair *msr_content; msr_content = xzalloc_array(struct arch_msr_pair, num_counters); if ( !msr_content ) goto out; vpmu->context = (void *)msr_content; vpmu_clear(vpmu); vpmu_set(vpmu, VPMU_PASSIVE_DOMAIN_ALLOCATED); return 1; out: printk(XENLOG_G_WARNING "Insufficient memory for oprofile," " oprofile is unavailable on dom%d vcpu%d\n", v->vcpu_id, v->domain->domain_id); return 0; }