Message ID | 23a121e309d5e880eb35c441d9bdfa642d6d59f4.1692580085.git.jpoimboe@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp3057628vqi; Mon, 21 Aug 2023 07:53:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMxJKSGBreFAGTv6EP7KOMFfbpXu6NmmLUavspJvSxpnZLgaPYA+eGDtCYeCdqG2Thp0gH X-Received: by 2002:a17:90b:4381:b0:263:4815:cb9a with SMTP id in1-20020a17090b438100b002634815cb9amr6187250pjb.41.1692629603519; Mon, 21 Aug 2023 07:53:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692629603; cv=none; d=google.com; s=arc-20160816; b=fOGfxZRjbQ76Jes00KXm5CY+E3wLiVD8MAshWOzAQrWNlbzcT+ndktWJuEnC9Ixrz5 xhHRshucl3Z6ibjtccUQRLnNlC+i2gY8Uh2hwRe2yunfk5Xp+v4hHcCj/DYD6TiRMwkt nQYljBI+YijpfjcE6DnTAVah8QsE4kefyzSJtOUdzZAXpdwPqSA3GkmkuWGWTZZIyY5K AW4uYoW/tWegP7HsgGGrkclL+PsHDB001sIjJ4U24Yn3vmwT4DxL4s8xD5bw6Fb4VqNR CB1eybu8/OtyZcHqbPtKQWqgVKK4C5+Xi6TlgbDvOc+0QZx7W7XFKt15r7ZFpExLRyDY x7eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LR1WuO7Rd11jdpaoxMTVIscNHd/g6pPAM0I8qNb/xC4=; fh=1KVrD/LnRsN9N7k2d12iARV4DA2tVMW012QtKSrD46c=; b=JXgEdXykLg5qgZ825X/TUqgrvBWpWbEH+OBTB8qbuatjDNMIYnN9ZbG2gNFzlgd2M9 k4kgvsJ6zlC+dj3G/K23DFQHXZoQcQjG52VscsQDWLzR7p6DgjmkOpwtgOE3clkSgLbF zEtBGEUddmWDQ9/nLMY8M95i8xQci2YTF6iy9deiJ6qy3+9Joc2eiF8QB4aaMl275B3n n+swwwp573+vMI0jQptekWS0pB84axTav6VF0LlUpLXQqu+d66OgjU4qAtE/f3nfJf7+ 25HXhdv1RrnX3gRSSG5fGzA6uYWXoXHvt5CM7H3fDQIxINig69YDaqHjzLgCvhXhYQFT Evwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DFLMKfTy; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id js23-20020a17090b149700b0026390b4a4e0si8999688pjb.124.2023.08.21.07.53.09; Mon, 21 Aug 2023 07:53:23 -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=DFLMKfTy; 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 S232308AbjHUBTi (ORCPT <rfc822;chiang.bai@gmail.com> + 99 others); Sun, 20 Aug 2023 21:19:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232276AbjHUBTb (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 20 Aug 2023 21:19:31 -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 46B60A1 for <linux-kernel@vger.kernel.org>; Sun, 20 Aug 2023 18:19:30 -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 270FB6260A for <linux-kernel@vger.kernel.org>; Mon, 21 Aug 2023 01:19:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11528C433C9; Mon, 21 Aug 2023 01:19:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692580769; bh=wseebdWJGAG73aEf4oxCFFQ8XYhFMGqIJFkJEq0d3CE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DFLMKfTyvmgfnWU15SexbYLc/zp8Rh6RZFrJdG+wh44jKu8nu78reOnXMBf7S6R6x DVDvl5Gz+FfL0AOjtsglr9Y41+A/T43NvyF8QSXAv8ohejPea4faN4Z5cRnIhBCLkU x0505HAbqP/g5Ix1OFB2gF+nDzA9nkatLKU2JfT/4/6YOVh5Z5LfwTd6kKVPZYPpNb 4uCY30PcXeTd9OvxSsMLbvb1hkvyY99OKK/7Qqqvlcz440trlJslhgwtcpLZOjdLI0 Gv5bm6F4zk5ri6h3dLHs9YS4PTNf58Szah9G497rkCJrxag92CPZkjMPa0hlBni9he i98CohRGFBX3g== From: Josh Poimboeuf <jpoimboe@kernel.org> To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Borislav Petkov <bp@alien8.de>, Peter Zijlstra <peterz@infradead.org>, Babu Moger <babu.moger@amd.com>, Paolo Bonzini <pbonzini@redhat.com>, Sean Christopherson <seanjc@google.com>, David.Kaplan@amd.com, Andrew Cooper <andrew.cooper3@citrix.com>, Nikolay Borisov <nik.borisov@suse.com>, gregkh@linuxfoundation.org, Thomas Gleixner <tglx@linutronix.de> Subject: [PATCH 04/22] x86/srso: Fix SBPB enablement for spec_rstack_overflow=off Date: Sun, 20 Aug 2023 18:19:01 -0700 Message-ID: <23a121e309d5e880eb35c441d9bdfa642d6d59f4.1692580085.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <cover.1692580085.git.jpoimboe@kernel.org> References: <cover.1692580085.git.jpoimboe@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774850779019500510 X-GMAIL-MSGID: 1774850779019500510 |
Series |
SRSO fixes/cleanups
|
|
Commit Message
Josh Poimboeuf
Aug. 21, 2023, 1:19 a.m. UTC
If the user has requested no SRSO mitigation, other mitigations can use
the lighter-weight SBPB instead of IBPB.
Fixes: fb3bd914b3ec ("x86/srso: Add a Speculative RAS Overflow mitigation")
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
arch/x86/kernel/cpu/bugs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Mon, Aug 21, 2023 at 04:16:19PM +0200, Borislav Petkov wrote: > On Sun, Aug 20, 2023 at 06:19:01PM -0700, Josh Poimboeuf wrote: > > If the user has requested no SRSO mitigation, other mitigations can use > > the lighter-weight SBPB instead of IBPB. > > > > Fixes: fb3bd914b3ec ("x86/srso: Add a Speculative RAS Overflow mitigation") > > Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> > > --- > > arch/x86/kernel/cpu/bugs.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c > > index b0ae985aa6a4..10499bcd4e39 100644 > > --- a/arch/x86/kernel/cpu/bugs.c > > +++ b/arch/x86/kernel/cpu/bugs.c > > @@ -2433,7 +2433,7 @@ static void __init srso_select_mitigation(void) > > > > switch (srso_cmd) { > > case SRSO_CMD_OFF: > > - return; > > + goto pred_cmd; > > Can't do that - you need to synchronize it with retbleed. If retbleed > has selected IBPB mitigation you must not override it. Hm? How exactly is this overriding the retbleed IBPB mitigation?
On Tue, Aug 22, 2023 at 08:07:06AM +0200, Borislav Petkov wrote: > On Tue, Aug 22, 2023 at 07:54:52AM +0200, Borislav Petkov wrote: > > If you goto pred_cmd, you will overwrite it with PRED_CMD_SBPB here. > > Looking at this more: > > "If SRSO mitigation is not required or is disabled, software may use > SBPB on context/virtual machine switch to help protect against > vulnerabilities like Spectre v2." > > I think we actually want this overwrite to happen. Yeah, I had seen that. The combination of spectre_v2_user=on with srso=off doesn't make a whole lot of sense, but... give the user what they want and all. Which would presumably be IBPB *without* the SRSO mitigation (aka SBPB). > But then if retbleed=ibpb, entry_ibpb() will do bit 0 unconditionally... > > Hmm, lemme talk to people. I don't think we need to worry about that, SBPB is >= fam19 but retbleed is <= fam17. So either way (0x17 or 0x19) entry_ibpb() should do IBPB.
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index b0ae985aa6a4..10499bcd4e39 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -2433,7 +2433,7 @@ static void __init srso_select_mitigation(void) switch (srso_cmd) { case SRSO_CMD_OFF: - return; + goto pred_cmd; case SRSO_CMD_MICROCODE: if (has_microcode) {