Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp186386rdb; Mon, 14 Aug 2023 13:35:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKJH/XGxHxXT1xnHUji4ilJucHLr51ENM1EZL/q6Nx9Clb2t7vAiBsbRHXs+6ojkZ75dqF X-Received: by 2002:a05:6a20:1589:b0:140:9a63:d5b9 with SMTP id h9-20020a056a20158900b001409a63d5b9mr10633580pzj.15.1692045344435; Mon, 14 Aug 2023 13:35:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692045344; cv=none; d=google.com; s=arc-20160816; b=agg6PoM2HrBz6Z6YWuAnw4G6EGUlIVq7uwfFtt+ISSNXyM761OnMbeKbNAKWPj/arI tOmXaOxUruCnyTF9TAm0xZ6yQ9Mu+0InL+zm5ooy84cbNNysJHtq436ipcs0CT+sIYLB /oD3DEuyyCdjuVhsPRK/8dWZjYf1RmlmD3xc2GqioK6i61Ul7q3to/QsEW5bXhec9UqG ZjFKaf/yq5x17YN46vd17gnCOhBhDSXOYMAYW+65zSDLTYQUIhoK10GN0J1btNJsucb9 coZ/f5WiqwuVN6FbgeZUgb7IThFZyQNHRXcH+zt41S8kiWKjiUqhAKe/iK1L31Xh94pr UHcQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=6X6Ll2p4+XtcCq+n/vAKpGEWQpJSUMLq0nvWbv3/BgU=; fh=0+Fce6NHVqSCOqm9t0Rv/G603hfjgl/8pLPSHCEK5zM=; b=xgSXHDj2AOWUkp20m7+KWNvXqYZFReK2iVkMvmVs4kbZL84ODMV60bLaDkrD2T2W2R CTu/hC3uW/nvZ+51jaGtdq5On7uFIwLuJsfDUsi3SHRvbJPri77ygDCLulX4zUzhFNSd Y5NDy2g9DpMVtdnE/zNjBPYA+EEtm/Cd6Nzf4KGscnReWkR5PVBtdL7c+7NIziHLyK9E YiJkI2qlUMbL9+Jnn/2z8uz8lBljp98REddMjzwbOYlLJWt7VJNrt9vfqK0VX/7xX/RN +uolrg+dx1hhRs5DT/O8FzBYXUc94It6FYheaqW3SOFF83AthXH7ZqUWtsFyGONqRmD2 4PAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nKYIqOq+; 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 u11-20020a6540cb000000b00565726bb47dsi6545105pgp.504.2023.08.14.13.35.30; Mon, 14 Aug 2023 13:35:44 -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=nKYIqOq+; 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 S230322AbjHNUIq (ORCPT + 99 others); Mon, 14 Aug 2023 16:08:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232067AbjHNUIR (ORCPT ); Mon, 14 Aug 2023 16:08:17 -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 A38ED10E3 for ; Mon, 14 Aug 2023 13:08:16 -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 2C035616EA for ; Mon, 14 Aug 2023 20:08:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5ED9AC433C7; Mon, 14 Aug 2023 20:08:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692043695; bh=my6PHpbJ1Nm3Ey57qu2YRyc6aZBGXa78nxO4Gzl8OMI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nKYIqOq+17joZ30QrtKHRtRNmtP50JlSZrN9R+Cp7s/MhWH3L2TDBgwx7YJniqCXg m+1swyswlITKkNooSAV4jUU2neWbfrFXGm3NwsI4DOO3gdyZFkLKktkWoHcHxsULIo eo0UNYaJNHL8NOW3v1CSdkCz8thz1k2DaHB5+Q01yLtxzJ90JmunUWlTofLQWZuiWk fuEJzojCBJbtsT8x62hVQTEyQwIlt5kLUxUtMJgRUOaVyVyKBENoelJDWvxo5/dYah PIjoE4F9nAenkF38Q5plFHda4xkDxZfG+ZF6KJDcobnANIdarYGzS66Fy8YGxoxKi/ GiULPrvZmetzQ== Date: Mon, 14 Aug 2023 13:08:13 -0700 From: Josh Poimboeuf To: Nikolay Borisov Cc: Borislav Petkov , X86 ML , Josh Poimboeuf , LKML Subject: Re: [PATCH] x86/srso: Disable the mitigation on unaffected configurations Message-ID: <20230814200813.p5czl47zssuej7nv@treble> References: <20230813104517.3346-1-bp@alien8.de> <1588ed00-be11-ff9d-e4c2-12db78cca06f@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1588ed00-be11-ff9d-e4c2-12db78cca06f@suse.com> 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 09:39:11AM +0300, Nikolay Borisov wrote: > > > On 13.08.23 г. 13:45 ч., Borislav Petkov wrote: > > From: "Borislav Petkov (AMD)" > > > > Skip the srso cmd line parsing which is not needed on Zen1/2 with SMT > > disabled and with the proper microcode applied (latter should be the > > case anyway) as those are not affected. > > > > Fixes: 5a15d8348881 ("x86/srso: Tie SBPB bit setting to microcode patch detection") > > Signed-off-by: Borislav Petkov (AMD) > > --- > > arch/x86/kernel/cpu/bugs.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c > > index d02f73c5339d..8959a1b9fb80 100644 > > --- a/arch/x86/kernel/cpu/bugs.c > > +++ b/arch/x86/kernel/cpu/bugs.c > > @@ -2418,8 +2418,10 @@ static void __init srso_select_mitigation(void) > > * IBPB microcode has been applied. > > */ > > if ((boot_cpu_data.x86 < 0x19) && > > - (!cpu_smt_possible() || (cpu_smt_control == CPU_SMT_DISABLED))) > > + (!cpu_smt_possible() || (cpu_smt_control == CPU_SMT_DISABLED))) { > > setup_force_cpu_cap(X86_FEATURE_SRSO_NO); > > + goto pred_cmd; > > Actually can't you simply return, given that zen1/2 never have the SBPB flag > set? Only zen3/4 with the updated microcode? Tangentially, the 'cpu_smt_control == CPU_SMT_DISABLED' check is wrong, as SMT could still get enabled at runtime and SRSO would be exposed. Also is there a reason to re-use the hardware SRSO_NO bit rather than clear the bug bit? That seems cleaner, then you wouldn't need this hack: > > + if (boot_cpu_has(X86_FEATURE_SRSO_NO)) > > + return sysfs_emit(buf, "Not affected\n"); > > + -- Josh