Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp764888imi; Fri, 22 Jul 2022 09:00:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1un/gTkavcP5dvTqfuXXY3vAeU2Fl64pLs1gr8y/fKXbvo9EKJc6BqDTR32Z0Y+jIvcd4/j X-Received: by 2002:a17:903:110c:b0:16c:cfae:e492 with SMTP id n12-20020a170903110c00b0016ccfaee492mr554082plh.162.1658505637081; Fri, 22 Jul 2022 09:00:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658505637; cv=none; d=google.com; s=arc-20160816; b=U4hemzcp7MOoIlYuK7zOLEbL7MuTpYRmiQScP0ptrcVY3frq+Vy21HLDGaotx9KdCs +fRjUPHd3VG/a2rjc4iVR0j/2sX3Whocu6MjcReQbtwRsIzYS0+dgZi0eo4vb/KsTElr +0Pz1LPrpaPfpy4jrUM8iX89kMD//3WAtydeOsoU3ckOTaKrVif3NbM7syDagEg3ktK4 hELExsyN5kDo4M31zAhtdmXein3I904OAyEsuu01IJ0vaJ1/JoQAYvhhUoWLwXetxPIp yTH7HhnrWy3P8jWPWEtD9y6WVaJ5Xbuv0ftRUfK4PepfmUlkdteNHdEROUOSWqeUqiEM 2M8w== 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=/rSrjqI9Kq8RGPKAfu3pLnMgTVnevgNO0y+F18A2TzA=; b=kTEAtArfUQcvFN4nEcb+DXiy+nYd5ug7NmWnjJVrKg1RHh6bZIhPOBcAXHwIPPilGi vgputkx3xtUdfAG5p5zsTRCd0ddjpV23aUY1lM+J1UHmqXF1kVakXfjMbxOp46nYo0jV aUk4zqr00M37jwznHBT+aK/MI83aTtHans4IM94xrEQ1k1RDBkTsdQVS8R6wGD43u0d1 j066x2u4wkxrLN/OqMZTXuDPNXztDTKvFc9QvYPqLDbg1y/06+yoo1sNf6Zq/jkva0m7 Pww0MVQKyIQxsQ2kWcksdDvLXKAt+MQZwUneg++kW9gVZcCJJdnXWZuay7PP6fzGcBxE 8ZlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=WV5ctrz1; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w1-20020a170902e88100b0016cf03900b4si6597021plg.537.2022.07.22.09.00.12; Fri, 22 Jul 2022 09:00:37 -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=@google.com header.s=20210112 header.b=WV5ctrz1; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235296AbiGVPi3 (ORCPT + 99 others); Fri, 22 Jul 2022 11:38:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233186AbiGVPi1 (ORCPT ); Fri, 22 Jul 2022 11:38:27 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 886779B9E2 for ; Fri, 22 Jul 2022 08:38:26 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id f11so4723733pgj.7 for ; Fri, 22 Jul 2022 08:38:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=/rSrjqI9Kq8RGPKAfu3pLnMgTVnevgNO0y+F18A2TzA=; b=WV5ctrz1+PeXgAcPRgqLh7wTHjXOYjUq7qOFHH+CFxhTLBBYOLTD+T3aVeQ1iTf3FA GbZ7o8cHdT5y5ztZFwpClnuN12p9WyBM7hU5B1u8zJBOz+KcUddlwgj6imTzQdZlyqPk 4CLZUWxvX0Ok+/+BTIJ/8g/nnstbkvCescOLG5DLZwysC4X0X94hY/3EM+XKtKfPfPXE HD5I4/NC0qfDahqJ3gzdmQ6nbSSfTmW5El49xlu8tPrNeTrxiLpxVUITqdG4u1JgoKMu UTG4p3PGbkF4GZXtTcYNnXop/EHetIENWcN9rzpO3wQiGhKULw+UIaW1iPE8qhkoZEjm mQOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/rSrjqI9Kq8RGPKAfu3pLnMgTVnevgNO0y+F18A2TzA=; b=w4N6+JlbMMS8u89lhdMhufiYJN7aewJS3ORfm4yrSdlPY4zp8qrVlQc7XwIXQcVv/z RfmrdAWiYRfV2qSk3GM15Vm1Ddsn+YjKP16vsfa2exl3nmgDFvrHeK3TWutobPbtkFmK T3+YQUDbft6TNLre/Ue41RA8RH6azIDFWzO5Knol3zvlRYU1PQopxlIDqO2RiokjUgd5 ANwJzDLns1fIbxY8A1WXdwjfxebgZuZ0vslSS6eqEXMpYuLlTdBTuliJMdeUefmYp/+l JIlP+Yp7r7KjsWYG2C7UCAEZTIg8CuL/eZaMyLL5ivZR/PIV4p6rp4dpN1X97cB+SAmB bQBw== X-Gm-Message-State: AJIora8eegYw6UiPLUz01nLewcLGa415XFqpBFVNM1QNHxIg5gdX53nm zHxq15xJHeWCJWNzKpUSELzXfg== X-Received: by 2002:a05:6a00:1d8f:b0:52a:b787:b480 with SMTP id z15-20020a056a001d8f00b0052ab787b480mr455620pfw.71.1658504305473; Fri, 22 Jul 2022 08:38:25 -0700 (PDT) Received: from google.com ([2620:15c:201:2:9655:152c:19f:5d09]) by smtp.gmail.com with ESMTPSA id k4-20020a170902c40400b0016782c55790sm3983157plk.232.2022.07.22.08.38.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 08:38:24 -0700 (PDT) Date: Fri, 22 Jul 2022 08:38:17 -0700 From: Sami Tolvanen To: Peter Zijlstra Cc: Linus Torvalds , Thomas Gleixner , Joao Moreira , LKML , the arch/x86 maintainers , Tim Chen , Josh Poimboeuf , "Cooper, Andrew" , Pawan Gupta , Johannes Wikner , Alyssa Milburn , Jann Horn , "H.J. Lu" , "Moreira, Joao" , "Nuzman, Joseph" , Steven Rostedt , "Gross, Jurgen" , Masami Hiramatsu , Alexei Starovoitov , Daniel Borkmann , Peter Collingbourne , Kees Cook Subject: Re: [patch 00/38] x86/retbleed: Call depth tracking mitigation Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Fri, Jul 22, 2022 at 12:23:30PM +0200, Peter Zijlstra wrote: > and things are 'good' again, except for functions that don't get a kcfi > preamble, those are unaligned... One way to fix this would be to just emit an empty KCFI preamble for non-address-taken functions when patchable-function-prefix > 0, so all the functions end up with the same alignment. Note that Clang doesn't keep the function entry aligned with -fpatchable-function-entry=N,M, where M>0. It generates .p2align 4, 0x90 before the nops, but if you want to maintain alignment for the entry, you just have to tell it to generate the correct number of prefix nops. > I couldn't find where the patchable-function-prefix nops are generated > to fix this up :/ It's all in AsmPrinter::emitFunctionHeader, look for emitNops. > Also; could you perhaps add a switch to supress ENDBR for functions with > a kCFI preamble ? I'm planning to do that in a follow-up patch. I would rather not add features that are not critical to the initial patch to avoid further delays in getting the compiler changes accepted. Sami