From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752478AbcBLSeM (ORCPT ); Fri, 12 Feb 2016 13:34:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36527 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751509AbcBLSeJ (ORCPT ); Fri, 12 Feb 2016 13:34:09 -0500 Date: Fri, 12 Feb 2016 12:34:00 -0600 From: Josh Poimboeuf To: Peter Zijlstra Cc: Jiri Slaby , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Michal Marek , Andy Lutomirski , Borislav Petkov , Linus Torvalds , Andi Kleen , Pedro Alves , Namhyung Kim , Bernd Petrovitsch , Chris J Arges , Andrew Morton , Arnaldo Carvalho de Melo , David Vrabel , Borislav Petkov , Konrad Rzeszutek Wilk , Boris Ostrovsky , Jeremy Fitzhardinge , Chris Wright , Alok Kataria , Rusty Russell , Herbert Xu , "David S. Miller" , Pavel Machek , "Rafael J. Wysocki" , Len Brown , Matt Fleming , Alexei Starovoitov , netdev@vger.kernel.org, Ananth N Mavinakayanahalli , Anil S Keshavamurthy , Masami Hiramatsu , Gleb Natapov , Paolo Bonzini , kvm@vger.kernel.org, Wim Van Sebroeck , Guenter Roeck , linux-watchdog@vger.kernel.org, Waiman Long Subject: Re: [PATCH 00/33] Compile-time stack metadata validation Message-ID: <20160212183400.GC29004@treble.redhat.com> References: <56BDB5A8.9030006@suse.cz> <20160212144543.GA29004@treble.redhat.com> <20160212171037.GV6357@twins.programming.kicks-ass.net> <20160212183206.GB29004@treble.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160212183206.GB29004@treble.redhat.com> 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 On Fri, Feb 12, 2016 at 12:32:06PM -0600, Josh Poimboeuf wrote: > On Fri, Feb 12, 2016 at 06:10:37PM +0100, Peter Zijlstra wrote: > > On Fri, Feb 12, 2016 at 08:45:43AM -0600, Josh Poimboeuf wrote: > > > On Fri, Feb 12, 2016 at 11:36:24AM +0100, Jiri Slaby wrote: > > > > > > This seems like a real frame pointer bug caused by the following line in > > > arch/x86/include/asm/preempt.h: > > > > > > # define __preempt_schedule() asm ("call ___preempt_schedule") > > > > The purpose there is that: > > > > preempt_enable(); > > > > turns into: > > > > decl __percpu_prefix:__preempt_count > > jnz 1f: > > call ___preempt_schedule > > 1: > > > > See arch/x86/include/asm/preempt.h:__preempt_count_dec_and_test() > > Sorry, I'm kind of confused. Do you mean that's what preempt_enable() > would turn into *without* the above define? > > What I actually see in the listing is: > > decl __percpu_prefix:__preempt_count > je 1f: > .... > 1: > call ___preempt_schedule > > So it puts the "call ___preempt_schedule" in the slow path. > > I also don't see how that would be related to the use of the asm > statement in the __preempt_schedule() macro. Doesn't the use of > unlikely() in preempt_enable() put the call in the slow path? > > #define preempt_enable() \ > do { \ > barrier(); \ > if (unlikely(preempt_count_dec_and_test())) \ > preempt_schedule(); \ > } while (0) > > Also, why is the thunk needed? Any reason why preempt_enable() can't be > called directly from C? Sorry, s/preempt_enable/preempt_schedule/ on that last sentence. -- Josh