Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2124997rdb; Mon, 20 Nov 2023 02:43:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IFC7StS6LzZdx+Bgu32iHLMu3O503GLY5Cpp3rjhIar4/XMfXC9sjk3Oj7wjjtw61HhXVyT X-Received: by 2002:a17:902:da84:b0:1ca:a07b:36d with SMTP id j4-20020a170902da8400b001caa07b036dmr6708217plx.48.1700477032135; Mon, 20 Nov 2023 02:43:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700477032; cv=none; d=google.com; s=arc-20160816; b=JQtLpuCIEaFWrQ+jVx0Hfu8a6TJN+mTEER0y0WNuwbCB0qcB4KxKovah2xYWQPjqtp oGG+UD2oHXM7YHZcT7A2PurfwdLuNrUKIk/rUobBjEwctkEVAwrS6w8GXn45B4GyEVQL 0VmvGkBjs2qLimk9pL5q4U9wbJxbFrP10DoYgd12/GG/lIct/pJXyYzAXc1/+ymF8J7J B3qFauegq+23RVFW5RJs5vqFtiQMnkS27nCpl6AcKRBYoTD9Jwgmm4yVHZOUvA+7loo9 b5XD/aOuN67JAPyQJBCS2krsZX4JS9/A9lkZsoiChFfHPmZct/G2SPj7p4VoEeoDhGEY uLGg== 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=TPWJis2GJGokQp7M1Nzs8bfXsMU0m/Jm/UETiwMVs+Q=; fh=yRofEPOsMYSFYi/7/f3tXB782BWAy0107oR1j5aafGk=; b=htETW0TyrXnmIgy8qUDr4u3/iEKxcjtWf6+RhIM6Iu11hVzhN/MhOGUQ5wNEwxqMeW J7xZs6F2LgEXevdvPFtS/Ly+Sgq8JUfF4s2eIspoVsupucJKKj9YesJlTkAO9GdS8aJq Tc3HEBeG2sx/Z+EL1rW/QXrGFWdz4LqzEmuDH0Th2Z0ry/2kewuP73YK2UY9Q+bJa9nT B7XAVSAkqIXcZGUMHKB6yv4Yu+Mwt0NmP9kWrYcae2C2RIqIgFOnX+pME77LiPGHLteJ jmZRmTM3kYGxueEEHLMPsA/+8DklXhsGbsG1i1qX/yB9QLsEHBdnFK43HJgdOSCRPjnf U7oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@alien8.de header.s=alien8 header.b=G0M0t6ZX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id n2-20020a170902d2c200b001b9e9edea43si8243974plc.552.2023.11.20.02.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 02:43:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@alien8.de header.s=alien8 header.b=G0M0t6ZX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 3C52D8046465; Mon, 20 Nov 2023 02:43:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233223AbjKTKnc (ORCPT + 99 others); Mon, 20 Nov 2023 05:43:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233184AbjKTKm4 (ORCPT ); Mon, 20 Nov 2023 05:42:56 -0500 Received: from mail.alien8.de (mail.alien8.de [IPv6:2a01:4f9:3051:3f93::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C02910EA for ; Mon, 20 Nov 2023 02:42:39 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id 163E940E01AF; Mon, 20 Nov 2023 10:42:38 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=fail (4096-bit key) reason="fail (body has been altered)" header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 3De19TxaWLSh; Mon, 20 Nov 2023 10:42:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1700476948; bh=b7mZX+/YHV/jz5ttaRN2Dh9DCKP1lBz9NGfieIiWDcE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G0M0t6ZXTaD1Z17gE0E9Z/wgh1AZGmcRa6arAhcaetXyA26rFCpa1jr1H8JWHS5j2 rAuRIEAYz00UIPtXO2Nc/NaZQVTHdkVoGv3E5l2U11YQ72bcptWTITUdy8xKULf/cN pbANYD5/anAFleP6otPVC0nCzQsnrWgjFQ1meiQCGlgYdz+uq6jjAX+2PXklw1YmIQ K9AGMYDJ9rKFJwK5OZDKYKcxL4s0dIpCyKAkUwBJ5oo4Y+CquKJnVHLp/Tvk04bx8N QBxHSq3uKMRELVbtdt/37AKRPqYrMoU3M/kCq7nKbGBr1YSUoHd9kSyA6UAg3/p8Vw JoMchPeRfHXBTywk3Fzv/JBwHaaZa1ih15gUg6WBak4MnTLErDgw6+UVWPfDa1wexv CA7/qgEUrbG3z/xkFRnwPug2OD2sh81lGOS5yLBAAMAQI3JnNWy/C38bw68xFLKzSA ABcGCJNMAe1S3+tTfyvA3e0nVRwJoSH/lPaAJ0vh5/soszlXBUKNd3nRoL85Bqs+Cd mL4dul9dbmL4KhGDi6dWhQ7hrO0A0H18R/hF/EEsBgK+7nhDB1cW0LAy3E33WW7vJM xtD4yJb2KvriFYBSGc9ICvEgatJys38QdewSgwq1boW1jhD4PW5gpAMcR/ltezGrLc KcHj04Nlk/VIPAPNQiAQjzvs= Received: from zn.tnic (pd95304da.dip0.t-ipconnect.de [217.83.4.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 2C9B940E01B7; Mon, 20 Nov 2023 10:42:26 +0000 (UTC) From: Borislav Petkov To: X86 ML Cc: LKML Subject: [PATCH 07/13] x86/CPU/AMD: Move Zenbleed check to the Zen2 init function Date: Mon, 20 Nov 2023 11:41:46 +0100 Message-ID: <20231120104152.13740-8-bp@alien8.de> X-Mailer: git-send-email 2.42.0.rc0.25.ga82fb66fed25 In-Reply-To: <20231120104152.13740-1-bp@alien8.de> References: <20231120104152.13740-1-bp@alien8.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 20 Nov 2023 02:43:47 -0800 (PST) From: "Borislav Petkov (AMD)" Prefix it properly so that it is clear which generation it is dealing with. No functional changes. Signed-off-by: Borislav Petkov (AMD) --- arch/x86/kernel/cpu/amd.c | 70 +++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 40 deletions(-) diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 8d90f5f6b0d9..7cbb108afaf4 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -70,12 +70,6 @@ static const int amd_erratum_383[] =3D static const int amd_erratum_1054[] =3D AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x17, 0, 0, 0x2f, 0xf)); =20 -static const int amd_zenbleed[] =3D - AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x17, 0x30, 0x0, 0x4f, 0xf), - AMD_MODEL_RANGE(0x17, 0x60, 0x0, 0x7f, 0xf), - AMD_MODEL_RANGE(0x17, 0x90, 0x0, 0x91, 0xf), - AMD_MODEL_RANGE(0x17, 0xa0, 0x0, 0xaf, 0xf)); - static const int amd_div0[] =3D AMD_LEGACY_ERRATUM(AMD_MODEL_RANGE(0x17, 0x00, 0x0, 0x2f, 0xf), AMD_MODEL_RANGE(0x17, 0x50, 0x0, 0x5f, 0xf)); @@ -1039,33 +1033,6 @@ static void init_amd_zen(struct cpuinfo_x86 *c) =20 } =20 -static void init_amd_zen2(struct cpuinfo_x86 *c) -{ - init_amd_zen_common(); - init_spectral_chicken(c); - fix_erratum_1386(c); -} - -static void init_amd_zen3(struct cpuinfo_x86 *c) -{ - init_amd_zen_common(); - - if (!cpu_has(c, X86_FEATURE_HYPERVISOR)) { - /* - * Zen3 (Fam19 model < 0x10) parts are not susceptible to - * Branch Type Confusion, but predate the allocation of the - * BTC_NO bit. - */ - if (!cpu_has(c, X86_FEATURE_BTC_NO)) - set_cpu_cap(c, X86_FEATURE_BTC_NO); - } -} - -static void init_amd_zen4(struct cpuinfo_x86 *c) -{ - init_amd_zen_common(); -} - static bool cpu_has_zenbleed_microcode(void) { u32 good_rev =3D 0; @@ -1087,11 +1054,8 @@ static bool cpu_has_zenbleed_microcode(void) return true; } =20 -static void zenbleed_check(struct cpuinfo_x86 *c) +static void zen2_zenbleed_check(struct cpuinfo_x86 *c) { - if (!cpu_has_amd_erratum(c, amd_zenbleed)) - return; - if (cpu_has(c, X86_FEATURE_HYPERVISOR)) return; =20 @@ -1106,6 +1070,34 @@ static void zenbleed_check(struct cpuinfo_x86 *c) } } =20 +static void init_amd_zen2(struct cpuinfo_x86 *c) +{ + init_amd_zen_common(); + init_spectral_chicken(c); + fix_erratum_1386(c); + zen2_zenbleed_check(c); +} + +static void init_amd_zen3(struct cpuinfo_x86 *c) +{ + init_amd_zen_common(); + + if (!cpu_has(c, X86_FEATURE_HYPERVISOR)) { + /* + * Zen3 (Fam19 model < 0x10) parts are not susceptible to + * Branch Type Confusion, but predate the allocation of the + * BTC_NO bit. + */ + if (!cpu_has(c, X86_FEATURE_BTC_NO)) + set_cpu_cap(c, X86_FEATURE_BTC_NO); + } +} + +static void init_amd_zen4(struct cpuinfo_x86 *c) +{ + init_amd_zen_common(); +} + static void init_amd(struct cpuinfo_x86 *c) { u64 vm_cr; @@ -1227,8 +1219,6 @@ static void init_amd(struct cpuinfo_x86 *c) cpu_has(c, X86_FEATURE_AUTOIBRS)) WARN_ON_ONCE(msr_set_bit(MSR_EFER, _EFER_AUTOIBRS)); =20 - zenbleed_check(c); - if (cpu_has_amd_erratum(c, amd_div0)) { pr_notice_once("AMD Zen1 DIV0 bug detected. Disable SMT for full prote= ction.\n"); setup_force_cpu_bug(X86_BUG_DIV0); @@ -1390,7 +1380,7 @@ static void zenbleed_check_cpu(void *unused) { struct cpuinfo_x86 *c =3D &cpu_data(smp_processor_id()); =20 - zenbleed_check(c); + zen2_zenbleed_check(c); } =20 void amd_check_microcode(void) --=20 2.42.0.rc0.25.ga82fb66fed25