Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2911440imu; Thu, 29 Nov 2018 12:13:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/U5e2TQ0sNN6HFO4gSzPSRsCh/vjTMIaZmRKYP1X+YZyJxQGqP+Y5XFBkkL03mPia5ltoOj X-Received: by 2002:a62:7a8b:: with SMTP id v133mr2826658pfc.159.1543522435391; Thu, 29 Nov 2018 12:13:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543522435; cv=none; d=google.com; s=arc-20160816; b=YshAUA0/9AtSCCzqGD8q7feHJyyTK9um2ehu7V6BYRAypQNj5slySA9ILLz8q1ywaY uMOgzWE7sowuHnfeEI9B6N9eADXrBhM3vvpIN1AVzk4bhYZ86h0+IGc4UPj9+LmFs7U/ Lx/3S4gZNK0ZsebWer7nBF7jRGqzgzrmVhoPzqYyXIaNvOmCG+GxDcVnznSdRWIhXEP9 MSP9oxhlfxs+4+rw4KJNV2Opw3DqslETb/Zoc2qtfFbhRXvtDUB8RFYiYQKKvxyet+2d iAHBdku4l3qxZZDqq4KSGE/uUAbsccKJEPE/KhRFPtRZQNa9kPrUnwJL22Kk+3R/K2GI fF+g== 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; bh=e+olJJVLlhVniUIbUehUnVSO0vmt8k2hIIyrL7TtS44=; b=zsf4AnUG9iA1Qc+uVUe0EAqU4sW0sAi55hj4HxPxwroV6gCMo3afy7mMXNyDRj8rgb iJKKIZkm0Pin1aXFPnc0uV2h5cbBRryl2Mg+YBvlQeh3lDe1UkACuY3wXWYFwmbxPfLb UuMSFmdmBdzyp3mn/exI2/Or9Vjo0lXNsFHsWVlUGgT02BLmRWWZp64AK0u2mRuwTeQ8 6Cy8Vy8TjfHWye1RyGnCTpm9+pf3VIz/397/lygcJZHcamidxNzeBf3EkaZwGSwDQiJM /i18Pp2Lq4Gece/CiabkTsee/e3eMkeWndRsAoslK1jeiM3wL1kJmSTXLrwnQ9pAAlW/ eynQ== 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 g34si3124168pld.15.2018.11.29.12.13.38; Thu, 29 Nov 2018 12:13:55 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726336AbeK3HT2 (ORCPT + 99 others); Fri, 30 Nov 2018 02:19:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51646 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725871AbeK3HT2 (ORCPT ); Fri, 30 Nov 2018 02:19:28 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7E41885541; Thu, 29 Nov 2018 20:12:51 +0000 (UTC) Received: from treble (ovpn-123-4.rdu2.redhat.com [10.10.123.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 45DC15D736; Thu, 29 Nov 2018 20:12:49 +0000 (UTC) Date: Thu, 29 Nov 2018 14:12:47 -0600 From: Josh Poimboeuf To: Linus Torvalds Cc: Steven Rostedt , Andy Lutomirski , 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: <20181129201247.hhkak4paqyja6d6d@treble> References: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 29 Nov 2018 20:12:51 +0000 (UTC) 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:58:40AM -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); > > 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. I think objtool could warn about many such issues, including function pointer references to trampolines and short tail call jumps. -- Josh