Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1369465imi; Sat, 23 Jul 2022 03:56:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tLU/LS/tIolV1AdCBr1vTNba6gC/MKb8qdPJ4kHXN5Dtrf9tNE4w0jdYcpbr/eBA2963Ne X-Received: by 2002:a17:907:96a8:b0:72b:40b0:658 with SMTP id hd40-20020a17090796a800b0072b40b00658mr3118544ejc.3.1658573766706; Sat, 23 Jul 2022 03:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658573766; cv=none; d=google.com; s=arc-20160816; b=lctqtRLDd0zdHziD4GXjqieBNxUPkRkYAE0QmhK9H1ROrmH7N15Vzy8rLm84HtVKoi y7GTQGWQczesvgPK+p5AIefmqUxu0ow7eVZ7SD+a3fQtbnONnHOxjYXewL22wq0aMbNo oPowPAea0V36LOhSu+psPy3YstC+Cl18gy+pH9ULNg8sgnhnxn3IPWOAzeC9+1RBsQBc wq3c1bEf6p8mdRXhqEHV7bTGA58NlqklqGshpV03o4y5jrr5NlfUnzN5Lrc24e0DVJhQ tZZi5CdN9QKj/Q/WaJGnPYGCN/i8I7THpXBPsh5wvyK9qto9/UDV3/XjZc5vc2AuH9e/ Lk6g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PRHhvgfPrHLMeOFsU5lD2hL1T4d/x8P0ocI4eesvXzI=; b=KRsFngOce9hEtg/M1cxruSmwvIn9U8jtOBnJU1pykTKat3eNaT7PAqNkfa9ZIPmxyi mxqRzG7+EWiSkEIhi1vnb/9ZGo2V40Zq5Sc1VKdUNApQONbVzqGbo2YKNFaq5XkkYmVR VzRH7/8HgS8c3tWHC/KiHiTLkT136c25w51KL+jJtkRrsxfChlLLRKmxUwtPaXGy6FRm 0x1n7kuzauJ/2gJ4OFNBVerojdTd/2oTzp3NcnV+Yv82sy2/HlKe112Ql1KK/G+2OzGk Lh3baH1/nIdMAdHq+IsKNeE0iJffO0ykHELcDik/DNxulj8SuXdRhTpd2Q8jjGBSKJhO o/2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pLtwvxjw; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f12-20020a056402354c00b0043bb671bf39si9395050edd.247.2022.07.23.03.55.41; Sat, 23 Jul 2022 03:56:06 -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=@linuxfoundation.org header.s=korg header.b=pLtwvxjw; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238907AbiGWKLi (ORCPT + 99 others); Sat, 23 Jul 2022 06:11:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239341AbiGWKJe (ORCPT ); Sat, 23 Jul 2022 06:09:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1709CCB74A; Sat, 23 Jul 2022 03:02:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 25EEF61212; Sat, 23 Jul 2022 10:02:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 307DDC341C0; Sat, 23 Jul 2022 10:02:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658570556; bh=MwuU+xseDp9KXWFIrzDY8KulQryfkv/g26Hg1/eETvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pLtwvxjw3ATFyH96Gh6I2MUbkPBwX89HSvoFmUkPijF6w9pMeNvuwbyNIEftdX2LE m7K46n4GN2TNeZX4CyW2bbXNRt+b6CYqCpno9u96UW9rXx7AT4Scs7179TC5GflHVp E3Kda3NPF9fHQlguZnIV+qypbXxZOqBSzetDCcJk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thadeu Lima de Souza Cascardo , Borislav Petkov , Ben Hutchings Subject: [PATCH 5.10 127/148] x86/bugs: Do not enable IBPB-on-entry when IBPB is not supported Date: Sat, 23 Jul 2022 11:55:39 +0200 Message-Id: <20220723095259.851395210@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220723095224.302504400@linuxfoundation.org> References: <20220723095224.302504400@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Thadeu Lima de Souza Cascardo commit 2259da159fbe5dba8ac00b560cf00b6a6537fa18 upstream. There are some VM configurations which have Skylake model but do not support IBPB. In those cases, when using retbleed=ibpb, userspace is going to be killed and kernel is going to panic. If the CPU does not support IBPB, warn and proceed with the auto option. Also, do not fallback to IBPB on AMD/Hygon systems if it is not supported. Fixes: 3ebc17006888 ("x86/bugs: Add retbleed=ibpb") Signed-off-by: Thadeu Lima de Souza Cascardo Signed-off-by: Borislav Petkov Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/bugs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -821,7 +821,10 @@ static void __init retbleed_select_mitig break; case RETBLEED_CMD_IBPB: - if (IS_ENABLED(CONFIG_CPU_IBPB_ENTRY)) { + if (!boot_cpu_has(X86_FEATURE_IBPB)) { + pr_err("WARNING: CPU does not support IBPB.\n"); + goto do_cmd_auto; + } else if (IS_ENABLED(CONFIG_CPU_IBPB_ENTRY)) { retbleed_mitigation = RETBLEED_MITIGATION_IBPB; } else { pr_err("WARNING: kernel not compiled with CPU_IBPB_ENTRY.\n"); @@ -836,7 +839,7 @@ do_cmd_auto: boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) { if (IS_ENABLED(CONFIG_CPU_UNRET_ENTRY)) retbleed_mitigation = RETBLEED_MITIGATION_UNRET; - else if (IS_ENABLED(CONFIG_CPU_IBPB_ENTRY)) + else if (IS_ENABLED(CONFIG_CPU_IBPB_ENTRY) && boot_cpu_has(X86_FEATURE_IBPB)) retbleed_mitigation = RETBLEED_MITIGATION_IBPB; }