Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp236156rdb; Mon, 14 Aug 2023 15:27:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEggGhU/Ogy+q2miOoasdGPM6Gle3xAwYtpLQbzwqMQQDS7RyuCGb/ijpOblAqEHjq70Zpp X-Received: by 2002:a05:6402:148c:b0:522:2ba9:6fce with SMTP id e12-20020a056402148c00b005222ba96fcemr8643372edv.8.1692052078488; Mon, 14 Aug 2023 15:27:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692052078; cv=none; d=google.com; s=arc-20160816; b=cQHoraEswG/GVxIVLEgNgZpIdixICidCvPon9R5hNadoE/SU2PEVd++QHZm7A6uFIB 0eM2nEtgKyIRKdrDXiPsxHUxBxg+d8UmO69NA23++WbhpZLmoCrIcXlVXpACC1cAGP52 ITV+tHLw2JkvDMwqwv3sBlxk6/+x82lDD5VX8OTwoliEX/PqFElb0qoxVVEnD/PmYuVC F35EzuBJ+GOj4Aq5rpPmAosgzegYiCUgYyAvFbwnOk4HL+2cQIzr1NIvc7+5+/R5xCKe At2/ZcwP/4ZIPLpVTxefXATo1VU8gKO2FDyFZjZxa0kZyAe29RcFs13OcEX7cS7koIzA NpOA== 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=lYhECvuRyUvhBzLzIvi59ABDB/Uzw4Bv4aWdzuLm1kQ=; fh=6FOLT3QtgAtV8LJZDMesKDGP2P4dFQe+HaPOXJuoKk4=; b=JmVoucaFGKgWby3Lm4buuBiElfo4Ycn7Xcv5+D7a/uwCqVlEHdpQpfQBfeF8FmmQwK h+ngjxMEHZAmyYvI5Xjp1NTc8hkwKU0RxBJG3qEbGjboZM6X5UxDYp5jViV/z2Fv5zSl WgOHCJUIKYXj0Z9u6evL4kFm4I2rzICDJg5GBReZX6n7kU1Tiks70xGaRBaqR7Qv0F/K FmnqOYi738cgZjQvOFwemVMLR/nK4KvxWXMEN8fyRJIFfFWUC3MuCYHBcLyxPEbgHYXp 8JN+nRw53EFmGnIXte4yQBwJnS0o4eSUfygItxdd7FAaGehGess6rkwo/jDXm7MIDYRj buOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qaiPXvIB; 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 a5-20020a50e705000000b00525722cba27si511426edn.468.2023.08.14.15.27.34; Mon, 14 Aug 2023 15:27:58 -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=qaiPXvIB; 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 S231545AbjHNTv7 (ORCPT + 99 others); Mon, 14 Aug 2023 15:51:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232280AbjHNTv4 (ORCPT ); Mon, 14 Aug 2023 15:51:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34D8FFA for ; Mon, 14 Aug 2023 12:51:56 -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 C706D6146F for ; Mon, 14 Aug 2023 19:51:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E28DBC433C8; Mon, 14 Aug 2023 19:51:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692042715; bh=49iSU5AQDaX/+FEOchcMQaaxJUj98rtv3qX05nA5C4Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qaiPXvIBrIoW9/wu/kdBhWgnBZIdQZtVXE991Td1wuMbJxK1OHytRezFCu2nroz9s v8DZ7NCqDvJpMnB+H/jfdZ1DwzOpU/YfW53MY63qIYUj6EwSM4wgi+oVvV7RQ+ut/E wcKJgz0UeXn1yDxAEDcPTgRsGM9txDDv2EhWcGExl084jqvFGQlwVXMq7j+Qjd5cbJ lCiBkNsdswPwOQNOQQQ5B52RJ2ZwCsyTgq5NN/V/mNiPTTaSpk0Rx2u7McrZYlPnZ8 ajRKsHqHnVv8n3ZIfln7WlrT3cMe1YatY/5WWjqykrjfpeYYSyJVJsT45L5rGzXucD VZ6knWFOuqnNg== Date: Mon, 14 Aug 2023 12:51:53 -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: <20230814195153.2zxtp6zx552trgh6@treble> References: <20230814114426.057251214@infradead.org> <20230814164447.GFZNpZ/64H4lENIe94@fat_crate.local> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230814164447.GFZNpZ/64H4lENIe94@fat_crate.local> 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 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? diff --git a/arch/x86/lib/retpoline.S b/arch/x86/lib/retpoline.S index 9bc19deacad1..373ac128a30a 100644 --- a/arch/x86/lib/retpoline.S +++ b/arch/x86/lib/retpoline.S @@ -251,13 +251,14 @@ __EXPORT_THUNK(retbleed_untrain_ret) * thus a "safe" one to use. */ .align 64 - .skip 64 - (srso_safe_ret - srso_untrain_ret), 0xcc + .skip 64 - (.Lsrso_ret - srso_untrain_ret), 0xcc SYM_START(srso_untrain_ret, SYM_L_GLOBAL, SYM_A_NONE) ANNOTATE_NOENDBR .byte 0x48, 0xb8 SYM_INNER_LABEL(srso_safe_ret, SYM_L_GLOBAL) lea 8(%_ASM_SP), %_ASM_SP +.Lsrso_ret: ret int3 int3