From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754955Ab2BVKE7 (ORCPT ); Wed, 22 Feb 2012 05:04:59 -0500 Received: from e5.ny.us.ibm.com ([32.97.182.145]:35830 "EHLO e5.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754175Ab2BVKE5 (ORCPT ); Wed, 22 Feb 2012 05:04:57 -0500 Date: Wed, 22 Feb 2012 15:34:31 +0530 From: Srikar Dronamraju To: Ingo Molnar Cc: Peter Zijlstra , Linus Torvalds , Oleg Nesterov , LKML , Christoph Hellwig , Steven Rostedt , Thomas Gleixner , Masami Hiramatsu , Anton Arapov , Ananth N Mavinakayanahalli , Jim Keniston , Jiri Olsa , Josh Stone Subject: Re: [PATCH 1/3] uprobes/core: Make instruction tables volatile. Message-ID: <20120222100431.GA15963@linux.vnet.ibm.com> Reply-To: Srikar Dronamraju References: <20120222091535.15880.12502.sendpatchset@srdronam.in.ibm.com> <20120222094710.GA31848@elte.hu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20120222094710.GA31848@elte.hu> User-Agent: Mutt/1.5.20 (2009-06-14) X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12022210-5930-0000-0000-0000056F06DF Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > * Srikar Dronamraju wrote: > > > From: Srikar Dronamraju > > > > Some versions of gcc spits a warning about the asm operand for test_bit and > > also causes the first long of the instruction table to be output. > > > > Fix is similar to 7115e3fc on arch/x86/kernel/kprobes.c > > > > Signed-off-by: Srikar Dronamraju > > --- > > arch/x86/kernel/uprobes.c | 61 ++++++++++++++++++++++++--------------------- > > 1 files changed, 32 insertions(+), 29 deletions(-) > > > > diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c > > index cf2a184..13d616d 100644 > > --- a/arch/x86/kernel/uprobes.c > > +++ b/arch/x86/kernel/uprobes.c > > @@ -53,34 +53,12 @@ > > (bc##UL << 0xc)|(bd##UL << 0xd)|(be##UL << 0xe)|(bf##UL << 0xf)) \ > > << (row % 32)) > > > > -#ifdef CONFIG_X86_64 > > -static u32 good_insns_64[256 / 32] = { > > - /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ > > - /* ---------------------------------------------- */ > > - W(0x00, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0) | /* 00 */ > > - W(0x10, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0) , /* 10 */ > > - W(0x20, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0) | /* 20 */ > > - W(0x30, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0) , /* 30 */ > > - W(0x40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* 40 */ > > - W(0x50, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 50 */ > > - W(0x60, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0) | /* 60 */ > > - W(0x70, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 70 */ > > - W(0x80, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 80 */ > > - W(0x90, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 90 */ > > - W(0xa0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* a0 */ > > - W(0xb0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* b0 */ > > - W(0xc0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0) | /* c0 */ > > - W(0xd0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* d0 */ > > - W(0xe0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0) | /* e0 */ > > - W(0xf0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1) /* f0 */ > > - /* ---------------------------------------------- */ > > - /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ > > -}; > > -#endif > > - > > -/* Good-instruction tables for 32-bit apps */ > > - > > -static u32 good_insns_32[256 / 32] = { > > +/* > > + * Good-instruction tables for 32-bit apps. This is non-const and volatile > > + * to keep gcc from statically optimizing it out, as variable_test_bit makes > > + * some versions of gcc to think only *(unsigned long*) is used. > > + */ > > +static volatile u32 good_insns_32[256 / 32] = { > > /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ > > /* ---------------------------------------------- */ > > W(0x00, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0) | /* 00 */ > > @@ -104,7 +82,7 @@ static u32 good_insns_32[256 / 32] = { > > }; > > > > /* Using this for both 64-bit and 32-bit apps */ > > -static u32 good_2byte_insns[256 / 32] = { > > +static volatile u32 good_2byte_insns[256 / 32] = { > > /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ > > /* ---------------------------------------------- */ > > W(0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1) | /* 00 */ > > @@ -127,6 +105,31 @@ static u32 good_2byte_insns[256 / 32] = { > > /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ > > }; > > > > +#ifdef CONFIG_X86_64 > > +/* Good-instruction tables for 64-bit apps */ > > +static volatile u32 good_insns_64[256 / 32] = { > > + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ > > + /* ---------------------------------------------- */ > > + W(0x00, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0) | /* 00 */ > > + W(0x10, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0) , /* 10 */ > > + W(0x20, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0) | /* 20 */ > > + W(0x30, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0) , /* 30 */ > > + W(0x40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* 40 */ > > + W(0x50, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 50 */ > > + W(0x60, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0) | /* 60 */ > > + W(0x70, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 70 */ > > + W(0x80, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 80 */ > > + W(0x90, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* 90 */ > > + W(0xa0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* a0 */ > > + W(0xb0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* b0 */ > > + W(0xc0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0) | /* c0 */ > > + W(0xd0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1) , /* d0 */ > > + W(0xe0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0) | /* e0 */ > > + W(0xf0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1) /* f0 */ > > + /* ---------------------------------------------- */ > > + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ > > +}; > > +#endif > > Hm, why was the table moved around? This makes it hard to see > whether it's just a single volatile that is added, or something > more. > Without the table moving, the volatile was first used under #ifdef CONFIG_X86_64. I was wondering if I add a comment in #ifdef people looking at it might assume that its a problem only on x86_64 only. So I moved the CONFIG_X86_64 specific table down and added the comment for volatile at the first instance its used. -- Thanks and Regards Srikar