Skip to content

Commit f19a0c2

Browse files
Gleb Natapovavikivity
authored andcommitted
KVM: PMU emulation: GLOBAL_CTRL MSR should be enabled on reset
On reset all MPU counters should be enabled in GLOBAL_CTRL MSR. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
1 parent 0034102 commit f19a0c2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

arch/x86/kvm/pmu.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -459,17 +459,17 @@ void kvm_pmu_cpuid_update(struct kvm_vcpu *vcpu)
459459
pmu->available_event_types = ~entry->ebx & ((1ull << bitmap_len) - 1);
460460

461461
if (pmu->version == 1) {
462-
pmu->global_ctrl = (1 << pmu->nr_arch_gp_counters) - 1;
463-
return;
462+
pmu->nr_arch_fixed_counters = 0;
463+
} else {
464+
pmu->nr_arch_fixed_counters = min((int)(entry->edx & 0x1f),
465+
X86_PMC_MAX_FIXED);
466+
pmu->counter_bitmask[KVM_PMC_FIXED] =
467+
((u64)1 << ((entry->edx >> 5) & 0xff)) - 1;
464468
}
465469

466-
pmu->nr_arch_fixed_counters = min((int)(entry->edx & 0x1f),
467-
X86_PMC_MAX_FIXED);
468-
pmu->counter_bitmask[KVM_PMC_FIXED] =
469-
((u64)1 << ((entry->edx >> 5) & 0xff)) - 1;
470-
pmu->global_ctrl_mask = ~(((1 << pmu->nr_arch_gp_counters) - 1)
471-
| (((1ull << pmu->nr_arch_fixed_counters) - 1)
472-
<< X86_PMC_IDX_FIXED));
470+
pmu->global_ctrl = ((1 << pmu->nr_arch_gp_counters) - 1) |
471+
(((1ull << pmu->nr_arch_fixed_counters) - 1) << X86_PMC_IDX_FIXED);
472+
pmu->global_ctrl_mask = ~pmu->global_ctrl;
473473
}
474474

475475
void kvm_pmu_init(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)