Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[linux-2.6-microblaze.git] / arch / x86 / kvm / pmu.c
index b1a0299..eca39f5 100644 (file)
@@ -96,8 +96,7 @@ static void kvm_perf_overflow(struct perf_event *perf_event,
 
 static void pmc_reprogram_counter(struct kvm_pmc *pmc, u32 type,
                                  u64 config, bool exclude_user,
-                                 bool exclude_kernel, bool intr,
-                                 bool in_tx, bool in_tx_cp)
+                                 bool exclude_kernel, bool intr)
 {
        struct perf_event *event;
        struct perf_event_attr attr = {
@@ -116,16 +115,14 @@ static void pmc_reprogram_counter(struct kvm_pmc *pmc, u32 type,
 
        attr.sample_period = get_sample_period(pmc, pmc->counter);
 
-       if (in_tx)
-               attr.config |= HSW_IN_TX;
-       if (in_tx_cp) {
+       if ((attr.config & HSW_IN_TX_CHECKPOINTED) &&
+           guest_cpuid_is_intel(pmc->vcpu)) {
                /*
                 * HSW_IN_TX_CHECKPOINTED is not supported with nonzero
                 * period. Just clear the sample period so at least
                 * allocating the counter doesn't fail.
                 */
                attr.sample_period = 0;
-               attr.config |= HSW_IN_TX_CHECKPOINTED;
        }
 
        event = perf_event_create_kernel_counter(&attr, -1, current,
@@ -185,6 +182,7 @@ void reprogram_gp_counter(struct kvm_pmc *pmc, u64 eventsel)
        u32 type = PERF_TYPE_RAW;
        struct kvm *kvm = pmc->vcpu->kvm;
        struct kvm_pmu_event_filter *filter;
+       struct kvm_pmu *pmu = vcpu_to_pmu(pmc->vcpu);
        bool allow_event = true;
 
        if (eventsel & ARCH_PERFMON_EVENTSEL_PIN_CONTROL)
@@ -221,7 +219,7 @@ void reprogram_gp_counter(struct kvm_pmc *pmc, u64 eventsel)
        }
 
        if (type == PERF_TYPE_RAW)
-               config = eventsel & AMD64_RAW_EVENT_MASK;
+               config = eventsel & pmu->raw_event_mask;
 
        if (pmc->current_config == eventsel && pmc_resume_counter(pmc))
                return;
@@ -232,9 +230,7 @@ void reprogram_gp_counter(struct kvm_pmc *pmc, u64 eventsel)
        pmc_reprogram_counter(pmc, type, config,
                              !(eventsel & ARCH_PERFMON_EVENTSEL_USR),
                              !(eventsel & ARCH_PERFMON_EVENTSEL_OS),
-                             eventsel & ARCH_PERFMON_EVENTSEL_INT,
-                             (eventsel & HSW_IN_TX),
-                             (eventsel & HSW_IN_TX_CHECKPOINTED));
+                             eventsel & ARCH_PERFMON_EVENTSEL_INT);
 }
 EXPORT_SYMBOL_GPL(reprogram_gp_counter);
 
@@ -270,7 +266,7 @@ void reprogram_fixed_counter(struct kvm_pmc *pmc, u8 ctrl, int idx)
                              kvm_x86_ops.pmu_ops->pmc_perf_hw_id(pmc),
                              !(en_field & 0x2), /* exclude user */
                              !(en_field & 0x1), /* exclude kernel */
-                             pmi, false, false);
+                             pmi);
 }
 EXPORT_SYMBOL_GPL(reprogram_fixed_counter);