Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934804Ab3DIRWI (ORCPT ); Tue, 9 Apr 2013 13:22:08 -0400 Received: from tx2ehsobe002.messaging.microsoft.com ([65.55.88.12]:5600 "EHLO tx2outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933213Ab3DIRWE (ORCPT ); Tue, 9 Apr 2013 13:22:04 -0400 X-Forefront-Antispam-Report: CIP:163.181.249.109;KIP:(null);UIP:(null);IPV:NLI;H:ausb3twp02.amd.com;RD:none;EFVD:NLI X-SpamScore: 0 X-BigFish: VPS0(zzzz1f42h1fc6h1ee6h1de0h1fdah1202h1e76h1d1ah1d2ahzz8275bhz2dh668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1155h) X-WSS-ID: 0ML008N-02-EE9-02 X-M-MSG: From: Jacob Shin To: Ingo Molnar , Peter Zijlstra , Arnaldo Carvalho de Melo CC: "H. Peter Anvin" , Thomas Gleixner , , Stephane Eranian , Jiri Olsa , , Jacob Shin Subject: [PATCH 1/5] perf: Add hardware breakpoint address mask Date: Tue, 9 Apr 2013 12:21:49 -0500 Message-ID: <1365528113-5458-2-git-send-email-jacob.shin@amd.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1365528113-5458-1-git-send-email-jacob.shin@amd.com> References: <1365528113-5458-1-git-send-email-jacob.shin@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-OriginatorOrg: amd.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2741 Lines: 84 Some architectures (for us, AMD Family 16h) allow for "don't care" bit mask to further qualify a hardware breakpoint address, in order to trap on range of addresses. Update perf uapi to add bp_addr_mask field and define HAVE_HW_BREAKPOINT_ADDR_MASK. Signed-off-by: Jacob Shin --- arch/Kconfig | 4 ++++ include/linux/hw_breakpoint.h | 6 ++++++ include/uapi/linux/perf_event.h | 5 ++++- kernel/events/hw_breakpoint.c | 3 +++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/arch/Kconfig b/arch/Kconfig index 1455579..8423e9c 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -249,6 +249,10 @@ config HAVE_HW_BREAKPOINT bool depends on PERF_EVENTS +config HAVE_HW_BREAKPOINT_ADDR_MASK + bool + depends on HAVE_HW_BREAKPOINT + config HAVE_MIXED_BREAKPOINTS_REGS bool depends on HAVE_HW_BREAKPOINT diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h index 0464c85..9384201 100644 --- a/include/linux/hw_breakpoint.h +++ b/include/linux/hw_breakpoint.h @@ -84,6 +84,12 @@ static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp) return &bp->hw.info; } +#ifdef CONFIG_HAVE_HW_BREAKPOINT_ADDR_MASK +extern int arch_has_hw_breakpoint_addr_mask(void); +#else +static inline int arch_has_hw_breakpoint_addr_mask(void) { return 0; } +#endif /* CONFIG_HAVE_HW_BREAKPOINT_ADDR_MASK */ + #else /* !CONFIG_HAVE_HW_BREAKPOINT */ static inline int __init init_hw_breakpoint(void) { return 0; } diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h index fb104e5..e22e1d1 100644 --- a/include/uapi/linux/perf_event.h +++ b/include/uapi/linux/perf_event.h @@ -286,7 +286,10 @@ struct perf_event_attr { __u64 config1; /* extension of config */ }; union { - __u64 bp_len; + struct { + __u32 bp_len; + __u32 bp_addr_mask; + }; __u64 config2; /* extension of config1 */ }; __u64 branch_sample_type; /* enum perf_branch_sample_type */ diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c index a64f8ae..e186a46 100644 --- a/kernel/events/hw_breakpoint.c +++ b/kernel/events/hw_breakpoint.c @@ -612,6 +612,9 @@ static int hw_breakpoint_add(struct perf_event *bp, int flags) if (!(flags & PERF_EF_START)) bp->hw.state = PERF_HES_STOPPED; + if (bp->attr.bp_addr_mask && !arch_has_hw_breakpoint_addr_mask()) + return -EOPNOTSUPP; + return arch_install_hw_breakpoint(bp); } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/