aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_ds.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c
index f364c13ddaa6..655d591b57a0 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_ds.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c
@@ -944,7 +944,7 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
944 struct perf_event *event = NULL; 944 struct perf_event *event = NULL;
945 void *at, *top; 945 void *at, *top;
946 u64 status = 0; 946 u64 status = 0;
947 int bit, n; 947 int bit;
948 948
949 if (!x86_pmu.pebs_active) 949 if (!x86_pmu.pebs_active)
950 return; 950 return;
@@ -954,16 +954,16 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs)
954 954
955 ds->pebs_index = ds->pebs_buffer_base; 955 ds->pebs_index = ds->pebs_buffer_base;
956 956
957 n = (top - at) / x86_pmu.pebs_record_size; 957 if (unlikely(at > top))
958 if (n <= 0)
959 return; 958 return;
960 959
961 /* 960 /*
962 * Should not happen, we program the threshold at 1 and do not 961 * Should not happen, we program the threshold at 1 and do not
963 * set a reset value. 962 * set a reset value.
964 */ 963 */
965 WARN_ONCE(n > x86_pmu.max_pebs_events, 964 WARN_ONCE(top - at > x86_pmu.max_pebs_events * x86_pmu.pebs_record_size,
966 "Unexpected number of pebs records %d\n", n); 965 "Unexpected number of pebs records %ld\n",
966 (top - at) / x86_pmu.pebs_record_size);
967 967
968 for (; at < top; at += x86_pmu.pebs_record_size) { 968 for (; at < top; at += x86_pmu.pebs_record_size) {
969 struct pebs_record_nhm *p = at; 969 struct pebs_record_nhm *p = at;