Bladeren bron

powerpc, hw_breakpoint: Tell generic code we have no instruction breakpoints

At present, hw_breakpoint_slots() returns 1 regardless of what
type of breakpoint is specified in the type argument.  Since we
don't define CONFIG_HAVE_MIXED_BREAKPOINTS_REGS, there are
separate values for TYPE_INST and TYPE_DATA, and hw_breakpoint_slots()
returns 1 for both, effectively advertising instruction breakpoint
support which doesn't exist.

This fixes it by making hw_breakpoint_slots return 1 for TYPE_DATA
and 0 for TYPE_INST.  This moves hw_breakpoint_slots() from the
powerpc hw_breakpoint.h to hw_breakpoint.c because the definitions
of TYPE_INST and TYPE_DATA aren't available in <asm/hw_breakpoint.h>.
They are defined in <linux/hw_breakpoint.h> but we can't include
that header in <asm/hw_breakpoint.h>, and nor can we rely on
<linux/hw_breakpoint.h> being included before <asm/hw_breakpoint.h>.
Since hw_breakpoint_slots() is only called at boot time, there is
no performance impact from making it a real function rather than
a static inline.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras 15 jaren geleden
bovenliggende
commit
d09ec73871
2 gewijzigde bestanden met toevoegingen van 11 en 4 verwijderingen
  1. 1 4
      arch/powerpc/include/asm/hw_breakpoint.h
  2. 10 0
      arch/powerpc/kernel/hw_breakpoint.c

+ 1 - 4
arch/powerpc/include/asm/hw_breakpoint.h

@@ -37,10 +37,6 @@ struct arch_hw_breakpoint {
 #include <asm/reg.h>
 #include <asm/reg.h>
 #include <asm/system.h>
 #include <asm/system.h>
 
 
-static inline int hw_breakpoint_slots(int type)
-{
-	return HBP_NUM;
-}
 struct perf_event;
 struct perf_event;
 struct pmu;
 struct pmu;
 struct perf_sample_data;
 struct perf_sample_data;
@@ -49,6 +45,7 @@ struct perf_sample_data;
 /* Maximum permissible length of any HW Breakpoint */
 /* Maximum permissible length of any HW Breakpoint */
 #define HW_BREAKPOINT_LEN 0x8
 #define HW_BREAKPOINT_LEN 0x8
 
 
+extern int hw_breakpoint_slots(int type);
 extern int arch_bp_generic_fields(int type, int *gen_bp_type);
 extern int arch_bp_generic_fields(int type, int *gen_bp_type);
 extern int arch_check_bp_in_kernelspace(struct perf_event *bp);
 extern int arch_check_bp_in_kernelspace(struct perf_event *bp);
 extern int arch_validate_hwbkpt_settings(struct perf_event *bp);
 extern int arch_validate_hwbkpt_settings(struct perf_event *bp);

+ 10 - 0
arch/powerpc/kernel/hw_breakpoint.c

@@ -43,6 +43,16 @@
  */
  */
 static DEFINE_PER_CPU(struct perf_event *, bp_per_reg);
 static DEFINE_PER_CPU(struct perf_event *, bp_per_reg);
 
 
+/*
+ * Returns total number of data or instruction breakpoints available.
+ */
+int hw_breakpoint_slots(int type)
+{
+	if (type == TYPE_DATA)
+		return HBP_NUM;
+	return 0;		/* no instruction breakpoints available */
+}
+
 /*
 /*
  * Install a perf counter breakpoint.
  * Install a perf counter breakpoint.
  *
  *