Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2825604imu; Thu, 29 Nov 2018 10:50:05 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xm/u8JzqWszdZalChne8FvzammycQxGgczAFP3/QZA6hkm1dSC/4PvyApEA28WkCBJEdsd X-Received: by 2002:a17:902:7603:: with SMTP id k3mr2602212pll.285.1543517405132; Thu, 29 Nov 2018 10:50:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543517405; cv=none; d=google.com; s=arc-20160816; b=Kh3/cDIubmd4rv8yqAmzUHVYp+rwh1BD3yegYaxPDC/PNiFTlmOzOiwTvaIGAyBw98 1pOMJDj/mnKVnCuh2xw81xUTdclo3Ge36k7bGqps3lElVGcQ99OF9bL2ZQeO7+KQjSRa XqgG9MoYB6nxsZEXXfwTOChOnuxqFsDaukAfUYcpB7SK1yLgzkdlFp5V08hiXVnGqA9g wvIlwb0qVZ+2p1TGlbUd4mvfun/BLPsehigzV/pqNDWc+V482crfvmChJe7l3Hat1jn5 yWnp0RU96jt/yKhQvp1UgGyzUOC77v6U7RvRnNtT/073Dd+d1FIhuZvXo6glYCT85ngL Ndbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=hBXTzVFCeXESYXc15GVm+W4pCXfGwIikmMqtKVO6zV0=; b=i2X57/L5tLxLT7DBbb54152juQOuOhI4B8N0i3o90JN/LOgHj7okS+KGiuKuIm9r1R Tff+VxQoy4E4AOlrR3DLeoRKlXAPeLv11hAeN5jmeTx2ozVqHzNf0KGuf5c9bxHdSQnZ 8hnD/QuCz3YpTva9tUjVtvJ92Sh69t3b2Bhh3ss3AWGoMto8YIv7y2BTNiaEXcSRWMgg qKscr2vHNWyMNYVKEHCpM8SK+tnD8fKa7tvJKPLiJFnDjTjIJzBGxin4z9gcfBCnzPsz euKrgCdU7/IlOmNy7ucHjq22bWwML7hS1FW6cCE0ykVIrB1dDUmhPRXyH6MTPGOFzEwS IV7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=aDWELOeM; 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 u5si2416493pgr.316.2018.11.29.10.49.50; Thu, 29 Nov 2018 10:50:05 -0800 (PST) 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=pass header.i=@linux-foundation.org header.s=google header.b=aDWELOeM; 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 S1726385AbeK3Fst (ORCPT + 99 others); Fri, 30 Nov 2018 00:48:49 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34090 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725877AbeK3Fst (ORCPT ); Fri, 30 Nov 2018 00:48:49 -0500 Received: by mail-lj1-f196.google.com with SMTP id u6-v6so2692867ljd.1 for ; Thu, 29 Nov 2018 10:42:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hBXTzVFCeXESYXc15GVm+W4pCXfGwIikmMqtKVO6zV0=; b=aDWELOeMmIHAnGuPmVxnnRD5AXZkBti98qOAAb1t8MPKZwIo98Vdo0oRhS1t2pniwA BaKQkG+6Yk3d/vO9VOI0vObsfXoX/lx8yt2QcjfY41KFaiXe6/+JcJXvjBxXichcc5iz dGGFjmEzqT61WxGSOUN85KunESX6i5fbNgmaM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hBXTzVFCeXESYXc15GVm+W4pCXfGwIikmMqtKVO6zV0=; b=GXrXi0rTZ592JJd89uVzxHTUTLuWKhL+e207NYgs4fR4bxZ/n4aGfMR3UNmD7H7u1S CPMluEIu9JlDrz+iuNZRLxFGfz1TmyXe4fPYwka6xs51OtJfh6b3wTexFVp/VDMTHQwE +okDoHdSbNe+kn30JVrJmZitCXJxMqk5V3Ym9DO1ElrV9SBtUE6HJhvdYo9AWIlq6xHj m0bIm5IGYJnB1PH7fY+ybaTJvWruO2YIS0tFeR5wAX4QM7G3kFUjvM1EZL34Jw/QZjX3 knp3P5Btcmgzl0Sy/b+y6mLLHSjg02Kp1vgi4RFYKimwfnVKz7Ec6Pm7g/czQ2wyDTAD Y3Zw== X-Gm-Message-State: AA+aEWZ2qjLTHD5hxQjzlIKCeDxbiaGVGIE2GuVg65VdYoG3ls5CzF1G 6kDw1uP07NtyppSCHVNQjYMjuAn0lcA= X-Received: by 2002:a2e:8702:: with SMTP id m2-v6mr1803898lji.132.1543516947111; Thu, 29 Nov 2018 10:42:27 -0800 (PST) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com. [209.85.167.41]) by smtp.gmail.com with ESMTPSA id m21sm428943lfl.97.2018.11.29.10.42.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 10:42:26 -0800 (PST) Received: by mail-lf1-f41.google.com with SMTP id z13so2216658lfe.11 for ; Thu, 29 Nov 2018 10:42:25 -0800 (PST) X-Received: by 2002:a19:982:: with SMTP id 124mr1717500lfj.138.1543516945195; Thu, 29 Nov 2018 10:42:25 -0800 (PST) MIME-Version: 1.0 References: <20181126160217.GR2113@hirez.programming.kicks-ass.net> <20181126171036.chcbmb35ygpxziub@treble> <20181126175624.bruqfbkngbucpvxr@treble> <20181126200801.GW2113@hirez.programming.kicks-ass.net> <20181126212628.4apztfazichxnt7r@treble> <20181127084330.GX2113@hirez.programming.kicks-ass.net> <20181129094210.GC2131@hirez.programming.kicks-ass.net> <20181129143853.GO2131@hirez.programming.kicks-ass.net> <20181129163342.tp5wlfcyiazwwyoh@treble> <0A629D30-ADCF-4159-9443-E5727146F65F@amacapital.net> <20181129121307.12393c57@gandalf.local.home> <20181129124404.2fe55dd0@gandalf.local.home> <60A06EF9-C301-4705-A32C-5E77E2D9DA9C@amacapital.net> In-Reply-To: <60A06EF9-C301-4705-A32C-5E77E2D9DA9C@amacapital.net> From: Linus Torvalds Date: Thu, 29 Nov 2018 10:42:09 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 4/4] x86/static_call: Add inline static call implementation for x86-64 To: Andy Lutomirski Cc: Steven Rostedt , Josh Poimboeuf , Peter Zijlstra , Andrew Lutomirski , "the arch/x86 maintainers" , Linux List Kernel Mailing , Ard Biesheuvel , Ingo Molnar , Thomas Gleixner , mhiramat@kernel.org, jbaron@akamai.com, Jiri Kosina , David.Laight@aculab.com, bp@alien8.de, julia@ni.com, jeyu@kernel.org, Peter Anvin Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 29, 2018 at 10:00 AM Andy Lutomirski wrote: > > then it really sounds pretty safe to just say "ok, just make it > > aligned and update the instruction with an atomic cmpxchg or > > something". > > And how do we do that? With a gcc plugin and some asm magic? Asm magic. You already have to mark the call sites with static_call(fn, arg1, arg2, ...); and while it right now just magically depends on gcc outputting the right code to call the trampoline. But it could do it as a jmp instruction (tail-call), and maybe that works right, maybe it doesn't. And maybe some gcc switch makes it output it as a indirect call due to instrumentation or something. Doing it with asm magic would, I feel, be safer anyway, so that we'd know *exactly* how that call gets done. For example, if gcc does it as a jmp due to a tail-call, the compiler/linker could in theory turn the jump into a short jump if it sees that the trampoline is close enough. Does that happen? Probably not. But I don't see why it *couldn't* happen in the current patch series. The trampoline is just a regular function, even if it has been defined by global asm. Putting the trampoline in a different code section could fix things like that (maybe there was a patch that did that and I missed it?) but I do think that doing the call with an asm would *also* fix it. But the "just always use a trampoline" is certainly the simpler model. Linus