Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8410983ybn; Tue, 1 Oct 2019 07:45:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2ah/qGePyutUS2H42dGAZT1zRBBpCckw316R4P/zPSaUFCtXnrwIxvTlDndI+mbCBzAxN X-Received: by 2002:aa7:df8e:: with SMTP id b14mr3602462edy.65.1569941154102; Tue, 01 Oct 2019 07:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569941154; cv=none; d=google.com; s=arc-20160816; b=bwlmBES2v8YlzshtZTUTk7ndJE9nhn8OVx1MlFOuacrRA5iylsjPIRPh+YMjGV6ih1 Qx3kCyXNq+OvAhqrjBrygMC3UrqP7kx7bTVhTR/4EuiY0EMJRRDoypVKUzDOtAcI29mH GOI4cQy3g/R6J+a3utYtJltOgjfKoszWTgNpUIp1PKdYjgg5cznss5yVnMjsoXaLQTXS zsS1oIFWDrjxoLFXYVZpYipw1Y/BuSmp6s77PEvvutiaY6C3GUBhmvawFp1oSRyXYJe1 xrqiAI9QlLqw7bZGtT8Cnl7v6IBc4JNVcpT/knpEpfDcEhCWvQV9nSgyt5M5JWD8HwIV kBxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7XYS68JRsX31K5FNAZ0r4/kwd1UKDXQc2kjO9l53ZkQ=; b=Xa/+FFmA6KkF3cyuahulejw1iDsI3LlJfS42z4xMgnA7DszBJfRzCRKMNghPBMTzW3 y5GkaC1rdzhKSVAT6q6KzQOF2aR6CRU0oM7qQFsl9eH8Xxi34MxUk9Wko3U21g8T/h5G Vn5C+6xwfMgE4mREZuOeLiCe/EECfiHJt7YHYT4xxOrFALLzirUhvlP4zqVYP/7EzPOX l3mw0jNq3zgKcRUY9D3hmRXSCQ7K+FsGUWKxi7XCEmZ3mAtuq+rhIPZlYJm6AB5twIrU nxKms7k2+NoiJVuXAuZaHHvrErCDTdi2W6ELbjxQ1IwxbkULSqfO6X7OHzz23Qaptfo0 GE8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=DS+DLd8f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si10156671edc.75.2019.10.01.07.45.29; Tue, 01 Oct 2019 07:45:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=DS+DLd8f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389231AbfJAOnz (ORCPT + 99 others); Tue, 1 Oct 2019 10:43:55 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:49846 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727083AbfJAOny (ORCPT ); Tue, 1 Oct 2019 10:43:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7XYS68JRsX31K5FNAZ0r4/kwd1UKDXQc2kjO9l53ZkQ=; b=DS+DLd8foqbMppOR2FgrfSY/c VNVf64l6qlMXcxd2kvJO/pgouyArI97fZZ7sYsQ31kfqbUHmfN00Kl7H2/p9OixKmaM9/Wu4avaAw ZP5EIznQGi7wk6xSW4olNVjNEoaKeKzpYfMc2sR5qHWTSWwHrwYmNgstn8jB4pZg8PrmKmVyMQ2HE MMLer0Oo8QzkZGyWotHl0nHvjLNA4HmKcaCIxfQARYEMQadcY5jho/ln0DFJ49pQWMRrSyHilYntD 0uCHv1MQEIf0aCbySIlbz2kr6EuCSKqp+gk/FWrLi8Ydb6Su6R4ix4UceLQvyRTdBieA8oPhd0OvC /S6Xr9dbg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.2 #3 (Red Hat Linux)) id 1iFJN8-0004g6-NL; Tue, 01 Oct 2019 14:43:26 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id E146930610C; Tue, 1 Oct 2019 16:42:34 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4D96A2652AB4D; Tue, 1 Oct 2019 16:43:23 +0200 (CEST) Date: Tue, 1 Oct 2019 16:43:23 +0200 From: Peter Zijlstra To: Josh Poimboeuf Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Ard Biesheuvel , Andy Lutomirski , Steven Rostedt , Ingo Molnar , Thomas Gleixner , Linus Torvalds , Masami Hiramatsu , Jason Baron , Jiri Kosina , David Laight , Borislav Petkov , Julia Cartwright , Jessica Yu , "H. Peter Anvin" , Nadav Amit , Rasmus Villemoes , Edward Cree , Daniel Bristot de Oliveira Subject: Re: [PATCH 13/15] x86/static_call: Add inline static call implementation for x86-64 Message-ID: <20191001144323.GR4519@hirez.programming.kicks-ass.net> References: <20190605130753.327195108@infradead.org> <20190605131945.313688119@infradead.org> <20190610183357.zj6rwdpgw36anpfc@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190610183357.zj6rwdpgw36anpfc@treble> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 10, 2019 at 01:33:57PM -0500, Josh Poimboeuf wrote: > On Wed, Jun 05, 2019 at 03:08:06PM +0200, Peter Zijlstra wrote: > > --- a/arch/x86/include/asm/static_call.h > > +++ b/arch/x86/include/asm/static_call.h > > @@ -2,6 +2,20 @@ > > #ifndef _ASM_STATIC_CALL_H > > #define _ASM_STATIC_CALL_H > > > > +#include > > + > > +#ifdef CONFIG_HAVE_STATIC_CALL_INLINE > > + > > +/* > > + * This trampoline is only used during boot / module init, so it's safe to use > > + * the indirect branch without a retpoline. > > + */ > > +#define __ARCH_STATIC_CALL_TRAMP_JMP(key, func) \ > > + ANNOTATE_RETPOLINE_SAFE \ > > + "jmpq *" __stringify(key) "+" __stringify(SC_KEY_func) "(%rip) \n" > > + > > +#else /* !CONFIG_HAVE_STATIC_CALL_INLINE */ > > I wonder if we can simplify this (and drop the indirect branch) by > getting rid of the above cruft, and instead just use the out-of-line > trampoline as the default for inline as well. > > Then the inline case could fall back to the out-of-line implementation > (by patching the trampoline's jmp dest) before static_call_initialized > is set. I think I've got that covered. I changed arch_static_call_transform() to (always) first rewrite the trampoline and then the in-line site. That way, when early/module crud comes in that still points at the trampoline, it will jump to the right place. I've not even compiled yet, but it ought to work ;-)