return (va >= TASK_SIZE_MAX) || ((va + len - 1) >= TASK_SIZE_MAX);
 }
 
+/*
+ * 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);
+}
+
 static int arch_build_bp_info(struct perf_event *bp,
                              const struct perf_event_attr *attr,
                              struct arch_hw_breakpoint *hw)
 {
+       unsigned long bp_end;
+
+       bp_end = attr->bp_addr + attr->bp_len - 1;
+       if (bp_end < attr->bp_addr)
+               return -EINVAL;
+
+       /*
+        * Prevent any breakpoint of any type that overlaps the
+        * cpu_entry_area.  This protects the IST stacks and also
+        * reduces the chance that we ever find out what happens if
+        * there's a data breakpoint on the GDT, IDT, or TSS.
+        */
+       if (within_cpu_entry_area(attr->bp_addr, bp_end))
+               return -EINVAL;
+
        hw->address = attr->bp_addr;
        hw->mask = 0;