[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200529213320.784524504@infradead.org>
Date: Fri, 29 May 2020 23:27:29 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: tglx@...utronix.de, luto@...capital.net, peterz@...radead.org
Cc: linux-kernel@...r.kernel.org, x86@...nel.org,
Lai Jiangshan <laijs@...ux.alibaba.com>,
sean.j.christopherson@...el.com, andrew.cooper3@...rix.com,
daniel.thompson@...aro.org, a.darwish@...utronix.de,
rostedt@...dmis.org, bigeasy@...utronix.de
Subject: [PATCH 01/14] x86/hw_breakpoint: Add within_area() to check data breakpoints
From: Lai Jiangshan <laijs@...ux.alibaba.com>
within_area() is added for checking if the data breakpoints overlap
with cpu_entry_area, and will be used for checking if the data
breakpoints overlap with GDT, IDT, or TSS in places other than
cpu_entry_area next patches.
Signed-off-by: Lai Jiangshan <laijs@...ux.alibaba.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Link: https://lkml.kernel.org/r/20200526014221.2119-2-laijs@linux.alibaba.com
---
arch/x86/kernel/hw_breakpoint.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
--- a/arch/x86/kernel/hw_breakpoint.c
+++ b/arch/x86/kernel/hw_breakpoint.c
@@ -228,13 +228,22 @@ int arch_check_bp_in_kernelspace(struct
}
/*
+ * Checks whether the range [addr, end], overlaps the area [base, base + size).
+ */
+static inline bool within_area(unsigned long addr, unsigned long end,
+ unsigned long base, unsigned long size)
+{
+ return end >= base && addr < (base + size);
+}
+
+/*
* Checks whether the range from addr to end, inclusive, overlaps the CPU
* entry area range.
*/
static inline bool within_cpu_entry_area(unsigned long addr, unsigned long end)
{
- return end >= CPU_ENTRY_AREA_BASE &&
- addr < (CPU_ENTRY_AREA_BASE + CPU_ENTRY_AREA_TOTAL_SIZE);
+ return within_area(addr, end, CPU_ENTRY_AREA_BASE,
+ CPU_ENTRY_AREA_TOTAL_SIZE);
}
static int arch_build_bp_info(struct perf_event *bp,
Powered by blists - more mailing lists