* [PATCH] KVM: PMU emulation: GLOBAL_CTRL MSR should be enabled on reset.
@ 2012-04-09 14:38 Gleb Natapov
2012-04-10 12:25 ` Avi Kivity
0 siblings, 1 reply; 2+ messages in thread
From: Gleb Natapov @ 2012-04-09 14:38 UTC (permalink / raw)
To: kvm; +Cc: avi, mtosatti
On reset all MPU counters should be enabled in GLOBAL_CTRL MSR.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index 173df38..2e88438 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -459,17 +459,17 @@ void kvm_pmu_cpuid_update(struct kvm_vcpu *vcpu)
pmu->available_event_types = ~entry->ebx & ((1ull << bitmap_len) - 1);
if (pmu->version == 1) {
- pmu->global_ctrl = (1 << pmu->nr_arch_gp_counters) - 1;
- return;
+ pmu->nr_arch_fixed_counters = 0;
+ } else {
+ pmu->nr_arch_fixed_counters = min((int)(entry->edx & 0x1f),
+ X86_PMC_MAX_FIXED);
+ pmu->counter_bitmask[KVM_PMC_FIXED] =
+ ((u64)1 << ((entry->edx >> 5) & 0xff)) - 1;
}
- pmu->nr_arch_fixed_counters = min((int)(entry->edx & 0x1f),
- X86_PMC_MAX_FIXED);
- pmu->counter_bitmask[KVM_PMC_FIXED] =
- ((u64)1 << ((entry->edx >> 5) & 0xff)) - 1;
- pmu->global_ctrl_mask = ~(((1 << pmu->nr_arch_gp_counters) - 1)
- | (((1ull << pmu->nr_arch_fixed_counters) - 1)
- << X86_PMC_IDX_FIXED));
+ pmu->global_ctrl = ((1 << pmu->nr_arch_gp_counters) - 1) |
+ (((1ull << pmu->nr_arch_fixed_counters) - 1) << X86_PMC_IDX_FIXED);
+ pmu->global_ctrl_mask = ~pmu->global_ctrl;
}
void kvm_pmu_init(struct kvm_vcpu *vcpu)
--
Gleb.
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: PMU emulation: GLOBAL_CTRL MSR should be enabled on reset.
2012-04-09 14:38 [PATCH] KVM: PMU emulation: GLOBAL_CTRL MSR should be enabled on reset Gleb Natapov
@ 2012-04-10 12:25 ` Avi Kivity
0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2012-04-10 12:25 UTC (permalink / raw)
To: Gleb Natapov; +Cc: kvm, mtosatti
On 04/09/2012 05:38 PM, Gleb Natapov wrote:
> On reset all MPU counters should be enabled in GLOBAL_CTRL MSR.
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
> index 173df38..2e88438 100644
> --- a/arch/x86/kvm/pmu.c
> +++ b/arch/x86/kvm/pmu.c
> @@ -459,17 +459,17 @@ void kvm_pmu_cpuid_update(struct kvm_vcpu *vcpu)
> pmu->available_event_types = ~entry->ebx & ((1ull << bitmap_len) - 1);
>
> if (pmu->version == 1) {
> - pmu->global_ctrl = (1 << pmu->nr_arch_gp_counters) - 1;
> - return;
> + pmu->nr_arch_fixed_counters = 0;
> + } else {
> + pmu->nr_arch_fixed_counters = min((int)(entry->edx & 0x1f),
> + X86_PMC_MAX_FIXED);
> + pmu->counter_bitmask[KVM_PMC_FIXED] =
> + ((u64)1 << ((entry->edx >> 5) & 0xff)) - 1;
> }
>
> - pmu->nr_arch_fixed_counters = min((int)(entry->edx & 0x1f),
> - X86_PMC_MAX_FIXED);
> - pmu->counter_bitmask[KVM_PMC_FIXED] =
> - ((u64)1 << ((entry->edx >> 5) & 0xff)) - 1;
> - pmu->global_ctrl_mask = ~(((1 << pmu->nr_arch_gp_counters) - 1)
> - | (((1ull << pmu->nr_arch_fixed_counters) - 1)
> - << X86_PMC_IDX_FIXED));
> + pmu->global_ctrl = ((1 << pmu->nr_arch_gp_counters) - 1) |
> + (((1ull << pmu->nr_arch_fixed_counters) - 1) << X86_PMC_IDX_FIXED);
> + pmu->global_ctrl_mask = ~pmu->global_ctrl;
> }
>
>
This is not called on INIT (not sure it should be). On the other hand
update_cpuid() is not the best place to initialize stuff.
Oh well, this can be fixed later (not sure its possible), I'll apply
this to master.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-04-10 12:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-09 14:38 [PATCH] KVM: PMU emulation: GLOBAL_CTRL MSR should be enabled on reset Gleb Natapov
2012-04-10 12:25 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox