Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp554529rdb; Tue, 15 Aug 2023 05:24:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZs+Phq8wlaMU7WnrZIyhUoS2xH8IQrnbDP4R87hFbwk4pe/VNS210bc/VNQNJ41x9upcw X-Received: by 2002:a05:6a00:2d91:b0:687:2be1:e335 with SMTP id fb17-20020a056a002d9100b006872be1e335mr10290866pfb.2.1692102256850; Tue, 15 Aug 2023 05:24:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692102256; cv=none; d=google.com; s=arc-20160816; b=vM4UzVOlctwnXQbc0hKTAQISS/ogZHwZCZMmspmGGum6sqqBezJ2DxHbw4eQVw6FK2 Yetbn96BNrdPrJg+6mNN9lrd3dsGm+IOHoK3rpn8SgRiWbAdHfijSPtwj/8gJNfLjsfZ DqAWMAJ/WxaTGmQ8sXv13ez03eLMRtI5bMiseiPf5DTXEzLOds9lf1ikLIsQmmFPnpXW 2zgqpD3uxZgq197x0/pOyaOnU22ZIwhC/Ka0MPGcp6ku7uJTgpJLI7TztD8B9vPKSIue gXHfAYM4Kf9B2SfrL5wsAaplVwSXQZcTBRqCkhzUGaXDj/v/SGZ3sg7adQYRMajFzRx/ L3lA== 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=t0cAYjMNTXRq3KOFQNvlPpGr6+mDXDI4O0dPUISMkms=; fh=6FOLT3QtgAtV8LJZDMesKDGP2P4dFQe+HaPOXJuoKk4=; b=tzFAF6S3y4lI0AeCP40FZWGgOb1EV0FQKnJxUeahz1Z2x+rVOPbzUZuS7TeS3bHsT9 zIza3wwI8m3yaSntM/JWjbKczDNRcpwXYituS3F3UwQkF5Hr57DiXsmDaD1s7SrXpPMI oa0hsP0xXKW/zfsmcrbKi70WPUFKAxGtb1KmCCp4G8NNOSMYQbmGlc1gyGlt4VR9sNom JrQW7etfA61rNXrxJ3hCSxWK8SM9pnCeolh49qbOpAhs537pBbI98zJkDt3xNF+yW68S 4888rjpDX15ULs2w3wHOTQK1malS5UyBbeBO8tqEIF1XQHT/ZJYPZmDlwnHkXdou+U1v Dbkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gjlvrGkA; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cp9-20020a056a00348900b00682d2ab09dbsi9657609pfb.306.2023.08.15.05.24.05; Tue, 15 Aug 2023 05:24:16 -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=@kernel.org header.s=k20201202 header.b=gjlvrGkA; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232345AbjHNUBv (ORCPT + 99 others); Mon, 14 Aug 2023 16:01:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232360AbjHNUBd (ORCPT ); Mon, 14 Aug 2023 16:01:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7CC410F0 for ; Mon, 14 Aug 2023 13:01:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6BCBE637E4 for ; Mon, 14 Aug 2023 20:01:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D273C433C7; Mon, 14 Aug 2023 20:01:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692043290; bh=0Dopu3Kr2QfFROt/Fub5T1L31qUpIl/MqUeM9m/mw6k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gjlvrGkAmq08fLoMQW3+seEBRrwbC1oUNnbb4Sfr5On5w7i9mKc7jnCN5+IeMdKCK awmk8fNryGoirR1GXJYvB4rJZExPxljLRyxGfZIjRzIysuIucF2pI0eeYt2vMvzxxU wJtJGLBLhko//QZBkzOKCUj5TYW9Iw1zW/lpd1LzKNBtQMQ/GaEZXWGPtJL6ZYAXkQ P5YSh3QcG2njGoSpHPANJSFJYXVBIK257zefhVfXqEufK6wBvfd1Or+eeu8iasPu+C GlUzRXRN5xKxZNSRNit5TeWtGhZsLegcudKiHXlZrcXxyFSILZ4FweNvOcVf4ffd7c lZVO49Zeq5vnQ== Date: Mon, 14 Aug 2023 13:01:28 -0700 From: Josh Poimboeuf To: Borislav Petkov Cc: Peter Zijlstra , x86@kernel.org, linux-kernel@vger.kernel.org, David.Kaplan@amd.com, Andrew.Cooper3@citrix.com, gregkh@linuxfoundation.org, nik.borisov@suse.com Subject: Re: [PATCH v2 00/11] Fix up SRSO stuff Message-ID: <20230814200128.ioas5lk2r3yzfkkv@treble> References: <20230814114426.057251214@infradead.org> <20230814164447.GFZNpZ/64H4lENIe94@fat_crate.local> <20230814195153.2zxtp6zx552trgh6@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230814195153.2zxtp6zx552trgh6@treble> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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, Aug 14, 2023 at 12:51:55PM -0700, Josh Poimboeuf wrote: > On Mon, Aug 14, 2023 at 06:44:47PM +0200, Borislav Petkov wrote: > > On Mon, Aug 14, 2023 at 01:44:26PM +0200, Peter Zijlstra wrote: > > > The one open techinical issue I have with the mitigation is the alignment of > > > the RET inside srso_safe_ret(). The details given for retbleed stated that RET > > > should be on a 64byte boundary, which is not the case here. > > > > I have written this in the hope to make this more clear: > > > > /* > > * Some generic notes on the untraining sequences: > > * > > * They are interchangeable when it comes to flushing potentially wrong > > * RET predictions from the BTB. > > * > > * The SRSO Zen1/2 (MOVABS) untraining sequence is longer than the > > * Retbleed sequence because the return sequence done there > > * (srso_safe_ret()) is longer and the return sequence must fully nest > > * (end before) the untraining sequence. Therefore, the untraining > > * sequence must overlap the return sequence. > > * > > * Regarding alignment - the instructions which need to be untrained, > > * must all start at a cacheline boundary for Zen1/2 generations. That > > * is, both the ret in zen_untrain_ret() and srso_safe_ret() in the > > * srso_untrain_ret() must both be placed at the beginning of > > * a cacheline. > > */ > > It's a good comment, but RET in srso_safe_ret() is still misaligned. > Don't we need something like so? Scratch that, I guess I misread the confusingly worded comment: "both the ret in zen_untrain_ret() and srso_safe_ret()..." to mean the RET in each function. How about: "both the RET in zen_untrain_ret() and the LEA in srso_untrain_ret()" ? -- Josh