提交 408c0988 编写于 作者: W Wei Li 提交者: Xie XiuQi

arm64: perf: fix Invalid PMEV* index WARNING

hulk inclusion
category: bugfix
bugzilla: NA
CVE: NA

-------------------------------------------------

When PMSELR_EL0.SEL == 31, the register PMXEVTYPER_EL0 accesses
PMCCFILTR_EL0. Add a branch to process such condition.

Fix: commit 2f10f935b6a6 ("arm64: perf: avoid PMXEV* indirection")
Signed-off-by: NWei Li <liwei391@huawei.com>
Reviewed-by: NCheng Jian <cj.chengjian@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 d6eedb6d
...@@ -538,7 +538,7 @@ static inline bool armv8pmu_event_is_chained(struct perf_event *event) ...@@ -538,7 +538,7 @@ static inline bool armv8pmu_event_is_chained(struct perf_event *event)
PMEVN_CASE(28, case_macro); \ PMEVN_CASE(28, case_macro); \
PMEVN_CASE(29, case_macro); \ PMEVN_CASE(29, case_macro); \
PMEVN_CASE(30, case_macro); \ PMEVN_CASE(30, case_macro); \
default: WARN(1, "Inavlid PMEV* index"); \ default: WARN(1, "Invalid PMEV* index %#x", __x); \
} \ } \
} while (0) } while (0)
...@@ -706,7 +706,7 @@ static inline void armv8pmu_write_evtype(int idx, u32 val) ...@@ -706,7 +706,7 @@ static inline void armv8pmu_write_evtype(int idx, u32 val)
} }
} }
static inline void armv8pmu_write_event_type(struct perf_event *event) static inline void armv8pmu_write_hw_type(struct perf_event *event)
{ {
struct hw_perf_event *hwc = &event->hw; struct hw_perf_event *hwc = &event->hw;
int idx = hwc->idx; int idx = hwc->idx;
...@@ -727,6 +727,26 @@ static inline void armv8pmu_write_event_type(struct perf_event *event) ...@@ -727,6 +727,26 @@ static inline void armv8pmu_write_event_type(struct perf_event *event)
} }
} }
static inline void armv8pmu_write_event_type(struct perf_event *event)
{
if (!pmu_nmi_enable) {
armv8pmu_write_hw_type(event);
} else {
struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu);
struct hw_perf_event *hwc = &event->hw;
int idx = hwc->idx;
if (!armv8pmu_counter_valid(cpu_pmu, idx))
pr_err("CPU%u writing wrong event %d\n",
smp_processor_id(), idx);
else if (idx == ARMV8_IDX_CYCLE_COUNTER)
write_sysreg(hwc->config_base & ARMV8_PMU_EVTYPE_MASK,
pmccfiltr_el0);
else
armv8pmu_write_hw_type(event);
}
}
static inline int armv8pmu_enable_counter(int idx) static inline int armv8pmu_enable_counter(int idx)
{ {
u32 counter = ARMV8_IDX_TO_COUNTER(idx); u32 counter = ARMV8_IDX_TO_COUNTER(idx);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册