From patchwork Tue Sep 19 09:45:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 142799 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp4803458vqi; Thu, 21 Sep 2023 05:21:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFjJpE8Z8/QTTU88LonHMpX0qO3Wal7GZHV9ng000gkLPL83P0XYS71BFLrfSZb84n9WlP X-Received: by 2002:a05:6808:2085:b0:3a7:330d:93da with SMTP id s5-20020a056808208500b003a7330d93damr5816842oiw.19.1695298890837; Thu, 21 Sep 2023 05:21:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695298890; cv=none; d=google.com; s=arc-20160816; b=SGjQHs2kRUcKOVt5JAIlZsrmlzBIhQ8Jo3uJ2OuJ/q2HqjZEb1csuIzZ66YQE2Fnju R4TVr6P0WQBO2HC+h2F8vdJo78uKFpCts7Aw4ONR4Y8dzNqbhkSbVQEdIBmoSmCPVxsw WlXeF5UEG9H72VpBTFEIq8G+pDU5uMD8/jiHUCbGQZBkpRS4WQtCMbQMYZ8nJ0dDtYVy 3nvwZA67tt/8FS1ENy5rfi3pv+Enp0buiOQIyZ+CgYFUJiG2qlBZSF0s0fiR1URpcg2e Xqi+ZmADm6vyCg049vJiESYFXQYmXc0A0r3UhC/vIzVOJXQze1go+W0ga13AHOvmb/N7 JVrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=3bfNwEv8rwXl1n1xKvOV/RnMdBIU+lyu6K6e055jI3A=; fh=57Ra0KH0qtnPYCBbICqMDqXrBloDYgjX4W0KVBtmmw8=; b=bFBOJ2JaGHrYQd5zB4Rq6E4kqjv4ykF8smdZhoGHX74i8grb3/HiNbOrkdDZzJ0yts aUfYPWR1cnlK9iW1tsvw5yz9N0xkLaWUvY+cB6LP4FXHS04GENG5mbzRtqWa8zX9WKwX 2+NxeUr7LM2brriOkSGLoLHbiZICMOMU2XDpqpqg0R0NgLm1bQp7TMfxRMqrj22TxLI6 cb3Kw/NcCmk/uKk0pUVzBpIhUgCsJXKNeJ0HIFqG3OGTlBZxbnYQbTS6r77PbKW2obTF g6fVnbeXo0NxDn98F77I2BRQWVi9ZlpnhlsaKUvnF89BA2obHO0ND9LgcasqTKyDeXwb Zn3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pekXexCT; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id w8-20020a63f508000000b00578daf88066si1313732pgh.215.2023.09.21.05.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 05:21:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pekXexCT; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 8478681A6C1D; Tue, 19 Sep 2023 02:45:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231626AbjISJpZ (ORCPT + 26 others); Tue, 19 Sep 2023 05:45:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231517AbjISJpP (ORCPT ); Tue, 19 Sep 2023 05:45:15 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13307F0; Tue, 19 Sep 2023 02:45:07 -0700 (PDT) Date: Tue, 19 Sep 2023 09:45:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695116706; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3bfNwEv8rwXl1n1xKvOV/RnMdBIU+lyu6K6e055jI3A=; b=pekXexCTzkkGRAgcrIwSVIQ32FCMpnkQbrkYQL5eJk8KF0iNnacIXrm7av0puk+pB5fBC5 kL4Ehj3rfOr1ZU5417dCSP6uDZaj4Xo9hj3TXqzg0c+XXzQDMwoKArIOZ6q/oKz+f1Zyoj ZHzLP2J3wEexRG8eM6OcewbQ+K+nSi8T1VodOPNKcDk9sc4YkRnPpSo3p7bFUt2YZQ//nB x6qqnjv85uEkqtv25aNTFMqudHybt4dKLzCRm99i7psytCTyQIdKd0iAvn7JuNf8OSlvOs EVbAAr+sOV6/VbAPm+6y+6irK+/grFBu0tV/Wlv1fMK2vRzxXqv2mB+SX4gekg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695116706; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3bfNwEv8rwXl1n1xKvOV/RnMdBIU+lyu6K6e055jI3A=; b=WPKF5erVqPp/uTkmQuXkKZmaVd2b4CqAnvXlBGjcu58PYoslKY58C0rFCDy8UX0EYNnEgi wkxJBuFlj0Y/vKBw== From: "tip-bot2 for Josh Poimboeuf" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/srso: Don't probe microcode in a guest Cc: Andrew Cooper , Josh Poimboeuf , Ingo Molnar , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <3938a7209606c045a3f50305d201d840e8c834c7.1693889988.git.jpoimboe@kernel.org> References: <3938a7209606c045a3f50305d201d840e8c834c7.1693889988.git.jpoimboe@kernel.org> MIME-Version: 1.0 Message-ID: <169511670568.27769.4434872346573872606.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 19 Sep 2023 02:45:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777649730168151054 X-GMAIL-MSGID: 1777649730168151054 The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 02428d0366a27c2f33bc4361eb10467777804f29 Gitweb: https://git.kernel.org/tip/02428d0366a27c2f33bc4361eb10467777804f29 Author: Josh Poimboeuf AuthorDate: Mon, 04 Sep 2023 22:04:47 -07:00 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 19 Sep 2023 10:54:23 +02:00 x86/srso: Don't probe microcode in a guest To support live migration, the hypervisor sets the "lowest common denominator" of features. Probing the microcode isn't allowed because any detected features might go away after a migration. As Andy Cooper states: "Linux must not probe microcode when virtualised.  What it may see instantaneously on boot (owing to MSR_PRED_CMD being fully passed through) is not accurate for the lifetime of the VM." Rely on the hypervisor to set the needed IBPB_BRTYPE and SBPB bits. Fixes: 1b5277c0ea0b ("x86/srso: Add SRSO_NO support") Suggested-by: Andrew Cooper Signed-off-by: Josh Poimboeuf Signed-off-by: Ingo Molnar Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Andrew Cooper Acked-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/3938a7209606c045a3f50305d201d840e8c834c7.1693889988.git.jpoimboe@kernel.org --- arch/x86/kernel/cpu/amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index afacc48..03ef962 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -767,7 +767,7 @@ static void early_init_amd(struct cpuinfo_x86 *c) if (cpu_has(c, X86_FEATURE_TOPOEXT)) smp_num_siblings = ((cpuid_ebx(0x8000001e) >> 8) & 0xff) + 1; - if (!cpu_has(c, X86_FEATURE_IBPB_BRTYPE)) { + if (!cpu_has(c, X86_FEATURE_HYPERVISOR) && !cpu_has(c, X86_FEATURE_IBPB_BRTYPE)) { if (c->x86 == 0x17 && boot_cpu_has(X86_FEATURE_AMD_IBPB)) setup_force_cpu_cap(X86_FEATURE_IBPB_BRTYPE); else if (c->x86 >= 0x19 && !wrmsrl_safe(MSR_IA32_PRED_CMD, PRED_CMD_SBPB)) {