Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2856005imu; Thu, 29 Nov 2018 11:17:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xm0quwOb0n1q8In65K9ANQsdEUFflVyF/BPuKeSejei4dDVlT0cZsRARuYWW5zg6RFHiqf X-Received: by 2002:a63:f141:: with SMTP id o1mr1111557pgk.134.1543519076674; Thu, 29 Nov 2018 11:17:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543519076; cv=none; d=google.com; s=arc-20160816; b=CVrivf8JsWVjFHgBvxFJo+V1qxk18MbHI7lGPmEWNqDIBFIT6MQmC71uWrvIKeo9Nq DH2pVBegFoO/b8/AyA9tKdXrHTDM8JwXXah4W6ZJ2o3nzS+21cAYrxe9EKdFOzE6nOKz 81PX37y+lObdnBPm+t6eu2/Ii03FtgAydEze/MaTQ50Qm8tz9wzEzEaO6nH0qjQ2UMSe Lr09Vw3nDSiP5XgNrd5I2olzfJQYfyttVcnG6L593mbpYJP7lkSYO0cMKbLig3A7cZnN 6rljvkV+cC7tqPjJy22tb+qWKTC2Qyp1h5FWvTzHOKFRVUHP3pH8d7LcPVu4gtxe3XCI DUuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=2pvQuapo3660SNg1rpHCzzg6C+/FadHFW9d65/6ZJ2Y=; b=sRlo2WOWDd+xwIqlUcydiLyvjHYNiAkBx1z4IPvqWV4wu5sZq9LPmWobhby4fLpnJE ZJXY+mgnf8szmSiBlCTawB0+zkxSiRurah08Xl7hbToMHMJyKzXEPPaCVS3MLSt/IDv0 xBPsV3GJRBhkMR0ZOO93IItNvkWBTZSXDR1Z08TjvlTkba6ndv48ZG+uzAOPqlon4P1D 81a5BLurbCSD2AgW43lYeUFA+82ibWI1t/5WLKB3MAxDSo9gqbdFbvq81ZVtc05fQC0l 1LJo90pPcKiRwytyosiMds9L2fN7tJ/A5MMPz5EJCRPqgWg7ikFMwlEA+ZGBzytzc+rA 3Z6g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r11si2957498pli.175.2018.11.29.11.17.42; Thu, 29 Nov 2018 11:17:56 -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; 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 S1726221AbeK3GXT (ORCPT + 99 others); Fri, 30 Nov 2018 01:23:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:58492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbeK3GXS (ORCPT ); Fri, 30 Nov 2018 01:23:18 -0500 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 99AA421104; Thu, 29 Nov 2018 19:16:49 +0000 (UTC) Date: Thu, 29 Nov 2018 14:16:48 -0500 From: Steven Rostedt To: Linus Torvalds Cc: Andy Lutomirski , 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 Subject: Re: [PATCH v2 4/4] x86/static_call: Add inline static call implementation for x86-64 Message-ID: <20181129141648.6ef944a9@gandalf.local.home> In-Reply-To: References: <20181126160217.GR2113@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> <20181129125857.75c55b96@gandalf.local.home> <20181129134725.6d86ade6@gandalf.local.home> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 29 Nov 2018 10:58:40 -0800 Linus Torvalds wrote: > On Thu, Nov 29, 2018 at 10:47 AM Steven Rostedt wrote: > > > > Note, we do have a bit of control at what is getting called. The patch > > set requires that the callers are wrapped in macros. We should not > > allow just any random callers (like from asm). > > Actually, I'd argue that asm is often more controlled than C code. > > Right now you can do odd things if you really want to, and have the > compiler generate indirect calls to those wrapper functions. > > For example, I can easily imagine a pre-retpoline compiler turning > > if (cond) > fn1(a,b) > else > fn2(a,b); > > into a function pointer conditional > > (cond ? fn1 : fn2)(a,b); If we are worried about such a construct, wouldn't a compiler barrier before and after the static_call solve that? barrier(); static_call(func...); barrier(); It should also stop tail calls too. > > and honestly, the way "static_call()" works now, can you guarantee > that the call-site doesn't end up doing that, and calling the > trampoline function for two different static calls from one indirect > call? > > See what I'm talking about? Saying "callers are wrapped in macros" > doesn't actually protect you from the compiler doing things like that. > > In contrast, if the call was wrapped in an inline asm, we'd *know* the > compiler couldn't turn a "call wrapper(%rip)" into anything else. But then we need to implement all numbers of parameters. -- Steve