Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3773053imw; Mon, 18 Jul 2022 14:20:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sso79mf1kiuXihomDp3aKVA4NlABO/P4Z2xX09RVYU3PcrGoikLdLM/V+o4rO2uGHLRQsW X-Received: by 2002:a17:902:f68f:b0:16c:2ab9:9bdb with SMTP id l15-20020a170902f68f00b0016c2ab99bdbmr29914174plg.23.1658179243921; Mon, 18 Jul 2022 14:20:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658179243; cv=none; d=google.com; s=arc-20160816; b=DOKMOjkV42NuwdiDcT96jwfIde8hqcezlHLgwFHOI7Z/NggzfIUSMM0iqcEU3MBIc0 3brWoj1nial/tDN2PZgnguyU1+9EwtdFZ3XEllXox+eYYPxG/h6oA1DtMQUwu9YSfjzw aQ/jcvt80iCmr+DFYqKEgGTC4bj0ouVkpYXBXcyDQLVhnuWqKL58yeMGn8TKDPoF0xN/ 9QfMoJgf5fAeltP+yiaZTXU3EyEq87uCwixfpbxZQjX3LuOKEwQudL50/8hju+gU37GK cgVSKNx6+svroUFYbLIGmiCUVh+3FNjW/hmE55yrb8FleGoCo9UnZwwO9o3JrR4Taap6 Gs1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ojAdpjQGp2/6VYLGnXT12hikGpG6gvDnZkT4uGicFqw=; b=qvIW90aIgH9fo+xe2wwyHt21jUwArWfkxArfFRNn/TYOeON7wiTHlo2nVSnE6d8xH6 pvpuwmdJSiahiqoblDhySo4TyKoxvyDflcuGkBTJOGzbFEBpfC3zkCFAEzHMkvHUsrYZ vCDFOwU/eUIhKil5fL6t9TD8ubblNTFElfh6KQ/JryWe2+RXgKWHb4zR1KuggHNqkQk1 wcxRaSaagVICQQAmtJBXlTuTQVghh/vs3iMtbqZZppGaHqVslwgr6idTZRhVGNakmUvc HFcrtlagi/D5HrW7CywJNdK4zREKaG9qx9woY2VHwjBPsweHI0QxUi9PX0p/Twotvxoj gApQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=D3nT8KtL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb9-20020a17090b35c900b001ef6ea57d7esi19688445pjb.55.2022.07.18.14.20.28; Mon, 18 Jul 2022 14:20:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=D3nT8KtL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234207AbiGRVTJ (ORCPT + 99 others); Mon, 18 Jul 2022 17:19:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234378AbiGRVTI (ORCPT ); Mon, 18 Jul 2022 17:19:08 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F3BB6140 for ; Mon, 18 Jul 2022 14:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=ojAdpjQGp2/6VYLGnXT12hikGpG6gvDnZkT4uGicFqw=; b=D3nT8KtLVXRCDD6/hVTgPzvdPU ot4deF0owRDntiYLw2XNF6CmF6DOerxOsQ0EvSE6wiLvkQnFtfGkHhV15gaVRGvNppMeNAJyRYfiO A4f95ZPkLl7gtylrxikqu5hV8Uk2s0alEBdH804MTTNw1aFLgKwZioYbUyNthC6F1/qx1koTVKrj9 lJwq9XkdkAheEJd5AGdubbq8eMoeBXEhWdIQAUEfpoSgyZCi+hEcNHXRhPJuKIWc7Y4kLjViOFazA blBe6io9P4nxrX89d7gujAsevL4Cf/YoSFxdA//W0vgdnMOomlr8GL/h5ghQnvXrLXtq2CBqfls8h 7A6ZhXNQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDY8X-00D2dE-Sd; Mon, 18 Jul 2022 21:18:42 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 7B0B49802A7; Mon, 18 Jul 2022 23:18:40 +0200 (CEST) Date: Mon, 18 Jul 2022 23:18:40 +0200 From: Peter Zijlstra To: Thomas Gleixner Cc: Linus Torvalds , LKML , the arch/x86 maintainers , Tim Chen , Josh Poimboeuf , Andrew Cooper , Pawan Gupta , Johannes Wikner , Alyssa Milburn , Jann Horn , "H.J. Lu" , Joao Moreira , Joseph Nuzman , Steven Rostedt , Juergen Gross , Masami Hiramatsu , Alexei Starovoitov , Daniel Borkmann , samitolvanen@google.com Subject: Re: [patch 00/38] x86/retbleed: Call depth tracking mitigation Message-ID: References: <20220716230344.239749011@linutronix.de> <87wncauslw.ffs@tglx> <87tu7euska.ffs@tglx> <87o7xmup5t.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87o7xmup5t.ffs@tglx> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 18, 2022 at 10:44:14PM +0200, Thomas Gleixner wrote: > > I do think that for generality, the "-mforce-function-padding" option > > should perhaps take as an argument how much padding (and how much > > alignment) to force: > > > > -mforce-function-padding=5:16 > > > > would force 5 bytes of minimum padding, and align functions to 16 > > bytes. It should be easy to generate (no more complexity than your > > current one) by just making the output do > > > > .skip 5,0xcc > > .palign 4,0xcc > > > > and now you can specify that you only need X bytes of padding, for example. > > Yes, I know. But it was horrible enough to find the right spot in that > gcc maze. Then I was happy that I figured how to add the boolean > option. I let real compiler people take care of the rest. HJL??? > > And we need input from the Clang folks because their CFI work also puts > stuff in front of the function entry, which nicely collides. Right, I need to go look at the latest kCFI patches, that sorta got side-tracked for working on all the retbleed muck :/ Basically kCFI wants to preface every (indirect callable) function with: __cfi_\func: int3 movl $0x12345678, %rax int3 int3 \func: endbr \func_direct: Ofc, we can still put the whole: sarq $5, PER_CPU_VAR(__x86_call_depth); jmp \func_direct thing in front of that. But it does somewhat destroy the version I had that only needs the 10 bytes padding for the sarq.