Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965208AbbFJOcV (ORCPT ); Wed, 10 Jun 2015 10:32:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48167 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754314AbbFJOcM (ORCPT ); Wed, 10 Jun 2015 10:32:12 -0400 Date: Wed, 10 Jun 2015 09:32:09 -0500 From: Josh Poimboeuf To: Andi Kleen Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Michal Marek , Peter Zijlstra , Andy Lutomirski , Borislav Petkov , Linus Torvalds , x86@kernel.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 00/10] x86/asm: Compile-time asm code validation Message-ID: <20150610143209.GA28843@treble.redhat.com> References: <20150610130814.GN19417@two.firstfloor.org> <20150610135203.GA19509@treble.redhat.com> <20150610141104.GQ19417@two.firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150610141104.GQ19417@two.firstfloor.org> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1892 Lines: 52 On Wed, Jun 10, 2015 at 04:11:04PM +0200, Andi Kleen wrote: > > In most cases there are ways to keep the optimizations. For example: > > > > - grow the function bounds to keep the jump internal > > So you mean moving it after the ret? That still means icache bloat. No, in most cases it just means changing the ELF annotations. See patch 9 for an example. > > - duplicate the destination code inside the function > > - convert the jump to a call > > That all won't work for a lot of cases. Hm, could you give an example? > > Also note that these rules only affect _callable_ functions, so the > > entry code and other non-function asm code can still be a pile of > > spaghetti (though I think Andy is working on improving that). > > Thank you for your kind words. Don't like spaghetti? :-) > > > In fact even gcc with the right options can generate code that violates > > > this. Standard Linux constructions, such as exception handling, > > > also violate this. > > > > > > If your tool needs that your tool is broken. > > > > This tool only validates asm code, so I don't see how whatever gcc does > > is relevant. > > Whoever needs it would need it everywhere, right? If it's not needed > for gcc then it shouldn't be needed for assembler code either. Well, I don't see how that's really a logical conclusion. But we're probably being too vague here... Do you have any examples where you really need to jump outside of a callable function? If we ignore C++, then 99% of the time, C functions are self-contained. The only exception I can think of is for switch statements, which sometimes have an external jump table. -- Josh -- 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/