Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp208743rdb; Mon, 14 Aug 2023 14:24:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8MxcpBup30hmEJHryN810CGAhDyIwxS8b+a76VD3NQ+OJ4kfhfb2RDA8ueq+JlCTcJQuL X-Received: by 2002:a2e:9a89:0:b0:2b9:df49:b818 with SMTP id p9-20020a2e9a89000000b002b9df49b818mr7094493lji.53.1692048284805; Mon, 14 Aug 2023 14:24:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692048284; cv=none; d=google.com; s=arc-20160816; b=H/47JjLn8t7l9rQksOz0le9j+KQPr96kncxtShs8L/2gbF2Ea+CBEb/RGWBOWUJ4be EiXkUvugsOhurdCKywJDPJI7gwIJTeqZkoZn9FfoxD15W4wwN4x55ijmTlZKNzIZGncb z/EsbBZB3nyunbgx5pQKrhpKZ/1XBWVBDoFoLCHk1251ds9KRrqdi9jouMc8zqrjdmT8 CCEjHe1FRH8ESVqpI5oVf/jm1+JHNJAQ70FMY1cRgZM5DGc/tUQeqprTbSHXYOfL9C/r y+ZaIpoYARg0W5SKav7GLn+wT708Se/HP870QunJgtlx9kqRifwgVpjyScDE8jvAcHwA qyhg== 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=zpEAHmqTIlpYaumhovmnJ7JbPxAu0C1/wcZVnUv6W+M=; fh=gKLyGoVE5kyeekC9wm1hIBWPDfgK5z4wsOZ8yWMTN4s=; b=O+dR5QzUyxCyhWWcz5drSLIGYO/VMbl4DQ2XyMepfNSBcImsW/Xs4NF6+kTmZtQ5bX P7oNNuVBVS9PJ2r85pmTFC6804spgJKU2zviIUIEBCQpXaKZwqHPKHEwt43N5LvQMbXU VQl9s/6KOaB1z5plHO5DbA9FELD33lX5LsaSVXAwIRpVjXl5XFrzz8bVBoUQtNCqKzg1 KGUVyTVX6MdMMEkLJ9IKMg+JZPlE+A4d5hwaCWAwRJ7THvUUJgiH/yxn7EJTG+Ex2H9N 7B4tBy1wiga0b7/b2/Zf8FGMBxGlDw8o/8UsTuVIRszfd6pClbU91BgPh+a53NelDERB Nfjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XYqcAlAj; 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 k18-20020a170906055200b0098d373fa9d9si8203148eja.149.2023.08.14.14.24.18; Mon, 14 Aug 2023 14:24: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=XYqcAlAj; 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 S231720AbjHNUxg (ORCPT + 99 others); Mon, 14 Aug 2023 16:53:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232539AbjHNUxJ (ORCPT ); Mon, 14 Aug 2023 16:53:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A00C61726 for ; Mon, 14 Aug 2023 13:53:03 -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 3C2ED64808 for ; Mon, 14 Aug 2023 20:53:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CEDCC433C7; Mon, 14 Aug 2023 20:53:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692046382; bh=XyBR3j4RRfgx19HWC6JTp88+g7mCXmQp42SAG0Yn0So=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XYqcAlAj3lPceyg0h96r/sd82AgFpuMeGtz+tYKH1MOQLy42ERVg3BBr01FEbsT+Y krRc/Lzhm2C9Lu5wx27YqkoPf/xSyVoy0fvxW66CLJjgAECnW08bA6rOMq2XK8WkX1 4Cg1AGPfYyxJgT6zuFVg/P7PtRMto77HGYlBP1pc8HAwqrGdRjyhF5Fe6s4I3d2gh6 KjWw2hlDJznTOFJwwDkZGTesc6NT6IY8F9o0vUnsfTBzzjq3bW/QLvTHpsSIqvIuFh wKQlnhJt9bofde8/qlxn5Nq/sk4Xek2CnYuIvU38HzN7xZldXmixAown3QFsJjEM81 KNFsz8BsocduA== Date: Mon, 14 Aug 2023 13:53:00 -0700 From: Josh Poimboeuf To: Borislav Petkov Cc: Nikolay Borisov , X86 ML , Josh Poimboeuf , LKML Subject: Re: [PATCH] x86/srso: Disable the mitigation on unaffected configurations Message-ID: <20230814205300.krikym7jeckehqik@treble> References: <20230813104517.3346-1-bp@alien8.de> <1588ed00-be11-ff9d-e4c2-12db78cca06f@suse.com> <20230814200813.p5czl47zssuej7nv@treble> <20230814202545.GKZNqNybUnKv+xyrtP@fat_crate.local> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230814202545.GKZNqNybUnKv+xyrtP@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 10:25:45PM +0200, Borislav Petkov wrote: > On Mon, Aug 14, 2023 at 01:08:13PM -0700, Josh Poimboeuf wrote: > > Tangentially, the 'cpu_smt_control == CPU_SMT_DISABLED' check is wrong, > > as SMT could still get enabled at runtime and SRSO would be exposed. > > Well, even if it gets exposed, I don't think we can safely enable the > mitigation at runtime as alternatives have run already. Right, I wasn't suggesting to enable the mitigation at runtime. Rather, enable the mitigation at boot time, if SMT is even possible. That's what we've done for other mitigations. Better safe than sorry. > I guess I could use CPU_SMT_FORCE_DISABLED here. cpu_smt_possible() already does that. > > Also is there a reason to re-use the hardware SRSO_NO bit > > Not a hardware bit - this is set by software - it is only allocated in > the CPUID leaf for easier interaction with guests. 2. ENUMERATION OF NEW CAPABILITIES AMD is defining three new CPUID bits to assist with the enumeration of capabilities related to SRSO: CPUID Fn8000_0021_EAX[29] (SRSO_NO) – If this bit is 1, it indicates the CPU is not subject to the SRSO vulnerability. CPUID Fn8000_0021_EAX[28] (IBPB_BRTYPE) – If this bit is 1, it indicates that MSR 49h (PRED_CMD) bit 0 (IBPB) flushes all branch type predictions from the CPU branch predictor. CPUID Fn8000_0021_EAX[27] (SBPB) > > rather than clear the bug bit? > > We don't clear the X86_BUGs. Ever. The logic is that if the CPU matches > an affected CPU, that flag remains to show that it is potentially > affected. Hm, ok. I thought that was the point of the vulnerabilities file. > /sys/devices/system/cpu/vulnerabilities/ tells you what the actual state > is. Since technically the CPU is affected, I'm thinking it should say "Mitigation: SMT disabled" or such, instead of "Not affected". > > That seems cleaner, then you wouldn't need this hack: > > Not a hack. This is just like the other "not affected" feature flags. Hm? You mean the *_NO ones that determine whether the BUG bits get set in the first place? How do they print "Not affected"? -- Josh