Skip to content

Commit d390e6d

Browse files
Lai JiangshanKAGA-KOKO
authored andcommitted
x86/hw_breakpoint: Add within_area() to check data breakpoints
Add a within_area() helper to checking whether the data breakpoints overlap with cpu_entry_area. It will be used to completely prevent data breakpoints on GDT, IDT, or TSS. Signed-off-by: Lai Jiangshan <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent 998c203 commit d390e6d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

arch/x86/kernel/hw_breakpoint.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,23 @@ int arch_check_bp_in_kernelspace(struct arch_hw_breakpoint *hw)
227227
return (va >= TASK_SIZE_MAX) || ((va + len - 1) >= TASK_SIZE_MAX);
228228
}
229229

230+
/*
231+
* Checks whether the range [addr, end], overlaps the area [base, base + size).
232+
*/
233+
static inline bool within_area(unsigned long addr, unsigned long end,
234+
unsigned long base, unsigned long size)
235+
{
236+
return end >= base && addr < (base + size);
237+
}
238+
230239
/*
231240
* Checks whether the range from addr to end, inclusive, overlaps the CPU
232241
* entry area range.
233242
*/
234243
static inline bool within_cpu_entry_area(unsigned long addr, unsigned long end)
235244
{
236-
return end >= CPU_ENTRY_AREA_BASE &&
237-
addr < (CPU_ENTRY_AREA_BASE + CPU_ENTRY_AREA_TOTAL_SIZE);
245+
return within_area(addr, end, CPU_ENTRY_AREA_BASE,
246+
CPU_ENTRY_AREA_TOTAL_SIZE);
238247
}
239248

240249
static int arch_build_bp_info(struct perf_event *bp,

0 commit comments

Comments
 (0)