From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752918AbbDAAqV (ORCPT ); Tue, 31 Mar 2015 20:46:21 -0400 Received: from mga01.intel.com ([192.55.52.88]:61057 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752778AbbDAAqQ (ORCPT ); Tue, 31 Mar 2015 20:46:16 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,503,1422950400"; d="scan'208";a="707028966" Subject: [PATCH 04/16] x86, mpx: trace entry to bounds exception paths To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, tglx@linutronix.de, Dave Hansen , dave.hansen@linux.intel.com From: Dave Hansen Date: Tue, 31 Mar 2015 17:46:29 -0700 References: <20150401004623.894DF37A@viggo.jf.intel.com> In-Reply-To: <20150401004623.894DF37A@viggo.jf.intel.com> Message-Id: <20150401004629.20B9DAE8@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Hansen There are two basic things that can happen as the result of a bounds exception (#BR): 1. We allocate a new bounds table 2. We pass up a bounds exception to userspace. This patch adds a trace point for the case where we are passing the exception up to userspace with a signal. We are also explicit that we're printing out the inverse of the 'upper' that we encounter. If you want to filter, for instance, you need to ~ the value first. Signed-off-by: Dave Hansen --- b/arch/x86/include/asm/trace/mpx.h | 25 +++++++++++++++++++++++++ b/arch/x86/mm/mpx.c | 2 ++ 2 files changed, 27 insertions(+) diff -puN arch/x86/include/asm/trace/mpx.h~x86-mpx-trace-1 arch/x86/include/asm/trace/mpx.h --- a/arch/x86/include/asm/trace/mpx.h~x86-mpx-trace-1 2015-03-31 16:41:56.817305954 -0700 +++ b/arch/x86/include/asm/trace/mpx.h 2015-03-31 16:41:56.822306179 -0700 @@ -8,6 +8,31 @@ #ifdef CONFIG_X86_INTEL_MPX +TRACE_EVENT(mpx_bounds_register_exception, + + TP_PROTO(void *addr_referenced, + struct bndreg *bndreg), + TP_ARGS(addr_referenced, bndreg), + + TP_STRUCT__entry( + __field(void *, addr_referenced) + __field(u64, lower_bound) + __field(u64, upper_bound) + ), + + TP_fast_assign( + __entry->addr_referenced = addr_referenced; + __entry->lower_bound = bndreg->lower_bound; + __entry->upper_bound = bndreg->upper_bound; + ), + + TP_printk("address referenced: 0x%p bounds: lower: 0x%llx ~upper: 0x%llx", + __entry->addr_referenced, + __entry->lower_bound, + ~__entry->upper_bound + ) +); + TRACE_EVENT(bounds_exception_mpx, TP_PROTO(struct bndcsr *bndcsr), diff -puN arch/x86/mm/mpx.c~x86-mpx-trace-1 arch/x86/mm/mpx.c --- a/arch/x86/mm/mpx.c~x86-mpx-trace-1 2015-03-31 16:41:56.819306044 -0700 +++ b/arch/x86/mm/mpx.c 2015-03-31 16:41:56.822306179 -0700 @@ -16,6 +16,7 @@ #include #include #include +#include #include #define CREATE_TRACE_POINTS @@ -337,6 +338,7 @@ siginfo_t *mpx_generate_siginfo(struct p err = -EINVAL; goto err_out; } + trace_mpx_bounds_register_exception(info->si_addr, bndreg); return info; err_out: /* info might be NULL, but kfree() handles that */ _