diff options
| author | Kan Liang <kan.liang@linux.intel.com> | 2020-05-28 08:19:29 -0700 |
|---|---|---|
| committer | Peter Zijlstra <peterz@infradead.org> | 2020-06-15 14:09:50 +0200 |
| commit | f01719730bbe04b90ae60c7e9d2b6d3533308502 (patch) | |
| tree | ce4a492b4a9cf7963cfe13175ed83a66d5c5ca16 /arch/x86/events/intel/uncore.h | |
| parent | perf/x86/intel/uncore: Record the size of mapped area (diff) | |
| download | linux-f01719730bbe04b90ae60c7e9d2b6d3533308502.tar.gz linux-f01719730bbe04b90ae60c7e9d2b6d3533308502.zip | |
perf/x86/intel/uncore: Validate MMIO address before accessing
An oops will be triggered, if perf tries to access an invalid address
which exceeds the mapped area.
Check the address before the actual access to MMIO sapce of an uncore
unit.
Suggested-by: David Laight <David.Laight@ACULAB.COM>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/1590679169-61823-3-git-send-email-kan.liang@linux.intel.com
Diffstat (limited to 'arch/x86/events/intel/uncore.h')
| -rw-r--r-- | arch/x86/events/intel/uncore.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h index 79ff626b7ea6..7859ac01f7a5 100644 --- a/arch/x86/events/intel/uncore.h +++ b/arch/x86/events/intel/uncore.h @@ -197,6 +197,18 @@ static inline bool uncore_pmc_freerunning(int idx) return idx == UNCORE_PMC_IDX_FREERUNNING; } +static inline bool uncore_mmio_is_valid_offset(struct intel_uncore_box *box, + unsigned long offset) +{ + if (offset < box->pmu->type->mmio_map_size) + return true; + + pr_warn_once("perf uncore: Invalid offset 0x%lx exceeds mapped area of %s.\n", + offset, box->pmu->type->name); + + return false; +} + static inline unsigned int uncore_mmio_box_ctl(struct intel_uncore_box *box) { |
