From patchwork Thu Feb 1 16:10:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 195386 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp268334dyb; Thu, 1 Feb 2024 08:18:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IF7gvhXxq40FJXZd1+Tw0TJn7SLgMuuDOu4DgdxC2l9SjSU3c6WGAxXrQaL6OXWdmutWLWc X-Received: by 2002:a17:902:e746:b0:1d5:eb28:abc7 with SMTP id p6-20020a170902e74600b001d5eb28abc7mr7892257plf.30.1706804303108; Thu, 01 Feb 2024 08:18:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706804303; cv=pass; d=google.com; s=arc-20160816; b=tp/2Wu6Gw6CEGkrjeqMZlYJkXDE8BY/j9idRUhz6ORWDJV0YZ7aC25QEadQ54t+3Bm mf6OlpxTAFH0XwtFdOqNM4kDURL4XJtMO3hHyK75Ol1WBV+OkpNc6S5Pf44GN/fRXGF4 V0bF4VIoc9UELamO8nl3ZmMFnCcKIo0ZXUMHyC3MucSK3R/PngBBQKmcR2Mnt8nm/k4S gqvypW+gvjNcNg3s7T4CMyDN02EnFgwoorxLMyUAI+DyajX2rSok3iJH3zfGKqhZL436 8onumb+FY5lCRKZu6SG34S7hR32Xu6UoukQ06I9aZ7HLZfvQ6HEFGUOe+hru3F1pGNA5 u60g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=c9WWizlVZGehQeKbzdlshAGyi9Gi9df6/GkTHOSz2Ss=; fh=ffqCfMxvGsGq+zY2LuEuvAbOXjciOQA8Qs+pWmhgO4Y=; b=fAhPWNlVBrUyW6xFUtbnckPol/Xj29ANUfTuop8BmL/l8pHjc8qRjsiEXEqo627MvJ DEjnGaL3oXjBsc2R4RjyagZQYcvMYa24frcbfhR8J3IQN0kZdfG553zDHARWVbKQnkEt CLNbRCnlWwJ3cxbM9XOo6poYnEHkLEstm+uCwbanr3DnYFw6juP5+G27XbwRANQMdbdG 90LbpXEQQRdayK3iOzUhx0ajGFYYOpKl5ovAZ00tIuzKI68MgxLVIeA7vZdeMfRsRkMN R1mNYcGdel1Re6S7rutBIlQLKiFeo56oyqwA5P70my5ViF35P5Q9WjW1V/Zb2ywZ+Eln R22w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=neutral (body hash did not verify) header.i=@alien8.de header.s=alien8 header.b=fqO097aj; arc=pass (i=1 spf=pass spfdomain=alien8.de dmarc=pass fromdomain=alien8.de); spf=pass (google.com: domain of linux-kernel+bounces-48477-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48477-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alien8.de X-Forwarded-Encrypted: i=1; AJvYcCW6GObJ/KDDAvjU3O3DV3s2/rBG5yoN2mvvK+pErLPRVj2JIwTjvKLPioE3lo5AGZ09d327CNTfiV5b0EzkrItDLX874w== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i15-20020a17090332cf00b001d6f2929011si51427plr.21.2024.02.01.08.18.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 08:18:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48477-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@alien8.de header.s=alien8 header.b=fqO097aj; arc=pass (i=1 spf=pass spfdomain=alien8.de dmarc=pass fromdomain=alien8.de); spf=pass (google.com: domain of linux-kernel+bounces-48477-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48477-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5D5E129C744 for ; Thu, 1 Feb 2024 16:10:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A15B779E0; Thu, 1 Feb 2024 16:10:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b="fqO097aj" Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA91C626AC for ; Thu, 1 Feb 2024 16:10:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=65.109.113.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706803842; cv=none; b=MnghxxlhHbaRAMxcKqWOU5Y4pKhvQNY5JWjmCuHQfc0PFnW+v5Z4VYwLGDxt33YHYspF9utzwZmfMr7uYnRJpRSyIg7yuIlEjSOB3AwTFD7qrVd08nL/2jFXRynyMSNVu/zv1UMegDtazJ99eFKKH1s5cDd4jTAcOnKAUJUsn90= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706803842; c=relaxed/simple; bh=VwIBUXKAEsKohjQKNiAhhvDm4Qf4t0hqmsmaz1tTZUs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=POcHIG+UEAzimFfoQJx5b5kBmd/S/Q21uuH0JipqYivNvMOauNRvtkSWTjSdeW9CMBeXReMuXu5xrxynGCX3wOvX7eyXUbepvKrbcQ1dKRJs4F5rFhOXWO0W66UNWeIl55m2cZsepJ7wt5wscLbgpcTiYsnAADJS/8tu2wl29yk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de; spf=pass smtp.mailfrom=alien8.de; dkim=fail (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b=fqO097aj reason="signature verification failed"; arc=none smtp.client-ip=65.109.113.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alien8.de Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id 44B7340E016C; Thu, 1 Feb 2024 16:10: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 FTpKQlxYPQCZ; Thu, 1 Feb 2024 16:10:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1706803834; bh=Gl/hMPFVob6VaW5tFPoWgIe0G5ZAaqiNxRi62AslekY=; h=From:To:Cc:Subject:Date:From; b=fqO097ajlr3PWH0VcGIUsMsBcgZy5yRmivH+vxfXcPaY/5bYhtpezQNSPQfv+hPus GFQxpBVPEZjPbT+7P9PfYBlzRDJRWO26DO3/CctuEKA7ySVacFPCn1TYGNzQBWgmet z/o1QF380No5SiK0DVKzOtWQY5nLE01T4JlTs1fyzv+yBG5GJKN6urDpxSCNyiP2xA FgUcZCWEIAT+UJYfWgrpiVQZ29SbMdwXtMtA6CWLa6jU/oOd3vdB2jmo3seyqpDIWt Ae/w1BI9adOuHk/XpwTPAsvTrCsOjt5IOAiAcfJsryfD9swD7omkUE+q1y/LxcHl7u XG3MEo3ZVjjXJQVvuruVqK5+2YFiiWXZhCUiCePRepMkOWwLUXjBqUS2XkLIrqr7jz xPDGUGsUl5r/m/pr9KJY5gdWA0Xbd1+UgVnjR72se9daU7IaIn8nTZwarNuT0t/nOk JQDfyP9hmXdw/W3Fm+JEM/goqU8Ylh98HcTRnwbBH728aH5eg4NZzqwxpzFp7cJIfu P+aGgbIenws+xIESkhdAUdjlw29Dx2jNCVK7nBytMYlRwUawGth807ptRZcfRR8oDK qvmIUTo1q1D18rwkYAVC5GiCI0Xlqj9duEcuHaQHH5mm5n7QSpqGocIIhsx/Oe+THK m/JLcDM/oCEx7Woy6eOB+Epw= Received: from zn.tnic (pd953033e.dip0.t-ipconnect.de [217.83.3.62]) (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 2C3F940E01A9; Thu, 1 Feb 2024 16:10:31 +0000 (UTC) From: Borislav Petkov To: X86 ML Cc: Tom Lendacky , LKML Subject: [PATCH] x86/CPU/AMD: Do the common init on future Zens too Date: Thu, 1 Feb 2024 17:10:24 +0100 Message-ID: <20240201161024.30839-1-bp@alien8.de> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789714028943630203 X-GMAIL-MSGID: 1789714028943630203 From: "Borislav Petkov (AMD)" There's no need to enable the common Zen init stuff for each new family - just do it by default on everything >= 0x17 family. Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Tom Lendacky --- arch/x86/kernel/cpu/amd.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 310fea1af124..adbad9bfded6 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -969,7 +969,6 @@ static void init_amd_zen_common(void) static void init_amd_zen1(struct cpuinfo_x86 *c) { - init_amd_zen_common(); fix_erratum_1386(c); /* Fix up CPUID bits, but only if not virtualised. */ @@ -1023,7 +1022,6 @@ static void zen2_zenbleed_check(struct cpuinfo_x86 *c) 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); @@ -1031,8 +1029,6 @@ static void init_amd_zen2(struct cpuinfo_x86 *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 @@ -1046,15 +1042,12 @@ static void init_amd_zen3(struct cpuinfo_x86 *c) static void init_amd_zen4(struct cpuinfo_x86 *c) { - init_amd_zen_common(); - if (!cpu_has(c, X86_FEATURE_HYPERVISOR)) msr_set_bit(MSR_ZEN4_BP_CFG, MSR_ZEN4_BP_CFG_SHARED_BTB_FIX_BIT); } static void init_amd_zen5(struct cpuinfo_x86 *c) { - init_amd_zen_common(); } static void init_amd(struct cpuinfo_x86 *c) @@ -1094,6 +1087,13 @@ static void init_amd(struct cpuinfo_x86 *c) case 0x16: init_amd_jg(c); break; } + /* + * Save up on some future enablement work and do common Zen + * settings. + */ + if (c->x86 >= 0x17) + init_amd_zen_common(); + if (boot_cpu_has(X86_FEATURE_ZEN1)) init_amd_zen1(c); else if (boot_cpu_has(X86_FEATURE_ZEN2))