From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795016376; b=HFtEbBPubbFKe+QwGjZ80oKMyJJ7WMMxNL0lv0ciyZM/jLvEMnEzhvg3v6ettrzNwYYj CNLtMEwPXofDJm17DI+VJohNpdMAqras/C6F25/qHv4YjZqR4RbZ3/+dBQYHzzO/sngPQ 6yLEjcae9kfA4S/QA5XpNGivCZNF+miYaoxGvB0T1ipFEpjC4yJ13GNqfjwJiYrDZasPA Tex/iVm4s7JHjoNMnJTWvIEtOoLVARPpRFvypr/TaxCn2nq2ZXWBvHuY5Z86HzcZWohdg TJcRXg/RpkVZladKQZmciZmoKLitGia/mvh+wk9iEXYF+LQ6gVLfLX0sumEPZnV6Z8A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795016376; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=3rRRL+YupCHof4Vm1f6ZfvXXLDXYgMLIlsl9s9rJLRI=; b=h1NWhqvoFUGta9V/iT8rZbTrTRFg2ETB/6yYo629pzAXljS26ofmIKIip9YQskg7MpDx F9VNNCrRi1qYzkeuPT0LhR2vZAaFTAHsbhmcgu082eJSB3MAVE5uer5fNdTBSoUFkNGjg aYtMHFqltwBMuq0a6dftZHuAAkbCrIimf4IQhERaU35NjoL6VaI6bgOP/aB4XebRmGczv ztNVNDxINBdTToQzGo7MGd8LSHKagg8X+PR/8oRtY7iP82lGipFx8q1bsFPkXHW/1d09V jd49TVfEhLb8G14n5hRAYeRpTyzrsndg7wT7QcK+wd0F8jMyMmQg3KL16xiTZ7IGNpQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ip6tRGjp; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0A0860A2602; Wed, 18 Nov 2026 15:39:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ip6tRGjp Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD4521F000C4; Wed, 18 Nov 2026 15:39:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795016376; bh=3rRRL+YupCHof4Vm1f6ZfvXXLDXYgMLIlsl9s9rJLRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ip6tRGjpHVxiZW6dOdFWJiZJhnN/YY5uwhPoLYHOZlxNzbfniAUCMM6psJ//Gubc0 ZF7NZdXXQibxRqx9CIOT3Ji2uWXDHGwuk6OHEQS+GAjoUbFLzaY5+LEQLJKO+zM5sd JcpOQQjbyFrhYzRxN9i2DkfRIiqIT/5STpjEzvoM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ihor Solodrai , "Borislav Petkov (AMD)" , Sasha Levin Subject: [PATCH 7.3 0506/2651] x86/cpu: Factor init_cpu_info() out of identify_cpu() Date: Wed, 18 Nov 2026 15:29:06 +0100 Message-ID: <20261118150305.976061508@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150247.972732815@linuxfoundation.org> References: <20261118150247.972732815@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ihor Solodrai [ Upstream commit 54a2882ab9f75ab8a77a4f113145d4d709d2387c ] identify_cpu() unconditionally resets the struct cpuinfo_x86 fields to their default values and clears the capability arrays with memset() before rescanning the CPU to fill it in again. However the boot CPU capabilities have already been scanned by early_identify_cpu(), with interrupts disabled. Introduce init_cpu_info() helper in preparation for letting the callers decide whether the reset is needed. No functional changes. Signed-off-by: Ihor Solodrai Signed-off-by: Borislav Petkov (AMD) Link: https://patch.msgid.link/20260916195203.1099646-2-ihor.solodrai@linux.dev Stable-dep-of: 2711d67bc3a7 ("x86/cpu: Don't transiently clear the boot CPU's capabilities") Signed-off-by: Sasha Levin --- arch/x86/kernel/cpu/common.c | 51 ++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index a9b3308f48a86..7ac09bb6881fe 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1783,6 +1783,32 @@ static void __init cpu_parse_early_param(void) } } +static void init_cpu_info(struct cpuinfo_x86 *c) +{ + c->x86_cache_size = 0; + c->x86_vendor = X86_VENDOR_UNKNOWN; + c->x86_model = c->x86_stepping = 0; /* So far unknown... */ + c->x86_vendor_id[0] = '\0'; /* Unset */ + c->x86_model_id[0] = '\0'; /* Unset */ +#ifdef CONFIG_X86_64 + c->x86_clflush_size = 64; + c->x86_phys_bits = 36; + c->x86_virt_bits = 48; +#else + c->cpuid_level = -1; /* CPUID not detected */ + c->x86_clflush_size = 32; + c->x86_phys_bits = 32; + c->x86_virt_bits = 32; +#endif + c->x86_cache_alignment = c->x86_clflush_size; + memset(&c->x86_capability, 0, sizeof(c->x86_capability)); + memset(&c->cpuid, 0, sizeof(c->cpuid)); +#ifdef CONFIG_X86_VMX_FEATURE_NAMES + memset(&c->vmx_capability, 0, sizeof(c->vmx_capability)); +#endif + c->extended_cpuid_level = 0; +} + /* * Do minimum CPU detection early. * Fields really needed: vendor, cpuid_level, family, model, mask, @@ -1967,8 +1993,6 @@ void check_null_seg_clears_base(struct cpuinfo_x86 *c) static void generic_identify(struct cpuinfo_x86 *c) { - c->extended_cpuid_level = 0; - if (!cpuid_feature()) identify_cpu_without_cpuid(c); @@ -2012,27 +2036,8 @@ static void identify_cpu(struct cpuinfo_x86 *c) int i; c->loops_per_jiffy = loops_per_jiffy; - c->x86_cache_size = 0; - c->x86_vendor = X86_VENDOR_UNKNOWN; - c->x86_model = c->x86_stepping = 0; /* So far unknown... */ - c->x86_vendor_id[0] = '\0'; /* Unset */ - c->x86_model_id[0] = '\0'; /* Unset */ -#ifdef CONFIG_X86_64 - c->x86_clflush_size = 64; - c->x86_phys_bits = 36; - c->x86_virt_bits = 48; -#else - c->cpuid_level = -1; /* CPUID not detected */ - c->x86_clflush_size = 32; - c->x86_phys_bits = 32; - c->x86_virt_bits = 32; -#endif - c->x86_cache_alignment = c->x86_clflush_size; - memset(&c->x86_capability, 0, sizeof(c->x86_capability)); - memset(&c->cpuid, 0, sizeof(c->cpuid)); -#ifdef CONFIG_X86_VMX_FEATURE_NAMES - memset(&c->vmx_capability, 0, sizeof(c->vmx_capability)); -#endif + + init_cpu_info(c); generic_identify(c); -- 2.53.0