From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6324C433DB for ; Wed, 24 Mar 2021 08:16:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E1E7619B6 for ; Wed, 24 Mar 2021 08:16:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233202AbhCXIP6 (ORCPT ); Wed, 24 Mar 2021 04:15:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233117AbhCXIP3 (ORCPT ); Wed, 24 Mar 2021 04:15:29 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32B90C061763 for ; Wed, 24 Mar 2021 01:15:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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; bh=SK5/sEmswbCoTPEGyfn8Cc4KW/hvJK6qOQtWnbzRl54=; b=XdtUWN3TsJGMPJm5NgiM+Us9E2 8gBz7Mx2lCWI0/dzhCaY99cp3REjFEDaJTA/BEQhs72Kpv1Wc5nB6m2BfANHznmXlKaWMFg/5FksT ag3Wg/5ZeKhKDvdOFDUyCUaw1Xi2sAZqgND2xLvZ/tiW2BREnv8/U99Zwb2ohNrpVVY1gkOOjJlDJ uSsKNcRZ32k3ku0U1z1sqLXjQIp51YYUVH+QONz4zV5RFw0Gg/KPQM2rb/gFBZEbufIuaMokg00lW Tre+jv4ciBDzAItuvcYfGlvIfE+u/MVSIWU/pHhDznVVf6kAQX0H/832EKwK39k5QPfCvi20RwQiz aT79X45A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lOyfQ-00GYZ1-Mc; Wed, 24 Mar 2021 08:15:06 +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 F41A33007CD; Wed, 24 Mar 2021 09:15:03 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D908823601880; Wed, 24 Mar 2021 09:15:03 +0100 (CET) Date: Wed, 24 Mar 2021 09:15:03 +0100 From: Peter Zijlstra To: Steven Rostedt Cc: Andrew Cooper , Nick Desaulniers , linux-toolchains@vger.kernel.org, clang-built-linux , "Jose E. Marchesi" , Kees Cook , Florian Weimer , Christian Brauner , nick.alcock@oracle.com, Segher Boessenkool , Josh Poimboeuf , Will Deacon Subject: Re: Plumbers CF MCs Message-ID: References: <20210323195358.GB4746@worktop.programming.kicks-ass.net> <20210323221246.GB5208@worktop.programming.kicks-ass.net> <20210323203612.02a5b29d@oasis.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210323203612.02a5b29d@oasis.local.home> Precedence: bulk List-ID: X-Mailing-List: linux-toolchains@vger.kernel.org On Tue, Mar 23, 2021 at 08:36:12PM -0400, Steven Rostedt wrote: > On Tue, 23 Mar 2021 23:12:46 +0100 > Peter Zijlstra wrote: > > > On Tue, Mar 23, 2021 at 08:53:58PM +0100, Peter Zijlstra wrote: > > > > > Another utterly disguisting option is to align all CALL instructions on > > > 8 bytes and have it followed by 3 INT3s to make it 8 bytes long. Then > > > have every function prologue round up the return address. This should > > > work with tail-call optimizations because the round-up is NOP when > > > repeated. The obvious down-side is that it will utterly wreck the RSB > > > > Slightly less horrible: "CALL func; INT3" + "INC (%RSP); RET; INT3". > > It still completely wrecks RSB, but isn't nearly as wasteful. > > I'm confused. Why is speculation after a CALL dangerous? That code will > be executed on the return of the call anyway. That is, it's not > speculating something that wont execute in the future, whereas code > after RET and JMP wont be executed. Like I just wrote to Andrew; it mostly isn't going to be. But there will be cases where running the code after, with the register contents from before, will get you a nice speculation gadget. The big problem is, like with Spectre-v1 compiler mitigations, recognising when it is and isn't a problem. Mostly compilers tend to take the safe option (understandably) and we end up with an incredible amount of LFENCE instructions and performance will suck. For SLS at least the CALL+LFENCE pattern is trivial enough to recognise and we can patch it out at runtime, with the only side effect being code bloat and I$ fail. That same isn't true for Spectre-v1 mitigations, where LFENCEs are emitted at less obviously recognised places.