Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3535272ybi; Mon, 10 Jun 2019 11:56:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxf99FMRSE0ccgppyOOTGAm+m9PArwuXTtbbPeZyzRQagKI6H+atxi3hcuQuABlMiKymoP4 X-Received: by 2002:a17:90a:372a:: with SMTP id u39mr22875900pjb.2.1560193009167; Mon, 10 Jun 2019 11:56:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560193009; cv=none; d=google.com; s=arc-20160816; b=nThB4Oedbpye201DzjPZIRIsMKbXol0JZGXBvRHalUuS5bSHOoNnIRifMMmxMhYgYU 1H2rgQBK8U3RqPsw9VFc3osMqHTc1coCUL088pnHJTzS0E2jqm+l7ytJk7iVMOrm6oGC NFuln3X11rOMYEafPrexcMyqIaaLaTUX1GzYLtU08Hsbq1yYBkdkKJsn9qP8mTuK4kbt iqkDnmZ4csWu6XYA5dbayc8/gY33bdbiZtPhydjreXc2VN/0uwApOjaBRkYPJ8Tk4Otb T/S9LHqfN9qFwEyiVVlqO4eu50IXrAcZDxGWLRHsSqfwaoRSAO7/NMEHex+qV3e6c7P7 U+GQ== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=EVWU65xs54cuq0/yZsl4aRU4OX+lYTznXT+04yQdvug=; b=PwuhidMO8xQ5o2C+IxBPLp9lGAsB5n0k5PyWUhaG1FsPfUCaAAIEGduFkgYgMkUjAk fY09cdlxbxY64+aF00jCmq4phaqu3/HZY10yXkOYPXVjtmxOluPfpGyxhmVmq7GW/0nm iCHm2eKFCzgcsYio0FYlvdJxZwDKgnyIZzAUo2+gZ9d3JZOnWtLzmFMucv/+c8mDRIn4 8PKSnZn64lSjQthSwP9nVJ+hdKEHqT3yHUoB6LXfs62NEtk4s6FVRaIw5eUujwWixrYR 94ZK/0R9URMag2V6xb5mODOcE/BhX4a2fEFVjbw9KMOVAbmLUdslogLm8Z2n45hKtKf5 VezQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t186si11028187pfb.19.2019.06.10.11.56.34; Mon, 10 Jun 2019 11:56:49 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388883AbfFJSz2 (ORCPT + 99 others); Mon, 10 Jun 2019 14:55:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54780 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388069AbfFJSz2 (ORCPT ); Mon, 10 Jun 2019 14:55:28 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2DEBC5AFD9; Mon, 10 Jun 2019 18:55:24 +0000 (UTC) Received: from treble (ovpn-121-189.rdu2.redhat.com [10.10.121.189]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 03B1E1001DC0; Mon, 10 Jun 2019 18:55:14 +0000 (UTC) Date: Mon, 10 Jun 2019 13:55:13 -0500 From: Josh Poimboeuf To: Nadav Amit Cc: Peter Zijlstra , the arch/x86 maintainers , LKML , 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" , 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: <20190610185513.pbtc7udpkfd5jsuu@treble> References: <20190605130753.327195108@infradead.org> <20190605131945.313688119@infradead.org> <20190610183357.zj6rwdpgw36anpfc@treble> <40096B8A-C063-4219-89FC-A8E42981BF28@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <40096B8A-C063-4219-89FC-A8E42981BF28@vmware.com> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 10 Jun 2019 18:55:27 +0000 (UTC) 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 06:45:52PM +0000, Nadav Amit wrote: > > On Jun 10, 2019, at 11:33 AM, 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 must be missing some context - but what guarantees that this indirect > branch would be exactly 5 bytes long? Isn’t there an assumption that this > would be the case? Shouldn’t there be some handling of the padding? We don't patch the indirect branch. It's just part of a temporary trampoline which is called by the call site, and which does "jmp key->func" during boot until static call initialization is done. (Though I'm suggesting removing that.) -- Josh