From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 463AC2DCC10 for ; Thu, 12 Jun 2025 23:40:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771625; cv=none; b=alJZoNVNG+AIu1rg7Sh7TFDrnZ2tpfDnIB7B9bAcGqifEtBYJ2MOzQ4XjqsTh/9G8xrW5w+aEJJa2ZHa72vsjr6jMktOABhAWw7Nz0aj1KbWkmW8IT0dpcscmOdIpgkBt+ImC365UudCvDyFaI4mhWoFjA73El3PAEWc7uA3ZHA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771625; c=relaxed/simple; bh=6Pf/tXMZzJo5FfKHir7iP/T7zDvDoWdK5wp07Bj9XFo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SlzFRLmV91icElnY/LmnOIJG8r68inwTOC2KWsdlaz/B1KucNBSw1quxlPB2z3jXSahdOYGyggDFFKuDVPnzDpMBNLXW4XSfGHDJ8B0MSXlbX0lzDNKSDfQaQb34Rk7g3I7SwIq0KYV3BBblTcye+s6LYdd/pKeQj1W1uQCqNAI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=H8PLXXZ0; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=/nDRbo4u; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="H8PLXXZ0"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="/nDRbo4u" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771622; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=moW3grsIEEkZ24nmNYOLsz6RTNF0J1cs4slM6upzMSY=; b=H8PLXXZ0nEu48ExfTAABpLtAj6SaRiuK4r+HT/KcwIfKXG1ku1heoSEPje+PV6R5uC3HJp EOE7BlxJDRSMGWfqM6goRWnRo2LdH5CbYw3tRIDEkL4lFkcwO/JghtA/fidAsOhx/QF00M mriYKQumLlFlDcNEEnKa/EcxIEFBL8OYAyV/H3plkOrMqdwJdV9XdQg1W/oHvlcwICyLKx M6oWhzCJbnoVkJDCRRtPI/W4LPTZDd6eb1tbxX1jtMXnU13l+6NDSHuB3b3Ld37HQdZFdO kBW5Wk8c4zr/ndVtvC6w3J2bq0b+KDHXRVrN07Rv3MWgXwP4iQJ7rgdNw4VuQg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771622; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=moW3grsIEEkZ24nmNYOLsz6RTNF0J1cs4slM6upzMSY=; b=/nDRbo4uxEJCyJkKA6dzwcEWp33Pl+d34uBuRpw7r34DCzJYO4SxGuagAsNsL6tDvLhrv7 tnHOAv018uurWrDA== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 01/44] x86/cpuid: Remove transitional header Date: Fri, 13 Jun 2025 01:39:27 +0200 Message-ID: <20250612234010.572636-2-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" All CPUID call sites were updated at commit: 968e30006807 ("x86/cpuid: Set as the main CPUID heade= r") to include instead of . The header was still retained as a wrapper, just in case some new code in -next started using it. Now that everything is merged to Linus' tree, remove the header. Signed-off-by: Ahmed S. Darwish --- arch/x86/include/asm/cpuid.h | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 arch/x86/include/asm/cpuid.h diff --git a/arch/x86/include/asm/cpuid.h b/arch/x86/include/asm/cpuid.h deleted file mode 100644 index d5749b25fa10..000000000000 --- a/arch/x86/include/asm/cpuid.h +++ /dev/null @@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ - -#ifndef _ASM_X86_CPUID_H -#define _ASM_X86_CPUID_H - -#include - -#endif /* _ASM_X86_CPUID_H */ --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 8379B2E172D for ; Thu, 12 Jun 2025 23:40:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771629; cv=none; b=NbJCLG/lLDygm1dgPoPIUoCpLJfUfNeyfmShr3beNT8vYTTos5BP/QEl4hYiHBsujoxOLHbXSydvASfWxiWj0Px/s1nDPJcG2jo1LHOudpr5KMD8UkHr10naEfaifLTfS9baRLVvfmcRSsNrH4OtIKgDw4hnq+EpSfsvpAvZydo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771629; c=relaxed/simple; bh=j/MxQJmLqteQkdH7tidFHqXDUcSXzs6RjKD25dy1XVA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IFwThMuAoOUBwFn/BM2U9ERW19Tx6vq1z3Y6YKB4mn1bvBCeECknn8G7Uk45brrsl3Dx59JQpnh0Lyxd1v+D3/D1eYYfmW+/A0ne0HasK5VqRD8CznKTMHDaD0wZ7G+YIG6sSKm/q3SJ75HuhVeXyM26whjo0w3TYErfPTo5ppU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=QLT4Qa5g; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=sVDSTl54; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="QLT4Qa5g"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="sVDSTl54" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771626; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cq1E0FuKK5sFEDeBEwjwBTOXySpdITktux1efgKrh14=; b=QLT4Qa5g6c815rKobMzPWhP+33yBRR6NWJkD7NVj5j4hTtkAOnFIgfrV8DNzeHtGZhPzIu UnjySnk8Uc1d2pV2TC+sXgMrcL+szzP6/9PNQtoVH7+YPJAyZSK//ErMHJdeYc7egAuvwU OsUrbdNeNAr56na08q0mCXjrxeW33xwykHhNGPINMYwOWV9LUos7zw9Ky/6UY16bwiuH63 tcFVc1P5bHYuoRD+cEPWC7DFuOWUHmu1A8smc8F0JGWZkNfhQowQgkJ4cbKSKnL8l15ixh +osR6Yh2KT5+2TRRKcixO6qpqE/8RUd5oQ6IHi9IPkU2FoG9OjUmGbM4LhnHOw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771626; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cq1E0FuKK5sFEDeBEwjwBTOXySpdITktux1efgKrh14=; b=sVDSTl54KE9HLWplB35afvhSP1pzGMHIQ8Y93dLRFB7UOiDCll03GVQW1sL2CNYQ+9djon SjJ/sym6z6ETaQDQ== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 02/44] ASoC: Intel: avs: Include CPUID header at file scope Date: Fri, 13 Jun 2025 01:39:28 +0200 Message-ID: <20250612234010.572636-3-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit cbe37a4d2b3c ("ASoC: Intel: avs: Configure basefw on TGL-based platform= s") includes the main CPUID header from within a C function. This obviously works by luck and forbids valid refactorings inside the CPUID header. Include the CPUID header at file scope instead. Note, for the CPUID(0x15) leaf number, use CPUID_LEAF_TSC instead of defining a custom local macro for it. Signed-off-by: Ahmed S. Darwish Acked-by: Cezary Rojewski --- sound/soc/intel/avs/tgl.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/sound/soc/intel/avs/tgl.c b/sound/soc/intel/avs/tgl.c index 9dbb3ad0954a..cf19d3a7ced2 100644 --- a/sound/soc/intel/avs/tgl.c +++ b/sound/soc/intel/avs/tgl.c @@ -10,8 +10,6 @@ #include "avs.h" #include "messages.h" =20 -#define CPUID_TSC_LEAF 0x15 - static int avs_tgl_dsp_core_power(struct avs_dev *adev, u32 core_mask, boo= l power) { core_mask &=3D AVS_MAIN_CORE_MASK; @@ -39,22 +37,31 @@ static int avs_tgl_dsp_core_stall(struct avs_dev *adev,= u32 core_mask, bool stal return avs_dsp_core_stall(adev, core_mask, stall); } =20 +#ifdef CONFIG_X86 +#include +static unsigned int intel_crystal_freq_hz(void) +{ + return cpuid_ecx(CPUID_LEAF_TSC); +} +#else +static unsigned int intel_crystal_freq_hz(void) +{ + return 0; +} +#endif /* !CONFIG_X86 */ + static int avs_tgl_config_basefw(struct avs_dev *adev) { + unsigned int freq =3D intel_crystal_freq_hz(); struct pci_dev *pci =3D adev->base.pci; struct avs_bus_hwid hwid; int ret; -#ifdef CONFIG_X86 - unsigned int ecx; =20 -#include - ecx =3D cpuid_ecx(CPUID_TSC_LEAF); - if (ecx) { - ret =3D avs_ipc_set_fw_config(adev, 1, AVS_FW_CFG_XTAL_FREQ_HZ, sizeof(e= cx), &ecx); + if (freq) { + ret =3D avs_ipc_set_fw_config(adev, 1, AVS_FW_CFG_XTAL_FREQ_HZ, sizeof(f= req), &freq); if (ret) return AVS_IPC_RET(ret); } -#endif =20 hwid.device =3D pci->device; hwid.subsystem =3D pci->subsystem_vendor | (pci->subsystem_device << 16); --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 B770F2E1755 for ; Thu, 12 Jun 2025 23:40:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771633; cv=none; b=bwhntHDLlwhnLnb9e8jzwdBL/a4Xa1ciq/DCbf7W43SsD8DvxFz3vuCHS5lY+o1GfB7pRniYNdAeQzxzG1BzsHnnki0u8eZMhGJpRbmtpwG+qk1v06dO8GrAK7T0TeloXO6g+dzCO4rVYD2Je6um1I1Ok7AOR5GQ/vzQkFP+Dfk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771633; c=relaxed/simple; bh=VM+Tq2JHqf5zPcRiSy1otnHq9UT5dGu3SFfeNLN2rO8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i59tsBTIGete+jaC5FSFqrXfSQorPNH3JD2VdOVye77AYjM7IBi8IGABrfTXhBOj5/kvIpqGlC+BUGmi0IFozxYCvuU/Fg6czxFjoH3q5nfw2pc6rwt/yXQTTYzkXru3Z4kqJXWvDrShw4aYjzzN51Z2ZvSZPvJf2Wi3AFoiNSQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=h/3NmRVl; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=aHDxpVi+; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="h/3NmRVl"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="aHDxpVi+" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771629; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9Dt63MaH2HMdvBtvlDsryqLPF+tYIcYR7emziyJ9L1M=; b=h/3NmRVlk2fm7TIjkaNzkyJYlzXqhwXNQGi+sVhT9qyosudX+8lpd9V51peiOIkGpWX3gu WV124HhcuW4lYEWRNoyuuICr51AwA5BspySa01/LusBytfEKn/Imcre10sELIFdxDB6rxD B9op0g5VYOZ+F1bnrsdQGXWoLXDIju6MuXmGIR4UdywvrOi9PSF4GGITJzx1xRoodpQumm FmfREoMqeo58/ZSFS0kSbRqQEIfiIR55Q58BappjFguVu4QCc86esjc5Qted2C5lMlahx6 ueSGymieQ7xowD/ozHFh0zkcc6a9r2eyXDSMVzKyTTOqOz9YpAxf0OogZ4Dalg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771629; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9Dt63MaH2HMdvBtvlDsryqLPF+tYIcYR7emziyJ9L1M=; b=aHDxpVi++tBoRmkbQDbIMzD5Ah+4ZXOWLWi/PCauyxFyxeJhKAsq3oXyLMCQUj4/8hvQxM L8U/TnVH/jStd1Bg== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 03/44] x86/boot: Reorder sme.c headers alphabetically Date: Fri, 13 Jun 2025 01:39:29 +0200 Message-ID: <20250612234010.572636-4-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The source file uses cpuid_*() macros, but it does not include . Sort its include lines so that the CPUID header can be included next. Signed-off-by: Ahmed S. Darwish --- arch/x86/boot/startup/sme.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/boot/startup/sme.c b/arch/x86/boot/startup/sme.c index 70ea1748c0a7..922b236be02f 100644 --- a/arch/x86/boot/startup/sme.c +++ b/arch/x86/boot/startup/sme.c @@ -34,15 +34,15 @@ */ #define USE_EARLY_PGTABLE_L5 =20 +#include #include -#include #include -#include +#include =20 +#include #include -#include #include -#include +#include #include =20 #define PGD_FLAGS _KERNPG_TABLE_NOENC --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 128142E2EE2 for ; Thu, 12 Jun 2025 23:40:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771636; cv=none; b=A/WceaZWbKN9lqjwOrkFNb9G9g3gHBcm9pEgxz3QnGP8pUBFUNsZ1mWq2OKYTPFhCxuOYgV+8mbSthmE9hP9wGtd09FdGWLELurh+1jWEViQNFimtR/rKfNrVKSlly9JzLqA97r9Idk+xtlwwrqIVbeLXbNkg1YiSkQWFpAWZq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771636; c=relaxed/simple; bh=uLB6+jUDU36CNXqX8JFhOtPaiBVOkrpnE6WiIL+0ESM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aPsxvOPKfNggfefLfC8Ajbubkt6FE/BYRyhamvfUAYzZP7Lf/yZRIKEObYWSPEYOuH1S3BT+lG36uueGB4i6uSg1RtUgCO4UWPhVHmvQA1VjyS2yxkHL7idxm+tPxvvJlYCNE2tYM9gAiZkS5hLuGlLD2FWjYjcG6PEgnXItmFc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=plVzzIWe; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=9N26kAI8; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="plVzzIWe"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="9N26kAI8" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AyX/eCKjMXH8T5o1dKBgq3rnP1IwAJ2aHpMeGCd3K88=; b=plVzzIWexYzQt8Vlx3432DSCnrrNqT1SHotZvMgBAwQkbIqdTdjltho/mbZ9A1iReUuUqo oXT4xZ/rAmU/jf34hTDkpp0PycvHJnUiFKn+q/8Jgba/s6YxSdBos3Wr/Hti7ENwWtjjW5 ieM1FV3zjA0nTXoncP0rwjHka5VYMcBb0KRt5dE10LnRQcYtMz3hpCP2sV4/Rnv2BuGxc1 wIcY78vhc8xoBFpd87wlx4gjxVeMRDRNf6kfrZID3RbrgxU08RD9IH6iWBOL8hlS0Yjf3K eyd24SuQU6wbYvlUhdcLl/SmEZIHwhbNzS3wFWWOYVAVxfp8uV0XmfXLdsiFSA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AyX/eCKjMXH8T5o1dKBgq3rnP1IwAJ2aHpMeGCd3K88=; b=9N26kAI8wXSWHCE139B9h3XBmG6Wkd5j+kSkvnZL5jrJxoziVd8IqToJeoEHVR7hmIZBbw LgtPpavu0lFJfrAg== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 04/44] x86/cpu: Reorder scattered.c headers alphabetically Date: Fri, 13 Jun 2025 01:39:30 +0200 Message-ID: <20250612234010.572636-5-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The source file uses cpuid_*() macros, but it does not include . Sort its include lines so that the CPUID header can be included next. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/scattered.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattere= d.c index dbf6d71bdf18..3d23b943f596 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -4,8 +4,8 @@ */ #include =20 -#include #include +#include #include =20 #include "cpu.h" --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 0D9372E2EF2 for ; Thu, 12 Jun 2025 23:40:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771638; cv=none; b=rwWhKbYQa9aAOg0GJyWbJaGZhTY4/YOiesFg6yC9T88o5Zdfzqg7iVdhm+cAbs+EA7Bdawajvj32C5pj6cTbQe+7xArEJ3aQjy3e9ptTl3s9Efrc4htUtGq7GgP0HFjLYSfVjvuMLUQx9jpbzrr1B5DtnrINjIuVvn6gbnq8Jmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771638; c=relaxed/simple; bh=Z5myvD/LZM1QB0DHHe0Xxmt7xk1NoF5DL50cjkyuxVM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RHa5RmMeiD/AJOvRAWU4+RXUubjLD3QFDFoTBfoDk9SvytNfsPI0NqnN0yQmOsg1AVnJeXck+q8fDOziuv1B2FggOyU5xkXoGrHFptBNrCDErd1405k+5hihLlyBJEkPZVZ4zf+CbZmhX07dORTR978jXWVkXqUcO+oJ8Q3qjvk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=cQ6O5hJH; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=cGtwnLME; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cQ6O5hJH"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cGtwnLME" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rxzMZiw++twmmpi3YWJOLkyjA3YsvRwP7t4EJ2qNmik=; b=cQ6O5hJHqC4GlESMcFgAQd+DQk5itSvBXgkj5YY7D9MXbwao4hU5ROIEd9EZoyYlafbioc 3miC/G2os3XzmQKCk9yWMvoEx53u80GYszpmhtK4hsWRi7cghiAFf7paLR9MwDbfkBYvut tllxXk5+jhSsxWJgpwXyNk8bGgaXHN2X1YMEkw1DCgRMvZr89rpa8UYYJeVm1PPvtsj1zN kCts341OL5g0HOc6OZR1mkk5/IQQxQGTbQS23AuhHH4gplPFSSotE4lRtE2BAAYpqbSSXB TJ3VlfZ0IDc7lAPKr3AduEvsR9MCl0VLbQJ8/dR2E+NCu1r5fLkafJjmBLkKPQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rxzMZiw++twmmpi3YWJOLkyjA3YsvRwP7t4EJ2qNmik=; b=cGtwnLMEFW3hQMpx64uFKMZSpRE7C0Pu6avRKYpT5r/g71cz0FfNP3RQg3FegfLuiqN36I P6fsxLhdh2k1LQCA== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 05/44] x86/cpu/amd: Reorder headers alphabetically Date: Fri, 13 Jun 2025 01:39:31 +0200 Message-ID: <20250612234010.572636-6-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The source file uses cpuid_*() macros, but it does not include . Sort its include lines so that the CPUID header can be included next. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/amd.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 93da466dfe2c..c988d876b700 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -1,29 +1,29 @@ // SPDX-License-Identifier: GPL-2.0-only -#include #include #include -#include - +#include #include +#include +#include #include #include -#include #include + #include -#include #include #include #include #include -#include -#include +#include +#include +#include #include #include -#include -#include +#include #include -#include #include +#include +#include =20 #ifdef CONFIG_X86_64 # include --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 8F8DA2E336B for ; Thu, 12 Jun 2025 23:40:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771643; cv=none; b=u0OvTSt9Dspske7hprafXtJzsPsYRvZ6hVoZez0B1sU3C7JAREeXlGCRI3kttO4/1EVNfo+1xO6wzVg+CFc5FE/WR/iNvzuhdOPWzW66V++7XVRcnIDiK3pZ0Og2gznXEB/YBmUcl2sjQfznkNjKEMx5VXxv4TI8XV2WpV2hEFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771643; c=relaxed/simple; bh=uDbQEMjpGwSYuviCS6Yz9UTd4NYGPbxFfhGqHoz6hpQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=isRxQW9zdwYjjgIHiaVwzCcjxpmvtPtW2SHGi9bwhY8ju1bWeHY8LNfHXw1vu+8LZ6Bb0B3S22LAMuGHbKWoa1sPrnzhttdG+KpJuhMFqfUg7iBpyi0ez+V5ZRCoedyEQjmBjTADShAaPq0YyyenN2KrjkmqluGKsbhkxBWtsAo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=DN+78nBe; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=WqcYQEfH; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="DN+78nBe"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="WqcYQEfH" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771639; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7us/GbD28rzIxUHSzQazlyTfJk9FvplS4pe3Mv5Vn24=; b=DN+78nBeC4hIPRAd0grYFTrfnRJHzzVqcpuOUp7TzjhE4HXxATGHDCkUGJUiyPxX9snKyl 6gEBinTwai9BBUs53CX9a0L0pRM0jFGeKogwEBSXJFiWSZDMuggs+2OySd50QB91ccWCAD ROdB9r9pagVtbYv0paWKHrfQMLp8Tr/WJIwREsC+sXLa4bFOW72RKL4aJ/IXvYoIgwr6RI mkUWmjjfwT/myCzng2eYXwDcreu6VIaYjvmO9itox5t6NptVFZo3HlYmSSKxN2036y4DNF AzPLoDLWAelHyuUl7oQCb8PWe/2xBUDAbcf7RIeaI7RgT+ozvl1bnuTZ0s/fQg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771639; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7us/GbD28rzIxUHSzQazlyTfJk9FvplS4pe3Mv5Vn24=; b=WqcYQEfHckFAppiOspuKvhanqpM23HxF4ac0TGLvYd+XHPJYB9l+wtHX8UgSLYqjJbLTFM XHmNcxHt9U31D9Bg== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 06/44] x86/cpu/topology: Reorder headers alphabetically Date: Fri, 13 Jun 2025 01:39:32 +0200 Message-ID: <20250612234010.572636-7-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The source file uses cpuid_*() macros, but it does not include . Sort its include lines so that the CPUID header can be included next. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/topology_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/topology_common.c b/arch/x86/kernel/cpu/to= pology_common.c index b5a5e1411469..48c47d02d8a9 100644 --- a/arch/x86/kernel/cpu/topology_common.c +++ b/arch/x86/kernel/cpu/topology_common.c @@ -3,8 +3,8 @@ =20 #include =20 -#include #include +#include #include #include =20 --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 DC8AF2E3377 for ; Thu, 12 Jun 2025 23:40:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771646; cv=none; b=UxjmTqDFPkdV/a/12BLkkecZNhSCtgbKzU+H/dKCYMbAaI05/wOncCV4qYOh5OGVTFyQ2vyLOMGlOPpSedOLO1KNiMgAsWzIH59rgddWyPyDS/Iriynirtkd1sdB+ROidannzbO66H11E/GtAXXZuDzikfwBpqFl3zxRVIeRsNU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771646; c=relaxed/simple; bh=lyZmPi3B4oF17ev9UTYg2muWF1nVtaEzGetNCY/OynY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fXUXmewbc0tY7zBnLcsQK/3gvzzN+yYC0jUiyBwQ3ITEvUEzv1WlcI3rAKq0JuqBzHXCqqKVzWzCMzC/UZdd3KrQ7FqtozvpFySuGzBCZHvW47kxvSzbWiqQqQ9YXbnS6Y35Rqzunz3rrt1agTX5kSq8LBpDhzTkWUU/zOTqPn8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=tTf/M6cP; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=X3xVFaRj; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="tTf/M6cP"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="X3xVFaRj" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hL6kR8PIDszFqQWu4ogIAnEYWUoEaYfz8wTwSpB7fkk=; b=tTf/M6cPV9as0BDx/16N4OCAY+yUmobHQ3+ua+0YUn4Xs5l7uyi2vcrMdx2H5Nzt2ERbLr NTosDM83mndNt7qMNLNiAH4B4325L346pcBjCtZILwg6gPUvrB1TOna/kuWbGV5osbMOs4 rJn2aVo5jXlDjqy5otv8BZpo1qssKVxL7kgb5/FbpU9eCq5tjtCNXR5EDthqv1nQSnoKNX 3yGAFwKoiVn3AaQ4Ueaa6FZE6VWEJydtfeexb2Q7NhaUoNnqu6WTGJAg8AVHD2ffq9RbtN gIwKJ9civeIX0dCj+rbOy44EiUrbIBhyWsmes6txC5wHWzIRE0aSUKBNbi/srQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hL6kR8PIDszFqQWu4ogIAnEYWUoEaYfz8wTwSpB7fkk=; b=X3xVFaRj7N3U2XV9ahXJXbE2OaGNwmI/pHxBWH5YSS0TG3WPMzzzHEQTNbKikm/qzgZav3 V+777uhDkssdK0DA== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 07/44] x86/mce: Reorder core.c headers alphabetically Date: Fri, 13 Jun 2025 01:39:33 +0200 Message-ID: <20250612234010.572636-8-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The source file uses cpuid_*() macros, but it does not include . Sort its include lines so that the CPUID header can be included next. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/mce/core.c | 62 +++++++++++++++++----------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index e9b3c5d4a52e..fe9e65f314fb 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -9,52 +9,52 @@ * Author: Andi Kleen */ =20 -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include #include -#include +#include +#include +#include #include -#include +#include +#include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include #include +#include +#include +#include #include +#include +#include #include -#include -#include +#include +#include +#include =20 -#include #include -#include -#include -#include +#include #include #include +#include #include #include +#include +#include =20 #include "internal.h" =20 --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 508802E3381 for ; Thu, 12 Jun 2025 23:40:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771649; cv=none; b=VW4/uk10R8fXUn1ECcUg7Jei9WHzsb0l4y2fF1H9Okb2jalNf53eCctylIVuzD2klNPU+j/rzXp2cl7TbDaZU286qsaY/yqtlf9ix1qNC+7MLDtWnRfyqYtTPz/7Jg04Qf/vaOLr3jADkU0LVrb+nW5X15nKHtoKD0nHnMZLYjY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771649; c=relaxed/simple; bh=SdDAw6XHJi/hxVE/IUBqwt13Gjwva4kHbz+8iCUDa6I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MxnEhPIAP0fvsdrJR4mWeuWDufSl9oYNZwBCd0ItYg4XppOBymL1ohSK6GkOzb2VTw+MRLFhV3fz8KH92BmHnQTXL6sns5Dsf90SIhDwpf+pRbix0M1W5QBuViGN9wbwEg+N2jBXik8u9yp2adRxE+Qh4RFl2JpARpir/3mcvR4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=uwZ41QvQ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Cd67XUmh; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="uwZ41QvQ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Cd67XUmh" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771647; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5OmPY1kT3M0ja+0CH2Wur4I4FysF/vnqURgtSJeVlIg=; b=uwZ41QvQXJHngjhbPVgP6+RFtEMw3KAsxpBzFH5mDXW5hc6SWxyewiVwdreQljr4SSv6f9 VvrlGUCI9g+8QrtUlCIWVwa272x1fFf63r/z3BTpyjlXzBmCRVwPtBX8K2HRsj6ss8gcrq e2glq1Wxcb6AKMa83wdhkk2Rqz1/pjK8uHz3CjJo/+hSTA4ACDvfFgcNJNgvJM8JCVeM7v EGKPLvsOLwQvaVRADYniJRBojVBj8G7oCV8wOhC7OqZwWxak9vIoQrSBzjsxlRLLxmzYJ5 D+5ztuVqXo1E8UBjbzvXuRygy6xG0gWPuGdTNLyKwNuvuK4Pru4zpKM5sLuDnQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771647; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5OmPY1kT3M0ja+0CH2Wur4I4FysF/vnqURgtSJeVlIg=; b=Cd67XUmhDkztUA9je8NtByFuqNgP2JP4GMzduliTPQjMN0jeSpc+XJzLMENTCs5o6ij1L/ 5FkfjcLPQq8D+ACQ== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 08/44] x86/paravirt: Reorder headers alphabetically Date: Fri, 13 Jun 2025 01:39:34 +0200 Message-ID: <20250612234010.572636-9-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The source file uses cpuid_*() macros, but it does not include . Sort its include lines so that the CPUID header can be included next. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/paravirt.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index ab3e172dcc69..3d745cd25a43 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -6,34 +6,34 @@ 2007 - x86_64 support added by Glauber de Oliveira Costa, Red Hat Inc */ =20 +#include +#include #include -#include #include -#include -#include #include +#include #include #include #include =20 +#include #include -#include #include +#include #include +#include +#include +#include +#include +#include +#include +#include #include +#include #include -#include -#include -#include -#include -#include -#include #include -#include #include -#include -#include -#include +#include =20 /* stub always returning 0. */ DEFINE_ASM_FUNC(paravirt_ret0, "xor %eax,%eax", .entry.text); --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 044682E3395 for ; Thu, 12 Jun 2025 23:40:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771653; cv=none; b=tJpGAEL4YTsPhsD2PqRaayQR2XcuR1zlzBMDe2Zqk2QoZtKpagbEm5VpAXExse7LsuGdtF4eE5L9zZL+ZmQBcIgtMac+Sny5eiaHQgfkIrKELf4SEcU/NgNe7JuN/qjkt2OpUFFgO4rWjXBw3a52UA5d7yBUquywPdXs/W4xfKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771653; c=relaxed/simple; bh=urbfpYJB7BRJdqVutwFNMY3nz2cVZo87E4j1bkM4ZEw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nfDqZJzJGFMeKDjvbTGIa7SrCyGOj2kaE2/mhO0Pj6+fr+Oo4G7yyBChu6/eZsjJgeppZD2ESkMFg7kUVtMIvTRkPqKkldzlEEwJzmRc+MWua+gKgz7eSM4YUM86RxX0gVchXnFshTWq4frvLREaxOg2sewVhol3Alt5wWVAi9I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=2L5iwY8G; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=CZECyNr8; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="2L5iwY8G"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="CZECyNr8" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771650; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MUGg50fnGzlgiN5hug/Z9cYMqVZSaR5sj8t00daGjms=; b=2L5iwY8G8T5fhY7ezZtYML5EgHr8jPDCnUR86ZSLr7zO6r07c5NxQxrQLCyW4S67aYob7D pCPIaJilq6annn8rqxATllTkY0d2QXftBX0dhKh540CjqwCYzwpyn+vl9rvDMirjlHeWIJ +Ej+knHIqdHFrFKUQ7k6oJ2jgrrSO/RGa0FrDisida5cUOTUe7eZb1xC7MyHeZBDTRMfZP Qvh28xyGox5l0Pc+VHyO9rVRI/PWEtabQ2mn14vDPUpHiJ9BULcFLjlWRv2K+iDyXkr+mB VJSNq8fDWC/o9r0ZqnF34j49WGAb4xq+FFEVFCfIB1hydC4Abng0yUv7gCq5nQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771650; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MUGg50fnGzlgiN5hug/Z9cYMqVZSaR5sj8t00daGjms=; b=CZECyNr8zBboQrslHSEFXZHY9St8WXnsreLrYZZmovR97kiO0rzqcEoytANI8/KfOLcYMq 2IAJpC5/x4CXQODg== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 09/44] x86/perf/zhaoxin: Reorder headers alphabetically Date: Fri, 13 Jun 2025 01:39:35 +0200 Message-ID: <20250612234010.572636-10-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The source file uses cpuid_*() macros, but it does not include . Sort its include lines so that the CPUID header can be included next. Signed-off-by: Ahmed S. Darwish --- arch/x86/events/zhaoxin/core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/x86/events/zhaoxin/core.c b/arch/x86/events/zhaoxin/core.c index 4bdfcf091200..d59992364880 100644 --- a/arch/x86/events/zhaoxin/core.c +++ b/arch/x86/events/zhaoxin/core.c @@ -5,16 +5,16 @@ =20 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt =20 -#include -#include -#include -#include #include +#include #include +#include +#include +#include =20 +#include #include #include -#include #include =20 #include "../perf_event.h" @@ -616,4 +616,3 @@ __init int zhaoxin_pmu_init(void) =20 return 0; } - --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 F11232E62AC for ; Thu, 12 Jun 2025 23:40:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771656; cv=none; b=KJ78wOwk4v0UtAax+WI5XO6fsUrVxmop5KeajsRhG3DKX+UYGGGmk1cmZngWRCTgVSLlBZtjW04BHrgKVMD0KATzBlZ0xYNLqM6u2uWtZVbqBGdlHb8Q7x824o11IO8dirryjVtIjLm6bo2FcMgRz7HAf1u15X/xQbEfqIStPlU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771656; c=relaxed/simple; bh=zVtu24Jq3Y5Vh/O39OdbkmPJ+eq8b964V5huRoplZPI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DExQm2NcHWaJZ5YmaydC0UF6MKT0zeqc3LqgO9q/FZJ5wKsrqnQ7DnjAqzjJMGX8s0JApVizMxHw4TGftOd+JNkek+tW+s8CXUkjGbqqy4bmKnEYE2FzSjLEjZ1YdDjLrmhPS5hx15MRHInmZRAFhDTbFgJROz8seLt/SfZ8NK4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=frxW2cfh; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=f0w2wKms; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="frxW2cfh"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="f0w2wKms" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771653; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/OAQdEEwtyXyr3kBijxT+OF/3UlkaKXjT5VRLgiNcqc=; b=frxW2cfh0z8H2Eod/4qUbHhBYaj2zxgyrIRSoyUspF3lPBFgn/aPCCignodAczFM5r4Ybk l4ZDPf9hCoGTIiCwb6EtdhQUMTG/XI/BYQ+RtaPHPAos5MYeWQaUAqTJXhUqTRLf0r4QhX QPqkLc/rCcUmxallLy6WX6USFQRnnog+Cl/fPtGVz65qKXjT3daeAEOkrtktVZSFqxE76g HBYTTe+x+1P4TdWJo8mZ83aAl/N+q3a3pVhgo/xPcBWNTsossDEwr1q8NW5B7OtwyIxRPK f6n71oXPOvdahazAJWyILAxwNglUOsm+n8KvZxkhKI/goud86wiPVGHb0th0tQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771653; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/OAQdEEwtyXyr3kBijxT+OF/3UlkaKXjT5VRLgiNcqc=; b=f0w2wKmsbV0baw0bbz/umfkjNJKnXLgkN6N68UwTKZpx+K7PJoBSgkH5Fr74QMEHuVytlK 6WyhS7T0nhXfL4Cw== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 10/44] x86/resctrl: Reorder core.c headers alphabetically Date: Fri, 13 Jun 2025 01:39:36 +0200 Message-ID: <20250612234010.572636-11-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The source file uses cpuid_*() macros, but it does not include . Sort its include lines so that the CPUID header can be included next. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/resctrl/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 7109cbfcad4f..289e79154922 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -17,13 +17,14 @@ #define pr_fmt(fmt) "resctrl: " fmt =20 #include -#include -#include #include +#include +#include =20 #include #include #include + #include "internal.h" =20 /* --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 55A772E62BC for ; Thu, 12 Jun 2025 23:40:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771659; cv=none; b=iQ/0gyUDPdytseexf9KwA4NoMIg18CXiFwOOmryHJke5uxzcH2biwwjnN1eJPLR1lGawQJmanCZSCBws5WrgaX5Tw6zaFyIsyF/+Pe3FrxrcxZ9EDF/PHLUYVIrVmMSUWCkXpW7g0QF9ze/HclOO4uw3yYESzLbFPP29dN4jRO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771659; c=relaxed/simple; bh=vS1cZf0d5qL6LPmnaM4drwsJ96/PyaaMLZ+fWFlqy9M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GdqImoLcA5zkwy7JhguPLQvwqD3tY8ATgC2qZF7NHSjCV51Ep4w+xDyMy5FwO6xfkj/T+wV8Ck33RyZCrnodVBoCwNnETLOFcz5g75qUHUKM/+hnuKNzWI+Yf4ceM58m3jwTj9KrsCBbom5f4/M+OV7AFuuUV1Q1rjtv5FtT6WY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=nOj9XrKX; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=giGPVX2w; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="nOj9XrKX"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="giGPVX2w" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771656; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7DreOZwLNuQHvqNjFYinmIaoBSei6IfxDF5yWW2B7pQ=; b=nOj9XrKXBoDFUbsVf1ETrP4XByS9pWtV8p0EBMpY+dCNLhy21o+qb5j/o1En/bogg3lWTy MO5IurSItNqBdu4M+YM1XYCzfbOMIcniRfEcoTPhV4009Sr8000VyjLrwWDdn9M9Bt1cM9 yj4otaMjQ+Z6UT2aM6qhnnzxsfFTTC/DQnyOg+e3JT2tPjGEzhz0ckwvJYAK8UuowV+Th7 DY3naPGDUhYCnrNebavnNV2NyKAcuhqe74lxbkK9KkOQN8V/L5lPqW1zgCH658/oDB1RiQ Z9bYS0fW7t1lKL1Uw2in3jPcqgeFSN4OuU3ERU6d3kfX8LgYKn/sVXQm/qPLNg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771656; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7DreOZwLNuQHvqNjFYinmIaoBSei6IfxDF5yWW2B7pQ=; b=giGPVX2wzQyb30TSNdVfm4+WMtayMZZF+rC0Lx/0SrxALW9c4FolCqWVqTf51zm9avDXcw x7RQXKzhpHb3E+Dg== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 11/44] x86/tdx: Reorder headers alphabetically Date: Fri, 13 Jun 2025 01:39:37 +0200 Message-ID: <20250612234010.572636-12-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The source file uses cpuid_*() macros, but it does not include . Sort its include lines so that the CPUID header can be included next. Signed-off-by: Ahmed S. Darwish --- arch/x86/coco/tdx/tdx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index 7b2833705d47..7bc11836c46a 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -8,16 +8,17 @@ #include #include #include + #include -#include -#include #include #include #include #include #include #include +#include #include +#include =20 /* MMIO direction */ #define EPT_READ 0 --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 CEFF32E6D09 for ; Thu, 12 Jun 2025 23:41:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771663; cv=none; b=c/aYHZrHsmjzw975VnpgjvK167M2k9XskK/+G6CplyYVErGFZiB16zmuhj4hj2ihAwDpvqEWw8LHpB99csr/XJ5hX9MNqpdqwRi2JGi+hYTDBrYJBV933aNSs/OtmFByVsCbCMyB3zPNPBEZqJS7vSQriGE+JWKIflamPTR+4Cc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771663; c=relaxed/simple; bh=mEtFfG6W0CCFrbtZulPgxhMk8e6DTFZehqrh77zePkA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZDCYZjiv9HgQVG3vvKWd1/Lnv0FoYzAMPBB7xyp/1+M2XwupIl7GpgE/cI/YV/PdCZodjDy/srWBNSxD64/Gz2VljVLWEIKuCyG79eMoc6TWU+3PVVg4+zg+ysDTGsKrWuR6jyMX34osMQ9YwjeLLoBkkYPt4Q/4+HicuXJku9g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=dOa9TLmy; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0qaH+Y0i; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dOa9TLmy"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0qaH+Y0i" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y3q6jSAatcw411UuRrDymvK+3jfuqUlUGK3N5JSO3nQ=; b=dOa9TLmygERCOUcCcZxKwgVn7ri6xSMHiRbKtFVZxBQZgM2W8+Y85qrPjHcocdBlsy9EGN gyTIDYcfDuzbbw+g3RAxLqsWFNg2ohkjwY8kd455I5qe/03L2FYOFTTtYZdYKXo9hqlk2c B/V1SArRyNs0AYQY97Q7TUjDMGQWyYFbDopg2Dx5Wg0svIoFUe1xtn3MQhhQFiMbjaXoxw NMzSa3ovEMahqXJfJ9vFJvjzgJux6x4kVMh1NsKprlbMU5goNDZYaQbk77yEteaeH4NGD3 rG6aalhtOQ46CQNJf4SoHZaFqyc6BEXMuAqRYinDjAAA+4SyJRYJNrlRh1kZDA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y3q6jSAatcw411UuRrDymvK+3jfuqUlUGK3N5JSO3nQ=; b=0qaH+Y0i8S0zgO5wZq7zv0KJcL8IXAdSGNO+rfbAfmUrL490u3XKTFZ9YDqqYf84y/jzSR 1SWnwsmfpm/i72Dw== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 12/44] cpufreq: Reorder headers alphabetically Date: Fri, 13 Jun 2025 01:39:38 +0200 Message-ID: <20250612234010.572636-13-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The source file uses cpuid_*() macros, but it does not include . Sort its include lines so that the CPUID header can be included next. Signed-off-by: Ahmed S. Darwish --- drivers/cpufreq/speedstep-lib.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/speedstep-lib.c b/drivers/cpufreq/speedstep-li= b.c index 0b66df4ed513..f08817331aec 100644 --- a/drivers/cpufreq/speedstep-lib.c +++ b/drivers/cpufreq/speedstep-lib.c @@ -9,14 +9,15 @@ =20 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt =20 +#include +#include #include #include #include -#include -#include =20 #include #include + #include "speedstep-lib.h" =20 #define PFX "speedstep-lib: " --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 2F8C82E62DF for ; Thu, 12 Jun 2025 23:41:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771666; cv=none; b=fWG/gr5e+3DkaNUp8RUY184YEAlc9aBL3ngpUyYC8mnBuyftTQwO9p9oJv9Ry/nwiRz0+qJi5Hoyo7VPw7FJ9CWSKARDtW2J2ZR75t+mpp/n3mgKxhLNoMZN6PUseCmxYODWbsu+ABbYH6DBMBsO/T6osZNXbABaDj9wZ3amK4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771666; c=relaxed/simple; bh=kwENynR0HQAEs2KkZiP/4lhLFlHG8UgRYTZ9OQeMRfE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nXkzNSm1eS4/U5SyFylF9FotRCDU32gjQVPxbH4gVg+3dsuHvMqJMskrJDzC7zf38/6vbDU/rtDBGQHJZqLOC3Sp1M7lHWV2GrA3QOIlkaNJ/XhZgeckev2WPCiDAHiJZKW8Pk8egGT4NFqQ4Z8v68A9Qz27FiORPhgcxjQkeRA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ovm7FIam; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=8pwcJcte; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ovm7FIam"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="8pwcJcte" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771663; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9OcfKWQHu3imp0k6viJCu2d7AM03u2m+zZIjbUdF7D4=; b=ovm7FIammt7hBTYe3ncMvRIhJTedKMZGs1nUBGZCFe9banCUU0ea59T92NyjiUb0biAG3W QQoOITfkG+Zk6TWN/7lXhbSolYJwATlwpd/+sXvZkdpwTVDbj83ky+2t7HaZlwg2Zv39rJ Z0rfL8Xa4zrHBCaKWHK8KzM8f4FK0e9wxbpyd3MLcx20LpTFGI/S3KF915DRZsoWcVhsS3 2ZN2N59UJq4fhmMNvgjRZFH539E4Xjbuj1a/uzObJiQLoCwDJWECf5P7c36Xqv1r5Qy7UD nVyepbh04tptk11ueo5g4hlMFapBhYsVM7wiEOI6/btIa37TKzuyOicQIDVumg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771663; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9OcfKWQHu3imp0k6viJCu2d7AM03u2m+zZIjbUdF7D4=; b=8pwcJcte1gp0DX4YVDYa0Pz3TjkJRfyDFIJfoWFpwfJIPjWNKViz/n17CJVt2G9kW9Q88Q 8fGXIa67d9kxqtAA== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 13/44] hwmon: (fam15h_power) Reorder headers alphabetically Date: Fri, 13 Jun 2025 01:39:39 +0200 Message-ID: <20250612234010.572636-14-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The source file uses cpuid_*() macros, but it does not include . Sort its include lines so that the CPUID header can be included next. Signed-off-by: Ahmed S. Darwish --- drivers/hwmon/fam15h_power.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c index 8ecebea53651..5a5674e85f63 100644 --- a/drivers/hwmon/fam15h_power.c +++ b/drivers/hwmon/fam15h_power.c @@ -6,20 +6,21 @@ * Author: Andreas Herrmann */ =20 +#include +#include +#include #include -#include #include +#include #include #include #include -#include -#include -#include -#include #include +#include #include -#include + #include +#include =20 MODULE_DESCRIPTION("AMD Family 15h CPU processor power monitor"); MODULE_AUTHOR("Andreas Herrmann "); --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 97E272E6D30 for ; Thu, 12 Jun 2025 23:41:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771670; cv=none; b=PDDc0we+CYxWIVp7jkARdF9Iut3qUO6KoosipDQoTCLtqSavPlZ4ty79SsHlt0+ycieuqWTmIITvofLQk6Aw4daiiViipRB0OFPx1bE8Qqk1FnPKmPKEKKbSoaU8RFJ78XuFhSR4Q01Ma2aAQZU8BDxUx8GGt+IJkTJQz5DJjHA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771670; c=relaxed/simple; bh=xTkNCtGv54QRP3zi04C/kKZV7/0Hr+t7JxjpmYJj1Pg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BLTSCF29kYY8Ueh1F3HVl9PsNw/s6WCNmBUFoe0U/G/LfQ9SSeLYa7SGQtPp3NKApPAdmqwtXLSpzEM1ZWfdYEG3KLEU7vkff2WrOpMvR1W8twpMRWzWDr196t8aAHsyW9rgGxzK9eNvNJFc6VvGxK67HH0mEIsGlvVXM4aQn3I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=hk4n5EST; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=LxwdS01S; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="hk4n5EST"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="LxwdS01S" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771667; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YMU6S8lg3lln4OqzSKY3PivZxKHqUKp79PCE1ks2MM8=; b=hk4n5ESTjgP6FCRO4xLYjSj7WtGsKw12mmBPdd917F2noMbpQ3mrTa5My1AyfGkiEEvMxd o6Wri+zCD2dI21/vrf1BHl6/KHQHIfjsmW+EI57OMo6ck12/36tsWzVxJatNmnRvc0Ddpr k0fed27IVZ1PY1NHbITgzRIkAIToZ8eRFBz/vxS4eyzVVDShfZ9zlq45dto5VjJOfTjToS bROxjxpZzfFvb59l8OO4x9zO3Ax+AqWcROm0niYoo2Z+1UorOcpN2Tpyb1e5Lx6nhLdOrb 4Z4TK5QCZ7s4jomD2Vg3mRvoG/QYpCHoeBqr9bV5vu+XTNRylu9I8wmZ8oD5Bg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771667; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YMU6S8lg3lln4OqzSKY3PivZxKHqUKp79PCE1ks2MM8=; b=LxwdS01SN6phZW1a4d4dwyb4qWB7maLyACMldx7eCau5rllk7o1Nxyam+iZlrHTca3pL80 086D9iWYBmfWebAg== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 14/44] hwmon: (k8temp) Reorder headers alphabetically Date: Fri, 13 Jun 2025 01:39:40 +0200 Message-ID: <20250612234010.572636-15-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The source file uses cpuid_*() macros, but it does not include . Sort its include lines so that the CPUID header can be included next. Signed-off-by: Ahmed S. Darwish --- drivers/hwmon/k8temp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c index 2b80ac410cd1..8c1efce9a04b 100644 --- a/drivers/hwmon/k8temp.c +++ b/drivers/hwmon/k8temp.c @@ -7,13 +7,14 @@ * Inspired from the w83785 and amd756 drivers. */ =20 -#include -#include -#include -#include -#include #include +#include +#include +#include #include +#include +#include + #include =20 #define TEMP_FROM_REG(val) (((((val) >> 16) & 0xff) - 49) * 1000) --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 C5CFB2E7623 for ; Thu, 12 Jun 2025 23:41:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771674; cv=none; b=RZBiC3B6tCaiWcRVZg6TxnMtNvEMYTlgzdYdicLEgGaEW+fH3grW+Hf7Stu5lNyKlmvxW/H6qDhifAHzqQOGqlhajWiUaxrcH+Awt81y5p5ealeKbdaxigj/crqci3KPi/j+1T5POdyGF1iUCEIzT+y7d4bPxpMt4MJWce9Fd1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771674; c=relaxed/simple; bh=GS/O6l7q82cHAdK1ICSA7cmyeoYsObESi8FWvEj/9FQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y3kaXnxrLT/cysSf09ntcAyP0lq/H6ad0A9+r4jFqHjU26jusJzIC9dkoyGcygcv8VACY0G9sSZMLrJNzVV9yzOX2J0HJ9Ylj+vr/M9ILD1FZYUikNri9Ik3uaT3IQ/dVrfeXb3HvaR8oiPT1pMMitb6wItxJCz+zLxc6G4ewns= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=OUAQIXMz; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=9cDoyULx; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="OUAQIXMz"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="9cDoyULx" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771670; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zt4WCz732vUfMxV2b2intBgT1aJnCmDcR2DgO+Zn+Po=; b=OUAQIXMzDk/JZedOI3k7F3xsWkH1ZTNJErRu4MiW7I9q2wGo/XEWTTsBAw0C+nM8URqdbU xb7ULi+VmHrvoDmNxDKAU0OZLZh7G5eeLHYkE53sULuVKtzpRuoytK9loudX8jlyIFKeRv SRTe/Vuuio13AJh194fEzGyOGbkif73m76DgN35REj7gTg/JDc5Mod7QiNP1rEBANjyX0m lx1zEVoQgQNgkBGm0whB6vuD14uN0cl3Jt/L07r+l/GMzLeBDo3jD6gRU9qG+Xe9kTa/mA zzNNIQgxK067Gd1phjK0dV57FfNBv0y6oJwHJKy3lehirlibQQn7Z9Pi89D4Qw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771670; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zt4WCz732vUfMxV2b2intBgT1aJnCmDcR2DgO+Zn+Po=; b=9cDoyULxyLVtvCNh6X3andpxOwb9jo4Em4l76GHUTJmRqbXfh0AaA5FILJe8JtxmeQLCM4 7KeFBy3E8McR91Aw== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 15/44] perf/x86/amd/uncore: Reorder headers alphabetically Date: Fri, 13 Jun 2025 01:39:41 +0200 Message-ID: <20250612234010.572636-16-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The source file uses cpuid_*() macros, but it does not include . Sort its include lines so that the CPUID header can be included next. Signed-off-by: Ahmed S. Darwish --- arch/x86/events/amd/uncore.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c index e8b6af199c73..c1483ef16c0b 100644 --- a/arch/x86/events/amd/uncore.c +++ b/arch/x86/events/amd/uncore.c @@ -5,18 +5,18 @@ * Author: Jacob Shin */ =20 -#include -#include -#include -#include -#include #include -#include #include +#include +#include +#include +#include +#include #include +#include =20 -#include #include +#include =20 #define NUM_COUNTERS_NB 4 #define NUM_COUNTERS_L2 4 --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 274A72E2F0A for ; Thu, 12 Jun 2025 23:41:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771676; cv=none; b=I38UNoTQv5DS5BPr/IfRugPq3re/9vDFg12yvDSq2Qe6bPeJn9tDyqi63GAjYxlC9iUhHVG2YPTA/Btmwsw8xjNU3P5z0AtWZbyioO+hFjZkREteWXs+QjITNcMXyaDa/FUErM4PedHXQuh9dgzMzw13iLC0rCYRx1+Tuz2XZGA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771676; c=relaxed/simple; bh=BOTIv1JT/df8iXEMB7pM5ixVBrjXOOY71KdA3T0iqTs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M8ZOuAJETPNx2+NMFlZtYK4Ft6TX8Y8G7dOL//sarOCwsogf8LVPxQmX4l1NDY4/+qsh/5UKkoOeXgGvForUY0h96lNoTHiN+TjyCWjZf5ri05kyHexdp+pgILDnPcXxDhbfEzMtNqeP7GOy1bwF5lkxkBkq+lNdG2nJKp+fw64= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=fBrQeAMK; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=OpaHr9r8; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fBrQeAMK"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="OpaHr9r8" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O37EfZZ9hCClxam6hs8B0tHuhYTXExkKqZiHQCfEhOI=; b=fBrQeAMKyCbWBSak89/If0CuNnSrX8hjA835+TyWQPw6qQGoDjYaKUazHULtve6h2ic1km SSgZiPlliPeQAXeKglTyeIGKMfQnwT6YSm6p9qosqM36uZLfk72o/Cj9ctCmym/+C7JdzO k1oGnKVQH4xqhKAdFyITypRBccNwWfV84Q5+65xN9Spvqe7tecfGdNDOFnh4BRfLCCWI4y py/0seLYFI5syNNjk6/7NSZCeK+TzQz5TgjR3wycj5aGXhmQPtVQbtBqjXQvlx61ux9WD/ YbYqddS+faZ6woVZNUnXTu5xxw3FlUMcJxM1hHoHXeW2mqwTk83nFuatZHYR5w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O37EfZZ9hCClxam6hs8B0tHuhYTXExkKqZiHQCfEhOI=; b=OpaHr9r8Iqh1+Vwn8sDWXNFHRyj8VawrskPRjkSbKwVecpb4FarhNSojuUh260U3TvMo5+ 52vaAkQb9H+6xbDw== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 16/44] thermal: intel: Reorder headers alphabetically Date: Fri, 13 Jun 2025 01:39:42 +0200 Message-ID: <20250612234010.572636-17-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The source file uses cpuid_*() macros, but it does not include . Sort its include lines so that the CPUID header can be included next. Signed-off-by: Ahmed S. Darwish --- drivers/thermal/intel/x86_pkg_temp_thermal.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c b/drivers/thermal= /intel/x86_pkg_temp_thermal.c index 3fc679b6f11b..c843cb5fc5c3 100644 --- a/drivers/thermal/intel/x86_pkg_temp_thermal.c +++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c @@ -5,19 +5,19 @@ */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt =20 -#include +#include +#include +#include +#include #include #include -#include +#include #include -#include #include -#include -#include -#include #include +#include +#include #include -#include =20 #include #include --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 61B222E7632 for ; Thu, 12 Jun 2025 23:41:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771680; cv=none; b=gHR49BZBVfjC86VjKN66QZ5KLRWQ3D+0P3ojoLO5c1D8XACmaxjzvIC45CkD5CJMqBrmuhmRty3TAituRpD9dDwOWXPZQU4VHZ+osrmKxhuXghMGUQWzl351tKj2F5x9jDTPr0850ac8s4/ut9vXL1zEiyK23D/BXHMiUdaKbn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771680; c=relaxed/simple; bh=0Y+YU2tG91aTV6rlj83yTw8wALOgBmQrp7y1v8/NaWc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AxZAHE5Lo94CpE5SeUe2Bq4+ujliI/S6sRYx6+dhSigSSYYVmkFJFNZ6hdGkRTImpyPkAe9llTmx/ICLjEU1ktMsamyBdglY82dqSnJyD4ddx2QS10GhAZqT8TAMdp2cc4POsJcfoc/MGQX4Di3ON0KMf4d09U42oSUvOj0fH9Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=SF66KC/J; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=pTzm+fnu; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="SF66KC/J"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pTzm+fnu" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=40K9B0t26LX1DySV5VsJmoyEVEFLIho/CTmnJzaTfWM=; b=SF66KC/J3vMyQ/0/y97n/EYvWWfTQy7KtHk7qLOYJYpVT6aZuhxVcIr6Ej7W0QvqojSpYk Gg79uojb2FGx4Asf6psjybjbZFa9ijYG/BwXA4oYPGlj3uHBMSH8syyLVvsp0qDpteFmam X718FEv4NBeF5nps84rB2ucXtDCGuq6WqN/bILEYGguW1w4+uA6HGyNcQYUIT2M0u5HMgo 4oIJyo6BVaZWTc3iJUZx++Yd8/icWb1w/wRPXIRbxWYQQTjQYAShJrSGqABhivrFfw9Zzd z/1ybk4gbnGC5vwptzz9NcfmWbt7N1TxRBG21skB/AY6RKKJEySlrDII7vPzYw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=40K9B0t26LX1DySV5VsJmoyEVEFLIho/CTmnJzaTfWM=; b=pTzm+fnucc5OUIrpcOVXdd0eGc26x8b7iRpW5u98lBSwCp4EMf0QJu7je2+aYh7sOdNVG7 JotHM3fBs4dOGcDg== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 17/44] treewide: Explicitly include Date: Fri, 13 Jun 2025 01:39:43 +0200 Message-ID: <20250612234010.572636-18-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Let all CPUID call sites which include the main CPUID API header implicitly though include it explicitly instead. This disentangles the CPUID API header from , thus avoiding a circular header dependency. Signed-off-by: Ahmed S. Darwish --- arch/x86/boot/compressed/pgtable_64.c | 1 + arch/x86/boot/startup/sme.c | 1 + arch/x86/coco/tdx/tdx.c | 1 + arch/x86/events/amd/core.c | 2 ++ arch/x86/events/amd/ibs.c | 1 + arch/x86/events/amd/lbr.c | 2 ++ arch/x86/events/amd/power.c | 3 +++ arch/x86/events/amd/uncore.c | 1 + arch/x86/events/intel/core.c | 1 + arch/x86/events/intel/lbr.c | 1 + arch/x86/events/zhaoxin/core.c | 1 + arch/x86/include/asm/acrn.h | 2 ++ arch/x86/include/asm/microcode.h | 1 + arch/x86/include/asm/xen/hypervisor.h | 1 + arch/x86/kernel/cpu/amd.c | 1 + arch/x86/kernel/cpu/centaur.c | 1 + arch/x86/kernel/cpu/hygon.c | 1 + arch/x86/kernel/cpu/mce/core.c | 1 + arch/x86/kernel/cpu/mce/inject.c | 1 + arch/x86/kernel/cpu/resctrl/core.c | 1 + arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/scattered.c | 1 + arch/x86/kernel/cpu/sgx/main.c | 3 +++ arch/x86/kernel/cpu/topology_amd.c | 1 + arch/x86/kernel/cpu/topology_common.c | 1 + arch/x86/kernel/cpu/topology_ext.c | 1 + arch/x86/kernel/cpu/transmeta.c | 3 +++ arch/x86/kernel/cpu/zhaoxin.c | 1 + arch/x86/kernel/cpuid.c | 1 + arch/x86/kernel/paravirt.c | 1 + arch/x86/kvm/cpuid.h | 3 +++ arch/x86/kvm/mmu/spte.c | 1 + drivers/cpufreq/speedstep-lib.c | 1 + drivers/firmware/efi/libstub/x86-5lvl.c | 1 + drivers/hwmon/fam15h_power.c | 1 + drivers/hwmon/k10temp.c | 2 ++ drivers/hwmon/k8temp.c | 1 + drivers/thermal/intel/intel_hfi.c | 1 + drivers/thermal/intel/x86_pkg_temp_thermal.c | 1 + 39 files changed, 51 insertions(+) diff --git a/arch/x86/boot/compressed/pgtable_64.c b/arch/x86/boot/compress= ed/pgtable_64.c index bdd26050dff7..d94d98595780 100644 --- a/arch/x86/boot/compressed/pgtable_64.c +++ b/arch/x86/boot/compressed/pgtable_64.c @@ -2,6 +2,7 @@ #include "misc.h" #include #include +#include #include #include #include "../string.h" diff --git a/arch/x86/boot/startup/sme.c b/arch/x86/boot/startup/sme.c index 922b236be02f..6a58ab568390 100644 --- a/arch/x86/boot/startup/sme.c +++ b/arch/x86/boot/startup/sme.c @@ -40,6 +40,7 @@ #include =20 #include +#include #include #include #include diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index 7bc11836c46a..4ed8ec642646 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -10,6 +10,7 @@ #include =20 #include +#include #include #include #include diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c index b20661b8621d..d28d45ceb707 100644 --- a/arch/x86/events/amd/core.c +++ b/arch/x86/events/amd/core.c @@ -7,8 +7,10 @@ #include #include #include + #include #include +#include #include #include =20 diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c index 112f43b23ebf..0c7848e6149e 100644 --- a/arch/x86/events/amd/ibs.c +++ b/arch/x86/events/amd/ibs.c @@ -15,6 +15,7 @@ #include =20 #include +#include #include =20 #include "../perf_event.h" diff --git a/arch/x86/events/amd/lbr.c b/arch/x86/events/amd/lbr.c index d24da377df77..5b437dc8e4ce 100644 --- a/arch/x86/events/amd/lbr.c +++ b/arch/x86/events/amd/lbr.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include + +#include #include #include =20 diff --git a/arch/x86/events/amd/power.c b/arch/x86/events/amd/power.c index dad42790cf7d..744dffa42dee 100644 --- a/arch/x86/events/amd/power.c +++ b/arch/x86/events/amd/power.c @@ -10,8 +10,11 @@ #include #include #include + #include +#include #include + #include "../perf_event.h" =20 /* Event code: LSB 8 bits, passed in attr->config any other bit is reserve= d. */ diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c index c1483ef16c0b..5261f12007df 100644 --- a/arch/x86/events/amd/uncore.c +++ b/arch/x86/events/amd/uncore.c @@ -15,6 +15,7 @@ #include #include =20 +#include #include #include =20 diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 741b229f0718..a372f0e2867a 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -17,6 +17,7 @@ #include =20 #include +#include #include #include #include diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c index 7aa59966e7c3..0d1ec3651735 100644 --- a/arch/x86/events/intel/lbr.c +++ b/arch/x86/events/intel/lbr.c @@ -3,6 +3,7 @@ #include =20 #include +#include #include #include =20 diff --git a/arch/x86/events/zhaoxin/core.c b/arch/x86/events/zhaoxin/core.c index d59992364880..15bb9c9c9358 100644 --- a/arch/x86/events/zhaoxin/core.c +++ b/arch/x86/events/zhaoxin/core.c @@ -14,6 +14,7 @@ =20 #include #include +#include #include #include =20 diff --git a/arch/x86/include/asm/acrn.h b/arch/x86/include/asm/acrn.h index fab11192c60a..db42b477c41d 100644 --- a/arch/x86/include/asm/acrn.h +++ b/arch/x86/include/asm/acrn.h @@ -2,6 +2,8 @@ #ifndef _ASM_X86_ACRN_H #define _ASM_X86_ACRN_H =20 +#include + /* * This CPUID returns feature bitmaps in EAX. * Guest VM uses this to detect the appropriate feature bit. diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microc= ode.h index 8b41f26f003b..645e65ac1586 100644 --- a/arch/x86/include/asm/microcode.h +++ b/arch/x86/include/asm/microcode.h @@ -3,6 +3,7 @@ #define _ASM_X86_MICROCODE_H =20 #include +#include =20 struct cpu_signature { unsigned int sig; diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/x= en/hypervisor.h index c2fc7869b996..7c596cebfb78 100644 --- a/arch/x86/include/asm/xen/hypervisor.h +++ b/arch/x86/include/asm/xen/hypervisor.h @@ -37,6 +37,7 @@ extern struct shared_info *HYPERVISOR_shared_info; extern struct start_info *xen_start_info; =20 #include +#include #include =20 #define XEN_SIGNATURE "XenVMMXenVMM" diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index c988d876b700..f982b3bb1c10 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c index a3b55db35c96..cc5a390dcd07 100644 --- a/arch/x86/kernel/cpu/centaur.c +++ b/arch/x86/kernel/cpu/centaur.c @@ -5,6 +5,7 @@ =20 #include #include +#include #include #include #include diff --git a/arch/x86/kernel/cpu/hygon.c b/arch/x86/kernel/cpu/hygon.c index 2154f12766fb..75ad7eb1301a 100644 --- a/arch/x86/kernel/cpu/hygon.c +++ b/arch/x86/kernel/cpu/hygon.c @@ -10,6 +10,7 @@ =20 #include #include +#include #include #include #include diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index fe9e65f314fb..9f7c39b4163f 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -47,6 +47,7 @@ #include =20 #include +#include #include #include #include diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inj= ect.c index d02c4f556cd0..42c82c14c48a 100644 --- a/arch/x86/kernel/cpu/mce/inject.c +++ b/arch/x86/kernel/cpu/mce/inject.c @@ -26,6 +26,7 @@ =20 #include #include +#include #include #include #include diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 289e79154922..9498d55d51e6 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -22,6 +22,7 @@ #include =20 #include +#include #include #include =20 diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index c261558276cd..5dffb9453d77 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -21,6 +21,7 @@ #include =20 #include +#include #include =20 #include "internal.h" diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattere= d.c index 3d23b943f596..15f8752d4132 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -5,6 +5,7 @@ #include =20 #include +#include #include #include =20 diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c index 2de01b379aa3..00bf42f4c536 100644 --- a/arch/x86/kernel/cpu/sgx/main.c +++ b/arch/x86/kernel/cpu/sgx/main.c @@ -14,8 +14,11 @@ #include #include #include + +#include #include #include + #include "driver.h" #include "encl.h" #include "encls.h" diff --git a/arch/x86/kernel/cpu/topology_amd.c b/arch/x86/kernel/cpu/topol= ogy_amd.c index 843b1655ab45..abc6f5a7a486 100644 --- a/arch/x86/kernel/cpu/topology_amd.c +++ b/arch/x86/kernel/cpu/topology_amd.c @@ -2,6 +2,7 @@ #include =20 #include +#include #include #include #include diff --git a/arch/x86/kernel/cpu/topology_common.c b/arch/x86/kernel/cpu/to= pology_common.c index 48c47d02d8a9..38189e4fea0e 100644 --- a/arch/x86/kernel/cpu/topology_common.c +++ b/arch/x86/kernel/cpu/topology_common.c @@ -4,6 +4,7 @@ #include =20 #include +#include #include #include #include diff --git a/arch/x86/kernel/cpu/topology_ext.c b/arch/x86/kernel/cpu/topol= ogy_ext.c index 467b0326bf1a..eb915c73895f 100644 --- a/arch/x86/kernel/cpu/topology_ext.c +++ b/arch/x86/kernel/cpu/topology_ext.c @@ -2,6 +2,7 @@ #include =20 #include +#include #include #include =20 diff --git a/arch/x86/kernel/cpu/transmeta.c b/arch/x86/kernel/cpu/transmet= a.c index 42c939827621..1fdcd69c625c 100644 --- a/arch/x86/kernel/cpu/transmeta.c +++ b/arch/x86/kernel/cpu/transmeta.c @@ -3,8 +3,11 @@ #include #include #include + #include +#include #include + #include "cpu.h" =20 static void early_init_transmeta(struct cpuinfo_x86 *c) diff --git a/arch/x86/kernel/cpu/zhaoxin.c b/arch/x86/kernel/cpu/zhaoxin.c index 89b1c8a70fe8..cfcfb6221e3f 100644 --- a/arch/x86/kernel/cpu/zhaoxin.c +++ b/arch/x86/kernel/cpu/zhaoxin.c @@ -4,6 +4,7 @@ =20 #include #include +#include #include =20 #include "cpu.h" diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c index dae436253de4..cbd04b677fd1 100644 --- a/arch/x86/kernel/cpuid.c +++ b/arch/x86/kernel/cpuid.c @@ -37,6 +37,7 @@ #include #include =20 +#include #include #include =20 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index 3d745cd25a43..b7fc3b78086c 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -18,6 +18,7 @@ =20 #include #include +#include #include #include #include diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h index d3f5ae15a7ca..89f8ed3fb37a 100644 --- a/arch/x86/kvm/cpuid.h +++ b/arch/x86/kvm/cpuid.h @@ -3,8 +3,11 @@ #define ARCH_X86_KVM_CPUID_H =20 #include "reverse_cpuid.h" + #include +#include #include + #include =20 extern u32 kvm_cpu_caps[NR_KVM_CPU_CAPS] __read_mostly; diff --git a/arch/x86/kvm/mmu/spte.c b/arch/x86/kvm/mmu/spte.c index cfce03d8f123..e7b69275ae50 100644 --- a/arch/x86/kvm/mmu/spte.c +++ b/arch/x86/kvm/mmu/spte.c @@ -15,6 +15,7 @@ #include "x86.h" #include "spte.h" =20 +#include #include #include #include diff --git a/drivers/cpufreq/speedstep-lib.c b/drivers/cpufreq/speedstep-li= b.c index f08817331aec..3c323cd8eede 100644 --- a/drivers/cpufreq/speedstep-lib.c +++ b/drivers/cpufreq/speedstep-lib.c @@ -15,6 +15,7 @@ #include #include =20 +#include #include #include =20 diff --git a/drivers/firmware/efi/libstub/x86-5lvl.c b/drivers/firmware/efi= /libstub/x86-5lvl.c index f1c5fb45d5f7..029ad80cf0b4 100644 --- a/drivers/firmware/efi/libstub/x86-5lvl.c +++ b/drivers/firmware/efi/libstub/x86-5lvl.c @@ -2,6 +2,7 @@ #include =20 #include +#include #include #include =20 diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c index 5a5674e85f63..1ecaef25f04e 100644 --- a/drivers/hwmon/fam15h_power.c +++ b/drivers/hwmon/fam15h_power.c @@ -19,6 +19,7 @@ #include #include =20 +#include #include #include =20 diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index babf2413d666..12115654689a 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -20,7 +20,9 @@ #include #include #include + #include +#include #include =20 MODULE_DESCRIPTION("AMD Family 10h+ CPU core temperature monitor"); diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c index 8c1efce9a04b..eb167be245b9 100644 --- a/drivers/hwmon/k8temp.c +++ b/drivers/hwmon/k8temp.c @@ -15,6 +15,7 @@ #include #include =20 +#include #include =20 #define TEMP_FROM_REG(val) (((((val) >> 16) & 0xff) - 49) * 1000) diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/inte= l_hfi.c index bd2fca7dc017..c910cc563d9d 100644 --- a/drivers/thermal/intel/intel_hfi.c +++ b/drivers/thermal/intel/intel_hfi.c @@ -41,6 +41,7 @@ #include #include =20 +#include #include =20 #include "intel_hfi.h" diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c b/drivers/thermal= /intel/x86_pkg_temp_thermal.c index c843cb5fc5c3..1b9e0b49856c 100644 --- a/drivers/thermal/intel/x86_pkg_temp_thermal.c +++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c @@ -20,6 +20,7 @@ #include =20 #include +#include #include =20 #include "thermal_interrupt.h" --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 AB0022E1737 for ; Thu, 12 Jun 2025 23:41:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771683; cv=none; b=G1XnfpPeVjHKpGLP05XSRcTkFBogjhgpygbSiHHD9rF5YpPiSKu407kspYjZ7afVuN8d++FyoStZvFMPVaKKBQ1jVzmuF6VW7MxjSqZqmCq1M3J9+7H8yaip1c101N4iRCGE/HmHS0bQKixwfNhm7fxZYioO3weREY564sXyu2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771683; c=relaxed/simple; bh=boRgXFhKddB07Ao/wmCchsRdbdJXJsaKKBS8cjumbkE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lb7E7cSxs3DWsmVtbTJL9GRjyb5xuuQcUNPs8+7Sbr91ZLOpv2XIiKB3jMDAfYFuAa++HXW2zqjT0RNqWkUVnOvDgPAMyufxbKyfnBH3xYIUOD1BGZLJqoIAs/T1eGo2dbhBp1CxjjcMTWFZLGdijcTYzNShmh/hwA95NkZqu3c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=NDOfKyLQ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=LIfeVP9m; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NDOfKyLQ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="LIfeVP9m" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771680; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5OwVg3uk2MbXbIzloOALjinnMmaKuXJuiDJZknzR0Gg=; b=NDOfKyLQ4T+8OfpdYRgkyv0iUYLoCFPgS4Gqq2KQYwKGYSpqB4x66bbM5LLy04jdK9ZumV VdLln5RMoC6yoAeYV22Zq2Wb6EZzE4ixRKpv/Wk7IMsPqQ3UDPlbu7hZ/I/+1mRd6AQD1F fCeaRK0kOP/fURghf4c/GC8CBco+OtBGMj6B+ct+s3tJkhYl2KZTDEx99LJBovbSg6dN0u ec8n0h+erNMSiONayk/+PQ+T3nmt47q18CImRhh2dmRRzADQ1llFKQb2uNXGRsP+wJSdLt uT35Fr0yxR+bE6Ehf/nz2FhsCWbwIQgGRFyA+myM/A9Yh6CQQshpcCOH4TSotg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771680; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5OwVg3uk2MbXbIzloOALjinnMmaKuXJuiDJZknzR0Gg=; b=LIfeVP9mqx4ld7B5cKtn2FCSom+z0Vu1rR8wMS2qHgmRXisDfSF9liUHMpkSja8kaWvrZP BqAUNLnPrZZoU9DA== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 18/44] x86/cpuid: Rename cpuid_leaf()/cpuid_subleaf() APIs Date: Fri, 13 Jun 2025 01:39:44 +0200 Message-ID: <20250612234010.572636-19-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A new CPUID model will be added where its APIs will be designated as the "official" CPUID API. Free the cpuid_leaf() and cpuid_subleaf() function names for that model. Rename them accordingly to cpuid_read() and cpuid_read_subleaf(). Note, for kernel/cpuid.c, rename its local file operations read function from cpuid_read() to cpuid_read_f() so that it does not conflict with the new names. No functional change. Signed-off-by: Ahmed S. Darwish --- arch/x86/include/asm/cpuid/api.h | 6 +++--- arch/x86/kernel/cpu/topology_amd.c | 2 +- arch/x86/kernel/cpu/topology_ext.c | 2 +- arch/x86/kernel/cpuid.c | 5 ++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/cpuid/api.h b/arch/x86/include/asm/cpuid/= api.h index 44fa82e1267c..2b9750cc8a75 100644 --- a/arch/x86/include/asm/cpuid/api.h +++ b/arch/x86/include/asm/cpuid/api.h @@ -131,12 +131,12 @@ static inline void __cpuid_read(u32 leaf, u32 subleaf= , u32 *regs) __cpuid(regs + CPUID_EAX, regs + CPUID_EBX, regs + CPUID_ECX, regs + CPUI= D_EDX); } =20 -#define cpuid_subleaf(leaf, subleaf, regs) { \ +#define cpuid_read_subleaf(leaf, subleaf, regs) { \ static_assert(sizeof(*(regs)) =3D=3D 16); \ __cpuid_read(leaf, subleaf, (u32 *)(regs)); \ } =20 -#define cpuid_leaf(leaf, regs) { \ +#define cpuid_read(leaf, regs) { \ static_assert(sizeof(*(regs)) =3D=3D 16); \ __cpuid_read(leaf, 0, (u32 *)(regs)); \ } @@ -228,7 +228,7 @@ static inline u32 cpuid_base_hypervisor(const char *sig= , u32 leaves) */ static inline void cpuid_leaf_0x2(union leaf_0x2_regs *regs) { - cpuid_leaf(0x2, regs); + cpuid_read(0x2, regs); =20 /* * All Intel CPUs must report an iteration count of 1. In case diff --git a/arch/x86/kernel/cpu/topology_amd.c b/arch/x86/kernel/cpu/topol= ogy_amd.c index abc6f5a7a486..c6bedae12a7e 100644 --- a/arch/x86/kernel/cpu/topology_amd.c +++ b/arch/x86/kernel/cpu/topology_amd.c @@ -80,7 +80,7 @@ static bool parse_8000_001e(struct topo_scan *tscan, bool= has_topoext) if (!boot_cpu_has(X86_FEATURE_TOPOEXT)) return false; =20 - cpuid_leaf(0x8000001e, &leaf); + cpuid_read(0x8000001e, &leaf); =20 tscan->c->topo.initial_apicid =3D leaf.ext_apic_id; =20 diff --git a/arch/x86/kernel/cpu/topology_ext.c b/arch/x86/kernel/cpu/topol= ogy_ext.c index eb915c73895f..60dfaa02ffd0 100644 --- a/arch/x86/kernel/cpu/topology_ext.c +++ b/arch/x86/kernel/cpu/topology_ext.c @@ -71,7 +71,7 @@ static inline bool topo_subleaf(struct topo_scan *tscan, = u32 leaf, u32 subleaf, default: return false; } =20 - cpuid_subleaf(leaf, subleaf, &sl); + cpuid_read_subleaf(leaf, subleaf, &sl); =20 if (!sl.num_processors || sl.type =3D=3D INVALID_TYPE) return false; diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c index cbd04b677fd1..b55fe9c7359a 100644 --- a/arch/x86/kernel/cpuid.c +++ b/arch/x86/kernel/cpuid.c @@ -59,8 +59,7 @@ static void cpuid_smp_cpuid(void *cmd_block) complete(&cmd->done); } =20 -static ssize_t cpuid_read(struct file *file, char __user *buf, - size_t count, loff_t *ppos) +static ssize_t cpuid_read_f(struct file *file, char __user *buf, size_t co= unt, loff_t *ppos) { char __user *tmp =3D buf; struct cpuid_regs_done cmd; @@ -120,7 +119,7 @@ static int cpuid_open(struct inode *inode, struct file = *file) static const struct file_operations cpuid_fops =3D { .owner =3D THIS_MODULE, .llseek =3D no_seek_end_llseek, - .read =3D cpuid_read, + .read =3D cpuid_read_f, .open =3D cpuid_open, }; =20 --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 666B42E7F04 for ; Thu, 12 Jun 2025 23:41:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771690; cv=none; b=EXq+0XBGjFJ+YElOGdYgh6FnCwMiD/rGdbNhvFmm5btMYCsZT+Xt3UA+vdkWVd2WL4pXO5hHAVm7m6BybNBVxeciR3Rjvw6bSfAfAgX+HyeD9B2FUCgHtvexVWPwb2mi6ZOx2CS44hWtCpuzwwGiF6j+PbfTvWuiuoHnwwv4vlM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771690; c=relaxed/simple; bh=ENPO2ZTrfgjWdTtgfpQM+rQwzNeFoKSjO9Vj8LP8/c8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KhL26OwLbAck1cJeRuAlJRe2lFUweQHJPal0rUh6iKFoDFmIg2uSGQNqKqqGNSGHHps45RpYI7DgIqTRLQRmWRv9FOk8F42PTQ/EFdgxSwqoobL4JljbKsiY+AoBkf7g0f7/KWkf/tcQWchaaWipDK4qbqGSEqFLhvItYTR7bD4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=gCStRftN; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=iiYtU9VS; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="gCStRftN"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="iiYtU9VS" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771683; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wH4K6bGM0q/Xb7+2uPsi88mPqiAMn02CHjdJ2pcNsyU=; b=gCStRftNc+HKJlEw51BJh4h7eCha+xNs8I/Mh+vcDwSFvF1LaQvbRoXWY73CemRrtpHnJi SkEZd1PCjJumdGxmNVG28QIsE6pcJxNg/BhKMFJB8WZpVNqL8WTLpQI+0zdrstbNlpjFm6 2DMBxnDrBlM/FGTYvgmQTd52LsbqxtKPsvckrRG+CndRxGqlYmUYfuNgEw1toqS4h/mDkr gmqA6LVrP0oJ7aJ6C1/wqAjO4jiE/P8TnlJ6j2t0VHH6DLTLZ9NemqGREE4w4S9N/bX3aB X3nnyx8q/+G0sy5zD/x7/wb5CHz5iEUPGVcz1VLH+Iz6dC87gDCz0/sxnzpFNw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771683; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wH4K6bGM0q/Xb7+2uPsi88mPqiAMn02CHjdJ2pcNsyU=; b=iiYtU9VSZIwP6DYr5SIYjv+NQF3ZR23FoyI1yzJxLv5xb6qg6Llko5BogtJjy4F88ANdY2 Eo8lG708sa9pSwBw== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 19/44] x86/cpuid: Introduce Date: Fri, 13 Jun 2025 01:39:45 +0200 Message-ID: <20250612234010.572636-20-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To centralize CPUID access across the x86 subsystem, introduce . It is generated by the x86-cpuid-db project and includes detailed C99 bitfield listings for all publicly known CPUID leaves. Add the header to MAINTAINERS x86 CPUID database entry. Suggested-by: Thomas Gleixner Signed-off-by: Ahmed S. Darwish Link: https://gitlab.com/x86-cpuid.org/x86-cpuid-db/-/blob/v2.4/CHANGELOG.r= st --- MAINTAINERS | 1 + arch/x86/include/asm/cpuid/leaf_types.h | 2055 +++++++++++++++++++++++ 2 files changed, 2056 insertions(+) create mode 100644 arch/x86/include/asm/cpuid/leaf_types.h diff --git a/MAINTAINERS b/MAINTAINERS index a92290fffa16..b8ac0a663e55 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26819,6 +26819,7 @@ R: Ahmed S. Darwish L: x86-cpuid@lists.linux.dev S: Maintained W: https://x86-cpuid.org +F: arch/x86/include/asm/cpuid/leaf_types.h F: tools/arch/x86/kcpuid/ =20 X86 ENTRY CODE diff --git a/arch/x86/include/asm/cpuid/leaf_types.h b/arch/x86/include/asm= /cpuid/leaf_types.h new file mode 100644 index 000000000000..0af2f67aee40 --- /dev/null +++ b/arch/x86/include/asm/cpuid/leaf_types.h @@ -0,0 +1,2055 @@ +/* SPDX-License-Identifier: MIT */ +/* Generator: x86-cpuid-db v2.4 */ + +/* + * Auto-generated file. + * Please submit all updates and bugfixes to https://x86-cpuid.org + */ + +#ifndef _ASM_X86_CPUID_LEAVES +#define _ASM_X86_CPUID_LEAVES + +#include + +/* + * Leaf 0x0 + * Maximum standard leaf number + CPU vendor string + */ + +struct leaf_0x0_0 { + // eax + u32 max_std_leaf : 32; // Highest standard CPUID leaf supported + // ebx + u32 cpu_vendorid_0 : 32; // CPU vendor ID string bytes 0 - 3 + // ecx + u32 cpu_vendorid_2 : 32; // CPU vendor ID string bytes 8 - 11 + // edx + u32 cpu_vendorid_1 : 32; // CPU vendor ID string bytes 4 - 7 +}; + +/* + * Leaf 0x1 + * CPU FMS (Family/Model/Stepping) + standard feature flags + */ + +struct leaf_0x1_0 { + // eax + u32 stepping : 4, // Stepping ID + base_model : 4, // Base CPU model ID + base_family_id : 4, // Base CPU family ID + cpu_type : 2, // CPU type + : 2, // Reserved + ext_model : 4, // Extended CPU model ID + ext_family : 8, // Extended CPU family ID + : 4; // Reserved + // ebx + u32 brand_id : 8, // Brand index + clflush_size : 8, // CLFLUSH instruction cache line size + n_logical_cpu : 8, // Logical CPU count + local_apic_id : 8; // Initial local APIC physical ID + // ecx + u32 sse3 : 1, // Streaming SIMD Extensions 3 (SSE3) + pclmulqdq : 1, // PCLMULQDQ instruction support + dtes64 : 1, // 64-bit DS save area + monitor : 1, // MONITOR/MWAIT support + dscpl : 1, // CPL Qualified Debug Store + vmx : 1, // Virtual Machine Extensions + smx : 1, // Safer Mode Extensions + est : 1, // Enhanced Intel SpeedStep + tm2 : 1, // Thermal Monitor 2 + ssse3 : 1, // Supplemental SSE3 + cntxt_id : 1, // L1 Context ID + sdbg : 1, // Silicon Debug + fma : 1, // FMA extensions using YMM state + cx16 : 1, // CMPXCHG16B instruction support + xtpr_update : 1, // xTPR Update Control + pdcm : 1, // Perfmon and Debug Capability + : 1, // Reserved + pcid : 1, // Process-context identifiers + dca : 1, // Direct Cache Access + sse4_1 : 1, // SSE4.1 + sse4_2 : 1, // SSE4.2 + x2apic : 1, // X2APIC support + movbe : 1, // MOVBE instruction support + popcnt : 1, // POPCNT instruction support + tsc_deadline_timer : 1, // APIC timer one-shot operation + aes : 1, // AES instructions + xsave : 1, // XSAVE (and related instructions) support + osxsave : 1, // XSAVE (and related instructions) are enabled by OS + avx : 1, // AVX instructions support + f16c : 1, // Half-precision floating-point conversion support + rdrand : 1, // RDRAND instruction support + guest_status : 1; // System is running as guest; (para-)virtualized s= ystem + // edx + u32 fpu : 1, // Floating-Point Unit on-chip (x87) + vme : 1, // Virtual-8086 Mode Extensions + de : 1, // Debugging Extensions + pse : 1, // Page Size Extension + tsc : 1, // Time Stamp Counter + msr : 1, // Model-Specific Registers (RDMSR and WRMSR support) + pae : 1, // Physical Address Extensions + mce : 1, // Machine Check Exception + cx8 : 1, // CMPXCHG8B instruction + apic : 1, // APIC on-chip + : 1, // Reserved + sep : 1, // SYSENTER, SYSEXIT, and associated MSRs + mtrr : 1, // Memory Type Range Registers + pge : 1, // Page Global Extensions + mca : 1, // Machine Check Architecture + cmov : 1, // Conditional Move Instruction + pat : 1, // Page Attribute Table + pse36 : 1, // Page Size Extension (36-bit) + psn : 1, // Processor Serial Number + clflush : 1, // CLFLUSH instruction + : 1, // Reserved + ds : 1, // Debug Store + acpi : 1, // Thermal monitor and clock control + mmx : 1, // MMX instructions + fxsr : 1, // FXSAVE and FXRSTOR instructions + sse : 1, // SSE instructions + sse2 : 1, // SSE2 instructions + selfsnoop : 1, // Self Snoop + htt : 1, // Hyper-threading + tm : 1, // Thermal Monitor + ia64 : 1, // Legacy IA-64 (Itanium) support bit, now reserved + pbe : 1; // Pending Break Enable +}; + +/* + * Leaf 0x2 + * Intel cache and TLB information one-byte descriptors + */ + +struct leaf_0x2_0 { + // eax + u32 iteration_count : 8, // Number of times this leaf must be queried + desc1 : 8, // Descriptor #1 + desc2 : 8, // Descriptor #2 + desc3 : 7, // Descriptor #3 + eax_invalid : 1; // Descriptors 1-3 are invalid if set + // ebx + u32 desc4 : 8, // Descriptor #4 + desc5 : 8, // Descriptor #5 + desc6 : 8, // Descriptor #6 + desc7 : 7, // Descriptor #7 + ebx_invalid : 1; // Descriptors 4-7 are invalid if set + // ecx + u32 desc8 : 8, // Descriptor #8 + desc9 : 8, // Descriptor #9 + desc10 : 8, // Descriptor #10 + desc11 : 7, // Descriptor #11 + ecx_invalid : 1; // Descriptors 8-11 are invalid if set + // edx + u32 desc12 : 8, // Descriptor #12 + desc13 : 8, // Descriptor #13 + desc14 : 8, // Descriptor #14 + desc15 : 7, // Descriptor #15 + edx_invalid : 1; // Descriptors 12-15 are invalid if set +}; + +/* + * Leaf 0x4 + * Intel deterministic cache parameters + */ + +struct leaf_0x4_0 { + // eax + u32 cache_type : 5, // Cache type field + cache_level : 3, // Cache level (1-based) + cache_self_init : 1, // Self-initializing cache level + fully_associative : 1, // Fully-associative cache + : 4, // Reserved + num_threads_sharing : 12, // Number logical CPUs sharing this cache + num_cores_on_die : 6; // Number of cores in the physical package + // ebx + u32 cache_linesize : 12, // System coherency line size (0-based) + cache_npartitions : 10, // Physical line partitions (0-based) + cache_nways : 10; // Ways of associativity (0-based) + // ecx + u32 cache_nsets : 31, // Cache number of sets (0-based) + : 1; // Reserved + // edx + u32 wbinvd_rll_no_guarantee : 1, // WBINVD/INVD not guaranteed for Remo= te Lower-Level caches + ll_inclusive : 1, // Cache is inclusive of Lower-Level caches + complex_indexing : 1, // Not a direct-mapped cache (complex function) + : 29; // Reserved +}; + +/* + * Leaf 0x5 + * MONITOR/MWAIT instructions enumeration + */ + +struct leaf_0x5_0 { + // eax + u32 min_mon_size : 16, // Smallest monitor-line size, in bytes + : 16; // Reserved + // ebx + u32 max_mon_size : 16, // Largest monitor-line size, in bytes + : 16; // Reserved + // ecx + u32 mwait_ext : 1, // Enumeration of MONITOR/MWAIT extensions is suppo= rted + mwait_irq_break : 1, // Interrupts as a break-event for MWAIT is supp= orted + : 30; // Reserved + // edx + u32 n_c0_substates : 4, // Number of C0 sub C-states supported using M= WAIT + n_c1_substates : 4, // Number of C1 sub C-states supported using MWAIT + n_c2_substates : 4, // Number of C2 sub C-states supported using MWAIT + n_c3_substates : 4, // Number of C3 sub C-states supported using MWAIT + n_c4_substates : 4, // Number of C4 sub C-states supported using MWAIT + n_c5_substates : 4, // Number of C5 sub C-states supported using MWAIT + n_c6_substates : 4, // Number of C6 sub C-states supported using MWAIT + n_c7_substates : 4; // Number of C7 sub C-states supported using MWAIT +}; + +/* + * Leaf 0x6 + * Thermal and Power Management enumeration + */ + +struct leaf_0x6_0 { + // eax + u32 digital_temp : 1, // Digital temperature sensor + turbo_boost : 1, // Intel Turbo Boost + lapic_timer_always_on : 1, // Always-Running APIC Timer (not affected = by p-state) + : 1, // Reserved + power_limit_event : 1, // Power Limit Notification (PLN) event + ecmd : 1, // Clock modulation duty cycle extension + package_thermal : 1, // Package thermal management + hwp_base_regs : 1, // HWP (Hardware P-states) base registers are supp= orted + hwp_notify : 1, // HWP notification (IA32_HWP_INTERRUPT MSR) + hwp_activity_window : 1, // HWP activity window (IA32_HWP_REQUEST[bits= 41:32]) supported + hwp_energy_perf_pr : 1, // HWP Energy Performance Preference + hwp_package_req : 1, // HWP Package Level Request + : 1, // Reserved + hdc_base_regs : 1, // HDC base registers are supported + turbo_boost_3_0 : 1, // Intel Turbo Boost Max 3.0 + hwp_capabilities : 1, // HWP Highest Performance change + hwp_peci_override : 1, // HWP PECI override + hwp_flexible : 1, // Flexible HWP + hwp_fast : 1, // IA32_HWP_REQUEST MSR fast access mode + hw_feedback : 1, // HW_FEEDBACK MSRs supported + hwp_ignore_idle : 1, // Ignoring idle logical CPU HWP req is supported + : 2, // Reserved + thread_director : 1, // Intel thread director support + therm_interrupt_bit25 : 1, // IA32_THERM_INTERRUPT MSR bit 25 is suppo= rted + : 7; // Reserved + // ebx + u32 n_therm_thresholds : 4, // Digital thermometer thresholds + : 28; // Reserved + // ecx + u32 aperf_mperf : 1, // MPERF/APERF MSRs (effective frequency interfac= e) + : 2, // Reserved + energy_perf_bias : 1, // IA32_ENERGY_PERF_BIAS MSR support + : 4, // Reserved + thrd_director_nclasses : 8, // Number of classes, Intel thread director + : 16; // Reserved + // edx + u32 perfcap_reporting : 1, // Performance capability reporting + encap_reporting : 1, // Energy efficiency capability reporting + : 6, // Reserved + feedback_sz : 4, // Feedback interface structure size, in 4K pages + : 4, // Reserved + this_lcpu_hwfdbk_idx : 16; // This logical CPU hardware feedback interf= ace index +}; + +/* + * Leaf 0x7 + * Extended CPU features enumeration + */ + +struct leaf_0x7_0 { + // eax + u32 leaf7_n_subleaves : 32; // Number of leaf 0x7 subleaves + // ebx + u32 fsgsbase : 1, // FSBASE/GSBASE read/write support + tsc_adjust : 1, // IA32_TSC_ADJUST MSR supported + sgx : 1, // Intel SGX (Software Guard Extensions) + bmi1 : 1, // Bit manipulation extensions group 1 + hle : 1, // Hardware Lock Elision + avx2 : 1, // AVX2 instruction set + fdp_excptn_only : 1, // FPU Data Pointer updated only on x87 exceptio= ns + smep : 1, // Supervisor Mode Execution Protection + bmi2 : 1, // Bit manipulation extensions group 2 + erms : 1, // Enhanced REP MOVSB/STOSB + invpcid : 1, // INVPCID instruction (Invalidate Processor Context ID) + rtm : 1, // Intel restricted transactional memory + pqm : 1, // Intel RDT-CMT / AMD Platform-QoS cache monitoring + zero_fcs_fds : 1, // Deprecated FPU CS/DS (stored as zero) + mpx : 1, // Intel memory protection extensions + rdt_a : 1, // Intel RDT / AMD Platform-QoS Enforcement + avx512f : 1, // AVX-512 foundation instructions + avx512dq : 1, // AVX-512 double/quadword instructions + rdseed : 1, // RDSEED instruction + adx : 1, // ADCX/ADOX instructions + smap : 1, // Supervisor mode access prevention + avx512ifma : 1, // AVX-512 integer fused multiply add + : 1, // Reserved + clflushopt : 1, // CLFLUSHOPT instruction + clwb : 1, // CLWB instruction + intel_pt : 1, // Intel processor trace + avx512pf : 1, // AVX-512 prefetch instructions + avx512er : 1, // AVX-512 exponent/reciprocal instructions + avx512cd : 1, // AVX-512 conflict detection instructions + sha : 1, // SHA/SHA256 instructions + avx512bw : 1, // AVX-512 byte/word instructions + avx512vl : 1; // AVX-512 VL (128/256 vector length) extensions + // ecx + u32 prefetchwt1 : 1, // PREFETCHWT1 (Intel Xeon Phi only) + avx512vbmi : 1, // AVX-512 Vector byte manipulation instructions + umip : 1, // User mode instruction protection + pku : 1, // Protection keys for user-space + ospke : 1, // OS protection keys enable + waitpkg : 1, // WAITPKG instructions + avx512_vbmi2 : 1, // AVX-512 vector byte manipulation instructions gr= oup 2 + cet_ss : 1, // CET shadow stack features + gfni : 1, // Galois field new instructions + vaes : 1, // Vector AES instructions + vpclmulqdq : 1, // VPCLMULQDQ 256-bit instruction support + avx512_vnni : 1, // Vector neural network instructions + avx512_bitalg : 1, // AVX-512 bitwise algorithms + tme : 1, // Intel total memory encryption + avx512_vpopcntdq : 1, // AVX-512: POPCNT for vectors of DWORD/QWORD + : 1, // Reserved + la57 : 1, // 57-bit linear addresses (five-level paging) + mawau_val_lm : 5, // BNDLDX/BNDSTX MAWAU value in 64-bit mode + rdpid : 1, // RDPID instruction + key_locker : 1, // Intel key locker support + bus_lock_detect : 1, // OS bus-lock detection + cldemote : 1, // CLDEMOTE instruction + : 1, // Reserved + movdiri : 1, // MOVDIRI instruction + movdir64b : 1, // MOVDIR64B instruction + enqcmd : 1, // Enqueue stores supported (ENQCMD{,S}) + sgx_lc : 1, // Intel SGX launch configuration + pks : 1; // Protection keys for supervisor-mode pages + // edx + u32 : 1, // Reserved + sgx_keys : 1, // Intel SGX attestation services + avx512_4vnniw : 1, // AVX-512 neural network instructions + avx512_4fmaps : 1, // AVX-512 multiply accumulation single precision + fsrm : 1, // Fast short REP MOV + uintr : 1, // CPU supports user interrupts + : 2, // Reserved + avx512_vp2intersect : 1, // VP2INTERSECT{D,Q} instructions + srdbs_ctrl : 1, // SRBDS mitigation MSR available + md_clear : 1, // VERW MD_CLEAR microcode support + rtm_always_abort : 1, // XBEGIN (RTM transaction) always aborts + : 1, // Reserved + tsx_force_abort : 1, // MSR TSX_FORCE_ABORT, RTM_ABORT bit, supported + serialize : 1, // SERIALIZE instruction + hybrid_cpu : 1, // The CPU is identified as a 'hybrid part' + tsxldtrk : 1, // TSX suspend/resume load address tracking + : 1, // Reserved + pconfig : 1, // PCONFIG instruction + arch_lbr : 1, // Intel architectural LBRs + cet_ibt : 1, // CET indirect branch tracking + : 1, // Reserved + amx_bf16 : 1, // AMX-BF16: tile bfloat16 support + avx512_fp16 : 1, // AVX-512 FP16 instructions + amx_tile : 1, // AMX-TILE: tile architecture support + amx_int8 : 1, // AMX-INT8: tile 8-bit integer support + spec_ctrl : 1, // Speculation Control (IBRS/IBPB: indirect branch res= trictions) + intel_stibp : 1, // Single thread indirect branch predictors + flush_l1d : 1, // FLUSH L1D cache: IA32_FLUSH_CMD MSR + arch_capabilities : 1, // Intel IA32_ARCH_CAPABILITIES MSR + core_capabilities : 1, // IA32_CORE_CAPABILITIES MSR + spec_ctrl_ssbd : 1; // Speculative store bypass disable +}; + +struct leaf_0x7_1 { + // eax + u32 : 4, // Reserved + avx_vnni : 1, // AVX-VNNI instructions + avx512_bf16 : 1, // AVX-512 bfloat16 instructions + lass : 1, // Linear address space separation + cmpccxadd : 1, // CMPccXADD instructions + arch_perfmon_ext : 1, // ArchPerfmonExt: leaf 0x23 is supported + : 1, // Reserved + fzrm : 1, // Fast zero-length REP MOVSB + fsrs : 1, // Fast short REP STOSB + fsrc : 1, // Fast Short REP CMPSB/SCASB + : 4, // Reserved + fred : 1, // FRED: Flexible return and event delivery transitions + lkgs : 1, // LKGS: Load 'kernel' (userspace) GS + wrmsrns : 1, // WRMSRNS instruction (WRMSR-non-serializing) + nmi_src : 1, // NMI-source reporting with FRED event data + amx_fp16 : 1, // AMX-FP16: FP16 tile operations + hreset : 1, // History reset support + avx_ifma : 1, // Integer fused multiply add + : 2, // Reserved + lam : 1, // Linear address masking + rd_wr_msrlist : 1, // RDMSRLIST/WRMSRLIST instructions + : 4; // Reserved + // ebx + u32 intel_ppin : 1, // Protected processor inventory number (PPIN{,_CT= L} MSRs) + : 31; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 : 4, // Reserved + avx_vnni_int8 : 1, // AVX-VNNI-INT8 instructions + avx_ne_convert : 1, // AVX-NE-CONVERT instructions + : 2, // Reserved + amx_complex : 1, // AMX-COMPLEX instructions (starting from Granite R= apids) + : 5, // Reserved + prefetchit_0_1 : 1, // PREFETCHIT0/1 instructions + : 3, // Reserved + cet_sss : 1, // CET supervisor shadow stacks safe to use + : 13; // Reserved +}; + +struct leaf_0x7_2 { + // eax + u32 : 32; // Reserved + // ebx + u32 : 32; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 intel_psfd : 1, // Intel predictive store forward disable + ipred_ctrl : 1, // MSR bits IA32_SPEC_CTRL.IPRED_DIS_{U,S} + rrsba_ctrl : 1, // MSR bits IA32_SPEC_CTRL.RRSBA_DIS_{U,S} + ddp_ctrl : 1, // MSR bit IA32_SPEC_CTRL.DDPD_U + bhi_ctrl : 1, // MSR bit IA32_SPEC_CTRL.BHI_DIS_S + mcdt_no : 1, // MCDT mitigation not needed + uclock_disable : 1, // UC-lock disable is supported + : 25; // Reserved +}; + +/* + * Leaf 0x9 + * Intel DCA (Direct Cache Access) enumeration + */ + +struct leaf_0x9_0 { + // eax + u32 dca_enabled_in_bios : 1, // DCA is enabled in BIOS + : 31; // Reserved + // ebx + u32 : 32; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0xa + * Intel PMU (Performance Monitoring Unit) enumeration + */ + +struct leaf_0xa_0 { + // eax + u32 pmu_version : 8, // Performance monitoring unit version ID + pmu_n_gcounters : 8, // Number of general PMU counters per logical CPU + pmu_gcounters_nbits : 8, // Bitwidth of PMU general counters + pmu_cpuid_ebx_bits : 8; // Length of leaf 0xa EBX bit vector + // ebx + u32 no_core_cycle_evt : 1, // Core cycle event not available + no_insn_retired_evt : 1, // Instruction retired event not available + no_refcycle_evt : 1, // Reference cycles event not available + no_llc_ref_evt : 1, // LLC-reference event not available + no_llc_miss_evt : 1, // LLC-misses event not available + no_br_insn_ret_evt : 1, // Branch instruction retired event not availa= ble + no_br_mispredict_evt : 1, // Branch mispredict retired event not avail= able + no_td_slots_evt : 1, // Topdown slots event not available + : 24; // Reserved + // ecx + u32 pmu_fcounters_bitmap : 32; // Fixed-function PMU counters support bi= tmap + // edx + u32 pmu_n_fcounters : 5, // Number of fixed PMU counters + pmu_fcounters_nbits : 8, // Bitwidth of PMU fixed counters + : 2, // Reserved + anythread_depr : 1, // AnyThread deprecation + : 16; // Reserved +}; + +/* + * Leaf 0xb + * CPUs v1 extended topology enumeration + */ + +struct leaf_0xb_0 { + // eax + u32 x2apic_id_shift : 5, // Bit width of this level (previous levels i= nclusive) + : 27; // Reserved + // ebx + u32 domain_lcpus_count : 16, // Logical CPUs count across all instances = of this domain + : 16; // Reserved + // ecx + u32 domain_nr : 8, // This domain level (subleaf ID) + domain_type : 8, // This domain type + : 16; // Reserved + // edx + u32 x2apic_id : 32; // x2APIC ID of current logical CPU +}; + +/* + * Leaf 0xd + * Processor extended state enumeration + */ + +struct leaf_0xd_0 { + // eax + u32 xcr0_x87 : 1, // XCR0.X87 (bit 0) supported + xcr0_sse : 1, // XCR0.SEE (bit 1) supported + xcr0_avx : 1, // XCR0.AVX (bit 2) supported + xcr0_mpx_bndregs : 1, // XCR0.BNDREGS (bit 3) supported (MPX BND0-BND3= registers) + xcr0_mpx_bndcsr : 1, // XCR0.BNDCSR (bit 4) supported (MPX BNDCFGU/BN= DSTATUS registers) + xcr0_avx512_opmask : 1, // XCR0.OPMASK (bit 5) supported (AVX-512 k0-k= 7 registers) + xcr0_avx512_zmm_hi256 : 1, // XCR0.ZMM_Hi256 (bit 6) supported (AVX-51= 2 ZMM0->ZMM7/15 registers) + xcr0_avx512_hi16_zmm : 1, // XCR0.HI16_ZMM (bit 7) supported (AVX-512 = ZMM16->ZMM31 registers) + : 1, // Reserved + xcr0_pkru : 1, // XCR0.PKRU (bit 9) supported (XSAVE PKRU registers) + : 1, // Reserved + xcr0_cet_u : 1, // XCR0.CET_U (bit 11) supported (CET user state) + xcr0_cet_s : 1, // XCR0.CET_S (bit 12) supported (CET supervisor stat= e) + : 4, // Reserved + xcr0_tileconfig : 1, // XCR0.TILECONFIG (bit 17) supported (AMX can m= anage TILECONFIG) + xcr0_tiledata : 1, // XCR0.TILEDATA (bit 18) supported (AMX can manag= e TILEDATA) + : 13; // Reserved + // ebx + u32 xsave_sz_xcr0_enabled : 32; // XSAVE/XRSTOR area byte size, for XCR0= enabled features + // ecx + u32 xsave_sz_max : 32; // XSAVE/XRSTOR area max byte size, all CPU feat= ures + // edx + u32 : 30, // Reserved + xcr0_lwp : 1, // AMD XCR0.LWP (bit 62) supported (Light-weight Profil= ing) + : 1; // Reserved +}; + +struct leaf_0xd_1 { + // eax + u32 xsaveopt : 1, // XSAVEOPT instruction + xsavec : 1, // XSAVEC instruction + xgetbv1 : 1, // XGETBV instruction with ECX =3D 1 + xsaves : 1, // XSAVES/XRSTORS instructions (and XSS MSR) + xfd : 1, // Extended feature disable support + : 27; // Reserved + // ebx + u32 xsave_sz_xcr0_xmms_enabled : 32; // XSAVE area size, all XCR0 and XMM= S features enabled + // ecx + u32 : 8, // Reserved + xss_pt : 1, // PT state, supported + : 1, // Reserved + xss_pasid : 1, // PASID state, supported + xss_cet_u : 1, // CET user state, supported + xss_cet_p : 1, // CET supervisor state, supported + xss_hdc : 1, // HDC state, supported + xss_uintr : 1, // UINTR state, supported + xss_lbr : 1, // LBR state, supported + xss_hwp : 1, // HWP state, supported + : 15; // Reserved + // edx + u32 : 32; // Reserved +}; + +struct leaf_0xd_2 { + // eax + u32 xsave_sz : 32; // Size of save area for subleaf-N feature, in bytes + // ebx + u32 xsave_offset : 32; // Offset of save area for subleaf-N feature, in= bytes + // ecx + u32 is_xss_bit : 1, // Subleaf N describes an XSS bit, otherwise XCR0 = bit + compacted_xsave_64byte_aligned : 1, // When compacted, subleaf-N featur= e XSAVE area is 64-byte aligned + : 30; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0xf + * Intel RDT / AMD PQoS resource monitoring + */ + +struct leaf_0xf_0 { + // eax + u32 : 32; // Reserved + // ebx + u32 core_rmid_max : 32; // RMID max, within this core, all types (0-bas= ed) + // ecx + u32 : 32; // Reserved + // edx + u32 : 1, // Reserved + llc_qos_mon : 1, // LLC QoS-monitoring supported + : 30; // Reserved +}; + +struct leaf_0xf_1 { + // eax + u32 l3c_qm_bitwidth : 8, // L3 QoS-monitoring counter bitwidth (24-bas= ed) + l3c_qm_overflow_bit : 1, // QM_CTR MSR bit 61 is an overflow bit + : 23; // Reserved + // ebx + u32 l3c_qm_conver_factor : 32; // QM_CTR MSR conversion factor to bytes + // ecx + u32 l3c_qm_rmid_max : 32; // L3 QoS-monitoring max RMID + // edx + u32 l3c_qm_occupancy : 1, // L3 QoS occupancy monitoring supported + l3c_qm_mbm_total : 1, // L3 QoS total bandwidth monitoring supported + l3c_qm_mbm_local : 1, // L3 QoS local bandwidth monitoring supported + : 29; // Reserved +}; + +/* + * Leaf 0x10 + * Intel RDT / AMD PQoS allocation enumeration + */ + +struct leaf_0x10_0 { + // eax + u32 : 32; // Reserved + // ebx + u32 : 1, // Reserved + cat_l3 : 1, // L3 Cache Allocation Technology supported + cat_l2 : 1, // L2 Cache Allocation Technology supported + mba : 1, // Memory Bandwidth Allocation supported + : 28; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +struct leaf_0x10_1 { + // eax + u32 cat_cbm_len : 5, // L3/L2_CAT capacity bitmask length, minus-one n= otation + : 27; // Reserved + // ebx + u32 cat_units_bitmap : 32; // L3/L2_CAT bitmap of allocation units + // ecx + u32 : 1, // Reserved + l3_cat_cos_infreq_updates : 1, // L3_CAT COS updates should be infreque= nt + cat_cdp_supported : 1, // L3/L2_CAT CDP (Code and Data Prioritization) + cat_sparse_1s : 1, // L3/L2_CAT non-contiguous 1s value supported + : 28; // Reserved + // edx + u32 cat_cos_max : 16, // L3/L2_CAT max COS (Class of Service) supported + : 16; // Reserved +}; + +struct leaf_0x10_3 { + // eax + u32 mba_max_delay : 12, // Max MBA throttling value; minus-one notation + : 20; // Reserved + // ebx + u32 : 32; // Reserved + // ecx + u32 mba_per_thread : 1, // Per-thread MBA controls are supported + : 1, // Reserved + mba_delay_linear : 1, // Delay values are linear + : 29; // Reserved + // edx + u32 mba_cos_max : 16, // MBA max Class of Service supported + : 16; // Reserved +}; + +/* + * Leaf 0x12 + * Intel Software Guard Extensions (SGX) enumeration + */ + +struct leaf_0x12_0 { + // eax + u32 sgx1 : 1, // SGX1 leaf functions supported + sgx2 : 1, // SGX2 leaf functions supported + : 3, // Reserved + enclv_leaves : 1, // ENCLV leaves (E{INC,DEC}VIRTCHILD, ESETCONTEXT) = supported + encls_leaves : 1, // ENCLS leaves (ENCLS ETRACKC, ERDINFO, ELDBC, ELD= UC) supported + enclu_everifyreport2 : 1, // ENCLU leaf EVERIFYREPORT2 supported + : 2, // Reserved + encls_eupdatesvn : 1, // ENCLS leaf EUPDATESVN supported + enclu_edeccssa : 1, // ENCLU leaf EDECCSSA supported + : 20; // Reserved + // ebx + u32 miscselect_exinfo : 1, // SSA.MISC frame: reporting #PF and #GP exc= eptions inside enclave supported + miscselect_cpinfo : 1, // SSA.MISC frame: reporting #CP exceptions ins= ide enclave supported + : 30; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 max_enclave_sz_not64 : 8, // Maximum enclave size in non-64-bit mod= e (log2) + max_enclave_sz_64 : 8, // Maximum enclave size in 64-bit mode (log2) + : 16; // Reserved +}; + +struct leaf_0x12_1 { + // eax + u32 secs_attr_init : 1, // ATTRIBUTES.INIT supported (enclave initiali= zed by EINIT) + secs_attr_debug : 1, // ATTRIBUTES.DEBUG supported (enclave permits d= ebugger read/write) + secs_attr_mode64bit : 1, // ATTRIBUTES.MODE64BIT supported (enclave ru= ns in 64-bit mode) + : 1, // Reserved + secs_attr_provisionkey : 1, // ATTRIBUTES.PROVISIONKEY supported (prov= isioning key available) + secs_attr_einittoken_key : 1, // ATTRIBUTES.EINITTOKEN_KEY supported (E= INIT token key available) + secs_attr_cet : 1, // ATTRIBUTES.CET supported (enable CET attributes) + secs_attr_kss : 1, // ATTRIBUTES.KSS supported (Key Separation and Sh= aring enabled) + : 2, // Reserved + secs_attr_aexnotify : 1, // ATTRIBUTES.AEXNOTIFY supported (enclave th= reads may get AEX notifications + : 21; // Reserved + // ebx + u32 : 32; // Reserved + // ecx + u32 xfrm_x87 : 1, // Enclave XFRM.X87 (bit 0) supported + xfrm_sse : 1, // Enclave XFRM.SEE (bit 1) supported + xfrm_avx : 1, // Enclave XFRM.AVX (bit 2) supported + xfrm_mpx_bndregs : 1, // Enclave XFRM.BNDREGS (bit 3) supported (MPX B= ND0-BND3 registers) + xfrm_mpx_bndcsr : 1, // Enclave XFRM.BNDCSR (bit 4) supported (MPX BN= DCFGU/BNDSTATUS registers) + xfrm_avx512_opmask : 1, // Enclave XFRM.OPMASK (bit 5) supported (AVX-= 512 k0-k7 registers) + xfrm_avx512_zmm_hi256 : 1, // Enclave XFRM.ZMM_Hi256 (bit 6) supported= (AVX-512 ZMM0->ZMM7/15 registers) + xfrm_avx512_hi16_zmm : 1, // Enclave XFRM.HI16_ZMM (bit 7) supported (= AVX-512 ZMM16->ZMM31 registers) + : 1, // Reserved + xfrm_pkru : 1, // Enclave XFRM.PKRU (bit 9) supported (XSAVE PKRU reg= isters) + : 7, // Reserved + xfrm_tileconfig : 1, // Enclave XFRM.TILECONFIG (bit 17) supported (A= MX can manage TILECONFIG) + xfrm_tiledata : 1, // Enclave XFRM.TILEDATA (bit 18) supported (AMX c= an manage TILEDATA) + : 13; // Reserved + // edx + u32 : 32; // Reserved +}; + +struct leaf_0x12_2 { + // eax + u32 subleaf_type : 4, // Subleaf type (dictates output layout) + : 8, // Reserved + epc_sec_base_addr_0 : 20; // EPC section base address, bits[12:31] + // ebx + u32 epc_sec_base_addr_1 : 20, // EPC section base address, bits[32:51] + : 12; // Reserved + // ecx + u32 epc_sec_type : 4, // EPC section type / property encoding + : 8, // Reserved + epc_sec_size_0 : 20; // EPC section size, bits[12:31] + // edx + u32 epc_sec_size_1 : 20, // EPC section size, bits[32:51] + : 12; // Reserved +}; + +/* + * Leaf 0x14 + * Intel Processor Trace enumeration + */ + +struct leaf_0x14_0 { + // eax + u32 pt_max_subleaf : 32; // Maximum leaf 0x14 subleaf + // ebx + u32 cr3_filtering : 1, // IA32_RTIT_CR3_MATCH is accessible + psb_cyc : 1, // Configurable PSB and cycle-accurate mode + ip_filtering : 1, // IP/TraceStop filtering; Warm-reset PT MSRs prese= rvation + mtc_timing : 1, // MTC timing packet; COFI-based packets suppression + ptwrite : 1, // PTWRITE support + power_event_trace : 1, // Power Event Trace support + psb_pmi_preserve : 1, // PSB and PMI preservation support + event_trace : 1, // Event Trace packet generation through IA32_RTIT_C= TL.EventEn + tnt_disable : 1, // TNT packet generation disable through IA32_RTIT_C= TL.DisTNT + : 23; // Reserved + // ecx + u32 topa_output : 1, // ToPA output scheme support + topa_multiple_entries : 1, // ToPA tables can hold multiple entries + single_range_output : 1, // Single-range output scheme supported + trance_transport_output : 1, // Trace Transport subsystem output suppo= rt + : 27, // Reserved + ip_payloads_lip : 1; // IP payloads have LIP values (CS base included) + // edx + u32 : 32; // Reserved +}; + +struct leaf_0x14_1 { + // eax + u32 num_address_ranges : 3, // Filtering number of configurable Address= Ranges + : 13, // Reserved + mtc_periods_bmp : 16; // Bitmap of supported MTC period encodings + // ebx + u32 cycle_thresholds_bmp : 16, // Bitmap of supported Cycle Threshold en= codings + psb_periods_bmp : 16; // Bitmap of supported Configurable PSB frequenc= y encodings + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x15 + * Intel TSC (Time Stamp Counter) enumeration + */ + +struct leaf_0x15_0 { + // eax + u32 tsc_denominator : 32; // Denominator of the TSC/'core crystal clock= ' ratio + // ebx + u32 tsc_numerator : 32; // Numerator of the TSC/'core crystal clock' ra= tio + // ecx + u32 cpu_crystal_hz : 32; // Core crystal clock nominal frequency, in Hz + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x16 + * Intel processor frequency enumeration + */ + +struct leaf_0x16_0 { + // eax + u32 cpu_base_mhz : 16, // Processor base frequency, in MHz + : 16; // Reserved + // ebx + u32 cpu_max_mhz : 16, // Processor max frequency, in MHz + : 16; // Reserved + // ecx + u32 bus_mhz : 16, // Bus reference frequency, in MHz + : 16; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x17 + * Intel SoC vendor attributes enumeration + */ + +struct leaf_0x17_0 { + // eax + u32 soc_max_subleaf : 32; // Maximum leaf 0x17 subleaf + // ebx + u32 soc_vendor_id : 16, // SoC vendor ID + is_vendor_scheme : 1, // Assigned by industry enumeration scheme (not = Intel) + : 15; // Reserved + // ecx + u32 soc_proj_id : 32; // SoC project ID, assigned by vendor + // edx + u32 soc_stepping_id : 32; // Soc project stepping ID, assigned by vendor +}; + +struct leaf_0x17_1 { + // eax + u32 vendor_brand_a : 32; // Vendor Brand ID string, bytes subleaf_nr * = (0 -> 3) + // ebx + u32 vendor_brand_b : 32; // Vendor Brand ID string, bytes subleaf_nr * = (4 -> 7) + // ecx + u32 vendor_brand_c : 32; // Vendor Brand ID string, bytes subleaf_nr * = (8 -> 11) + // edx + u32 vendor_brand_d : 32; // Vendor Brand ID string, bytes subleaf_nr * = (12 -> 15) +}; + +/* + * Leaf 0x18 + * Intel determenestic address translation (TLB) parameters + */ + +struct leaf_0x18_0 { + // eax + u32 tlb_max_subleaf : 32; // Maximum leaf 0x18 subleaf + // ebx + u32 tlb_4k_page : 1, // TLB 4KB-page entries supported + tlb_2m_page : 1, // TLB 2MB-page entries supported + tlb_4m_page : 1, // TLB 4MB-page entries supported + tlb_1g_page : 1, // TLB 1GB-page entries supported + : 4, // Reserved + hard_partitioning : 3, // (Hard/Soft) partitioning between logical CPU= s sharing this structure + : 5, // Reserved + n_way_associative : 16; // Ways of associativity + // ecx + u32 n_sets : 32; // Number of sets + // edx + u32 tlb_type : 5, // Translation cache type (TLB type) + tlb_cache_level : 3, // Translation cache level (1-based) + is_fully_associative : 1, // Fully-associative structure + : 5, // Reserved + tlb_max_addressible_ids : 12, // Max number of addressable IDs for logi= cal CPUs sharing this TLB - 1 + : 6; // Reserved +}; + +/* + * Leaf 0x19 + * Intel Key Locker enumeration + */ + +struct leaf_0x19_0 { + // eax + u32 kl_cpl0_only : 1, // CPL0-only key Locker restriction supported + kl_no_encrypt : 1, // No-encrypt key locker restriction supported + kl_no_decrypt : 1, // No-decrypt key locker restriction supported + : 29; // Reserved + // ebx + u32 aes_keylocker : 1, // AES key locker instructions supported + : 1, // Reserved + aes_keylocker_wide : 1, // AES wide key locker instructions supported + : 1, // Reserved + kl_msr_iwkey : 1, // Key locker MSRs and IWKEY backups supported + : 27; // Reserved + // ecx + u32 loadiwkey_no_backup : 1, // LOADIWKEY NoBackup parameter supported + iwkey_rand : 1, // IWKEY randomization (KeySource encoding 1) support= ed + : 30; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x1a + * Intel hybrid CPUs identification (e.g. Atom, Core) + */ + +struct leaf_0x1a_0 { + // eax + u32 core_native_model : 24, // This core's native model ID + core_type : 8; // This core's type + // ebx + u32 : 32; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x1b + * Intel PCONFIG (Platform configuration) enumeration + */ + +struct leaf_0x1b_0 { + // eax + u32 pconfig_subleaf_type : 12, // CPUID 0x1b subleaf type + : 20; // Reserved + // ebx + u32 pconfig_target_id_x : 32; // A supported PCONFIG target ID + // ecx + u32 pconfig_target_id_y : 32; // A supported PCONFIG target ID + // edx + u32 pconfig_target_id_z : 32; // A supported PCONFIG target ID +}; + +/* + * Leaf 0x1c + * Intel LBR (Last Branch Record) enumeration + */ + +struct leaf_0x1c_0 { + // eax + u32 lbr_depth_8 : 1, // Max stack depth (number of LBR entries) =3D 8 + lbr_depth_16 : 1, // Max stack depth (number of LBR entries) =3D 16 + lbr_depth_24 : 1, // Max stack depth (number of LBR entries) =3D 24 + lbr_depth_32 : 1, // Max stack depth (number of LBR entries) =3D 32 + lbr_depth_40 : 1, // Max stack depth (number of LBR entries) =3D 40 + lbr_depth_48 : 1, // Max stack depth (number of LBR entries) =3D 48 + lbr_depth_56 : 1, // Max stack depth (number of LBR entries) =3D 56 + lbr_depth_64 : 1, // Max stack depth (number of LBR entries) =3D 64 + : 22, // Reserved + lbr_deep_c_reset : 1, // LBRs maybe cleared on MWAIT C-state > C1 + lbr_ip_is_lip : 1; // LBR IP contain Last IP, otherwise effective IP + // ebx + u32 lbr_cpl : 1, // CPL filtering (non-zero IA32_LBR_CTL[2:1]) suppor= ted + lbr_branch_filter : 1, // Branch filtering (non-zero IA32_LBR_CTL[22:1= 6]) supported + lbr_call_stack : 1, // Call-stack mode (IA32_LBR_CTL[3] =3D 1) suppor= ted + : 29; // Reserved + // ecx + u32 lbr_mispredict : 1, // Branch misprediction bit supported (IA32_LB= R_x_INFO[63]) + lbr_timed_lbr : 1, // Timed LBRs (CPU cycles since last LBR entry) su= pported + lbr_branch_type : 1, // Branch type field (IA32_LBR_INFO_x[59:56]) su= pported + : 13, // Reserved + lbr_events_gpc_bmp : 4, // LBR PMU-events logging support; bitmap for = first 4 GP (general-purpose) Counters + : 12; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x1d + * Intel AMX (Advanced Matrix Extensions) tile information + */ + +struct leaf_0x1d_0 { + // eax + u32 amx_max_palette : 32; // Highest palette ID / subleaf ID + // ebx + u32 : 32; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +struct leaf_0x1d_1 { + // eax + u32 amx_palette_size : 16, // AMX palette total tiles size, in bytes + amx_tile_size : 16; // AMX single tile's size, in bytes + // ebx + u32 amx_tile_row_size : 16, // AMX tile single row's size, in bytes + amx_palette_nr_tiles : 16; // AMX palette number of tiles + // ecx + u32 amx_tile_nr_rows : 16, // AMX tile max number of rows + : 16; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x1e + * Intel AMX, TMUL (Tile-matrix MULtiply) accelerator unit enumeration + */ + +struct leaf_0x1e_0 { + // eax + u32 : 32; // Reserved + // ebx + u32 tmul_maxk : 8, // TMUL unit maximum height, K (rows or columns) + tmul_maxn : 16, // TMUL unit maximum SIMD dimension, N (column bytes) + : 8; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x1f + * Intel extended topology enumeration v2 + */ + +struct leaf_0x1f_0 { + // eax + u32 x2apic_id_shift : 5, // Bit width of this level (previous levels i= nclusive) + : 27; // Reserved + // ebx + u32 domain_lcpus_count : 16, // Logical CPUs count across all instances = of this domain + : 16; // Reserved + // ecx + u32 domain_level : 8, // This domain level (subleaf ID) + domain_type : 8, // This domain type + : 16; // Reserved + // edx + u32 x2apic_id : 32; // x2APIC ID of current logical CPU +}; + +/* + * Leaf 0x20 + * Intel HRESET (History Reset) enumeration + */ + +struct leaf_0x20_0 { + // eax + u32 hreset_nr_subleaves : 32; // CPUID 0x20 max subleaf + 1 + // ebx + u32 hreset_thread_director : 1, // HRESET of Intel thread director is s= upported + : 31; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x21 + * Intel TD (Trust Domain) guest execution environment enumeration + */ + +struct leaf_0x21_0 { + // eax + u32 : 32; // Reserved + // ebx + u32 tdx_vendorid_0 : 32; // TDX vendor ID string bytes 0 - 3 + // ecx + u32 tdx_vendorid_2 : 32; // CPU vendor ID string bytes 8 - 11 + // edx + u32 tdx_vendorid_1 : 32; // CPU vendor ID string bytes 4 - 7 +}; + +/* + * Leaf 0x23 + * Intel Architectural Performance Monitoring Extended (ArchPerfmonExt) + */ + +struct leaf_0x23_0 { + // eax + u32 : 1, // Reserved + subleaf_1_counters : 1, // Subleaf 1, PMU counters bitmaps, is valid + : 1, // Reserved + subleaf_3_events : 1, // Subleaf 3, PMU events bitmaps, is valid + : 28; // Reserved + // ebx + u32 unitmask2 : 1, // IA32_PERFEVTSELx MSRs UnitMask2 is supported + zbit : 1, // IA32_PERFEVTSELx MSRs Z-bit is supported + : 30; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +struct leaf_0x23_1 { + // eax + u32 pmu_gp_counters_bitmap : 32; // General-purpose PMU counters bitmap + // ebx + u32 pmu_f_counters_bitmap : 32; // Fixed PMU counters bitmap + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +struct leaf_0x23_3 { + // eax + u32 core_cycles_evt : 1, // Core cycles event supported + insn_retired_evt : 1, // Instructions retired event supported + ref_cycles_evt : 1, // Reference cycles event supported + llc_refs_evt : 1, // Last-level cache references event supported + llc_misses_evt : 1, // Last-level cache misses event supported + br_insn_ret_evt : 1, // Branch instruction retired event supported + br_mispr_evt : 1, // Branch mispredict retired event supported + td_slots_evt : 1, // Topdown slots event supported + td_backend_bound_evt : 1, // Topdown backend bound event supported + td_bad_spec_evt : 1, // Topdown bad speculation event supported + td_frontend_bound_evt : 1, // Topdown frontend bound event supported + td_retiring_evt : 1, // Topdown retiring event support + : 20; // Reserved + // ebx + u32 : 32; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x40000000 + * Maximum hypervisor standard leaf + hypervisor vendor string + */ + +struct leaf_0x40000000_0 { + // eax + u32 max_hyp_leaf : 32; // Maximum hypervisor standard leaf number + // ebx + u32 hypervisor_id_0 : 32; // Hypervisor ID string bytes 0 - 3 + // ecx + u32 hypervisor_id_1 : 32; // Hypervisor ID string bytes 4 - 7 + // edx + u32 hypervisor_id_2 : 32; // Hypervisor ID string bytes 8 - 11 +}; + +/* + * Leaf 0x80000000 + * Maximum extended leaf number + AMD/Transmeta CPU vendor string + */ + +struct leaf_0x80000000_0 { + // eax + u32 max_ext_leaf : 32; // Maximum extended CPUID leaf supported + // ebx + u32 cpu_vendorid_0 : 32; // Vendor ID string bytes 0 - 3 + // ecx + u32 cpu_vendorid_2 : 32; // Vendor ID string bytes 8 - 11 + // edx + u32 cpu_vendorid_1 : 32; // Vendor ID string bytes 4 - 7 +}; + +/* + * Leaf 0x80000001 + * Extended CPU feature identifiers + */ + +struct leaf_0x80000001_0 { + // eax + u32 e_stepping_id : 4, // Stepping ID + e_base_model : 4, // Base processor model + e_base_family : 4, // Base processor family + e_base_type : 2, // Base processor type (Transmeta) + : 2, // Reserved + e_ext_model : 4, // Extended processor model + e_ext_family : 8, // Extended processor family + : 4; // Reserved + // ebx + u32 brand_id : 16, // Brand ID + : 12, // Reserved + pkg_type : 4; // Package type + // ecx + u32 lahf_lm : 1, // LAHF and SAHF in 64-bit mode + cmp_legacy : 1, // Multi-processing legacy mode (No HT) + svm : 1, // Secure Virtual Machine + extapic : 1, // Extended APIC space + cr8_legacy : 1, // LOCK MOV CR0 means MOV CR8 + lzcnt_abm : 1, // LZCNT advanced bit manipulation + sse4a : 1, // SSE4A support + misaligned_sse : 1, // Misaligned SSE mode + _3dnow_prefetch : 1, // 3DNow PREFETCH/PREFETCHW support + osvw : 1, // OS visible workaround + ibs : 1, // Instruction based sampling + xop : 1, // XOP: extended operation (AVX instructions) + skinit : 1, // SKINIT/STGI support + wdt : 1, // Watchdog timer support + : 1, // Reserved + lwp : 1, // Lightweight profiling + fma4 : 1, // 4-operand FMA instruction + tce : 1, // Translation cache extension + : 1, // Reserved + nodeid_msr : 1, // NodeId MSR (0xc001100c) + : 1, // Reserved + tbm : 1, // Trailing bit manipulations + topoext : 1, // Topology Extensions (leaf 0x8000001d) + perfctr_core : 1, // Core performance counter extensions + perfctr_nb : 1, // NB/DF performance counter extensions + : 1, // Reserved + data_bp_ext : 1, // Data access breakpoint extension + perf_tsc : 1, // Performance time-stamp counter + perfctr_llc : 1, // LLC (L3) performance counter extensions + mwaitx : 1, // MWAITX/MONITORX support + addr_mask_ext : 1, // Breakpoint address mask extension (to bit 31) + : 1; // Reserved + // edx + u32 e_fpu : 1, // Floating-Point Unit on-chip (x87) + e_vme : 1, // Virtual-8086 Mode Extensions + e_de : 1, // Debugging Extensions + e_pse : 1, // Page Size Extension + e_tsc : 1, // Time Stamp Counter + e_msr : 1, // Model-Specific Registers (RDMSR and WRMSR support) + pae : 1, // Physical Address Extensions + mce : 1, // Machine Check Exception + cx8 : 1, // CMPXCHG8B instruction + apic : 1, // APIC on-chip + : 1, // Reserved + syscall : 1, // SYSCALL and SYSRET instructions + mtrr : 1, // Memory Type Range Registers + pge : 1, // Page Global Extensions + mca : 1, // Machine Check Architecture + cmov : 1, // Conditional Move Instruction + pat : 1, // Page Attribute Table + pse36 : 1, // Page Size Extension (36-bit) + : 1, // Reserved + obsolete_mp_bit : 1, // Out-of-spec AMD Multiprocessing bit + nx : 1, // No-execute page protection + : 1, // Reserved + mmxext : 1, // AMD MMX extensions + e_mmx : 1, // MMX instructions + e_fxsr : 1, // FXSAVE and FXRSTOR instructions + fxsr_opt : 1, // FXSAVE and FXRSTOR optimizations + page1gb : 1, // 1-GB large page support + rdtscp : 1, // RDTSCP instruction + : 1, // Reserved + lm : 1, // Long mode (x86-64, 64-bit support) + _3dnowext : 1, // AMD 3DNow extensions + _3dnow : 1; // 3DNow instructions +}; + +/* + * Leaf 0x80000002 + * CPU brand ID string, bytes 0 - 15 + */ + +struct leaf_0x80000002_0 { + // eax + u32 cpu_brandid_0 : 32; // CPU brand ID string, bytes 0 - 3 + // ebx + u32 cpu_brandid_1 : 32; // CPU brand ID string, bytes 4 - 7 + // ecx + u32 cpu_brandid_2 : 32; // CPU brand ID string, bytes 8 - 11 + // edx + u32 cpu_brandid_3 : 32; // CPU brand ID string, bytes 12 - 15 +}; + +/* + * Leaf 0x80000003 + * CPU brand ID string, bytes 16 - 31 + */ + +struct leaf_0x80000003_0 { + // eax + u32 cpu_brandid_4 : 32; // CPU brand ID string bytes, 16 - 19 + // ebx + u32 cpu_brandid_5 : 32; // CPU brand ID string bytes, 20 - 23 + // ecx + u32 cpu_brandid_6 : 32; // CPU brand ID string bytes, 24 - 27 + // edx + u32 cpu_brandid_7 : 32; // CPU brand ID string bytes, 28 - 31 +}; + +/* + * Leaf 0x80000004 + * CPU brand ID string, bytes 32 - 47 + */ + +struct leaf_0x80000004_0 { + // eax + u32 cpu_brandid_8 : 32; // CPU brand ID string, bytes 32 - 35 + // ebx + u32 cpu_brandid_9 : 32; // CPU brand ID string, bytes 36 - 39 + // ecx + u32 cpu_brandid_10 : 32; // CPU brand ID string, bytes 40 - 43 + // edx + u32 cpu_brandid_11 : 32; // CPU brand ID string, bytes 44 - 47 +}; + +/* + * Leaf 0x80000005 + * AMD/Transmeta L1 cache and L1 TLB enumeration + */ + +struct leaf_0x80000005_0 { + // eax + u32 l1_itlb_2m_4m_nentries : 8, // L1 ITLB #entries, 2M and 4M pages + l1_itlb_2m_4m_assoc : 8, // L1 ITLB associativity, 2M and 4M pages + l1_dtlb_2m_4m_nentries : 8, // L1 DTLB #entries, 2M and 4M pages + l1_dtlb_2m_4m_assoc : 8; // L1 DTLB associativity, 2M and 4M pages + // ebx + u32 l1_itlb_4k_nentries : 8, // L1 ITLB #entries, 4K pages + l1_itlb_4k_assoc : 8, // L1 ITLB associativity, 4K pages + l1_dtlb_4k_nentries : 8, // L1 DTLB #entries, 4K pages + l1_dtlb_4k_assoc : 8; // L1 DTLB associativity, 4K pages + // ecx + u32 l1_dcache_line_size : 8, // L1 dcache line size, in bytes + l1_dcache_nlines : 8, // L1 dcache lines per tag + l1_dcache_assoc : 8, // L1 dcache associativity + l1_dcache_size_kb : 8; // L1 dcache size, in KB + // edx + u32 l1_icache_line_size : 8, // L1 icache line size, in bytes + l1_icache_nlines : 8, // L1 icache lines per tag + l1_icache_assoc : 8, // L1 icache associativity + l1_icache_size_kb : 8; // L1 icache size, in KB +}; + +/* + * Leaf 0x80000006 + * (Mostly AMD) L2 TLB, L2 cache, and L3 cache enumeration + */ + +struct leaf_0x80000006_0 { + // eax + u32 l2_itlb_2m_4m_nentries : 12, // L2 iTLB #entries, 2M and 4M pages + l2_itlb_2m_4m_assoc : 4, // L2 iTLB associativity, 2M and 4M pages + l2_dtlb_2m_4m_nentries : 12, // L2 dTLB #entries, 2M and 4M pages + l2_dtlb_2m_4m_assoc : 4; // L2 dTLB associativity, 2M and 4M pages + // ebx + u32 l2_itlb_4k_nentries : 12, // L2 iTLB #entries, 4K pages + l2_itlb_4k_assoc : 4, // L2 iTLB associativity, 4K pages + l2_dtlb_4k_nentries : 12, // L2 dTLB #entries, 4K pages + l2_dtlb_4k_assoc : 4; // L2 dTLB associativity, 4K pages + // ecx + u32 l2_line_size : 8, // L2 cache line size, in bytes + l2_nlines : 4, // L2 cache number of lines per tag + l2_assoc : 4, // L2 cache associativity + l2_size_kb : 16; // L2 cache size, in KB + // edx + u32 l3_line_size : 8, // L3 cache line size, in bytes + l3_nlines : 4, // L3 cache number of lines per tag + l3_assoc : 4, // L3 cache associativity + : 2, // Reserved + l3_size_range : 14; // L3 cache size range +}; + +/* + * Leaf 0x80000007 + * CPU power management (mostly AMD) and AMD RAS enumeration + */ + +struct leaf_0x80000007_0 { + // eax + u32 : 32; // Reserved + // ebx + u32 mca_overflow_recovery : 1, // MCA overflow conditions not fatal + succor : 1, // Software containment of uncorrectable errors + hw_assert : 1, // Hardware assert MSRs + scalable_mca : 1, // Scalable MCA (MCAX MSRs) + : 28; // Reserved + // ecx + u32 cpu_pwr_sample_ratio : 32; // CPU power sample time ratio + // edx + u32 digital_temp : 1, // Digital temperature sensor + powernow_freq_id : 1, // PowerNOW! frequency scaling + powernow_volt_id : 1, // PowerNOW! voltage scaling + thermal_trip : 1, // THERMTRIP (Thermal Trip) + hw_thermal_control : 1, // Hardware thermal control + sw_thermal_control : 1, // Software thermal control + _100mhz_steps : 1, // 100 MHz multiplier control + hw_pstate : 1, // Hardware P-state control + constant_tsc : 1, // TSC ticks at constant rate across all P and C st= ates + core_perf_boost : 1, // Core performance boost + eff_freq_ro : 1, // Read-only effective frequency interface + proc_feedback : 1, // Processor feedback interface (deprecated) + proc_power_reporting : 1, // Processor power reporting interface + connected_standby : 1, // CPU Connected Standby support + rapl_interface : 1, // Runtime Average Power Limit interface + : 17; // Reserved +}; + +/* + * Leaf 0x80000008 + * CPU capacity parameters and extended feature flags (mostly AMD) + */ + +struct leaf_0x80000008_0 { + // eax + u32 phys_addr_bits : 8, // Max physical address bits + virt_addr_bits : 8, // Max virtual address bits + guest_phys_addr_bits : 8, // Max nested-paging guest physical address = bits + : 8; // Reserved + // ebx + u32 clzero : 1, // CLZERO supported + insn_retired_perf : 1, // Instruction retired counter MSR + xsave_err_ptr : 1, // XSAVE/XRSTOR always saves/restores FPU error po= inters + invlpgb : 1, // INVLPGB broadcasts a TLB invalidate to all threads + rdpru : 1, // RDPRU (Read Processor Register at User level) supported + : 1, // Reserved + mba : 1, // Memory Bandwidth Allocation (AMD bit) + : 1, // Reserved + mcommit : 1, // MCOMMIT (Memory commit) supported + wbnoinvd : 1, // WBNOINVD supported + : 2, // Reserved + ibpb : 1, // Indirect Branch Prediction Barrier + wbinvd_int : 1, // Interruptible WBINVD/WBNOINVD + ibrs : 1, // Indirect Branch Restricted Speculation + stibp : 1, // Single Thread Indirect Branch Prediction mode + ibrs_always_on : 1, // IBRS always-on preferred + stibp_always_on : 1, // STIBP always-on preferred + ibrs_fast : 1, // IBRS is preferred over software solution + ibrs_same_mode : 1, // IBRS provides same mode protection + no_efer_lmsle : 1, // EFER[LMSLE] bit (Long-Mode Segment Limit Enable= ) unsupported + tlb_flush_nested : 1, // INVLPGB RAX[5] bit can be set (nested transla= tions) + : 1, // Reserved + amd_ppin : 1, // Protected Processor Inventory Number + amd_ssbd : 1, // Speculative Store Bypass Disable + virt_ssbd : 1, // virtualized SSBD (Speculative Store Bypass Disable) + amd_ssb_no : 1, // SSBD is not needed (fixed in hardware) + cppc : 1, // Collaborative Processor Performance Control + amd_psfd : 1, // Predictive Store Forward Disable + btc_no : 1, // CPU not affected by Branch Type Confusion + ibpb_ret : 1, // IBPB clears RSB/RAS too + branch_sampling : 1; // Branch Sampling supported + // ecx + u32 cpu_nthreads : 8, // Number of physical threads - 1 + : 4, // Reserved + apicid_coreid_len : 4, // Number of thread core ID bits (shift) in API= C ID + perf_tsc_len : 2, // Performance time-stamp counter size + : 14; // Reserved + // edx + u32 invlpgb_max_pages : 16, // INVLPGB maximum page count + rdpru_max_reg_id : 16; // RDPRU max register ID (ECX input) +}; + +/* + * Leaf 0x8000000a + * AMD SVM (Secure Virtual Machine) enumeration + */ + +struct leaf_0x8000000a_0 { + // eax + u32 svm_version : 8, // SVM revision number + : 24; // Reserved + // ebx + u32 svm_nasid : 32; // Number of address space identifiers (ASID) + // ecx + u32 : 32; // Reserved + // edx + u32 nested_pt : 1, // Nested paging + lbr_virt : 1, // LBR virtualization + svm_lock : 1, // SVM lock + nrip_save : 1, // NRIP save support on #VMEXIT + tsc_rate_msr : 1, // MSR based TSC rate control + vmcb_clean : 1, // VMCB clean bits support + flush_by_asid : 1, // Flush by ASID + Extended VMCB TLB_Control + decode_assists : 1, // Decode Assists support + : 2, // Reserved + pause_filter : 1, // Pause intercept filter + : 1, // Reserved + pf_threshold : 1, // Pause filter threshold + avic : 1, // Advanced virtual interrupt controller + : 1, // Reserved + v_vmsave_vmload : 1, // Virtual VMSAVE/VMLOAD (nested virtualization) + v_gif : 1, // Virtualize the Global Interrupt Flag + gmet : 1, // Guest mode execution trap + x2avic : 1, // Virtual x2APIC + sss_check : 1, // Supervisor Shadow Stack restrictions + v_spec_ctrl : 1, // Virtual SPEC_CTRL + ro_gpt : 1, // Read-Only guest page table support + : 1, // Reserved + h_mce_override : 1, // Host MCE override + tlbsync_int : 1, // TLBSYNC intercept + INVLPGB/TLBSYNC in VMCB + nmi_virt : 1, // NMI virtualization + ibs_virt : 1, // IBS Virtualization + ext_lvt_off_chg : 1, // Extended LVT offset fault change + svme_addr_chk : 1, // Guest SVME address check + : 3; // Reserved +}; + +/* + * Leaf 0x80000019 + * AMD TLB 1G-pages enumeration + */ + +struct leaf_0x80000019_0 { + // eax + u32 l1_itlb_1g_nentries : 12, // L1 iTLB #entries, 1G pages + l1_itlb_1g_assoc : 4, // L1 iTLB associativity, 1G pages + l1_dtlb_1g_nentries : 12, // L1 dTLB #entries, 1G pages + l1_dtlb_1g_assoc : 4; // L1 dTLB associativity, 1G pages + // ebx + u32 l2_itlb_1g_nentries : 12, // L2 iTLB #entries, 1G pages + l2_itlb_1g_assoc : 4, // L2 iTLB associativity, 1G pages + l2_dtlb_1g_nentries : 12, // L2 dTLB #entries, 1G pages + l2_dtlb_1g_assoc : 4; // L2 dTLB associativity, 1G pages + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x8000001a + * AMD instruction optimizations enumeration + */ + +struct leaf_0x8000001a_0 { + // eax + u32 fp_128 : 1, // Internal FP/SIMD exec data path is 128-bits wide + movu_preferred : 1, // SSE: MOVU* better than MOVL*/MOVH* + fp_256 : 1, // internal FP/SSE exec data path is 256-bits wide + : 29; // Reserved + // ebx + u32 : 32; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x8000001b + * AMD IBS (Instruction-Based Sampling) enumeration + */ + +struct leaf_0x8000001b_0 { + // eax + u32 ibs_flags_valid : 1, // IBS feature flags valid + ibs_fetch_sampling : 1, // IBS fetch sampling supported + ibs_op_sampling : 1, // IBS execution sampling supported + ibs_rdwr_op_counter : 1, // IBS read/write of op counter supported + ibs_op_count : 1, // IBS OP counting mode supported + ibs_branch_target : 1, // IBS branch target address reporting supported + ibs_op_counters_ext : 1, // IBS IbsOpCurCnt/IbsOpMaxCnt extend by 7 bi= ts + ibs_rip_invalid_chk : 1, // IBS invalid RIP indication supported + ibs_op_branch_fuse : 1, // IBS fused branch micro-op indication suppor= ted + ibs_fetch_ctl_ext : 1, // IBS Fetch Control Extended MSR (0xc001103c) = supported + ibs_op_data_4 : 1, // IBS op data 4 MSR supported + ibs_l3_miss_filter : 1, // IBS L3-miss filtering supported (Zen4+) + : 20; // Reserved + // ebx + u32 : 32; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x8000001c + * AMD LWP (Lightweight Profiling) + */ + +struct leaf_0x8000001c_0 { + // eax + u32 os_lwp_avail : 1, // LWP is available to application programs (sup= ported by OS) + os_lpwval : 1, // LWPVAL instruction is supported by OS + os_lwp_ire : 1, // Instructions Retired Event is supported by OS + os_lwp_bre : 1, // Branch Retired Event is supported by OS + os_lwp_dme : 1, // Dcache Miss Event is supported by OS + os_lwp_cnh : 1, // CPU Clocks Not Halted event is supported by OS + os_lwp_rnh : 1, // CPU Reference clocks Not Halted event is supported= by OS + : 22, // Reserved + os_lwp_cont : 1, // LWP sampling in continuous mode is supported by OS + os_lwp_ptsc : 1, // Performance Time Stamp Counter in event records i= s supported by OS + os_lwp_int : 1; // Interrupt on threshold overflow is supported by OS + // ebx + u32 lwp_lwpcb_sz : 8, // LWP Control Block size, in quadwords + lwp_event_sz : 8, // LWP event record size, in bytes + lwp_max_events : 8, // LWP max supported EventID value (EventID 255 n= ot included) + lwp_event_offset : 8; // LWP events area offset in the LWP Control Blo= ck + // ecx + u32 lwp_latency_max : 5, // Number of bits in cache latency counters (= 10 to 31) + lwp_data_adddr : 1, // Cache miss events report the data address of t= he reference + lwp_latency_rnd : 3, // Amount by which cache latency is rounded + lwp_version : 7, // LWP implementation version + lwp_buf_min_sz : 8, // LWP event ring buffer min size, in units of 32= event records + : 4, // Reserved + lwp_branch_predict : 1, // Branches Retired events can be filtered + lwp_ip_filtering : 1, // IP filtering (IPI, IPF, BaseIP, and LimitIP @= LWPCP) supported + lwp_cache_levels : 1, // Cache-related events can be filtered by cache= level + lwp_cache_latency : 1; // Cache-related events can be filtered by late= ncy + // edx + u32 hw_lwp_avail : 1, // LWP is available in hardware + hw_lpwval : 1, // LWPVAL instruction is available in hardware + hw_lwp_ire : 1, // Instructions Retired Event is available in hardware + hw_lwp_bre : 1, // Branch Retired Event is available in hardware + hw_lwp_dme : 1, // Dcache Miss Event is available in hardware + hw_lwp_cnh : 1, // Clocks Not Halted event is available in hardware + hw_lwp_rnh : 1, // Reference clocks Not Halted event is available in = hardware + : 22, // Reserved + hw_lwp_cont : 1, // LWP sampling in continuous mode is available in h= ardware + hw_lwp_ptsc : 1, // Performance Time Stamp Counter in event records i= s available in hardware + hw_lwp_int : 1; // Interrupt on threshold overflow is available in ha= rdware +}; + +/* + * Leaf 0x8000001d + * AMD deterministic cache parameters + */ + +struct leaf_0x8000001d_0 { + // eax + u32 cache_type : 5, // Cache type field + cache_level : 3, // Cache level (1-based) + cache_self_init : 1, // Self-initializing cache level + fully_associative : 1, // Fully-associative cache + : 4, // Reserved + num_threads_sharing : 12, // Number of logical CPUs sharing cache + : 6; // Reserved + // ebx + u32 cache_linesize : 12, // System coherency line size (0-based) + cache_npartitions : 10, // Physical line partitions (0-based) + cache_nways : 10; // Ways of associativity (0-based) + // ecx + u32 cache_nsets : 31, // Cache number of sets (0-based) + : 1; // Reserved + // edx + u32 wbinvd_rll_no_guarantee : 1, // WBINVD/INVD not guaranteed for Remo= te Lower-Level caches + ll_inclusive : 1, // Cache is inclusive of Lower-Level caches + : 30; // Reserved +}; + +/* + * Leaf 0x8000001e + * AMD CPU topology enumeration + */ + +struct leaf_0x8000001e_0 { + // eax + u32 ext_apic_id : 32; // Extended APIC ID + // ebx + u32 core_id : 8, // Unique per-socket logical core unit ID + core_nthreas : 8, // #Threads per core (zero-based) + : 16; // Reserved + // ecx + u32 node_id : 8, // Node (die) ID of invoking logical CPU + nnodes_per_socket : 3, // #nodes in invoking logical CPU's package/soc= ket + : 21; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x8000001f + * AMD encrypted memory capabilities enumeration (SME/SEV) + */ + +struct leaf_0x8000001f_0 { + // eax + u32 sme : 1, // Secure Memory Encryption supported + sev : 1, // Secure Encrypted Virtualization supported + vm_page_flush : 1, // VM Page Flush MSR (0xc001011e) available + sev_encrypted_state : 1, // SEV Encrypted State supported + sev_nested_paging : 1, // SEV secure nested paging supported + vm_permission_levels : 1, // VMPL supported + rpmquery : 1, // RPMQUERY instruction supported + vmpl_sss : 1, // VMPL supervisor shadow stack supported + secure_tsc : 1, // Secure TSC supported + virt_tsc_aux : 1, // Hardware virtualizes TSC_AUX + sme_coherent : 1, // Cache coherency is enforced across encryption do= mains + req_64bit_hypervisor : 1, // SEV guest mandates 64-bit hypervisor + restricted_injection : 1, // Restricted Injection supported + alternate_injection : 1, // Alternate Injection supported + debug_swap : 1, // SEV-ES: full debug state swap is supported + disallow_host_ibs : 1, // SEV-ES: Disallowing IBS use by the host is s= upported + virt_transparent_enc : 1, // Virtual Transparent Encryption + vmgexit_paremeter : 1, // VmgexitParameter is supported in SEV_FEATURES + virt_tom_msr : 1, // Virtual TOM MSR is supported + virt_ibs : 1, // IBS state virtualization is supported for SEV-ES gue= sts + : 4, // Reserved + vmsa_reg_protection : 1, // VMSA register protection is supported + smt_protection : 1, // SMT protection is supported + : 2, // Reserved + svsm_page_msr : 1, // SVSM communication page MSR (0xc001f000) is sup= ported + nested_virt_snp_msr : 1, // VIRT_RMPUPDATE/VIRT_PSMASH MSRs are suppor= ted + : 2; // Reserved + // ebx + u32 pte_cbit_pos : 6, // PTE bit number used to enable memory encrypti= on + phys_addr_reduction_nbits : 6, // Reduction of phys address space when = encryption is enabled, in bits + vmpl_count : 4, // Number of VM permission levels (VMPL) supported + : 16; // Reserved + // ecx + u32 enc_guests_max : 32; // Max supported number of simultaneous encryp= ted guests + // edx + u32 min_sev_asid_no_sev_es : 32; // Minimum ASID for SEV-enabled SEV-ES-= disabled guest +}; + +/* + * Leaf 0x80000020 + * AMD Platform QoS extended feature IDs + */ + +struct leaf_0x80000020_0 { + // eax + u32 : 32; // Reserved + // ebx + u32 : 1, // Reserved + mba : 1, // Memory Bandwidth Allocation support + smba : 1, // Slow Memory Bandwidth Allocation support + bmec : 1, // Bandwidth Monitoring Event Configuration support + l3rr : 1, // L3 Range Reservation support + abmc : 1, // Assignable Bandwidth Monitoring Counters + sdciae : 1, // Smart Data Cache Injection (SDCI) Allocation Enforcem= ent + : 25; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +struct leaf_0x80000020_1 { + // eax + u32 mba_limit_len : 32; // MBA enforcement limit size + // ebx + u32 : 32; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 mba_cos_max : 32; // MBA max Class of Service number (zero-based) +}; + +struct leaf_0x80000020_2 { + // eax + u32 smba_limit_len : 32; // SMBA enforcement limit size + // ebx + u32 : 32; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 smba_cos_max : 32; // SMBA max Class of Service number (zero-based) +}; + +struct leaf_0x80000020_3 { + // eax + u32 : 32; // Reserved + // ebx + u32 bmec_num_events : 8, // BMEC number of bandwidth events available + : 24; // Reserved + // ecx + u32 bmec_local_reads : 1, // Local NUMA reads can be tracked + bmec_remote_reads : 1, // Remote NUMA reads can be tracked + bmec_local_nontemp_wr : 1, // Local NUMA non-temporal writes can be tr= acked + bmec_remote_nontemp_wr : 1, // Remote NUMA non-temporal writes can be = tracked + bmec_local_slow_mem_rd : 1, // Local NUMA slow-memory reads can be tra= cked + bmec_remote_slow_mem_rd : 1, // Remote NUMA slow-memory reads can be t= racked + bmec_all_dirty_victims : 1, // Dirty QoS victims to all types of memor= y can be tracked + : 25; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x80000021 + * AMD extended features enumeration 2 + */ + +struct leaf_0x80000021_0 { + // eax + u32 no_nested_data_bp : 1, // No nested data breakpoints + fsgs_non_serializing : 1, // WRMSR to {FS,GS,KERNEL_GS}_BASE is non-se= rializing + lfence_serializing : 1, // LFENCE always serializing / synchronizes RD= TSC + smm_page_cfg_lock : 1, // SMM paging configuration lock + : 2, // Reserved + null_sel_clr_base : 1, // Null selector clears base + upper_addr_ignore : 1, // EFER MSR Upper Address Ignore + auto_ibrs : 1, // EFER MSR Automatic IBRS + no_smm_ctl_msr : 1, // SMM_CTL MSR (0xc0010116) is not available + fsrs : 1, // Fast Short Rep STOSB + fsrc : 1, // Fast Short Rep CMPSB + : 1, // Reserved + prefetch_ctl_msr : 1, // Prefetch control MSR is available + : 2, // Reserved + opcode_reclaim : 1, // Reserves opcode space + user_cpuid_disable : 1, // #GP when executing CPUID at CPL > 0 is supp= orted + epsf : 1, // Enhanced Predictive Store Forwarding + : 3, // Reserved + wl_feedback : 1, // Workload-based heuristic feedback to OS + : 1, // Reserved + eraps : 1, // Enhanced Return Address Predictor Security + : 2, // Reserved + sbpb : 1, // Selective Branch Predictor Barrier + ibpb_brtype : 1, // Branch predictions flushed from CPU branch predic= tor + srso_no : 1, // CPU is not subject to the SRSO vulnerability + srso_uk_no : 1, // CPU is not vulnerable to SRSO at user-kernel bound= ary + srso_msr_fix : 1; // Software may use MSR BP_CFG[BpSpecReduce] to mit= igate SRSO + // ebx + u32 microcode_patch_size : 16, // Size of microcode patch, in 16-byte un= its + rap_size : 8, // Return Address Predictor size + : 8; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x80000022 + * AMD Performance Monitoring v2 enumeration + */ + +struct leaf_0x80000022_0 { + // eax + u32 perfmon_v2 : 1, // Performance monitoring v2 supported + lbr_v2 : 1, // Last Branch Record v2 extensions (LBR Stack) + lbr_pmc_freeze : 1, // Freezing core performance counters / LBR Stack= supported + : 29; // Reserved + // ebx + u32 n_pmc_core : 4, // Number of core performance counters + lbr_v2_stack_size : 6, // Number of available LBR stack entries + n_pmc_northbridge : 6, // Number of available northbridge (data fabric= ) performance counters + n_pmc_umc : 6, // Number of available UMC performance counters + : 10; // Reserved + // ecx + u32 active_umc_bitmask : 32; // Active UMCs bitmask + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x80000023 + * AMD Secure Multi-key Encryption enumeration + */ + +struct leaf_0x80000023_0 { + // eax + u32 mem_hmk_mode : 1, // MEM-HMK encryption mode is supported + : 31; // Reserved + // ebx + u32 mem_hmk_avail_keys : 16, // MEM-HMK mode: total number of available = encryption keys + : 16; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x80000026 + * AMD extended topology enumeration v2 + */ + +struct leaf_0x80000026_0 { + // eax + u32 x2apic_id_shift : 5, // Bit width of this level (previous levels i= nclusive) + : 24, // Reserved + core_has_pwreff_ranking : 1, // This core has a power efficiency ranki= ng + domain_has_hybrid_cores : 1, // This domain level has hybrid (E, P) co= res + domain_core_count_asymm : 1; // The 'Core' domain has asymmetric cores= count + // ebx + u32 domain_lcpus_count : 16, // Number of logical CPUs at this domain in= stance + core_pwreff_ranking : 8, // This core's static power efficiency ranking + core_native_model_id : 4, // This core's native model ID + core_type : 4; // This core's type + // ecx + u32 domain_level : 8, // This domain level (subleaf ID) + domain_type : 8, // This domain type + : 16; // Reserved + // edx + u32 x2apic_id : 32; // x2APIC ID of current logical CPU +}; + +/* + * Leaf 0x80860000 + * Maximum Transmeta leaf number + CPU vendor ID string + */ + +struct leaf_0x80860000_0 { + // eax + u32 max_tra_leaf : 32; // Maximum supported Transmeta leaf number + // ebx + u32 cpu_vendorid_0 : 32; // Transmeta Vendor ID string bytes 0 - 3 + // ecx + u32 cpu_vendorid_2 : 32; // Transmeta Vendor ID string bytes 8 - 11 + // edx + u32 cpu_vendorid_1 : 32; // Transmeta Vendor ID string bytes 4 - 7 +}; + +/* + * Leaf 0x80860001 + * Transmeta extended CPU information + */ + +struct leaf_0x80860001_0 { + // eax + u32 stepping : 4, // Stepping ID + base_model : 4, // Base CPU model ID + base_family_id : 4, // Base CPU family ID + cpu_type : 2, // CPU type + : 18; // Reserved + // ebx + u32 cpu_rev_mask_minor : 8, // CPU revision ID, mask minor + cpu_rev_mask_major : 8, // CPU revision ID, mask major + cpu_rev_minor : 8, // CPU revision ID, minor + cpu_rev_major : 8; // CPU revision ID, major + // ecx + u32 cpu_base_mhz : 32; // CPU nominal frequency, in MHz + // edx + u32 recovery : 1, // Recovery CMS is active (after bad flush) + longrun : 1, // LongRun power management capabilities + : 1, // Reserved + lrti : 1, // LongRun Table Interface + : 28; // Reserved +}; + +/* + * Leaf 0x80860002 + * Transmeta Code Morphing Software (CMS) enumeration + */ + +struct leaf_0x80860002_0 { + // eax + u32 cpu_rev_id : 32; // CPU revision ID + // ebx + u32 cms_rev_mask_2 : 8, // CMS revision ID, mask component 2 + cms_rev_mask_1 : 8, // CMS revision ID, mask component 1 + cms_rev_minor : 8, // CMS revision ID, minor + cms_rev_major : 8; // CMS revision ID, major + // ecx + u32 cms_rev_mask_3 : 32; // CMS revision ID, mask component 3 + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0x80860003 + * Transmeta CPU information string, bytes 0 - 15 + */ + +struct leaf_0x80860003_0 { + // eax + u32 cpu_info_0 : 32; // CPU info string bytes 0 - 3 + // ebx + u32 cpu_info_1 : 32; // CPU info string bytes 4 - 7 + // ecx + u32 cpu_info_2 : 32; // CPU info string bytes 8 - 11 + // edx + u32 cpu_info_3 : 32; // CPU info string bytes 12 - 15 +}; + +/* + * Leaf 0x80860004 + * Transmeta CPU information string, bytes 16 - 31 + */ + +struct leaf_0x80860004_0 { + // eax + u32 cpu_info_4 : 32; // CPU info string bytes 16 - 19 + // ebx + u32 cpu_info_5 : 32; // CPU info string bytes 20 - 23 + // ecx + u32 cpu_info_6 : 32; // CPU info string bytes 24 - 27 + // edx + u32 cpu_info_7 : 32; // CPU info string bytes 28 - 31 +}; + +/* + * Leaf 0x80860005 + * Transmeta CPU information string, bytes 32 - 47 + */ + +struct leaf_0x80860005_0 { + // eax + u32 cpu_info_8 : 32; // CPU info string bytes 32 - 35 + // ebx + u32 cpu_info_9 : 32; // CPU info string bytes 36 - 39 + // ecx + u32 cpu_info_10 : 32; // CPU info string bytes 40 - 43 + // edx + u32 cpu_info_11 : 32; // CPU info string bytes 44 - 47 +}; + +/* + * Leaf 0x80860006 + * Transmeta CPU information string, bytes 48 - 63 + */ + +struct leaf_0x80860006_0 { + // eax + u32 cpu_info_12 : 32; // CPU info string bytes 48 - 51 + // ebx + u32 cpu_info_13 : 32; // CPU info string bytes 52 - 55 + // ecx + u32 cpu_info_14 : 32; // CPU info string bytes 56 - 59 + // edx + u32 cpu_info_15 : 32; // CPU info string bytes 60 - 63 +}; + +/* + * Leaf 0x80860007 + * Transmeta live CPU information + */ + +struct leaf_0x80860007_0 { + // eax + u32 cpu_cur_mhz : 32; // Current CPU frequency, in MHz + // ebx + u32 cpu_cur_voltage : 32; // Current CPU voltage, in millivolts + // ecx + u32 cpu_cur_perf_pctg : 32; // Current CPU performance percentage, 0 - 1= 00 + // edx + u32 cpu_cur_gate_delay : 32; // Current CPU gate delay, in femtoseconds +}; + +/* + * Leaf 0xc0000000 + * Maximum Centaur/Zhaoxin leaf number + */ + +struct leaf_0xc0000000_0 { + // eax + u32 max_cntr_leaf : 32; // Maximum Centaur/Zhaoxin leaf number + // ebx + u32 : 32; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 : 32; // Reserved +}; + +/* + * Leaf 0xc0000001 + * Centaur/Zhaoxin extended CPU features + */ + +struct leaf_0xc0000001_0 { + // eax + u32 : 32; // Reserved + // ebx + u32 : 32; // Reserved + // ecx + u32 : 32; // Reserved + // edx + u32 ccs_sm2 : 1, // CCS SM2 instructions + ccs_sm2_en : 1, // CCS SM2 enabled + rng : 1, // Random Number Generator + rng_en : 1, // RNG enabled + ccs_sm3_sm4 : 1, // CCS SM3 and SM4 instructions + ccs_sm3_sm4_en : 1, // CCS SM3/SM4 enabled + ace : 1, // Advanced Cryptography Engine + ace_en : 1, // ACE enabled + ace2 : 1, // Advanced Cryptography Engine v2 + ace2_en : 1, // ACE v2 enabled + phe : 1, // PadLock Hash Engine + phe_en : 1, // PHE enabled + pmm : 1, // PadLock Montgomery Multiplier + pmm_en : 1, // PMM enabled + : 2, // Reserved + parallax : 1, // Parallax auto adjust processor voltage + parallax_en : 1, // Parallax enabled + : 2, // Reserved + tm3 : 1, // Thermal Monitor v3 + tm3_en : 1, // TM v3 enabled + : 3, // Reserved + phe2 : 1, // PadLock Hash Engine v2 (SHA384/SHA512) + phe2_en : 1, // PHE v2 enabled + rsa : 1, // RSA instructions (XMODEXP/MONTMUL2) + rsa_en : 1, // RSA instructions enabled + : 3; // Reserved +}; + +#endif /* _ASM_X86_CPUID_LEAVES */ --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 9F5AC2E3374 for ; Thu, 12 Jun 2025 23:41:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771691; cv=none; b=ssRBWiT7iFQaNz8tv1i+xM+9SJre7DTAvN1+s1Ndemi0UetoXXrUlBetA8bJQtZkiCTdNuIH07NmGnECXzaGEKdsfksJSXcu1Pl2Ku4Tw8Ew/eSRkiSbYMENJm8EkN8RV9YJ7N74Gn6OKyYmklD+Wz9xsx5XZ5M3hpEQs/kHX10= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771691; c=relaxed/simple; bh=7qlYrd8ADkiSEKc+gzHN8gdQbL+o5MjgLp2U/du+a8Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mNNCciEo84fH4L/9VdjKaX4CTuFF/mDp/+5tcOiOVRn+mmbuSu0HGX8Cv8PSOW0CMgx8jkqBWbAqBj4z2Eoze1ui6+BeN/bAzB+LoRuOlcOMFA7MVHt8hH4JvmENmWvoxeFN3K487J8viNUSSU5LR1c0g+QlUbh4qv0owWSQ49U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=bDsy54sl; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=1o6YCbtR; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="bDsy54sl"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="1o6YCbtR" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771687; h=from:from: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=HdOLrTj2U5RFTlroOZyASJWCedyIKcQ0mE4WTpPnqnQ=; b=bDsy54slVWVp23joNbyk0sACA4UFIHUZq05poudKw8mBh3sQBzURIKYAGD4kfxl9pajwRL RxxxMCTp04fTVaNPDIvoTyKQKGoi2T8Lq8/wBokqeRp7bWpUQ/lFHBf/p7jpNsI2JYMp2t d5TGShE8fBh5YnWntqY7ipMsFSk5cvhhRoXIiQgIk0WhZv90QyAueo3kOw2TW3fmfJnDpW 8FRXHQ53jXOlnDoO3Z1srwU+LK1nyP2Kup4EIeqCJYVRMt7imNr2ItsFi4dlTxzWpGqdb8 168QS81nx8U+X1X/O6D1q5wQVRk1K6/SGuR22D8e45GteI87FRVx50LsWZuvtQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771687; h=from:from: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=HdOLrTj2U5RFTlroOZyASJWCedyIKcQ0mE4WTpPnqnQ=; b=1o6YCbtRKBh/UeOiuTZC1MPuBameYd4JOdWNbCNyj/DU1vwSG0Y3GzbI0kkSHPfz5l40ag o2sQ5Akz+3FbdBAQ== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 20/44] x86/cpuid: Introduce a centralized CPUID data model Date: Fri, 13 Jun 2025 01:39:46 +0200 Message-ID: <20250612234010.572636-21-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable ** Context The x86-cpuid-db project generates a C header file with full C99 bitfield listings for all known CPUID leaf/subleaf query outputs. That header is now merged by parent commits at , and is in the form: struct leaf_0x0_0 { /* CPUID(0x0), subleaf 0, C99 bitfields */ }; ... struct leaf_0x7_0 { /* CPUID(0x7), subleaf 0, C99 bitfields */ }; struct leaf_0x7_1 { /* CPUID(0x7), subleaf 1, C99 bitfields */ }; ... ** Goal Introduce a structured, size-efficient, per-CPU, CPUID data repository. Use the x86-cpuid-db auto-generated data types, and custom CPUID leaf parsers, to build that repository. Given a leaf, subleaf, and index, provide direct memory access to the parsed and cached per-CPU CPUID output. ** Long-term goal Remove the need for drivers and other areas in the kernel to invoke direct CPUID queries. Only one place in the kernel should be allowed to use the CPUID instruction: the CPUID parser code. ** Implementation Introduce CPUID_LEAF() to build a compact CPUID storage layout in the form: struct leaf_0x0_0 leaf_0x0_0[1]; struct leaf_query_info leaf_0x0_0_info; struct leaf_0x1_0 leaf_0x1_0[1]; struct leaf_query_info leaf_0x0_0_info; struct leaf_0x4_0 leaf_0x4_0[8]; struct leaf_query_info leaf_0x4_0_info; ... where each CPUID leaf 0xN subleaf M query stores its output at the designated leaf_0xN_M[] array and has an associated "CPUID query info" structure. Introduce 'struct cpuid_leaves' to group all the parsed CPUID outputs and their metadata =E2=80=93in the layout above=E2=80=93 in one structure. Def= ine a 'struct cpuid_table' to wrap it, so that global per-table CPUID data can be added later. Embed that 'struct cpuid_table' inside 'struct cpuinfo_x86' to ensure early-boot and per-CPU access through the current CPU's capability structure. Given the data layout above, and assuming a CPU capability structure 'c', a macro can access CPUID(0x7) subleaf 0 parsed query output using the compile time tokenization below: const struct leaf_0x7_0 *l7_0; l7_0 =3D cpuid_subleaf(c, 0x7, 0); | | =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 | =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 | * * * &c.cpuid.leaf_0x7_0[0] Similarly, CPUID(0x7) subleaf 1 output can be accessed using the CPP tokenization: const struct leaf_0x7_1 *l7_1; l7_1 =3D cpuid_subleaf(c, 0x7, 1); | | =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 | =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 | * * * &c.cpuid.leaf_0x7_1[0] which all translate to a single assembly instruction offset calculation. Use an array of CPUID output storage entries for each leaf/subleaf combination to accommodate leaves which produce the same output format for a large subleaf range. This is typical for CPUID leaves enumerating hierarchical objects; e.g. CPUID(0x4) cache topology enumeration, CPUID(0xd) XSAVE enumeration, and CPUID(0x12) SGX Enclave Page Cache enumeration. In the CPUID_LEAF() data layout above, CPUID(0x4) has 8 storage entries to accomodate the suleaves 0 to 7, which all have the same bitfield's output format. With that, CPUID(0x4) subleaves 0->7 can be accessed using the compile time tokenization: const struct leaf_0x4_0 *l4_0, *l4_1, l4_2; l4_0 =3D cpuid_subleaf_index(c, 0x4, 0); | | =E2=94=94=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 | =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 | * * v &c.cpuid.leaf_0x4_0[0] l4_1 =3D cpuid_subleaf_index(c, 0x4, 1); | | =E2=94=94=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 | =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 | * * v &c.cpuid.leaf_0x4_0[1] l4_2 =3D cpuid_subleaf_index(c, 0x4, 2); | | =E2=94=94=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 | =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 | * * v &c.cpuid.leaf_0x4_0[2] where the indices 0, 1, 2 above can be provided dynamically. This is by design since call-sites hierarchical CPUID enumeration usually passes the CPUID subleaf enumeration index dynamically; e.g., within a for loop. For each of the CPUID leaf/subleaf output storage entries, attach a 'struct leaf_query_info' leaf_0xN_M_info instance. It is to be filled by the CPUID parsing logic filling the CPUID table(s). For now, this info structure has one element: the number of filled slots by the CPUID paraser in the CPUID leaf/subleaf output storage array. ** Call-site APIs Introduce below APIs for CPUID leaves with static subleaves: cpuid_subleaf(_cpuinfo, _leaf, _subleaf) cpuid_leaf(_cpuinfo, _leaf) cpuid_leaf_regs(_cpuinfo, _leaf) And below APIs for CPUID leaves with dynamic subleaves: cpuid_subleaf_count(_cpuinfo, _leaf) cpuid_subleaf_index(_cpuinfo, _leaf, _idx) cpuid_subleaf_index_regs(_cpuinfo, _leaf, _idx) At , add a clear rationale for why call sites should use the above APIs instead of directly invoking CPUID queries. ** Next steps For now, define entries for CPUID(0x0) and CPUID(0x1) in the CPUID table. Generic CPUID parser logic to fill the per-CPU CPUID tables, along with more CPUID leaves support, will be added next. Suggested-by: Thomas Gleixner # CPUID data model Suggested-by: Andrew Cooper # x86-cpuid-db sche= ma Suggested-by: Ingo Molnar # CPUID APIs restructuring Signed-off-by: Ahmed S. Darwish Link: https://lore.kernel.org/lkml/874ixernra.ffs@tglx Link: https://gitlab.com/x86-cpuid.org/x86-cpuid-db --- arch/x86/include/asm/cpuid/api.h | 254 +++++++++++++++++++++++++++++ arch/x86/include/asm/cpuid/types.h | 104 ++++++++++++ arch/x86/include/asm/processor.h | 1 + 3 files changed, 359 insertions(+) diff --git a/arch/x86/include/asm/cpuid/api.h b/arch/x86/include/asm/cpuid/= api.h index 2b9750cc8a75..b277c82e062f 100644 --- a/arch/x86/include/asm/cpuid/api.h +++ b/arch/x86/include/asm/cpuid/api.h @@ -289,4 +289,258 @@ static inline bool cpuid_amd_hygon_has_l3_cache(void) return cpuid_edx(0x80000006); } =20 +/* + * 'struct cpuid_leaves' accessors: + * + * For internal-use by the CPUID parser. These macros do not perform any + * sanity checks. + */ + +/** + * __cpuid_leaves_subleaf_idx() - Get parsed CPUID output (without sanity = checks) + * @_leaves: &struct cpuid_leaves instance + * @_leaf: CPUID leaf, in compile-time 0xN format + * @_subleaf: CPUID subleaf, in compile-time decimal format + * @_idx: @_leaf/@_subleaf CPUID output's storage array index. Check + * __CPUID_LEAF() for info on CPUID output storage arrays indexing. + * + * Returns the parsed CPUID output at @_leaves as a d= ata + * type: 'struct leaf_0xN_M', where 0xN is the token provided at @_leaf, a= nd M + * is token provided at @_subleaf. + */ +#define __cpuid_leaves_subleaf_idx(_leaves, _leaf, _subleaf, _idx) \ + ((_leaves)->leaf_ ## _leaf ## _ ## _subleaf)[_idx] + +/** + * __cpuid_leaves_subleaf_0() - Get parsed CPUID output (without sanity ch= ecks) + * @_leaves: &struct cpuid_leaves instance + * @_leaf: CPUID leaf, in compile-time 0xN format + * + * Like __cpuid_leaves_subleaf_idx(), but with subleaf =3D 0 and index =3D= 0. + */ +#define __cpuid_leaves_subleaf_0(_leaves, _leaf) \ + __cpuid_leaves_subleaf_idx(_leaves, _leaf, 0, 0) + +/** + * __cpuid_leaves_subleaf_info() - Get CPUID query info for @_leaf/@_suble= af + * @_leaves: &struct cpuid_leaves instance + * @_leaf: CPUID leaf, in compile-time 0xN format + * @_subleaf: CPUID subleaf, in compile-time decimal format + * + * Returns a pointer to the &struct leaf_query_info instance associated wi= th + * the given @_leaf/@_subleaf pair at the CPUID @_leaves data repository. = See + * __CPUID_LEAF(). + */ +#define __cpuid_leaves_subleaf_info(_leaves, _leaf, _subleaf) \ + ((_leaves)->leaf_ ## _leaf ## _ ## _subleaf ## _ ## info) + +/* + * 'struct cpuid_table' accessors: + * + * For internal-use by the CPUID parser. These macros perform the necessa= ry + * sanity checks by default. + */ + +/** + * __cpuid_table_subleaf_idx() - Get parsed CPUID output (with sanity chec= ks) + * @_table: &struct cpuid_table instance + * @_leaf: CPUID leaf, in compile-time 0xN format + * @_subleaf: CPUID subleaf, in compile-time decimal format + * @_idx: @_leaf/@_subleaf CPUID query output's storage array index. + * See __CPUID_LEAF(). + * + * Return a pointer to the requested parsed CPUID output at @_table, as a + * data type: 'struct leaf_0xN_M', where 0xN is the t= oken + * provided at @_leaf, and M is the token provided at @_subleaf; e.g. 'str= uct + * leaf_0x7_0'. + * + * Returns NULL if the requested CPUID @_leaf/@_subleaf/@_idx query output= is + * not present at @_table. + */ +#define __cpuid_table_subleaf_idx(_table, _leaf, _subleaf, _idx) \ + (((_idx) >=3D __cpuid_leaves_subleaf_info(&((_table)->leaves), _leaf, _su= bleaf).nr_entries) ? \ + NULL : &__cpuid_leaves_subleaf_idx(&((_table)->leaves), _leaf, _subleaf,= _idx)) + +/** + * __cpuid_table_subleaf() - Get parsed CPUID output (with sanity checks) + * @_table: &struct cpuid_table instance + * @_leaf: CPUID leaf, in compile-time 0xN format + * @_subleaf: CPUID subleaf, in compile-time decimal format + * + * Like __cpuid_table_subleaf_idx(), but with CPUID output storage index = =3D 0. + */ +#define __cpuid_table_subleaf(_table, _leaf, _subleaf) \ + __cpuid_table_subleaf_idx(_table, _leaf, _subleaf, 0) + +/* + * External APIs for accessing parsed CPUID data: + * + * Call sites should use below APIs instead of invoking direct CPUID queri= es. + * + * Benefits include: + * + * - Return CPUID output as typed C structures that are auto-generated fro= m a + * centralized database (see data type: 'struct leaf_0xN_M', wh= ere + * 0xN is the token provided at @_leaf, and M is the token provided at + * @_subleaf; e.g. struct leaf_0x7_0. + * + * Returns NULL if the requested CPUID @_leaf/@_subleaf query output is not + * present at the parsed CPUID table inside @_cpuinfo. This can happen if: + * + * - The CPUID table inside @_cpuinfo has not yet been populated. + * - The CPUID table inside @_cpuinfo was populated, but the CPU does not + * implement the requested CPUID @_leaf/@_subleaf combination. + * - The CPUID table inside @_cpuinfo was populated, but the kernel's CPUID + * parser has predetermined that the requested CPUID @_leaf/@_subleaf + * hardware output is invalid or unsupported. + * + * Example usage:: + * + * const struct leaf_0x7_0 *l7_0 =3D cpuid_subleaf(c, 0x7, 0); + * if (!l7_0) { + * // Handle error + * } + * + * const struct leaf_0x7_1 *l7_1 =3D cpuid_subleaf(c, 0x7, 1); + * if (!l7_1) { + * // Handle error + * } + */ +#define cpuid_subleaf(_cpuinfo, _leaf, _subleaf) \ + __cpuid_table_subleaf(&_cpuinfo->cpuid, _leaf, _subleaf) + +/** + * cpuid_leaf() - Access parsed CPUID data + * @_cpuinfo: CPU capability structure reference ('struct cpuinfo_x86') + * @_leaf: CPUID leaf, in compile-time 0xN format; e.g. 0x0, 0x2, 0x800000= 00 + * + * Similar to cpuid_subleaf(), but with a CPUID subleaf =3D 0. + * + * Example usage:: + * + * const struct leaf_0x0_0 *l0 =3D cpuid_leaf(c, 0x0); + * if (!l0) { + * // Handle error + * } + * + * const struct leaf_0x80000000_0 *el0 =3D cpuid_leaf(c, 0x80000000); + * if (!el0) { + * // Handle error + * } + */ +#define cpuid_leaf(_cpuinfo, _leaf) \ + cpuid_subleaf(_cpuinfo, _leaf, 0) + +/** + * cpuid_leaf_regs() - Access parsed CPUID data in raw format + * @_cpuinfo: CPU capability structure reference ('struct cpuinfo_x86') + * @_leaf: CPUID leaf, in compile-time 0xN format + * + * Similar to cpuid_leaf(), but returns a raw 'struct cpuid_regs' pointer = to + * the parsed CPUID data instead of a "typed" pointer. + */ +#define cpuid_leaf_regs(_cpuinfo, _leaf) \ + ((struct cpuid_regs *)(cpuid_leaf(_cpuinfo, _leaf))) + +#define __cpuid_assert_leaf_has_dynamic_subleaves(_cpuinfo, _leaf) \ + static_assert(ARRAY_SIZE(_cpuinfo->cpuid.leaves.leaf_ ## _leaf ## _0) > 1= ); + +/** + * cpuid_subleaf_index() - Access parsed CPUID data at runtime subleaf ind= ex + * @_cpuinfo: CPU capability structure reference ('struct cpuinfo_x86') + * @_leaf: CPUID leaf, in compile-time 0xN format; e.g. 0x4, 0x8000001d + * @_idx: Index within CPUID(@_leaf) output storage array. It must be + * smaller than "cpuid_subleaf_count(@_cpuinfo, @_leaf)". Unlike + * @_leaf, this value can be provided dynamically. + * + * For a given leaf/subleaf combination, the CPUID table inside @_cpuinfo + * contains an array of CPUID output storage entries. An array of storage + * entries is used to accommodate CPUID leaves which produce the same outp= ut + * format for a large subleaf range. This is common for CPUID hierarchical + * objects enumeration; e.g., CPUID(0x4) and CPUID(0xd). Check CPUID_LEAF= (). + * + * CPUID leaves that are to be accessed using this macro are specified at + * , 'struct cpuid_leaves', with a CPUID_LEAF() count field + * bigger than 1. A build-time error will be generated otherwise. + * + * Example usage:: + * + * const struct leaf_0x4_0 *l4; + * + * for (int i =3D 0; i < cpuid_subleaf_count(c, 0x4); i++) { + * l4 =3D cpuid_subleaf_index(c, 0x4, i); + * if (!l4) { + * // Handle error + * } + * + * // Access CPUID(0x4, i) data; e.g. l4->cache_type + * } + * + * Beside the standard error situations detailed at cpuid_subleaf(), this + * macro will return NULL if @_idx is out of range. + */ +#define cpuid_subleaf_index(_cpuinfo, _leaf, _idx) \ +({ \ + __cpuid_assert_leaf_has_dynamic_subleaves(_cpuinfo, _leaf); \ + __cpuid_table_subleaf_idx(&_cpuinfo->cpuid, _leaf, 0, _idx); \ +}) + +/** + * cpuid_subleaf_index_regs() - Access parsed CPUID data at runtime sublea= f index + * @_cpuinfo: CPU capability structure reference ('struct cpuinfo_x86') + * @_leaf: CPUID leaf, in compile-time 0xN format; e.g. 0x4, 0x8000001d + * @_idx: Index within CPUID(@_leaf) output storage array. It must be + * smaller than "cpuid_subleaf_count(@_cpuinfo, @_leaf)". + * + * Similar to cpuid_subleaf_index(), but returns a raw 'struct cpuid_regs' + * pointer to the parsed CPUID data, instead of a "typed" + * pointer. + */ +#define cpuid_subleaf_index_regs(_cpuinfo, _leaf, _idx) \ + ((struct cpuid_regs *)cpuid_subleaf_index(_cpuinfo, _leaf, _idx)) + +/** + * cpuid_subleaf_count() - Number of valid (filled) subleaves for @_leaf + * @_cpuinfo: CPU capability structure reference ('struct cpuinfo_x86') + * @_leaf: CPUID leaf, in compile-time 0xN format; e.g. 0x4, 0x8000001d + * + * Return the number of subleaves filled by the CPUID parser for @_leaf. C= heck + * cpuid_subleaf_index(). + * + * CPUID leaves that are to be accessed using this macro are specified at + * , 'struct cpuid_leaves', with a CPUID_LEAF() count field + * bigger than 1. A build-time error will be generated otherwise. + */ +#define cpuid_subleaf_count(_cpuinfo, _leaf) \ +({ \ + __cpuid_assert_leaf_has_dynamic_subleaves(_cpuinfo, _leaf); \ + __cpuid_leaves_subleaf_info(&_cpuinfo->cpuid.leaves, _leaf, 0).nr_entries= ;\ +}) + #endif /* _ASM_X86_CPUID_API_H */ diff --git a/arch/x86/include/asm/cpuid/types.h b/arch/x86/include/asm/cpui= d/types.h index 8a00364b79de..f1b51ba21ca4 100644 --- a/arch/x86/include/asm/cpuid/types.h +++ b/arch/x86/include/asm/cpuid/types.h @@ -5,6 +5,8 @@ #include #include =20 +#include + /* * Types for raw CPUID access: */ @@ -124,4 +126,106 @@ extern const struct leaf_0x2_table cpuid_0x2_table[25= 6]; */ #define TLB_0x63_2M_4M_ENTRIES 32 =20 +/* + * Types for centralized CPUID tables: + * + * For internal use by the CPUID parser. + */ + +/** + * struct leaf_query_info - Parse info for a CPUID leaf/subleaf query + * @nr_entries: Number of valid output storage entries filled by the CPUID= parser + * + * In a CPUID table (struct cpuid_leaves), each CPUID leaf/subleaf query o= utput + * storage entry from is paired with a unique instanc= e of + * this type. + */ +struct leaf_query_info { + unsigned int nr_entries; +}; + +/** + * __CPUID_LEAF() - Define CPUID output storage and query info entry + * @_name: Struct type name of the CPUID leaf/subleaf (e.g. 'leaf_0x4_0'). + * Such types are defined at , and follow the + * format 'struct leaf_0xN_M', where 0xN is the leaf and M is the + * subleaf. + * @_count: Number of storage entries to allocate for this leaf/subleaf + * + * For the given leaf/subleaf combination, define an array of CPUID output + * storage entries and an associated query info structure =E2=80=94 both r= esiding in a + * 'struct cpuid_leaves' instance. + * + * Use an array of storage entries to accommodate CPUID leaves which produ= ce + * the same output format for a large subleaf range. This is common for + * hierarchical objects enumeration; e.g., CPUID(0x4), CPUID(0xd), and + * CPUID(0x12). + * + * The example invocation for CPUID(0x7) storage, subleaves 0->1: + * + * __CPUID_LEAF(leaf_0x7_0, 1); + * __CPUID_LEAF(leaf_0x7_1, 1); + * + * generates 'struct cpuid_leaves' storage entries in the form:: + * + * struct leaf_0x7_0 leaf_0x7_0[1]; + * struct leaf_query_info leaf_0x7_0_info; + * + * struct leaf_0x7_1 leaf_0x7_1[1]; + * struct leaf_query_info leaf_0x7_1_info; + * + * The example invocation for CPUID(0x4) storage:: + * + * __CPUID_LEAF(leaf_0x4_0, 8); + * + * generates storage entries in the form: + * + * struct leaf_0x4_0 leaf_0x4_0[8]; + * struct leaf_query_info leaf_0x4_0_info; + * + * where the 'leaf_0x4_0[8]' storage array can accommodate the output of + * CPUID(0x4) subleaves 0->7, since they all have the same output format. + */ +#define __CPUID_LEAF(_name, _count) \ + struct _name _name[_count]; \ + struct leaf_query_info _name##_info + +/** + * CPUID_LEAF() - Define a CPUID storage entry in 'struct cpuid_leaves' + * @_leaf: CPUID Leaf number in the 0xN format; e.g., 0x4. + * @_subleaf: Subleaf number in decimal + * @_count: Number of repeated storage entries for this @_leaf/@_subleaf + * + * Convenience wrapper around __CPUID_LEAF(). + */ +#define CPUID_LEAF(_leaf, _subleaf, _count) \ + __CPUID_LEAF(leaf_ ## _leaf ## _ ## _subleaf, _count) + +/* + * struct cpuid_leaves - Structured CPUID data repository + */ +struct cpuid_leaves { + /* leaf subleaf count */ + CPUID_LEAF(0x0, 0, 1); + CPUID_LEAF(0x1, 0, 1); +}; + +/* + * Types for centralized CPUID tables: + * + * For external use. + */ + +/** + * struct cpuid_table - Per-CPU CPUID data repository + * @leaves: CPUID leaf/subleaf queries' output and metadata + * + * Embedded inside 'struct cpuinfo_x86' to provide access to stored, parse= d, + * and sanitized CPUID output per-CPU. Thus removing the need for any dir= ect + * CPUID query by call sites. + */ +struct cpuid_table { + struct cpuid_leaves leaves; +}; + #endif /* _ASM_X86_CPUID_TYPES_H */ diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/proces= sor.h index bde58f6510ac..b5d90b60191b 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -165,6 +165,7 @@ struct cpuinfo_x86 { char x86_vendor_id[16]; char x86_model_id[64]; struct cpuinfo_topology topo; + struct cpuid_table cpuid; /* in KB - valid for CPUS which support this call: */ unsigned int x86_cache_size; int x86_cache_alignment; /* In bytes */ --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 150D82E765D for ; Thu, 12 Jun 2025 23:41:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771694; cv=none; b=mnK8Fg++l0D4lE7hs1I7ZP77iBsbDguUhuaGUaGng1wyHNYBeWNENk3r+Z4GMrCgoP7ds+hMqu+ENtbupl6dErGyJZPpFx2EhGziawo3/76x5yBbl5/f8TUEbA2/kLatwE1uzFfMP40F7d/zGHRxBAKv4NEmMl+CWDW4aUAugnk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771694; c=relaxed/simple; bh=Br2MhpkVuZh3+/cv3ccqxj4b9D2nXRTOCHF1OSeOtwY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yb4B+/Q0Kht76e4X6KuAG4zD9UKhcpkNWbA5qSB+BvWrTlEWWnG5G47uF2b+R8JvxkvXR1T9KvJBISzbTCA0FQd26oHMaqjwdEN/NwRYdBD3C3UCDfVtgZy/C0cAwWynhUhyQ1uaJRJlFfoD0Tr5U0vFCz1iVL/TiCPTtxTVlaE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=BhdAAUih; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=sBKvciyd; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="BhdAAUih"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="sBKvciyd" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1sfGuVsoYi10+GGV/LFH78iI6yDFtHz0rLTs8wO6ktc=; b=BhdAAUihBbor8ZkRFrWgW4CBOZffETCG7B2MTFhd5RFhjPzWoz5OonOv+LyQCUkf6/+Tys 4vZOWXdSYpjzKeG19zsJoBX6wJuYnRNFlnAZRDgfP0y6yPqLuLXWaLgHwjh2kgAGbuFaVM p4e+PGq+rjRhP4yd1RZR9FszE7A7X6hkXTLkvg42zweUj23K32Mcb8cqzmrZzo0qBE2Zwa CcEx9VXyFqwRjCK+QUuT+t6huw5Zk3j2JiBrMij2D3LiTLx6Eawu5mcxV4IEnmN8qmbpd2 uG95op6hA01Z+HI/sP7J3+M1RybyPymHfUfGKBkzgPNybyI0IGu9mQ5u+UfxUw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1sfGuVsoYi10+GGV/LFH78iI6yDFtHz0rLTs8wO6ktc=; b=sBKvciydEMZCGzJYEe9loYzPAPNVFIIfxsdAE3AsdQW/krKROdDu0VeDh8qNMI2qyZQ0J2 3aZ9PGr7aVIqPmCQ== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 21/44] x86/cpuid: Introduce a centralized CPUID parser Date: Fri, 13 Jun 2025 01:39:47 +0200 Message-ID: <20250612234010.572636-22-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce a centralized CPUID parser to populate the per-CPU CPUID tables. To ensures consistent and early availablity of parsed CPUID data, invoke this parser during both early boot and secondary CPUs bring up. Since accessing the CPUID leaf output storage areas at 'struct cpuid_table' requires compile time tokenization, split the parser implementation into two stages: compile time macros for tokenizing the leaf/subleaf output offsets within a CPUID table, and generic runtime code to access and populate the relevant CPUID leaf/subleaf data structures using such offsets. For flexible parsing of CPUID leaf/subleaf outputs, support both generic and leaf-specific CPUID read functions. Note, add three section headers to cpuid_parser.c: "Leaf read functions", "Leaf-independent parser code", and "Exported APIs". Each section will be further expanded next. Suggested-by: Thomas Gleixner Signed-off-by: Ahmed S. Darwish --- arch/x86/include/asm/cpuid/api.h | 7 ++ arch/x86/include/asm/cpuid/types.h | 3 + arch/x86/kernel/cpu/Makefile | 1 + arch/x86/kernel/cpu/common.c | 2 + arch/x86/kernel/cpu/cpuid_parser.c | 114 +++++++++++++++++++++++++++++ arch/x86/kernel/cpu/cpuid_parser.h | 100 +++++++++++++++++++++++++ 6 files changed, 227 insertions(+) create mode 100644 arch/x86/kernel/cpu/cpuid_parser.c create mode 100644 arch/x86/kernel/cpu/cpuid_parser.h diff --git a/arch/x86/include/asm/cpuid/api.h b/arch/x86/include/asm/cpuid/= api.h index b277c82e062f..dbc954e21b7e 100644 --- a/arch/x86/include/asm/cpuid/api.h +++ b/arch/x86/include/asm/cpuid/api.h @@ -7,6 +7,7 @@ #include #include =20 +#include #include =20 /* @@ -543,4 +544,10 @@ static inline bool cpuid_amd_hygon_has_l3_cache(void) __cpuid_leaves_subleaf_info(&_cpuinfo->cpuid.leaves, _leaf, 0).nr_entries= ;\ }) =20 +/* + * CPUID parser exported APIs: + */ + +void cpuid_parser_scan_cpu(struct cpuinfo_x86 *c); + #endif /* _ASM_X86_CPUID_API_H */ diff --git a/arch/x86/include/asm/cpuid/types.h b/arch/x86/include/asm/cpui= d/types.h index f1b51ba21ca4..320f152675af 100644 --- a/arch/x86/include/asm/cpuid/types.h +++ b/arch/x86/include/asm/cpuid/types.h @@ -32,6 +32,9 @@ enum cpuid_regs_idx { #define CPUID_LEAF_FREQ 0x16 #define CPUID_LEAF_TILE 0x1d =20 +#define CPUID_BASE_START 0x0 +#define CPUID_BASE_END (CPUID_BASE_START + 0xffff) + /* * Types for CPUID(0x2) parsing: */ diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile index 1e26179ff18c..b2421cfb59ed 100644 --- a/arch/x86/kernel/cpu/Makefile +++ b/arch/x86/kernel/cpu/Makefile @@ -19,6 +19,7 @@ KCSAN_SANITIZE_common.o :=3D n =20 obj-y :=3D cacheinfo.o scattered.o obj-y +=3D topology_common.o topology_ext.o topology_amd.o +obj-y +=3D cpuid_parser.o obj-y +=3D common.o obj-y +=3D rdrand.o obj-y +=3D match.o diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 8feb8fd2957a..8aa3ba269c0b 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1716,6 +1716,7 @@ static void __init early_identify_cpu(struct cpuinfo_= x86 *c) =20 /* cyrix could have cpuid enabled via c_identify()*/ if (cpuid_feature()) { + cpuid_parser_scan_cpu(c); cpu_detect(c); get_cpu_vendor(c); intel_unlock_cpuid_leafs(c); @@ -2096,6 +2097,7 @@ void identify_secondary_cpu(unsigned int cpu) *c =3D boot_cpu_data; c->cpu_index =3D cpu; =20 + cpuid_parser_scan_cpu(c); identify_cpu(c); #ifdef CONFIG_X86_32 enable_sep_cpu(); diff --git a/arch/x86/kernel/cpu/cpuid_parser.c b/arch/x86/kernel/cpu/cpuid= _parser.c new file mode 100644 index 000000000000..3a0215e75795 --- /dev/null +++ b/arch/x86/kernel/cpu/cpuid_parser.c @@ -0,0 +1,114 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Centralized CPUID parser (for populating the system's CPUID tables.) + */ + +#include +#include + +#include +#include +#include + +#include "cpuid_parser.h" + +/* + * Leaf read functions: + */ + +/* + * Default CPUID parser read function + * + * Satisfies the requirements stated at 'struct cpuid_parse_entry'->read(). + */ +static void cpuid_read_generic(const struct cpuid_parse_entry *e, struct c= puid_read_output *output) +{ + for (int i =3D 0; i < e->maxcnt; i++, output->regs++, output->info->nr_en= tries++) + cpuid_read_subleaf(e->leaf, e->subleaf + i, output->regs); +} + +/* + * Leaf-independent parser code: + */ + +static unsigned int cpuid_range_max_leaf(const struct cpuid_table *t, unsi= gned int range) +{ + switch (range) { + case CPUID_BASE_START: return __cpuid_leaves_subleaf_0(&t->leaves, 0x0).m= ax_std_leaf; + default: return 0; + } +} + +static bool +cpuid_range_valid(const struct cpuid_table *t, unsigned int leaf, unsigned= int start, unsigned int end) +{ + if (leaf < start || leaf > end) + return false; + + return leaf =3D=3D start || leaf <=3D cpuid_range_max_leaf(t, start); +} + +static bool cpuid_leaf_valid(const struct cpuid_table *t, unsigned int lea= f) +{ + return cpuid_range_valid(t, leaf, CPUID_BASE_START, CPUID_BASE_END); +} + +static const struct cpuid_parse_entry cpuid_common_parse_entries[] =3D { + CPUID_PARSE_ENTRIES +}; + +static void +cpuid_fill_table(struct cpuid_table *t, const struct cpuid_parse_entry ent= ries[], unsigned int nr_entries) +{ + const struct cpuid_parse_entry *entry =3D entries; + + for (unsigned int i =3D 0; i < nr_entries; i++, entry++) { + struct cpuid_read_output output =3D { + .regs =3D cpuid_table_query_regs_p(t, entry->regs_offs), + .info =3D cpuid_table_query_info_p(t, entry->info_offs), + }; + + if (!cpuid_leaf_valid(t, entry->leaf)) + continue; + + WARN_ON_ONCE(output.info->nr_entries !=3D 0); + entry->read(entry, &output); + } +} + +/* + * Exported APIs: + */ + +/** + * cpuid_parser_scan_cpu() - Populate current CPU's CPUID table + * @c: CPU capability structure associated with the current CPU + * + * Populate the CPUID table embedded within @c with parsed CPUID data. Si= nce all CPUID + * instructions are invoked locally, this must be called on the CPU associ= ated with @c. + */ +void cpuid_parser_scan_cpu(struct cpuinfo_x86 *c) +{ + struct cpuid_table *table =3D &c->cpuid; + + /* + * For correctness, clear the CPUID table first. + * + * This is due to the CPUID leaf access APIs at using the l= eaf's + * "nr_entries" field as a validity check. If the field is non-zero, the= macros + * assume that the cached leaf outputs are valid and return them. Otherw= ise, NULL + * is returned. + * + * On the primary CPU, the CPUID tables are zeroed at boot. For secondar= y CPUs, + * the capability structures (containing the CPUID table) are copied from= the + * primary CPU. This would result in a "nr_entries" values carry-over fr= om the + * primary CPU unless the table is explicitly cleared. + * + * Also, for CPUID table re-scans, which are triggered by hardware state = changes, + * previously valid CPUID leaves might become invalid. The CPUID table, = and its + * leaves' "nr_entries" fields, must thus be cleared beforehand. + */ + memset(table, 0, sizeof(*table)); + + cpuid_fill_table(table, cpuid_common_parse_entries, ARRAY_SIZE(cpuid_comm= on_parse_entries)); +} diff --git a/arch/x86/kernel/cpu/cpuid_parser.h b/arch/x86/kernel/cpu/cpuid= _parser.h new file mode 100644 index 000000000000..41499fa36fdc --- /dev/null +++ b/arch/x86/kernel/cpu/cpuid_parser.h @@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ARCH_X86_CPUID_PARSER_H +#define _ARCH_X86_CPUID_PARSER_H + +#include + +/* + * 'struct cpuid_leaves' CPUID query output storage area accessors: + * + * @_leaf: CPUID leaf, in compile-time 0xN format + * @_subleaf: CPUID subleaf, in compile-time decimal format + * + * Since accessing the CPUID leaf output storage areas at 'struct cpuid_le= aves' requires + * compile time tokenization, split the CPUID parser implementation into t= wo stages: + * compile time macros for tokenizing the leaf/subleaf output offsets with= in the CPUID + * table, and generic runtime code to access and populate the relevant CPU= ID leaf/subleaf + * output data structures using such offsets. + * + * That is, the output of the __cpuid_leaves_query_*_offset() macros will= be cached by a + * compile time "parse entry" (see 'struct cpuid_parse_entry'). The runti= me parser code + * will then utilize such offsets by passing them to cpuid_table_query_*_p= () functions. + */ + +#define __cpuid_leaves_query_regs_offset(_leaf, _subleaf) \ + offsetof(struct cpuid_leaves, leaf_ ## _leaf ## _ ## _subleaf) + +#define __cpuid_leaves_query_info_offset(_leaf, _subleaf) \ + offsetof(struct cpuid_leaves, leaf_ ## _leaf ## _ ## _subleaf ## _ ## inf= o) + +#define __cpuid_leaves_query_regs_maxcnt(_leaf, _subleaf) \ + ARRAY_SIZE(((struct cpuid_leaves *)NULL)->leaf_ ## _leaf ## _ ## _subleaf) + +static inline struct cpuid_regs * +cpuid_table_query_regs_p(const struct cpuid_table *t, unsigned long regs_o= ffset) +{ + return (struct cpuid_regs *)((unsigned long)(&t->leaves) + regs_offset); +} + +static inline struct leaf_query_info * +cpuid_table_query_info_p(const struct cpuid_table *t, unsigned long info_o= ffset) +{ + return (struct leaf_query_info *)((unsigned long)(&t->leaves) + info_offs= et); +} + +/** + * struct cpuid_read_output - Output of a CPUID parser read operation + * @regs: Pointer to an array of CPUID outputs, where each array element c= overs the + * full EAX->EDX output range. + * @info: Pointer to query info; for saving the number of filled @regs arr= ay elements. + * + * A CPUID parser read function like cpuid_read_generic() or cpuid_read_0x= N() uses this + * structure to save its CPUID query outputs. Actual storage for @regs an= d @info is provided + * by its caller, and is typically within a CPU's CPUID table (struct cpui= d_table.leaves). + * + * See struct cpuid_parse_entry.read(). + */ +struct cpuid_read_output { + struct cpuid_regs *regs; + struct leaf_query_info *info; +}; + +/** + * struct cpuid_parse_entry - Runtime CPUID parsing context for @leaf/@sub= leaf + * @leaf: Leaf number to be parsed + * @subleaf: Subleaf number to be parsed + * @regs_offs: Offset within 'struct cpuid_leaves' for saving CPUID @leaf/= @subleaf output; to be + * passed to cpuid_table_query_regs_p(). + * @info_offs: Offset within 'struct cpuid_leaves' for accessing @leaf/@su= bleaf parse info; to be + * passed to cpuid_table_query_info_p(). + * @maxcnt: Maximum number of output storage entries available for the @le= af/@subleaf query + * @read: Read function for this entry. It must save the parsed CPUID out= put to the passed + * 'struct cpuid_read_output'->regs registers array of size >=3D @maxcnt.= It must set + * 'struct cpuid_read_output'->info.nr_entries to the actual number of st= orage output + * entries filled. A generic implementation is provided at cpuid_read_ge= neric(). + */ +struct cpuid_parse_entry { + unsigned int leaf; + unsigned int subleaf; + unsigned int regs_offs; + unsigned int info_offs; + unsigned int maxcnt; + void (*read)(const struct cpuid_parse_entry *e, struct cpuid_read_output= *o); +}; + +#define CPUID_PARSE_ENTRY(_leaf, _subleaf, _reader_fn) \ + { \ + .leaf =3D _leaf, \ + .subleaf =3D _subleaf, \ + .regs_offs =3D __cpuid_leaves_query_regs_offset(_leaf, _subleaf), \ + .info_offs =3D __cpuid_leaves_query_info_offset(_leaf, _subleaf), \ + .maxcnt =3D __cpuid_leaves_query_regs_maxcnt(_leaf, _subleaf), \ + .read =3D cpuid_read_ ## _reader_fn, \ + } + +#define CPUID_PARSE_ENTRIES \ + /* Leaf Subleaf Reader function */ \ + CPUID_PARSE_ENTRY(0x0, 0, generic), \ + CPUID_PARSE_ENTRY(0x1, 0, generic), \ + +#endif /* _ARCH_X86_CPUID_PARSER_H */ --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 305F32E7F3C for ; Thu, 12 Jun 2025 23:41:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771697; cv=none; b=q79ZR/gWYlADfXoAFgapcX1FrqSuFlUfYEOMIYpYKasZkaY54+qirE8fnsOFXwD20EBpL1YzcOqLnob81vLxjgOYHijojkagriIzsgGzzjH7NYZ42VaRLy3P3IoSY3+XBLAZCMKOivT5/dejrKxoGvNfy5MiEZRh+ABCGyqiJt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771697; c=relaxed/simple; bh=NO0cbM/Mwx3CrlSUKijbUIuqtnuX4RJgbFvuEtuGHV4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CV0YoZ1AzDmYpkIuLAZfLsACWRyc5pUxzB79zKMSQSbIDf6qpsg6aGVSL7uyTd4v1FBicVWpc7w7CymJLk4gwjzIkP4VUr1mtWXrx5IqBTVxYpoJjLo2aVqUrUiDMAphY8e4gOH1DcmXR7osYDrpw4+JacggXtHQJarArZArzgg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=JoU8TjhF; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=fft/BwPY; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JoU8TjhF"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fft/BwPY" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iLede88b8Ofo343hNkFru5ebfUcWPc2UOkTgoq77d6g=; b=JoU8TjhFHVB79eEnLSNjDedd0oeu+XcaemKRSg6na5fAdhtXqMTFved9n4pkGkogEpicjf +eWiBFbYf59RWGTqcH9VVPtZO84sxXQD8Eprg/9Alff7Mg983w3b+5rH5yJoW92W3i5935 e8DrhicTUGyyeH/EEuIRTgKZ7k1zU1fuMZ+gI5ebLxXLk5ZWuQq9AwhU2AOWLEp8kaXmg0 pY3AbD+N6aFmJWXCvdgF65o5VRISto41Cde6tomf2/5qh6p6b6vbBjyXamk+Z3kQMROdNH RBz0exGloAJCQBNoRpCCf8laog12BNx+5o/a3l08NkOSBe/+YskJ69TjLV41Gg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iLede88b8Ofo343hNkFru5ebfUcWPc2UOkTgoq77d6g=; b=fft/BwPYKvA5P/EvTv9OyZmPf0o97BQ15AcMN8JMkqvdnDktw6XcllMX598uzNBVnPZTgL lkiSK18XgU45l/Bg== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 22/44] x86/cpuid: Parse CPUID(0x80000000) Date: Fri, 13 Jun 2025 01:39:48 +0200 Message-ID: <20250612234010.572636-23-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add CPUID parser logic for CPUID(0x80000000). Similar to kernel/head_32.S and kernel/cpu/common.c, verify the CPUID(0x80000000) query output beforehand. This is due to x86-32 machines without an extended CPUID range, where a CPUID(0x80000000) query will just repeat the max-valid standard CPUID leaf output. References: 8a50e5135af0 ("x86-32: Use symbolic constants, safer CPUID when= enabling EFER.NX") References: 67ad24e6d39c ("- pre5: - Rasmus Andersen: add proper...") #= Historical git Suggested-by: Andrew Cooper Suggested-by: Thomas Gleixner Signed-off-by: Ahmed S. Darwish Cc: "H. Peter Anvin" Link: https://lore.kernel.org/r/d4fcfd91-cc92-4b3c-9dd2-56ecd754cecc@citrix= .com --- arch/x86/include/asm/cpuid/types.h | 7 ++++++- arch/x86/kernel/cpu/cpuid_parser.c | 27 ++++++++++++++++++++++++++- arch/x86/kernel/cpu/cpuid_parser.h | 1 + 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/cpuid/types.h b/arch/x86/include/asm/cpui= d/types.h index 320f152675af..d0f0e6a8a457 100644 --- a/arch/x86/include/asm/cpuid/types.h +++ b/arch/x86/include/asm/cpuid/types.h @@ -33,7 +33,11 @@ enum cpuid_regs_idx { #define CPUID_LEAF_TILE 0x1d =20 #define CPUID_BASE_START 0x0 -#define CPUID_BASE_END (CPUID_BASE_START + 0xffff) +#define CPUID_EXT_START 0x80000000 + +#define __CPUID_RANGE_END(idx) ((idx) + 0xffff) +#define CPUID_BASE_END __CPUID_RANGE_END(CPUID_BASE_START) +#define CPUID_EXT_END __CPUID_RANGE_END(CPUID_EXT_START) =20 /* * Types for CPUID(0x2) parsing: @@ -211,6 +215,7 @@ struct cpuid_leaves { /* leaf subleaf count */ CPUID_LEAF(0x0, 0, 1); CPUID_LEAF(0x1, 0, 1); + CPUID_LEAF(0x80000000, 0, 1); }; =20 /* diff --git a/arch/x86/kernel/cpu/cpuid_parser.c b/arch/x86/kernel/cpu/cpuid= _parser.c index 3a0215e75795..e4c45658c75f 100644 --- a/arch/x86/kernel/cpu/cpuid_parser.c +++ b/arch/x86/kernel/cpu/cpuid_parser.c @@ -31,10 +31,34 @@ static void cpuid_read_generic(const struct cpuid_parse= _entry *e, struct cpuid_r * Leaf-independent parser code: */ =20 +static void cpuid_read_0x80000000(const struct cpuid_parse_entry *e, struc= t cpuid_read_output *output) +{ + struct leaf_0x80000000_0 *l =3D (struct leaf_0x80000000_0 *)output->regs; + + cpuid_read_subleaf(e->leaf, e->subleaf, l); + + /* + * Protect against 32-bit CPUs lacking an extended CPUID range: Ensure th= at the + * returned max extended CPUID leaf is in the 0x80000001-0x8000ffff range. + * + * Do not depend on leaving 'info->nr_entries' set as zero, but zero-out = the + * whole leaf output area as well. This is due to the CPUID parser inter= nals + * using the __cpuid_leaves_subleaf_0() API to get the cached max extende= d leaf, + * which does not do any sanity checks, + */ + if ((l->max_ext_leaf & 0xffff0000) !=3D 0x80000000) { + *l =3D (struct leaf_0x80000000_0){ }; + return; + } + + output->info->nr_entries =3D 1; +} + static unsigned int cpuid_range_max_leaf(const struct cpuid_table *t, unsi= gned int range) { switch (range) { case CPUID_BASE_START: return __cpuid_leaves_subleaf_0(&t->leaves, 0x0).m= ax_std_leaf; + case CPUID_EXT_START: return __cpuid_leaves_subleaf_0(&t->leaves, 0x800= 00000).max_ext_leaf; default: return 0; } } @@ -50,7 +74,8 @@ cpuid_range_valid(const struct cpuid_table *t, unsigned i= nt leaf, unsigned int s =20 static bool cpuid_leaf_valid(const struct cpuid_table *t, unsigned int lea= f) { - return cpuid_range_valid(t, leaf, CPUID_BASE_START, CPUID_BASE_END); + return cpuid_range_valid(t, leaf, CPUID_BASE_START, CPUID_BASE_END) || + cpuid_range_valid(t, leaf, CPUID_EXT_START, CPUID_EXT_END); } =20 static const struct cpuid_parse_entry cpuid_common_parse_entries[] =3D { diff --git a/arch/x86/kernel/cpu/cpuid_parser.h b/arch/x86/kernel/cpu/cpuid= _parser.h index 41499fa36fdc..49b7e739852d 100644 --- a/arch/x86/kernel/cpu/cpuid_parser.h +++ b/arch/x86/kernel/cpu/cpuid_parser.h @@ -96,5 +96,6 @@ struct cpuid_parse_entry { /* Leaf Subleaf Reader function */ \ CPUID_PARSE_ENTRY(0x0, 0, generic), \ CPUID_PARSE_ENTRY(0x1, 0, generic), \ + CPUID_PARSE_ENTRY(0x80000000, 0, 0x80000000), =20 #endif /* _ARCH_X86_CPUID_PARSER_H */ --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 8B9622E8899 for ; Thu, 12 Jun 2025 23:41:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771700; cv=none; b=HVNNaADV38wLOXhHjRmbDa6iRIqfqzs2tFZA1zYpux45ScX4UMjI3vVwHJC7I6YCcz/1D50B5steP6M7RNxuhAVat0bt16L14FhVBWsG0QYcg/v7o1jForZze+QC0c7euDTM0NaOj/XDVsT60uKhyBsy1I74ckbVgk2avPC4yYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771700; c=relaxed/simple; bh=oNUZpLtYQB3iGyzw2UvXk+jev7ELA4bbFhrZGIVIz4Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hwdp7K5K/MGvHEoEkUdrvOFJSIhBeGOjUhOQwoFfC9bKoU9yhynrkAyTv7LwuZlF6JJKVVegic7RLGes0fBLNZg5V2qFzWtwx+Is+H/VhAQmpqsQ+Fgys6KEq5ZI9hGmu6xq8kU41DlAaK4qjx1F6eKb4Fq4RPnuaaod1ln9Q30= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=45ZFCJIq; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=uHBd4/Py; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="45ZFCJIq"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="uHBd4/Py" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KRm897uibC0KBWra1pnlfHHGnmRRKrh2Oo3qojg7nFw=; b=45ZFCJIqpIzCB0byHTnzj1Ays9rDd9ok4T6ArDcOid3FE7XGw3CQAvp78Uqbz4uNREk1SA 9mPB/bG0EBO5Nw2R1AkjdjmVVRjDExr6BJUIlaECaX+H77wnZ2ZjzepGurlzkSAraksFir HT7UYnapBYN1xPDOd6L37l9cLHV1u1eBN+UOp6s+1sgeSrM4xIyMK0dO49soK6rYYtyD/c vOVMgFbIfcJsn08wZvOJ/CXIg/g4z6PVthUjdm8y7sN+Tzp9GlrgCGDdcw49ePaZrKLOlt 4kMHg3YKTI4HaIlcTJQewCckS6R7orw8LRVA9nfB4qhG6AeTyhh2zBP+04dGzw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KRm897uibC0KBWra1pnlfHHGnmRRKrh2Oo3qojg7nFw=; b=uHBd4/Py/BINrKr8cftgKvRioarxbia6ZDuElXpuqgRdIlS/+ydObw6opmpjbAZeCnzLSP iJ7k5VblWnnnDIDA== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 23/44] x86/cpuid: Introduce CPUID parser debugfs interface Date: Fri, 13 Jun 2025 01:39:49 +0200 Message-ID: <20250612234010.572636-24-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce the debugfs files 'x86/cpuid/[0-ncpus]' to dump each CPU's cached CPUID table. For each cached CPUID leaf/subleaf, invoke the CPUID instruction on the target CPU and compare the hardware result against the cached values. Mark any mismatched cached CPUID output value with an asterisk. This should help with tricky bug reports in the future, if/when the cached CPUID tables get unexpectedly out of sync with actual hardware state. It also simplifies the development and testing of adding new CPUID leaves to the CPUID parser. Note, expose cpuid_common_parse_entries[] via "cpuid_parser.h" to allow the debugfs code to traverse and dump the parsed CPUID data. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/Makefile | 2 +- arch/x86/kernel/cpu/cpuid_debugfs.c | 102 ++++++++++++++++++++++++++++ arch/x86/kernel/cpu/cpuid_parser.c | 6 +- arch/x86/kernel/cpu/cpuid_parser.h | 3 + 4 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 arch/x86/kernel/cpu/cpuid_debugfs.c diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile index b2421cfb59ed..4e032ad851c7 100644 --- a/arch/x86/kernel/cpu/Makefile +++ b/arch/x86/kernel/cpu/Makefile @@ -61,7 +61,7 @@ obj-$(CONFIG_X86_LOCAL_APIC) +=3D perfctr-watchdog.o obj-$(CONFIG_HYPERVISOR_GUEST) +=3D vmware.o hypervisor.o mshyperv.o obj-$(CONFIG_ACRN_GUEST) +=3D acrn.o =20 -obj-$(CONFIG_DEBUG_FS) +=3D debugfs.o +obj-$(CONFIG_DEBUG_FS) +=3D debugfs.o cpuid_debugfs.o =20 obj-$(CONFIG_X86_BUS_LOCK_DETECT) +=3D bus_lock.o =20 diff --git a/arch/x86/kernel/cpu/cpuid_debugfs.c b/arch/x86/kernel/cpu/cpui= d_debugfs.c new file mode 100644 index 000000000000..99ebbd14b139 --- /dev/null +++ b/arch/x86/kernel/cpu/cpuid_debugfs.c @@ -0,0 +1,102 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * CPUID parser debugfs entries: x86/cpuid/[0-ncpus] + * + * Dump each CPU's cached CPUID table and compare its values against curre= nt + * CPUID output on that CPU. Mark changed entries with an asterisk. + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include "cpuid_parser.h" + +static void cpuid_this_cpu(void *info) +{ + struct cpuid_regs *regs =3D info; + + __cpuid(®s->eax, ®s->ebx, ®s->ecx, ®s->edx); +} + +static void +cpuid_show_leaf(struct seq_file *m, uintptr_t cpu_id, const struct cpuid_p= arse_entry *entry, + const struct leaf_query_info *info, const struct cpuid_regs *cached) +{ + for (int j =3D 0; j < info->nr_entries; j++) { + u32 subleaf =3D entry->subleaf + j; + struct cpuid_regs regs =3D { + .eax =3D entry->leaf, + .ecx =3D subleaf, + }; + int ret; + + seq_printf(m, "Leaf 0x%08x, subleaf %u:\n", entry->leaf, subleaf); + + ret =3D smp_call_function_single(cpu_id, cpuid_this_cpu, ®s, true); + if (ret) { + seq_printf(m, "Failed to invoke CPUID on CPU %lu: %d\n\n", cpu_id, ret); + continue; + } + + seq_printf(m, " cached: %cEAX=3D0x%08x %cEBX=3D0x%08x %cECX=3D0x%= 08x %cEDX=3D0x%08x\n", + cached[j].eax =3D=3D regs.eax ? ' ' : '*', cached[j].eax, + cached[j].ebx =3D=3D regs.ebx ? ' ' : '*', cached[j].ebx, + cached[j].ecx =3D=3D regs.ecx ? ' ' : '*', cached[j].ecx, + cached[j].edx =3D=3D regs.edx ? ' ' : '*', cached[j].edx); + seq_printf(m, " actual: EAX=3D0x%08x EBX=3D0x%08x ECX=3D0x%08x= EDX=3D0x%08x\n", + regs.eax, regs.ebx, regs.ecx, regs.edx); + } +} + +static int cpuid_debug_show(struct seq_file *m, void *p) +{ + uintptr_t cpu_id =3D (uintptr_t)m->private; + const struct cpuinfo_x86 *c =3D per_cpu_ptr(&cpu_info, cpu_id); + const struct cpuid_table *t =3D &c->cpuid; + + const struct cpuid_parse_entry *entry =3D cpuid_common_parse_entries; + + for (unsigned int i =3D 0; i < cpuid_common_parse_entries_size; i++, entr= y++) { + const struct leaf_query_info *qi =3D cpuid_table_query_info_p(t, entry->= info_offs); + const struct cpuid_regs *qr =3D cpuid_table_query_regs_p(t, entry->regs_= offs); + + cpuid_show_leaf(m, cpu_id, entry, qi, qr); + } + + return 0; +} + +static int cpuid_debug_open(struct inode *inode, struct file *file) +{ + return single_open(file, cpuid_debug_show, inode->i_private); +} + +static const struct file_operations cpuid_ops =3D { + .open =3D cpuid_debug_open, + .read =3D seq_read, + .llseek =3D seq_lseek, + .release =3D single_release, +}; + +static __init int cpuid_init_debugfs(void) +{ + struct dentry *dir; + uintptr_t cpu_id; + char cpu_name[24]; + + dir =3D debugfs_create_dir("cpuid", arch_debugfs_dir); + + for_each_possible_cpu(cpu_id) { + scnprintf(cpu_name, sizeof(cpu_name), "%lu", cpu_id); + debugfs_create_file(cpu_name, 0444, dir, (void *)cpu_id, &cpuid_ops); + } + + return 0; +} +late_initcall(cpuid_init_debugfs); diff --git a/arch/x86/kernel/cpu/cpuid_parser.c b/arch/x86/kernel/cpu/cpuid= _parser.c index e4c45658c75f..eb8975de497a 100644 --- a/arch/x86/kernel/cpu/cpuid_parser.c +++ b/arch/x86/kernel/cpu/cpuid_parser.c @@ -78,10 +78,12 @@ static bool cpuid_leaf_valid(const struct cpuid_table *= t, unsigned int leaf) cpuid_range_valid(t, leaf, CPUID_EXT_START, CPUID_EXT_END); } =20 -static const struct cpuid_parse_entry cpuid_common_parse_entries[] =3D { +const struct cpuid_parse_entry cpuid_common_parse_entries[] =3D { CPUID_PARSE_ENTRIES }; =20 +const int cpuid_common_parse_entries_size =3D ARRAY_SIZE(cpuid_common_pars= e_entries); + static void cpuid_fill_table(struct cpuid_table *t, const struct cpuid_parse_entry ent= ries[], unsigned int nr_entries) { @@ -135,5 +137,5 @@ void cpuid_parser_scan_cpu(struct cpuinfo_x86 *c) */ memset(table, 0, sizeof(*table)); =20 - cpuid_fill_table(table, cpuid_common_parse_entries, ARRAY_SIZE(cpuid_comm= on_parse_entries)); + cpuid_fill_table(table, cpuid_common_parse_entries, cpuid_common_parse_en= tries_size); } diff --git a/arch/x86/kernel/cpu/cpuid_parser.h b/arch/x86/kernel/cpu/cpuid= _parser.h index 49b7e739852d..882e96b000ba 100644 --- a/arch/x86/kernel/cpu/cpuid_parser.h +++ b/arch/x86/kernel/cpu/cpuid_parser.h @@ -98,4 +98,7 @@ struct cpuid_parse_entry { CPUID_PARSE_ENTRY(0x1, 0, generic), \ CPUID_PARSE_ENTRY(0x80000000, 0, 0x80000000), =20 +extern const struct cpuid_parse_entry cpuid_common_parse_entries[]; +extern const int cpuid_common_parse_entries_size; + #endif /* _ARCH_X86_CPUID_PARSER_H */ --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 C086B2E337E for ; Thu, 12 Jun 2025 23:41:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771703; cv=none; b=n48/L8/N3qan2smn/MAo9jr/GqCl+KdigdNKoA6r4Y70L5hPeDkv66jBi4F0M9vDa28Ld0aDBS/ss6RAKld62XS1vQ7H+LhdT2grlFJVSSCU33vo/wlvn6CDrziwgIksRdj2694ayVXR962GjApgUpurKCaoCWonQ3rYTObKq3U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771703; c=relaxed/simple; bh=pO+IMBkT0Cz0KPmZgdkoQHtAYDwL7rAeaWkAl4ieH5A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fnmQab7yAcFuPcaooxcE+GLn3fhsWayrWAoYfL9UsmT0po8GKcxnetsixWjlSZtfim9vhuDINkLus/2FFt+7xlDnLdHWK6viMzcjCrhtOovvdDS/FEknjZAdIK3Lit7w3NXvHGK0eobiCQdMUmpLMy/aWkrLnyzer1J19dTNNzg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=phY6lihw; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=JCsY/C3x; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="phY6lihw"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JCsY/C3x" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771700; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HNGt1l4gf4CrsIJvTjbTMUyEMVYVm+r7Tudxfo9S6Lk=; b=phY6lihwwFp+9WXl0Y1Hms8Pzfh/uendugdoR5ApAwOJ7GhHy2fxQLPxO4cMszOOIwUpR3 s9bLgieHMdlqKINEzOcwD7/5/hEsL6dgyKhcNPSHLxlhKw88B6kiwO8K0IvEjvplrZoMqe nv56S9q9uH05ETOBAEJxF6LAZ7dyHCvP0+DESSNme1ZIx9i5bHjq/jslDuosLImsRAkU7F /IqUR4KMIEI7r5M9vm6Fr1eta1sMDzcGdPjmeBGmmh/tI92lIaZrXeNcxrxaQVNK7rwSRi tAuSac6k9gNLuI3f3dDr442nZn1iDPsZcgkIzt0fs4Pubnf+IMxTlfhxZcu06A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771700; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HNGt1l4gf4CrsIJvTjbTMUyEMVYVm+r7Tudxfo9S6Lk=; b=JCsY/C3xs/yX5L9mlVXjSJCY2elFsTMH2w20zy973qNOAZyEFAPPZwH5p22QTIUe7anP5L F1fWf3y8VA6PsHBg== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 24/44] x86/cpu: Use parsed CPUID(0x0) Date: Fri, 13 Jun 2025 01:39:50 +0200 Message-ID: <20250612234010.572636-25-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use parsed CPUID(0x0) access instead of a direct CPUID query. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/common.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 8aa3ba269c0b..234d0f5de39e 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -895,11 +895,12 @@ void get_cpu_vendor(struct cpuinfo_x86 *c) =20 void cpu_detect(struct cpuinfo_x86 *c) { - /* Get vendor name */ - cpuid(0x00000000, (unsigned int *)&c->cpuid_level, - (unsigned int *)&c->x86_vendor_id[0], - (unsigned int *)&c->x86_vendor_id[8], - (unsigned int *)&c->x86_vendor_id[4]); + const struct leaf_0x0_0 *l0 =3D cpuid_leaf(c, 0x0); + + c->cpuid_level =3D l0->max_std_leaf; + *(u32 *)&c->x86_vendor_id[0] =3D l0->cpu_vendorid_0; + *(u32 *)&c->x86_vendor_id[4] =3D l0->cpu_vendorid_1; + *(u32 *)&c->x86_vendor_id[8] =3D l0->cpu_vendorid_2; =20 c->x86 =3D 4; /* Intel-defined flags: level 0x00000001 */ --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 1EE902E92B1 for ; Thu, 12 Jun 2025 23:41:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771706; cv=none; b=iNvQREpzbmOouIfWKtv04qWORJMObpxTI2+eBAF/eJ+NotnQ0EzznfZhENr1hs+NYwh9SE8Fagcq5IGtsQ8wcCR7Grr003Kc/H3GcsLNh5SiHJcMsu9GcDUfFHHl4UxdYZ5dt7sNR9kfI2qtebJiH9iviOJfjrnCbrOa2TMbZTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771706; c=relaxed/simple; bh=GxUUBUz9xnjBH1SiZKleVg0aLiELrmJZFMUrgj2GWPs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KTHxOhec00PnZcUZbq72afZMEm/ZlUHUCqibnVP5Se8xb23ilmloxEEOHMVTD07qZayqC+jlYCLPZNl3dGivEPrpwK6ZjRgq5eLsTqWGM+lEQkx2Sx0IPqaZM9Ow8TRBn3dvuBhwrRZA4/TWFo5bYEFEmA03q374hQp2TkSRW9Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=MlOvnSgN; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=u2torbeN; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="MlOvnSgN"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="u2torbeN" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771703; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GFv6MLNTZNByU7fUhT79iIPGJmtLlz5VVmjMAqBlUqY=; b=MlOvnSgNClgBOpU4INaO9kJE+eNWiUZgV8aiMUQ8K4hvskjavmOznNI2eRZyoLAGcDz46G F7DwSayBm9j6YgIadA/s2amzbX2cFmhY0IlS3UmNwijOOv2ch13mD9ItUou/68KryhdhZS P2sspvLU8DVytRlrxGFKgUd33Pqxc9OPvoEw4LP2K6+SCSKCxS07qteOSzw6uf4l9pcq+I 4dew/tcxguTNMiKYJLPd/1lX6rfrbt72gQ7EittAmBcR3mgFdrWDlgdLmd439xgl13bCka tYHNhuyFlGwqprd10tzI8m0VZNEglL83l7p0l5JdlNZcPSvopDHJl+kzlfWlOA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771703; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GFv6MLNTZNByU7fUhT79iIPGJmtLlz5VVmjMAqBlUqY=; b=u2torbeNu31LIwNV8bozio+4xtv75vLtL0OuQ7n+B+E65WD5wTIbn1/MAxCM/1lX5qLwmd 03fGr9ogBMS1/HCw== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 25/44] x86/cpu: Use parsed CPUID(0x80000000) Date: Fri, 13 Jun 2025 01:39:51 +0200 Message-ID: <20250612234010.572636-26-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use parsed CPUID(0x80000000) access instead of a direct CPUID query. The affected code has the check: (eax & 0xffff0000) =3D=3D 0x80000000 to protect against Intel 32-bit CPUs that lack extended CPUID support. A similar check is already done at the CPUID(0x80000000) scanner read function at cpuid_parser.c: /* * Protect against 32-bit CPUs lacking extended CPUID support: Max * extended CPUID leaf must be in the 0x80000001-0x8000ffff range. */ if ((l->max_ext_leaf & 0xffff0000) !=3D 0x80000000) { // Handle error } Thus, just check that the parsed CPUID macro: cpuid_leaf(c, 0x80000000) does not return NULL, thus providing a sanity check similar to the original code. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/common.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 234d0f5de39e..b3408ae2b144 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -972,6 +972,7 @@ static void init_speculation_control(struct cpuinfo_x86= *c) =20 void get_cpu_cap(struct cpuinfo_x86 *c) { + const struct leaf_0x80000000_0 *el0; u32 eax, ebx, ecx, edx; =20 /* Intel-defined flags: level 0x00000001 */ @@ -1007,12 +1008,8 @@ void get_cpu_cap(struct cpuinfo_x86 *c) c->x86_capability[CPUID_D_1_EAX] =3D eax; } =20 - /* - * Check if extended CPUID leaves are implemented: Max extended - * CPUID leaf must be in the 0x80000001-0x8000ffff range. - */ - eax =3D cpuid_eax(0x80000000); - c->extended_cpuid_level =3D ((eax & 0xffff0000) =3D=3D 0x80000000) ? eax = : 0; + el0 =3D cpuid_leaf(c, 0x80000000); + c->extended_cpuid_level =3D (el0) ? el0->max_ext_leaf : 0; =20 if (c->extended_cpuid_level >=3D 0x80000001) { cpuid(0x80000001, &eax, &ebx, &ecx, &edx); --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 B53A72E92CD for ; Thu, 12 Jun 2025 23:41:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771710; cv=none; b=gEM17I9YxQQW3rKlhPEoOe0NmW9e8ftJe+vpqHa2G0sTDKFabQ0akoHt/mPj7fURMCkUOYKcWajwRQwY8WeRs/LS5CU9C2JGSzqbhsmlyKACTPzVbcB9KI71QxfGrN2/e35pcxKpX1ji7zp5zxWxXREvgXWe+iHOWbF8hGKsL3Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771710; c=relaxed/simple; bh=JjpKnEEeb8EihD6NhJ+3mHH6ulCNckG1EK6KQwd39Rs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=shquHvwEAOTBquIPyVpZuEBIaqz3RIhBtk50mBAJ8HpSY6tJqRdgmCEydTpiC/osJj5ys48j/liO7nRzWacSoSGRFiQK13xR3vuUeIv9+Ba1OMmF2d875mZB2J6bPNlRWL4eCdzDLZUZ2kMs+6BwVIZTE0LEcxWx/jI63iuYjkI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Stk8Adrb; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=MJCoLsU3; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Stk8Adrb"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="MJCoLsU3" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+Xr7p/ILqaWRsY65Bf4IVSsO8x0nPruOpeIN/uFfX+o=; b=Stk8AdrbRQP9m/VWbYFCfb7VyI4kOXbu3TesUASMabP9+WdrV7ovingiF4ajfSNQysRJu3 jvu7ZZQGRHO1PvGi+M4Ts7y6zImz6eIrm55OljnrsvmraXF3bmNJ888UV0UrXznn5ghA1Y 33WwKcp5AG3/VdGLeQwU3BRPrtegLvol6zXjCDCGgbUQMDkqaHykNUeCMVqsOtDF3DmnBd ytHOuEzEEBJAKY4iEK/4pEjmYwcQQ1K39k7Y8poqoBUqU/fQbtYQoaL+G9x8v3x8oEWWSQ eQFkRXQbKcQxLYkGUEDrzYVZuIC9ZiQETuymkoJ2ZEpzwKeVGfV40QvoJ1JHPg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+Xr7p/ILqaWRsY65Bf4IVSsO8x0nPruOpeIN/uFfX+o=; b=MJCoLsU3KCogV1qTyYXCbCH6JF+W25eXgQHeGqAF0rFEKuoUdxRr3Xxsi3KY65srth0Syi ptUFmMkRawKyvmCg== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 26/44] x86/lib: Add CPUID(0x1) CPU family and model calculation Date: Fri, 13 Jun 2025 01:39:52 +0200 Message-ID: <20250612234010.572636-27-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The x86 library code provides x86_family() and x86_model(). They take raw CPUID(0x1) EAX register output, extract the necessary bitfields with bitwise operations, then calculate out the CPU family and model. In follow-up commits, the x86 code will use parsed CPUID access, along with its auto-generated CPUID leaf data structures and their detailed C99 bitfields. Introduce CPU family and model calculation functions to x86/lib that take the auto-generated 'struct leaf_0x1_0' data type. Refactor the pure CPU family and model calculation logic into internal static functions so that no logic is duplicated. Signed-off-by: Ahmed S. Darwish --- arch/x86/include/asm/cpu.h | 6 ++++++ arch/x86/lib/cpu.c | 41 ++++++++++++++++++++++---------------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h index ad235dda1ded..90902cd91335 100644 --- a/arch/x86/include/asm/cpu.h +++ b/arch/x86/include/asm/cpu.h @@ -7,7 +7,9 @@ #include #include #include + #include +#include =20 #ifndef CONFIG_SMP #define cpu_physical_id(cpu) boot_cpu_physical_apicid @@ -25,6 +27,10 @@ int mwait_usable(const struct cpuinfo_x86 *); unsigned int x86_family(unsigned int sig); unsigned int x86_model(unsigned int sig); unsigned int x86_stepping(unsigned int sig); + +unsigned int cpuid_family(const struct leaf_0x1_0 *l); +unsigned int cpuid_model(const struct leaf_0x1_0 *l); + #ifdef CONFIG_X86_BUS_LOCK_DETECT extern void __init sld_setup(struct cpuinfo_x86 *c); extern bool handle_user_split_lock(struct pt_regs *regs, long error_code); diff --git a/arch/x86/lib/cpu.c b/arch/x86/lib/cpu.c index 7ad68917a51e..eac217d637ac 100644 --- a/arch/x86/lib/cpu.c +++ b/arch/x86/lib/cpu.c @@ -1,36 +1,43 @@ // SPDX-License-Identifier: GPL-2.0-only #include #include + #include +#include =20 -unsigned int x86_family(unsigned int sig) +static unsigned int __x86_family(unsigned int base_fam, unsigned int ext_f= am) { - unsigned int x86; - - x86 =3D (sig >> 8) & 0xf; + return (base_fam =3D=3D 0xf) ? base_fam + ext_fam : base_fam; +} =20 - if (x86 =3D=3D 0xf) - x86 +=3D (sig >> 20) & 0xff; +static unsigned int +__x86_model(unsigned int family, unsigned int base_model, unsigned int ext= _model) +{ + return (family >=3D 0x6) ? base_model | ext_model << 4 : base_model; +} =20 - return x86; +unsigned int x86_family(unsigned int sig) +{ + return __x86_family((sig >> 8) & 0xf, (sig >> 20) & 0xff); } EXPORT_SYMBOL_GPL(x86_family); =20 -unsigned int x86_model(unsigned int sig) +unsigned int cpuid_family(const struct leaf_0x1_0 *l) { - unsigned int fam, model; - - fam =3D x86_family(sig); - - model =3D (sig >> 4) & 0xf; - - if (fam >=3D 0x6) - model +=3D ((sig >> 16) & 0xf) << 4; + return __x86_family(l->base_family_id, l->ext_family); +} =20 - return model; +unsigned int x86_model(unsigned int sig) +{ + return __x86_model(x86_family(sig), (sig >> 4) & 0xf, (sig >> 16) & 0xf); } EXPORT_SYMBOL_GPL(x86_model); =20 +unsigned int cpuid_model(const struct leaf_0x1_0 *l) +{ + return __x86_model(cpuid_family(l), l->base_model, l->ext_model); +} + unsigned int x86_stepping(unsigned int sig) { return sig & 0xf; --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 A75F92E92D9 for ; Thu, 12 Jun 2025 23:41:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771713; cv=none; b=pAGvJithJqouzNKb94/NAdZJHuJXZ2BmnaN0wPXrd12JVjJ7hNjdPX5nSaBnCr73ZQG3vnFrS9LiO5KNxyVYihdVTk5bUCso8uabrpwrPngXvlg0pR8KuDaGoGDtNpDVlR+ofBszY+flPMibNvEYAzXuKjwCSe4zZ5T6XMrHHvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771713; c=relaxed/simple; bh=lSnfTGNvCCHUD1g3OuwoLvAwB3bAKJBfyXYmqNb6quc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ETJcF+mIQmI+z3IvdeqztrzlHidKNXFXMLBruI7/jAfTb2QYGtpl+LIoIRxNnmStiqJDXqzXynqn8i/NC5ipFOQhDqziPn/mehd+HLTSWDtY5fEbMyCIzU2lt/KUtOUGDAt50cMz6byvJ75gqRPK0DhqiN9bnnwXmEfEuwg5EjE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=pVY3m3cF; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=SMyO02Ks; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pVY3m3cF"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="SMyO02Ks" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771710; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CGXqbv3TKuxoI3faR1b+5Z5vqE19ecaVzTdKl1HhrNQ=; b=pVY3m3cFzWy0NkwFKjXWC2unM/Esw2Soz0SmrY+QXUJGP2Ga0ORTNLPJSrf8BYsF1lgswl qyAEOo4gjmmBKV7WgWNxeOXuKkB74x8fa86kYWYVdcAzHnwwDczkrshTpBa1OpvCro9MxI pl2PPd0dwHfeIzVTfiryny/aFUnBRn2BRUCJdVxKu5CTOiRa/ShSN/2KKfQWBJ2q/bZqqr ncwrf2GsgqFqAp//k4hMpJN+sNTWExBb2M7EJw3j/TVUQx06gw94YvccZmlVWSP2wRv0Tk oRwgUkqX+bTMf3sgZywu3GYQut8Gr/iyWDQjLVyjvPmiW4BkrRKt7/72uA1MMw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771710; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CGXqbv3TKuxoI3faR1b+5Z5vqE19ecaVzTdKl1HhrNQ=; b=SMyO02KsTHAX/bM0XB1TCVyNRTLXYd0DFXfDHKEDxo1qEtbqT3jxhH5dZr7ZrYPSMPqI8v 7DTnHwWdI+v/tjCA== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 27/44] x86/cpu: Use parsed CPUID(0x1) Date: Fri, 13 Jun 2025 01:39:53 +0200 Message-ID: <20250612234010.572636-28-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use parsed CPUID(0x1) access, instead of a direct CPUID query, at early boot CPU detection code. Beside the centralization benefits of the new CPUID model APIs, this allows using the auto-generated leaf data types and their full C99 bitfields instead of performing ugly bitwise operations on CPUID register output. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/common.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index b3408ae2b144..023613698b15 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -896,6 +896,7 @@ void get_cpu_vendor(struct cpuinfo_x86 *c) void cpu_detect(struct cpuinfo_x86 *c) { const struct leaf_0x0_0 *l0 =3D cpuid_leaf(c, 0x0); + const struct leaf_0x1_0 *l1 =3D cpuid_leaf(c, 0x1); =20 c->cpuid_level =3D l0->max_std_leaf; *(u32 *)&c->x86_vendor_id[0] =3D l0->cpu_vendorid_0; @@ -903,17 +904,14 @@ void cpu_detect(struct cpuinfo_x86 *c) *(u32 *)&c->x86_vendor_id[8] =3D l0->cpu_vendorid_2; =20 c->x86 =3D 4; - /* Intel-defined flags: level 0x00000001 */ - if (c->cpuid_level >=3D 0x00000001) { - u32 junk, tfms, cap0, misc; =20 - cpuid(0x00000001, &tfms, &misc, &junk, &cap0); - c->x86 =3D x86_family(tfms); - c->x86_model =3D x86_model(tfms); - c->x86_stepping =3D x86_stepping(tfms); + if (l1) { + c->x86 =3D cpuid_family(l1); + c->x86_model =3D cpuid_model(l1); + c->x86_stepping =3D l1->stepping; =20 - if (cap0 & (1<<19)) { - c->x86_clflush_size =3D ((misc >> 8) & 0xff) * 8; + if (l1->clflush) { + c->x86_clflush_size =3D l1->clflush_size * 8; c->x86_cache_alignment =3D c->x86_clflush_size; } } --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 ECF2B2E92D3 for ; Thu, 12 Jun 2025 23:41:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771716; cv=none; b=Y1RiwfBltbx19dY1yyOpDtGgobWZRSu7DJkUGP+bvX/CCUB7aKJUQIbMBXClWAQERoqwCq325qozKxWshNsdUEphJcC6psgrVj0npaMFxcEZ0ScIUXaWmNbTZ54Sn9r2WbUjXiPgPVEFSbbGRkH2Cat20381Wj4c3Xce/7iDgXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771716; c=relaxed/simple; bh=fxZA4A0MuuY0Xd61MPGho94Qj3uh9SSI2gFLBw5yCr0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ai3EzN9S7yGY4b0DMMyHGkTvUt4OWLOazfwa3RTWniz0zohnCPlCGqszQbu7W19O/O9teeWbEodsIycrab/r2Ch3wN99jFMk/aaPd9Me5s1uXWd7LSatZUA98wlXhDxQ0DhX7KffUFzfqU2qlPzqfk+ZQagwqCsTbadHuZfN0/k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=tAOWOCNC; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=P94ySQS9; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="tAOWOCNC"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="P94ySQS9" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771713; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aucTGch6VIspEvZqsNKH9dxMONrsSTbqBKsLK1ul2nA=; b=tAOWOCNCBOhpXxdL+z8WrRlzXJoy/xnjE2kWAjDNQlFzH2XwLfI6YAwA2CAoQIR45hnf82 OWniDYNyTMFUq5WE35nBhb+XM6xHg9oCnRLqUDAo1FPZNG0JZAbFg981+/z/J5x5wBwL07 PwH0AjNwO8L/sVwIECQIPXI60GtKokmfmN9omkM88JNQs+w126Vx8oKF29PUIPjWjKjFZR puOyc/IyHg8fSC3g5ngT59EmYvDAWvOwy+FEfa9+KQe6E5KDaOAgsYcETaoLUkwNDYzwf2 fYlkYSzG3DMJeCUn/niPT0Eg+7VoLT40z1vXrpHs6Vnywmt1icUoq1BEpqc10w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771713; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aucTGch6VIspEvZqsNKH9dxMONrsSTbqBKsLK1ul2nA=; b=P94ySQS9ROnKBS5U+6EulaGW9hPjUNt8j4aOY7hNfe4H6nWmQLNI2iZHySlp1OASUnHvwv AYlYd60SpnuWc9Dw== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 28/44] x86/cpuid: Parse CPUID(0x2) Date: Fri, 13 Jun 2025 01:39:54 +0200 Message-ID: <20250612234010.572636-29-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add CPUID(0x2) support to the CPUID parser. Keep the leaf marked as invalid at the CPUID table if the whole leaf, or all of its output registers, were malformed. Note, the cpuid_leaf_0x2() logic at will be removed once all the CPUID(0x2) call sites are transformed to the new CPUID model API. References: fe78079ec07f ("x86/cpu: Introduce and use CPUID leaf 0x2 parsin= g helpers") Signed-off-by: Ahmed S. Darwish --- arch/x86/include/asm/cpuid/types.h | 1 + arch/x86/kernel/cpu/cpuid_parser.c | 41 +++++++++++++++++++++++++++--- arch/x86/kernel/cpu/cpuid_parser.h | 1 + 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/cpuid/types.h b/arch/x86/include/asm/cpui= d/types.h index d0f0e6a8a457..7bbf0671cb95 100644 --- a/arch/x86/include/asm/cpuid/types.h +++ b/arch/x86/include/asm/cpuid/types.h @@ -215,6 +215,7 @@ struct cpuid_leaves { /* leaf subleaf count */ CPUID_LEAF(0x0, 0, 1); CPUID_LEAF(0x1, 0, 1); + CPUID_LEAF(0x2, 0, 1); CPUID_LEAF(0x80000000, 0, 1); }; =20 diff --git a/arch/x86/kernel/cpu/cpuid_parser.c b/arch/x86/kernel/cpu/cpuid= _parser.c index eb8975de497a..9bd68b150150 100644 --- a/arch/x86/kernel/cpu/cpuid_parser.c +++ b/arch/x86/kernel/cpu/cpuid_parser.c @@ -27,9 +27,40 @@ static void cpuid_read_generic(const struct cpuid_parse_= entry *e, struct cpuid_r cpuid_read_subleaf(e->leaf, e->subleaf + i, output->regs); } =20 -/* - * Leaf-independent parser code: - */ +static void cpuid_read_0x2(const struct cpuid_parse_entry *e, struct cpuid= _read_output *output) +{ + union leaf_0x2_regs *regs =3D (union leaf_0x2_regs *)output->regs; + struct leaf_0x2_0 *l =3D (struct leaf_0x2_0 *)output->regs; + int invalid_regs =3D 0; + + /* + * All Intel CPUs must report an iteration count of 1. For broken hardwa= re, + * keep the leaf marked as invalid at the CPUID table. + */ + cpuid_read_subleaf(e->leaf, e->subleaf, l); + if (l->iteration_count !=3D 0x01) + return; + + /* + * The most significant bit (MSB) of each CPUID(0x2) register must be cle= ar. + * If a register is malformed, replace its 1-byte descriptors with NULL. + */ + for (int i =3D 0; i < 4; i++) { + if (regs->reg[i].invalid) { + regs->regv[i] =3D 0; + invalid_regs++; + } + } + + /* + * If all of the CPUID(0x2) output registers were malformed, keep the leaf + * marked as invalid at the CPUID table. + */ + if (invalid_regs =3D=3D 4) + return; + + output->info->nr_entries =3D 1; +} =20 static void cpuid_read_0x80000000(const struct cpuid_parse_entry *e, struc= t cpuid_read_output *output) { @@ -54,6 +85,10 @@ static void cpuid_read_0x80000000(const struct cpuid_par= se_entry *e, struct cpui output->info->nr_entries =3D 1; } =20 +/* + * Leaf-independent parser code: + */ + static unsigned int cpuid_range_max_leaf(const struct cpuid_table *t, unsi= gned int range) { switch (range) { diff --git a/arch/x86/kernel/cpu/cpuid_parser.h b/arch/x86/kernel/cpu/cpuid= _parser.h index 882e96b000ba..cf999e6a574d 100644 --- a/arch/x86/kernel/cpu/cpuid_parser.h +++ b/arch/x86/kernel/cpu/cpuid_parser.h @@ -96,6 +96,7 @@ struct cpuid_parse_entry { /* Leaf Subleaf Reader function */ \ CPUID_PARSE_ENTRY(0x0, 0, generic), \ CPUID_PARSE_ENTRY(0x1, 0, generic), \ + CPUID_PARSE_ENTRY(0x2, 0, 0x2), \ CPUID_PARSE_ENTRY(0x80000000, 0, 0x80000000), =20 extern const struct cpuid_parse_entry cpuid_common_parse_entries[]; --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 3FC012EA47F for ; Thu, 12 Jun 2025 23:41:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771719; cv=none; b=CpCxLIMgis3Twey0ovjIa/vsuBLIT7RpNgZdnrmqtY2E2LRU5uYDNHCl9v0WKyRPqmU6cPOa6DjWn/OtMZDQAp57uqP7cUT6CyupiEDZIjt/0Qalx1InOYwFmd2yIWTsLLiiIgagJqvYFBHY9x+WekwjDg2T28g7nPvP4wpvN2U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771719; c=relaxed/simple; bh=XnIAh2DBgis63hKFk2UK5e7z6J0ZuL4OXW2F7KTTBu0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xw1WO5syp1iTynzjOxD0RHb9AbFc+mHxH6y2xlmbg30yBrAnexU/i52r999m+UrkZFVhDBmbndPXfA2QmpFnic8ReIXyUQRh6pCQAkmcOGccJcyO87RjEq6cqA40oiTCjD4w4s3g5BnTgzIRPA5W4jmBpQPNFELYvhi1q+eRagE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=07Tn3zcY; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=wfzeSLos; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="07Tn3zcY"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="wfzeSLos" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771716; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bqtlKNOMLvwsPQYHA55+cYkA8khdSW+f11FE0sVNEcc=; b=07Tn3zcY0rDMZPA2QdCR8/wKcXvKFogNmHwoiUnhQksHaowI2MX2P2UjQbBzogNQFyK3wD /9JfQl2QTF60AFlRCxB8qo9aoU5eH24eabDvHIA9f8Fx52YILqEucWGieGJLjHKotNE245 fSp/bEoW5duO24dRr2ts+nV3Z5YNbwbluQQdEEYVBGbJasZN7DM7YGj1MtKZt7LRhOtdN0 pGd3MYTCsTxx6uBI1IwIvpfwrQq0cUprUIkL6SV9rOZS7+Y2ghrbLUg7vmY+qzxwyhPqLG iuRe6VjDgiF/sMImJ5rmzCIOoAp2ucOF03u1GlH5RQ+WgB24FmyE4JnjOzMBuQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771716; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bqtlKNOMLvwsPQYHA55+cYkA8khdSW+f11FE0sVNEcc=; b=wfzeSLosbZFW1ohZmqfyKIxxGaM134rt0cwwGRYv92SkFWESFUFbahaieBHywPaGO2Xml4 ls93jjoipnVAqGBw== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 29/44] x86/cpuid: Introduce parsed CPUID(0x2) API Date: Fri, 13 Jun 2025 01:39:55 +0200 Message-ID: <20250612234010.572636-30-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a new iterator macro, for_each_parsed_cpuid_0x2_desc(), for retrieving parsed CPUID(0x2) entries as 1-byte descriptors. Unlike the existing for_each_cpuid_0x2_desc() macro, which operates on directly retrieved CPUID data, the new one takes its input from the centralized CPUID parser. That is, it is expected to be used as: const struct leaf_0x2_table *desc; const struct cpuid_regs *regs; u8 *ptr; regs =3D cpuid_leaf_regs(c, 0x2); // Parsed CPUID access for_each_parsed_cpuid_0x2_desc(regs, ptr, desc) { ... } which should replace the older method: const struct leaf_0x2_table *desc; union leaf_0x2_regs regs; u8 *ptr; cpuid_leaf_0x2(®s); // Direct CPUID access for_each_leaf_0x2_desc(regs, ptr, desc) { ... } In the new macro, assert that the passed 'regs' is the same size as a 'union leaf_0x2_regs'. This is necessary since the macro internally casts 'regs' to that union in order to iterate over the CPUID(0x2) output as a 1-byte array. A size equivalence assert is used, instead of a typeof() check, to give callers the freedom to either pass a 'struct cpuid_regs' pointer or a 'struct leaf_0x2_0' pointer, both as returned by the parsed CPUID API at . That size comparison matches what other kernel CPUID APIs do; e.g. cpuid_read() and cpuid_read_subleaf() at . Note, put the size equivalence check inside a GNU statement expression, ({..}), so that it can be placed inside the macro's loop initialization. Signed-off-by: Ahmed S. Darwish --- arch/x86/include/asm/cpuid/api.h | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/arch/x86/include/asm/cpuid/api.h b/arch/x86/include/asm/cpuid/= api.h index dbc954e21b7e..6a0e766de565 100644 --- a/arch/x86/include/asm/cpuid/api.h +++ b/arch/x86/include/asm/cpuid/api.h @@ -544,6 +544,49 @@ static inline bool cpuid_amd_hygon_has_l3_cache(void) __cpuid_leaves_subleaf_info(&_cpuinfo->cpuid.leaves, _leaf, 0).nr_entries= ;\ }) =20 +/* + * Convenience leaf-specific functions (using parsed CPUID data): + */ + +/* + * CPUID(0x2) + */ + +/** + * for_each_parsed_cpuid_0x2_desc() - Iterator for parsed CPUID(0x2) descr= iptors + * @_regs: Leaf 0x2 register output, as returned by cpuid_leaf_regs() + * @_ptr: u8 pointer, for macro internal use only + * @_desc: Pointer to parsed descriptor information at each iteration + * + * Loop over the 1-byte descriptors in the passed CPUID(0x2) output regist= ers + * @_regs. Provide the parsed information for each descriptor through @_d= esc. + * + * To handle cache-specific descriptors, switch on @_desc->c_type. For TLB + * descriptors, switch on @_desc->t_type. + * + * Example usage for cache descriptors:: + * + * const struct leaf_0x2_table *desc; + * struct cpuid_regs *regs; + * u8 *ptr; + * + * regs =3D cpuid_leaf_regs(c, 0x2); + * if (!regs) { + * // Handle error + * } + * + * for_each_parsed_cpuid_0x2_desc(regs, ptr, desc) { + * switch (desc->c_type) { + * ... + * } + * } + */ +#define for_each_parsed_cpuid_0x2_desc(_regs, _ptr, _desc) \ + for (({ static_assert(sizeof(*_regs) =3D=3D sizeof(union leaf_0x2_regs));= }), \ + _ptr =3D &((union leaf_0x2_regs *)(_regs))->desc[1]; \ + _ptr < &((union leaf_0x2_regs *)(_regs))->desc[16] && (_desc =3D &cp= uid_0x2_table[*_ptr]);\ + _ptr++) + /* * CPUID parser exported APIs: */ --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 7FCD12EA498 for ; Thu, 12 Jun 2025 23:42:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771722; cv=none; b=DrNrGHdMzy0R+gXo3flesG6GiGJJ4xPp91ju5ffeCsEyQalL5aPtNcEpQzFqjpe0460fS69QQsLtMXY5g0jhmczJ1TcVNUnaemVzAvQPh5JZM+W2Ot6AuWttaKoNpzDNfiuqDDUC4YbxqIPDm6vIueHYG4j9PPMlIwe1ZWhIQTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771722; c=relaxed/simple; bh=qNz1iLYzXxbN2lk1k0TKlGVeCiAHYj+yH8k72e66X/g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RB0wCwvd+QC4xwSo6hCupatGsMAbDB5nTyP4yfb0adXaWvCUBz1NR9bQ+FtltF5xsD4lu0ozU/EQgQMa/6dOQZOBWdGhYgloQM19LmVMU8Xt81x/xnFoLdDfQD0vUKPd2gr45kmePQXu6qm+nSn9nkrUow3oodqFxhmeafR/Bqc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=uDAi4PiU; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=2CzMqAPx; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="uDAi4PiU"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="2CzMqAPx" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771720; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lTVNlPfPuV0WuhPUD2xW99Y6GJi+2sofUiXVRrozsf0=; b=uDAi4PiUJwh31SppfJCjbdL6H92a+lVXSOefzpyReeJR8lIYLfVEVO7Ce389rgS0/iDiJe 5RrcYjjmNEOHRvhejVQOqx5YvJYuW1N1kgZVWVIe2i5ORtILRuPDEzZBWw/+TbzD10jv33 PacYmUCHVJAkPXZsVfZHRgmOwGBW5ck3KNb5wt1mq0do/nYkpfuWNY67OMuQdfl2BLWhpY 53Z3U4i7Uv/uw8zWxWVDor8v4x4zDNPJyfLkKwDTG3jyZPyKJPUQT5Xg88nOG34FcSPMh6 X4y0cKYuqyTdtowRXhauVPJAkSO805ODH9vd22C1BwbKH4q1YLEoCqsqX4Wgzw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771720; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lTVNlPfPuV0WuhPUD2xW99Y6GJi+2sofUiXVRrozsf0=; b=2CzMqAPx5lnzVm+6mpTkEptOMYI94D4qKmYx3YBfAOucCamvupmdRS8RGaiB3vNUsaA4XG YBjb6HmuUKxkSJCQ== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 30/44] x86/cpu: Use parsed CPUID(0x2) Date: Fri, 13 Jun 2025 01:39:56 +0200 Message-ID: <20250612234010.572636-31-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use parsed CPUID(0x2) access instead of direct CPUID queries. Remove the max standard CPUID level check since the NULL check of cpuid_leaf_regs()'s result is equivalent. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/intel.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 076eaa41b8c8..5eab9135b144 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -710,14 +710,14 @@ static void intel_tlb_lookup(const struct leaf_0x2_ta= ble *desc) static void intel_detect_tlb(struct cpuinfo_x86 *c) { const struct leaf_0x2_table *desc; - union leaf_0x2_regs regs; + struct cpuid_regs *regs; u8 *ptr; =20 - if (c->cpuid_level < 2) + regs =3D cpuid_leaf_regs(c, 0x2); + if (!regs) return; =20 - cpuid_leaf_0x2(®s); - for_each_cpuid_0x2_desc(regs, ptr, desc) + for_each_parsed_cpuid_0x2_desc(regs, ptr, desc) intel_tlb_lookup(desc); } =20 --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 D98562EACF6 for ; Thu, 12 Jun 2025 23:42:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771726; cv=none; b=u7DGtYq+emlMgqv7vCjvZGnBtdGL3MB2ZIrdsgXcZh8ungJBfCJvL4roainIiVxgpEU6iL20KjoHKkMl3xg6uh4PPB5sPeZPCezhXihheYnkY70UQtU7RzJuJ29Pp2VYRubS/L93ZTvgW5W+vk3GbIPLxam1TGv4j0Q+HVRmTiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771726; c=relaxed/simple; bh=Q6VUb++4XOTCTCjcxAP97gZhJFg//ThEY0Q6wlCmFQg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WbJUoEwNIqsqD+A9d1ThYmkoJBF8e/hsaRB0EOSrBWRytz804qWwXs2Wt4bDsBrb+i56yo6NRoTs4Lo98VB+spKHtMLpsYjkwxzfRqvjEycc8wyVKcytwV4/BTE4Pich+QKkJKQhQT4URotzi0Eqz7sKDvZVHEG7tVUW4rbSySM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=hptZ5t+p; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=pbTxUH6l; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="hptZ5t+p"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pbTxUH6l" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771723; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rmtXB3vSta6fGqJCXxmMRAj9XLGXz6rgjPfCqdr78qY=; b=hptZ5t+pYwCmnsssTs3kV5p+jZ0m5ydkuqMpHln+/4EOvcc/F5UXzudfZ6iYmzGw1SicCn q8MhfSVTKewVDHWAtQoQLKBmrixWrJJQ08ObCG+W0L+8w2c7sqFJg7Wp16aFivW/dD/PIV GsBhaq2EkWWkzI/WJM0kjHQVR6OgAdrwO1vxxc8NqJiNG8w6HaxjRCDQJsq/qDMaq3rZaw QdYvy3kA9i5A4MpPVNcMpwR6o1+Jcef46FL1/NUo3CC8LdeEiAtFvn1gCgeiJS195Fr3Y1 kGay/LjhAos7/MFrPqRFchA2kb90KwBOSbfh+CpXp/Y8meLiwaafGSf85ogIkg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771723; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rmtXB3vSta6fGqJCXxmMRAj9XLGXz6rgjPfCqdr78qY=; b=pbTxUH6l/rkZHujxFSfFNjT0CG3mIE9+TTUGhkeFZuclR+mcPGmFtTKlvpqiHAsYw+mA+E pigsH4JcBepjNEAQ== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 31/44] x86/cacheinfo: Use parsed CPUID(0x2) Date: Fri, 13 Jun 2025 01:39:57 +0200 Message-ID: <20250612234010.572636-32-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use parsed CPUID(0x2) access instead of direct CPUID queries. Remove the max standard CPUID level check since the NULL check of cpuid_leaf_regs()'s result is equivalent. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/cacheinfo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinf= o.c index adfa7e8bb865..39cd6db4f702 100644 --- a/arch/x86/kernel/cpu/cacheinfo.c +++ b/arch/x86/kernel/cpu/cacheinfo.c @@ -382,14 +382,14 @@ static void intel_cacheinfo_0x2(struct cpuinfo_x86 *c) { unsigned int l1i =3D 0, l1d =3D 0, l2 =3D 0, l3 =3D 0; const struct leaf_0x2_table *desc; - union leaf_0x2_regs regs; + struct cpuid_regs *regs; u8 *ptr; =20 - if (c->cpuid_level < 2) + regs =3D cpuid_leaf_regs(c, 0x2); + if (!regs) return; =20 - cpuid_leaf_0x2(®s); - for_each_cpuid_0x2_desc(regs, ptr, desc) { + for_each_parsed_cpuid_0x2_desc(regs, ptr, desc) { switch (desc->c_type) { case CACHE_L1_INST: l1i +=3D desc->c_size; break; case CACHE_L1_DATA: l1d +=3D desc->c_size; break; --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 36D6D2E174B for ; Thu, 12 Jun 2025 23:42:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771730; cv=none; b=IvD12Mvz1g+qVQ6JAlJG+hzB23g39TkKwKKHviAMux26qmLZJrcaSKxsp9ojdrxuxFbdlN3ydGoxUJPK3G9jlY49sHXQgBAsix5Go6ayXT0FhdjRah+EyvMxRUFnavVswJCBJsI20ocWH+Vhp9Gr7Roe2n3br1OsCxeuVKd5pgU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771730; c=relaxed/simple; bh=z82VwTthUFfnUcTiSCwqdtyH+Epbo4FG69WCMbpyjBg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H8vi7NVM89DA++pO1aR1fco18YGCjbxeQdbiWUi99zCq+JnB1YV1y2fcMeZedFyLqC0lt7MjGDssjgeKGGqDMWHfjtsA20FU1B1+2xszKvRo56GDp50S1xiCNncD62vuJT9G0NBRNW4RM8/RQeQ8clMaOjcQsiq83+UMAiDToGk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=04+TRuU2; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=llmdiGYQ; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="04+TRuU2"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="llmdiGYQ" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771726; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d6VR7KDQRHAhp6nDb7UdnP2R2S4/sVMGxNhQnlYT1M4=; b=04+TRuU24KBcaHpYDxBZXAFti2dPt/80pTixfC84I9VFxWBmuJEHaBU06Ra/CixLvyi3FY d3/06buirwmRkzoM2xhMuREOyKoI7Qm99pFPga8TPB9pjqtjZfezboBnsprCsVbkSMUaZK MqvcHraRbEVoeFLa47IArpb/sezKPIdP+wsf4DFwNocIh0QfEMUM+rSxN1OWOXintUQSs7 RqC/lx6NTWJehbw0MuSS1PLfH20uS+NXjccui85NWVSvmzOiUDP7DqOCsZd4iOoWv4XG8y Zlxr2GLiHW8VJdnzMgwPUEmL94SeRWuhJe1DHiSuZyOyj1Oi9sXQjHy2KjMRXA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771726; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d6VR7KDQRHAhp6nDb7UdnP2R2S4/sVMGxNhQnlYT1M4=; b=llmdiGYQc6s2WIEJoyRUj6FPxXSKeyTLiOQ7QKVcd+plmglrP1CW/xLaC0+/iHBQ+91RkS otmYhIpZ9pL3BSBg== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 32/44] x86/cpuid: Remove direct CPUID(0x2) query API Date: Fri, 13 Jun 2025 01:39:58 +0200 Message-ID: <20250612234010.572636-33-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" All call sites at x86/cpu and x86/cacheinfo has been switched from direct CPUID(0x2) access to parsed CPUID access. Remove the direct CPUID(0x2) query APIs at : cpuid_leaf_0x2() for_each_cpuid_0x2_desc() Rename the iterator macro: for_each_parsed_cpuid_0x2_desc() back to: for_each_cpuid_0x2_desc() since the "for_each_parsed_.." name and was just chosen to accommodate the transition from direct CPUID(0x2) access to parsed access. Signed-off-by: Ahmed S. Darwish --- arch/x86/include/asm/cpuid/api.h | 75 ++------------------------------ arch/x86/kernel/cpu/cacheinfo.c | 2 +- arch/x86/kernel/cpu/intel.c | 2 +- 3 files changed, 5 insertions(+), 74 deletions(-) diff --git a/arch/x86/include/asm/cpuid/api.h b/arch/x86/include/asm/cpuid/= api.h index 6a0e766de565..9f9c035a9e73 100644 --- a/arch/x86/include/asm/cpuid/api.h +++ b/arch/x86/include/asm/cpuid/api.h @@ -212,75 +212,6 @@ static inline u32 cpuid_base_hypervisor(const char *si= g, u32 leaves) return 0; } =20 -/* - * CPUID(0x2) parsing: - */ - -/** - * cpuid_leaf_0x2() - Return sanitized CPUID(0x2) register output - * @regs: Output parameter - * - * Query CPUID(0x2) and store its output in @regs. Force set any - * invalid 1-byte descriptor returned by the hardware to zero (the NULL - * cache/TLB descriptor) before returning it to the caller. - * - * Use for_each_cpuid_0x2_desc() to iterate over the register output in - * parsed form. - */ -static inline void cpuid_leaf_0x2(union leaf_0x2_regs *regs) -{ - cpuid_read(0x2, regs); - - /* - * All Intel CPUs must report an iteration count of 1. In case - * of bogus hardware, treat all returned descriptors as NULL. - */ - if (regs->desc[0] !=3D 0x01) { - for (int i =3D 0; i < 4; i++) - regs->regv[i] =3D 0; - return; - } - - /* - * The most significant bit (MSB) of each register must be clear. - * If a register is invalid, replace its descriptors with NULL. - */ - for (int i =3D 0; i < 4; i++) { - if (regs->reg[i].invalid) - regs->regv[i] =3D 0; - } -} - -/** - * for_each_cpuid_0x2_desc() - Iterator for parsed CPUID(0x2) descriptors - * @_regs: CPUID(0x2) register output, as returned by cpuid_leaf_0x2() - * @_ptr: u8 pointer, for macro internal use only - * @_desc: Pointer to the parsed CPUID(0x2) descriptor at each iteration - * - * Loop over the 1-byte descriptors in the passed CPUID(0x2) output regist= ers - * @_regs. Provide the parsed information for each descriptor through @_d= esc. - * - * To handle cache-specific descriptors, switch on @_desc->c_type. For TLB - * descriptors, switch on @_desc->t_type. - * - * Example usage for cache descriptors:: - * - * const struct leaf_0x2_table *desc; - * union leaf_0x2_regs regs; - * u8 *ptr; - * - * cpuid_leaf_0x2(®s); - * for_each_cpuid_0x2_desc(regs, ptr, desc) { - * switch (desc->c_type) { - * ... - * } - * } - */ -#define for_each_cpuid_0x2_desc(_regs, _ptr, _desc) \ - for (_ptr =3D &(_regs).desc[1]; \ - _ptr < &(_regs).desc[16] && (_desc =3D &cpuid_0x2_table[*_ptr]); \ - _ptr++) - /* * CPUID(0x80000006) parsing: */ @@ -553,7 +484,7 @@ static inline bool cpuid_amd_hygon_has_l3_cache(void) */ =20 /** - * for_each_parsed_cpuid_0x2_desc() - Iterator for parsed CPUID(0x2) descr= iptors + * for_each_cpuid_0x2_desc() - Iterator for parsed CPUID(0x2) descriptors * @_regs: Leaf 0x2 register output, as returned by cpuid_leaf_regs() * @_ptr: u8 pointer, for macro internal use only * @_desc: Pointer to parsed descriptor information at each iteration @@ -575,13 +506,13 @@ static inline bool cpuid_amd_hygon_has_l3_cache(void) * // Handle error * } * - * for_each_parsed_cpuid_0x2_desc(regs, ptr, desc) { + * for_each_cpuid_0x2_desc(regs, ptr, desc) { * switch (desc->c_type) { * ... * } * } */ -#define for_each_parsed_cpuid_0x2_desc(_regs, _ptr, _desc) \ +#define for_each_cpuid_0x2_desc(_regs, _ptr, _desc) \ for (({ static_assert(sizeof(*_regs) =3D=3D sizeof(union leaf_0x2_regs));= }), \ _ptr =3D &((union leaf_0x2_regs *)(_regs))->desc[1]; \ _ptr < &((union leaf_0x2_regs *)(_regs))->desc[16] && (_desc =3D &cp= uid_0x2_table[*_ptr]);\ diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinf= o.c index 39cd6db4f702..f837ccdec116 100644 --- a/arch/x86/kernel/cpu/cacheinfo.c +++ b/arch/x86/kernel/cpu/cacheinfo.c @@ -389,7 +389,7 @@ static void intel_cacheinfo_0x2(struct cpuinfo_x86 *c) if (!regs) return; =20 - for_each_parsed_cpuid_0x2_desc(regs, ptr, desc) { + for_each_cpuid_0x2_desc(regs, ptr, desc) { switch (desc->c_type) { case CACHE_L1_INST: l1i +=3D desc->c_size; break; case CACHE_L1_DATA: l1d +=3D desc->c_size; break; diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 5eab9135b144..06c249110c8b 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -717,7 +717,7 @@ static void intel_detect_tlb(struct cpuinfo_x86 *c) if (!regs) return; =20 - for_each_parsed_cpuid_0x2_desc(regs, ptr, desc) + for_each_cpuid_0x2_desc(regs, ptr, desc) intel_tlb_lookup(desc); } =20 --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 F3C9D2E1748 for ; Thu, 12 Jun 2025 23:42:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771733; cv=none; b=ijNjVNj/1rqbROudjpXSl+svoCV/2E08PT+SBjsTiokqdw7mFuNkRU31x6LAanRYZQMk+LpL+rlwJehzfDOaimlfgaWQ5rryfeTdI/3M7m9fRNpzKrTW7zHTDmi3RzS3i6nryPJiDumVRdX373Sui1FlttSiQsZeYRf0p8o6AuE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771733; c=relaxed/simple; bh=aR+UI4C4MAimQMAqPv1GqDX3IwIC2H0GKylAz7pDzCc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rfqaFbjo5w+teULUHtFa0uXNRSGb2HrUYaAfFe5b5PYx4i6S2KOcRjO1hGzj6/3vnQxqtwqDZBrxtsuArgFnxnsl1+43V3Gvlb8Ekshc0Sw1adr1jYvzvN7lOMgCZ47ovl1NbdjiJhIVUfKuSLwngEoEMgyb5K8SmgxBYmU/xII= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0OhGCgq4; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=CSnzt7WK; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0OhGCgq4"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="CSnzt7WK" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771730; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=whCh25rfx8GS4+bYaV14J04tuZqHGipi3a6qkBt9AVI=; b=0OhGCgq4qnehIpgm7u20AM9hxqQqZQDuGIXvX97WcGQZMD9eUr3UXMtUfPN5zMCXAqYUlf /EAqdTdfge754+p4XQYIVeCLZnlBoAe0u/x1joOKxHHn33p9wdVRIsZW73p3mHF+l0fSjh CzqmwWlX2a5QT51rGb9gt+u7DEzK/n+XJr2h3wAoleL/lqwAh51lfDyizQcNEHFoVU9vSC Z5+yicCDvorZ8D6s7KgL5n6of6L+flH54qWxW2dLgIc9ikcFUnJkqgxWmlJF4EioJiSBI7 W9HyCoaLnmRc92SlWocFAFIptcyOk55yOtu+kuSwXWaNp3oBaV3Hu+abMxW5uA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771730; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=whCh25rfx8GS4+bYaV14J04tuZqHGipi3a6qkBt9AVI=; b=CSnzt7WKS6qSpdnBqVQhEnIRdIn0PVxGHTFmhvRenq2znSTY91Cl6oyPKnrIhX7qhkQfOD kVqhd6d70gWb/nDA== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 33/44] x86/cpuid: Parse deterministic cache parameters CPUID leaves Date: Fri, 13 Jun 2025 01:39:59 +0200 Message-ID: <20250612234010.572636-34-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add CPUID parser logic for Intel CPUID(0x4) and AMD CPUID(0x8000001d). Define a single cpuid_read_deterministic_cache() parsing function for both leaves, as both have the same subleaf cache enumeration logic. Introduce __define_cpuid_read_function() macro to avoid code duplication between cpuid_read_generic(), the CPUID parser's default read function, and the new cpuid_read_deterministic_cache() one. Signed-off-by: Ahmed S. Darwish --- arch/x86/include/asm/cpuid/types.h | 2 ++ arch/x86/kernel/cpu/cpuid_parser.c | 37 +++++++++++++++++++++++++----- arch/x86/kernel/cpu/cpuid_parser.h | 4 +++- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/cpuid/types.h b/arch/x86/include/asm/cpui= d/types.h index 7bbf0671cb95..89c399629e58 100644 --- a/arch/x86/include/asm/cpuid/types.h +++ b/arch/x86/include/asm/cpuid/types.h @@ -216,7 +216,9 @@ struct cpuid_leaves { CPUID_LEAF(0x0, 0, 1); CPUID_LEAF(0x1, 0, 1); CPUID_LEAF(0x2, 0, 1); + CPUID_LEAF(0x4, 0, 8); CPUID_LEAF(0x80000000, 0, 1); + CPUID_LEAF(0x8000001d, 0, 8); }; =20 /* diff --git a/arch/x86/kernel/cpu/cpuid_parser.c b/arch/x86/kernel/cpu/cpuid= _parser.c index 9bd68b150150..3d0fa1c12ad0 100644 --- a/arch/x86/kernel/cpu/cpuid_parser.c +++ b/arch/x86/kernel/cpu/cpuid_parser.c @@ -16,17 +16,42 @@ * Leaf read functions: */ =20 -/* - * Default CPUID parser read function +/** + * __define_cpuid_parser_read_function() - Generate a CPUID parser leaf re= ad function + * @suffix: Generated function name suffix (full name becomes: cpuid_read_= @suffix()) + * @_leaf_t: Type to cast the CPUID query output storage pointer + * @_leaf: Name of the CPUID query storage pointer + * @_break_c: Condition to break the CPUID parsing loop, which may referen= ce @_leaf, and + * where @_leaf stores each iteration's CPUID query output. * * Satisfies the requirements stated at 'struct cpuid_parse_entry'->read(). + * Define a CPUID parser read function according to the requirements state= d at + * 'struct cpuid_parse_entry'->read(). */ -static void cpuid_read_generic(const struct cpuid_parse_entry *e, struct c= puid_read_output *output) -{ - for (int i =3D 0; i < e->maxcnt; i++, output->regs++, output->info->nr_en= tries++) - cpuid_read_subleaf(e->leaf, e->subleaf + i, output->regs); +#define __define_cpuid_parser_read_function(suffix, _leaf_t, _leaf, _break= _c) \ +static void \ +cpuid_read_##suffix(const struct cpuid_parse_entry *e, struct cpuid_read_o= utput *output) \ +{ \ + struct _leaf_t *_leaf =3D (struct _leaf_t *)output->regs; \ + \ + for (int i =3D 0; i < e->maxcnt; i++, _leaf++, output->info->nr_entries++= ) { \ + cpuid_read_subleaf(e->leaf, e->subleaf + i, _leaf); \ + if (_break_c) \ + break; \ + } \ } =20 +/* + * Default CPUID parser read function + */ +__define_cpuid_parser_read_function(generic, cpuid_regs, ignored, false); + +/* + * Shared read function for Intel CPUID(0x4) and AMD CPUID(0x8000001d), as= both have + * the same subleaf enumeration logic and registers output format. + */ +__define_cpuid_parser_read_function(deterministic_cache, leaf_0x4_0, l, l-= >cache_type =3D=3D 0); + static void cpuid_read_0x2(const struct cpuid_parse_entry *e, struct cpuid= _read_output *output) { union leaf_0x2_regs *regs =3D (union leaf_0x2_regs *)output->regs; diff --git a/arch/x86/kernel/cpu/cpuid_parser.h b/arch/x86/kernel/cpu/cpuid= _parser.h index cf999e6a574d..be4ef64c48b6 100644 --- a/arch/x86/kernel/cpu/cpuid_parser.h +++ b/arch/x86/kernel/cpu/cpuid_parser.h @@ -97,7 +97,9 @@ struct cpuid_parse_entry { CPUID_PARSE_ENTRY(0x0, 0, generic), \ CPUID_PARSE_ENTRY(0x1, 0, generic), \ CPUID_PARSE_ENTRY(0x2, 0, 0x2), \ - CPUID_PARSE_ENTRY(0x80000000, 0, 0x80000000), + CPUID_PARSE_ENTRY(0x4, 0, deterministic_cache), \ + CPUID_PARSE_ENTRY(0x80000000, 0, 0x80000000), \ + CPUID_PARSE_ENTRY(0x8000001d, 0, deterministic_cache), =20 extern const struct cpuid_parse_entry cpuid_common_parse_entries[]; extern const int cpuid_common_parse_entries_size; --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 24CC02EB5BB for ; Thu, 12 Jun 2025 23:42:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771736; cv=none; b=luvvnPvzCRko9rITNQlU5Pve4JfwpkKfpnWvR9xB1t8TRZ6K45Va7SVfElt7Yg8hON+8q6J4LOVFn4Q33rZBYItv7ybf0kVpX4E3AQgABp1J6xZJ4p8KFnt2SCXlUGEVOLPdj1PVR+gPoDOcZurRptjaP70kFTkYLLbRha9DS/8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771736; c=relaxed/simple; bh=ZRkIeO0BTcv/lumFRsJ4Atyy4DdC7OCXYFbW9VI5Lig=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CKqVAA9mIOIl7rMBGaWiaE3oWT8rHyc2faFmpNLmeOr2GCYREK1F4nHBAj2lacYp3MfHfaOIPZPZaC6pvGo8SL9b1QLQ4Rk5XngN6l9vbEh2GJirl0k478eQ/ELe9Pj9HFEWOqW8OGlmnuMEoIQD/hmlvRXwG9pO8mgZ38ooTkI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=KiQwRa5p; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=DuEQIMIg; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="KiQwRa5p"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="DuEQIMIg" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771733; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0d6+AjEeMoKQFGCB/Vkk9/QFVZvuEWvHCBVLkE734to=; b=KiQwRa5p63Y3G9U+VRMTisFWQQRk78Au6sFGLaYf1Sqml5c2PfG0EGupkvwlpw9oMPgc91 aXH2yX1gRGpOM6dhZ0O+oWaAaB8LqK/P+bEJ9cGp249Dr4Eq1jMZmMYdrXGT52wH7jKtXc lyt4UR0SpJstNElK35CIt4jzZkNiqB14E4Dop3XRDSO87B12DgG1Q00+9ug72idtNqsrCD 8zCl6Xht2oVOqaPUmT4KqNsaWqXPo4+LplClqYu2ppSVTRSh6tfQBl0oaYC7OOSZwPfG/W v0v8sS9zSX6vmFrysBg5wNPKu209fi0OuLxEO8h3EhNyDoSqvHpBfzUmigRpYg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771733; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0d6+AjEeMoKQFGCB/Vkk9/QFVZvuEWvHCBVLkE734to=; b=DuEQIMIgJChsyGP90pMD53URrrAja1/3HeWmx0P7fEBlxTmTSi8CEOkL7Ti29oP7vsgy8x QHP9TZlKqTWvBZCA== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 34/44] x86/cacheinfo: Pass a 'struct cpuinfo_x86' refrence to CPUID(0x4) code Date: Fri, 13 Jun 2025 01:40:00 +0200 Message-ID: <20250612234010.572636-35-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Prepare the CPUID(0x4) cache topology code for using parsed CPUID APIs instead of invoking direct CPUID queries. Since such an API requires a 'struct cpuinfo_x86' reference, trickle it from the 's populate_cache_leaves() x86 implementation down to fill_cpuid4_info() and its Intel-specific CPUID(0x4) code. No functional change intended. Suggested-by: Ingo Molnar Signed-off-by: Ahmed S. Darwish Link: https://lore.kernel.org/lkml/aBnEBbDATdE2LTGU@gmail.com --- arch/x86/kernel/cpu/cacheinfo.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinf= o.c index f837ccdec116..0ed5dd6d29ef 100644 --- a/arch/x86/kernel/cpu/cacheinfo.c +++ b/arch/x86/kernel/cpu/cacheinfo.c @@ -252,7 +252,7 @@ static int amd_fill_cpuid4_info(int index, struct _cpui= d4_info *id4) return cpuid4_info_fill_done(id4, eax, ebx, ecx); } =20 -static int intel_fill_cpuid4_info(int index, struct _cpuid4_info *id4) +static int intel_fill_cpuid4_info(struct cpuinfo_x86 *unused, int index, s= truct _cpuid4_info *id4) { union _cpuid4_leaf_eax eax; union _cpuid4_leaf_ebx ebx; @@ -264,13 +264,13 @@ static int intel_fill_cpuid4_info(int index, struct _= cpuid4_info *id4) return cpuid4_info_fill_done(id4, eax, ebx, ecx); } =20 -static int fill_cpuid4_info(int index, struct _cpuid4_info *id4) +static int fill_cpuid4_info(struct cpuinfo_x86 *c, int index, struct _cpui= d4_info *id4) { u8 cpu_vendor =3D boot_cpu_data.x86_vendor; =20 return (cpu_vendor =3D=3D X86_VENDOR_AMD || cpu_vendor =3D=3D X86_VENDOR_= HYGON) ? amd_fill_cpuid4_info(index, id4) : - intel_fill_cpuid4_info(index, id4); + intel_fill_cpuid4_info(c, index, id4); } =20 static int find_num_cache_leaves(struct cpuinfo_x86 *c) @@ -434,7 +434,7 @@ static bool intel_cacheinfo_0x4(struct cpuinfo_x86 *c) struct _cpuid4_info id4 =3D {}; int ret; =20 - ret =3D intel_fill_cpuid4_info(i, &id4); + ret =3D intel_fill_cpuid4_info(c, i, &id4); if (ret < 0) continue; =20 @@ -618,13 +618,14 @@ int populate_cache_leaves(unsigned int cpu) { struct cpu_cacheinfo *this_cpu_ci =3D get_cpu_cacheinfo(cpu); struct cacheinfo *ci =3D this_cpu_ci->info_list; + struct cpuinfo_x86 *c =3D &cpu_data(cpu); u8 cpu_vendor =3D boot_cpu_data.x86_vendor; struct amd_northbridge *nb =3D NULL; struct _cpuid4_info id4 =3D {}; int idx, ret; =20 for (idx =3D 0; idx < this_cpu_ci->num_leaves; idx++) { - ret =3D fill_cpuid4_info(idx, &id4); + ret =3D fill_cpuid4_info(c, idx, &id4); if (ret) return ret; =20 --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 322372EB5CA for ; Thu, 12 Jun 2025 23:42:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771739; cv=none; b=fKkJ/D8Yq5fh9IECd1Hz5yCaGZsBJiQVj1PfOYKKZiqe7DStLI9oX4ZQ3WrSE48FlB3BVUg2GSP0P9pfKKJmGHiq5azrmPB5S3EgR98X4s52Y/oY5dloSPxZmpxLyCOF0jJd7F7JP0Npwal3G4sdLcefK3VhQ939JcrTtnEiVJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771739; c=relaxed/simple; bh=EbfwzJoyPeSWcXCnGLgeZ+nY1PlcXpzd7l86nm+NKwQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X1mBcWtEm+dtX3R3FTiAeF3f+J0g+65FqLMEegFXyqVuxWXNMSdLkN0G6xFVWMnSv6lkhMTByVfBCft/GnK3KWbEJFqOqqSEzxByLuxh07sVk+/zfUlwehkttOcxQ7zHaQjJjhYiC7GrjjjMz9yyKK1P7z034OrsoxP5nESUzWI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=UA9BsVcA; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=6lFtoll2; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="UA9BsVcA"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="6lFtoll2" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771736; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9tsVcjRsrmz5t1HharsE0QO5QjInb35V8lQCspKnDVw=; b=UA9BsVcAFW5j9TfqZv1/QV2FHsKHlbPZ/EWx1aCjwkrFR7h7ZuwHF8JOsdvOYg0K4UPbE+ GoCQlqIH60AiEYXmZVwNoC9uCpFlMNS0kA2it557J3grlpw3NrXgBah7UNavS8lXypHnLi 06vLbfTWw7ODk+Mhg0UGmAFDlMwJSOYcHDvx5k4kCHBm81XDUd0ya3wnczHRMJdntVfXBn 1xrCzLXqp7sUAlO60sH+D6hympWel9VU4n1/TWS3cJYp6Hp99CWcPAQ97CQqOU1IzvOR++ YA5qtHPaAq7DYpsFfRY5B+5SwMIKebV+cj148TFzHbvE3fc5CyrD1MzJxLhU8A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771736; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9tsVcjRsrmz5t1HharsE0QO5QjInb35V8lQCspKnDVw=; b=6lFtoll2NUtCSJ8rQ22/k/qsbVfa50hpprWPHZdiBjJm8fpTlanyIao9I9hSY1ORmMbzKO XZBtt+y0/OTMOCAw== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 35/44] x86/cacheinfo: Use parsed CPUID(0x4) Date: Fri, 13 Jun 2025 01:40:01 +0200 Message-ID: <20250612234010.572636-36-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Refactor the Intel CPUID(0x4) cacheinfo logic to use parsed CPUID access instead of issuing direct CPUID queries. Use the parsed CPUID access macro: cpuid_subleaf_count(c, 0x4) to determine the number of Intel CPUID(0x4) cache leaves instead of calling find_num_cache_leaves(), which internally issues direct CPUID queries. Since find_num_cache_leaves() is no longer needed for Intel code paths, make it AMD-specific. Rename it to amd_find_num_cache_leaves() and remove its Intel CPUID(0x4) logic. Adjust the AMD paths accordingly. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/cacheinfo.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinf= o.c index 0ed5dd6d29ef..07f0883f9fbe 100644 --- a/arch/x86/kernel/cpu/cacheinfo.c +++ b/arch/x86/kernel/cpu/cacheinfo.c @@ -252,16 +252,14 @@ static int amd_fill_cpuid4_info(int index, struct _cp= uid4_info *id4) return cpuid4_info_fill_done(id4, eax, ebx, ecx); } =20 -static int intel_fill_cpuid4_info(struct cpuinfo_x86 *unused, int index, s= truct _cpuid4_info *id4) +static int intel_fill_cpuid4_info(struct cpuinfo_x86 *c, int index, struct= _cpuid4_info *id4) { - union _cpuid4_leaf_eax eax; - union _cpuid4_leaf_ebx ebx; - union _cpuid4_leaf_ecx ecx; - u32 ignored; - - cpuid_count(4, index, &eax.full, &ebx.full, &ecx.full, &ignored); + const struct cpuid_regs *regs =3D cpuid_subleaf_index_regs(c, 0x4, index); =20 - return cpuid4_info_fill_done(id4, eax, ebx, ecx); + return cpuid4_info_fill_done(id4, + (union _cpuid4_leaf_eax)(regs->eax), + (union _cpuid4_leaf_ebx)(regs->ebx), + (union _cpuid4_leaf_ecx)(regs->ecx)); } =20 static int fill_cpuid4_info(struct cpuinfo_x86 *c, int index, struct _cpui= d4_info *id4) @@ -273,17 +271,16 @@ static int fill_cpuid4_info(struct cpuinfo_x86 *c, in= t index, struct _cpuid4_inf intel_fill_cpuid4_info(c, index, id4); } =20 -static int find_num_cache_leaves(struct cpuinfo_x86 *c) +static int amd_find_num_cache_leaves(struct cpuinfo_x86 *c) { - unsigned int eax, ebx, ecx, edx, op; union _cpuid4_leaf_eax cache_eax; + unsigned int eax, ebx, ecx, edx; int i =3D -1; =20 - /* Do a CPUID(op) loop to calculate num_cache_leaves */ - op =3D (c->x86_vendor =3D=3D X86_VENDOR_AMD || c->x86_vendor =3D=3D X86_V= ENDOR_HYGON) ? 0x8000001d : 4; + /* Do a CPUID(0x8000001d) loop to calculate num_cache_leaves */ do { ++i; - cpuid_count(op, i, &eax, &ebx, &ecx, &edx); + cpuid_count(0x8000001d, i, &eax, &ebx, &ecx, &edx); cache_eax.full =3D eax; } while (cache_eax.split.type !=3D CTYPE_NULL); return i; @@ -313,7 +310,7 @@ void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c, u= 16 die_id) * of threads sharing the L3 cache. */ u32 eax, ebx, ecx, edx, num_sharing_cache =3D 0; - u32 llc_index =3D find_num_cache_leaves(c) - 1; + u32 llc_index =3D amd_find_num_cache_leaves(c) - 1; =20 cpuid_count(0x8000001d, llc_index, &eax, &ebx, &ecx, &edx); if (eax) @@ -344,7 +341,7 @@ void init_amd_cacheinfo(struct cpuinfo_x86 *c) struct cpu_cacheinfo *ci =3D get_cpu_cacheinfo(c->cpu_index); =20 if (boot_cpu_has(X86_FEATURE_TOPOEXT)) - ci->num_leaves =3D find_num_cache_leaves(c); + ci->num_leaves =3D amd_find_num_cache_leaves(c); else if (c->extended_cpuid_level >=3D 0x80000006) ci->num_leaves =3D (cpuid_edx(0x80000006) & 0xf000) ? 4 : 3; } @@ -353,7 +350,7 @@ void init_hygon_cacheinfo(struct cpuinfo_x86 *c) { struct cpu_cacheinfo *ci =3D get_cpu_cacheinfo(c->cpu_index); =20 - ci->num_leaves =3D find_num_cache_leaves(c); + ci->num_leaves =3D amd_find_num_cache_leaves(c); } =20 static void intel_cacheinfo_done(struct cpuinfo_x86 *c, unsigned int l3, @@ -425,7 +422,7 @@ static bool intel_cacheinfo_0x4(struct cpuinfo_x86 *c) * that the number of leaves has been previously initialized. */ if (!ci->num_leaves) - ci->num_leaves =3D find_num_cache_leaves(c); + ci->num_leaves =3D cpuid_subleaf_count(c, 0x4); =20 if (!ci->num_leaves) return false; --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 7A2E72EBDC2 for ; Thu, 12 Jun 2025 23:42:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771743; cv=none; b=WkpazL2NmDN/eq4mJ95hRduTqHY3zABGqd+Zd88ZuhGYpPmHwBZ7dLmjCdCkMqcKovH+r/p6JwEiYwGtyZRa2iwWxQ8DGax6/eKViVNpN2bKKcow1Ap/rliP8iPMY+v4LMkXWA5lA2oGvbiGnn0DK0yRpT+35a/mtZ2PbBHUWX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771743; c=relaxed/simple; bh=FPi0T+ZPHVxFlKBJeZhvqtH99ssopk9ydCy7etjY6jM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jV5HkIyDdRvjj/fJqDF8VSUDavdEbGHkQMxTXgkwTw1FwnFh/lK+yIoBYUS7TKcpkcHt+Cf3Gv1IJnwBIsYu63q8+YwVaf0JC6XVr9nZIO/8gfVw/RuJ5LHU6gR9cua1o0AtiFZR/DAGxbqdz9M5zleDySzPU2O6fo5s688v1gs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ZvRF/pDT; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=NjB3MXsY; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ZvRF/pDT"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NjB3MXsY" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mjuF6lOnbxM2mnXkJdbZYdkl6Gf4g+uakMCPx4X7vT8=; b=ZvRF/pDTQ3dZzYCM45JbeDpHxMyOl1x8slccSp922ts9wmnrDnkk2yFtS2b7+ivnVTgCXC u8N4lJSQy11+M57RSONF/C6citnjgIp0Ln+iJ6bu+cOlOidKd/DlXCPlZDIkZ/yPkx9BG2 bBTWPWo+NKUdzJO3S7BeFi6+kKYzZ9pN4EzF5Z+y5Li//XjPP1mLCDKk29Ug/BKZesMUxg +mmSZUl7yMXNAHew+JISzZ3e6OG5uXXgJt3lsNhv5CXRgyF6H6YD1XXc+TIY2aVz9mb78Z ysag2hbRtRGU7PQ7cmoJjUwUkgG7880iytzpgI5Xkm6yQiUpazJlwfraRZJ0Vw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mjuF6lOnbxM2mnXkJdbZYdkl6Gf4g+uakMCPx4X7vT8=; b=NjB3MXsYFn9QV9B0xTjR+LHfu12OFf5e03rqdT7WBQgc7S694Nz7AQGAqNTN6tVbMYqsLF 3v4Cx1UnfsesvlDA== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 36/44] x86/cacheinfo: Use parsed CPUID(0x8000001d) Date: Fri, 13 Jun 2025 01:40:02 +0200 Message-ID: <20250612234010.572636-37-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Refactor the AMD CPUID(0x8000001d) cacheinfo logic to use the parsed CPUID API instead of issuing direct CPUID queries. Beside CPUID data centralization benefits, this allows using the auto-generated 'struct cpuid_0x8000001d_0' data type with its full C99 bitfields instead of doing ugly bitwise operations. Since parsed CPUID access requires a 'struct cpuinfo_x86' reference, trickle it down to relevant functions. Use the parsed CPUID API: cpuid_subleaf_count(c, 0x8000001d) to find the number of cache leaves, thus replacing amd_find_num_cache_leaves() and its direct CPUID queries. Drop that function entirely as it is no longer needed. For now, keep using the 'union _cpuid4_leaf_eax/ebx/ecx' structures as they are required by the AMD CPUID(0x4) emulation code paths. A follow up commit will replace them with equivalents. Note, for below code: cpuid_count(0x8000001d, llc_index, &eax, &ebx, &ecx, &edx); if (eax) num_sharing_cache =3D ((eax >> 14) & 0xfff) + 1; if (num_sharing_cache) { int index_msb =3D get_count_order(num_sharing_cache); ... } it is replaced with: const struct leaf_0x8000001d_0 *leaf =3D cpuid_subleaf_index(c, 0x8000001d, llc_index); if (leaf) { int index_msb =3D get_count_order(l->num_threads_sharing + 1); ... } The "if (leaf)" check is sufficient since the parsed CPUID API returns NULL if the leaf is out of range (> max CPU extended leaf) or if the 'llc_index' is out of range. An out of range LLC index is equivalent to "EAX.cache_type =3D=3D 0" in the original code, making the logic match. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/cacheinfo.c | 47 +++++++++++---------------------- 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinf= o.c index 07f0883f9fbe..05a3fbd0d849 100644 --- a/arch/x86/kernel/cpu/cacheinfo.c +++ b/arch/x86/kernel/cpu/cacheinfo.c @@ -237,16 +237,19 @@ static int cpuid4_info_fill_done(struct _cpuid4_info = *id4, union _cpuid4_leaf_ea return 0; } =20 -static int amd_fill_cpuid4_info(int index, struct _cpuid4_info *id4) +static int amd_fill_cpuid4_info(struct cpuinfo_x86 *c, int index, struct _= cpuid4_info *id4) { union _cpuid4_leaf_eax eax; union _cpuid4_leaf_ebx ebx; union _cpuid4_leaf_ecx ecx; - u32 ignored; =20 - if (boot_cpu_has(X86_FEATURE_TOPOEXT) || boot_cpu_data.x86_vendor =3D=3D = X86_VENDOR_HYGON) - cpuid_count(0x8000001d, index, &eax.full, &ebx.full, &ecx.full, &ignored= ); - else + if (boot_cpu_has(X86_FEATURE_TOPOEXT) || boot_cpu_data.x86_vendor =3D=3D = X86_VENDOR_HYGON) { + const struct cpuid_regs *regs =3D cpuid_subleaf_index_regs(c, 0x8000001d= , index); + + eax.full =3D regs->eax; + ebx.full =3D regs->ebx; + ecx.full =3D regs->ecx; + } else legacy_amd_cpuid4(index, &eax, &ebx, &ecx); =20 return cpuid4_info_fill_done(id4, eax, ebx, ecx); @@ -267,25 +270,10 @@ static int fill_cpuid4_info(struct cpuinfo_x86 *c, in= t index, struct _cpuid4_inf u8 cpu_vendor =3D boot_cpu_data.x86_vendor; =20 return (cpu_vendor =3D=3D X86_VENDOR_AMD || cpu_vendor =3D=3D X86_VENDOR_= HYGON) ? - amd_fill_cpuid4_info(index, id4) : + amd_fill_cpuid4_info(c, index, id4) : intel_fill_cpuid4_info(c, index, id4); } =20 -static int amd_find_num_cache_leaves(struct cpuinfo_x86 *c) -{ - union _cpuid4_leaf_eax cache_eax; - unsigned int eax, ebx, ecx, edx; - int i =3D -1; - - /* Do a CPUID(0x8000001d) loop to calculate num_cache_leaves */ - do { - ++i; - cpuid_count(0x8000001d, i, &eax, &ebx, &ecx, &edx); - cache_eax.full =3D eax; - } while (cache_eax.split.type !=3D CTYPE_NULL); - return i; -} - /* * AMD/Hygon CPUs may have multiple LLCs if L3 caches exist. */ @@ -309,15 +297,12 @@ void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c,= u16 die_id) * Newer families: LLC ID is calculated from the number * of threads sharing the L3 cache. */ - u32 eax, ebx, ecx, edx, num_sharing_cache =3D 0; - u32 llc_index =3D amd_find_num_cache_leaves(c) - 1; - - cpuid_count(0x8000001d, llc_index, &eax, &ebx, &ecx, &edx); - if (eax) - num_sharing_cache =3D ((eax >> 14) & 0xfff) + 1; + u32 llc_index =3D cpuid_subleaf_count(c, 0x8000001d) - 1; + const struct leaf_0x8000001d_0 *leaf =3D + cpuid_subleaf_index(c, 0x8000001d, llc_index); =20 - if (num_sharing_cache) { - int index_msb =3D get_count_order(num_sharing_cache); + if (leaf) { + int index_msb =3D get_count_order(leaf->num_threads_sharing + 1); =20 c->topo.llc_id =3D c->topo.apicid >> index_msb; } @@ -341,7 +326,7 @@ void init_amd_cacheinfo(struct cpuinfo_x86 *c) struct cpu_cacheinfo *ci =3D get_cpu_cacheinfo(c->cpu_index); =20 if (boot_cpu_has(X86_FEATURE_TOPOEXT)) - ci->num_leaves =3D amd_find_num_cache_leaves(c); + ci->num_leaves =3D cpuid_subleaf_count(c, 0x8000001d); else if (c->extended_cpuid_level >=3D 0x80000006) ci->num_leaves =3D (cpuid_edx(0x80000006) & 0xf000) ? 4 : 3; } @@ -350,7 +335,7 @@ void init_hygon_cacheinfo(struct cpuinfo_x86 *c) { struct cpu_cacheinfo *ci =3D get_cpu_cacheinfo(c->cpu_index); =20 - ci->num_leaves =3D amd_find_num_cache_leaves(c); + ci->num_leaves =3D cpuid_subleaf_count(c, 0x8000001d); } =20 static void intel_cacheinfo_done(struct cpuinfo_x86 *c, unsigned int l3, --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 A1F372EBDCB for ; Thu, 12 Jun 2025 23:42:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771746; cv=none; b=jYqCnYzCVC0ST3+LlJGLsdcgCQ5EciyvdALjl0Lj7+70oviRQb89qdoCFpDjJybMxeez1wgYbjG7ZW94SSFDG9PtVWkuHIZYhy5Fn4cODX5VAU1XegAnrKVyf1hqpAkGQG12LTEdbXS6fYlsoFHjf1P9SRHJJoIZUuc7dsQSFyc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771746; c=relaxed/simple; bh=EVKH8nfEgonaFzkVahC/BRc7Qbl6kfDEPJpWVI/fQLs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BBGrPJsvqnj8NA7wVNVBtj+bGzdt36e95+760T5bkONFVHcpT5t25uofc1yZ8Frud3pcmUVdrnJykqW66WYrTsEk9ZKANBiWKSo/2oRepboJUMEgJ4WgG+wWPfcStgbJM/Gjt2NkYMNMA241UgsOyQeIq+6kH7IeiipOB4BVArg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=B+8FETRN; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=T1Yaeif0; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="B+8FETRN"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="T1Yaeif0" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CUY+X91MtS5sqFzNBN+KlUOYWoIRlN0bK845o2Ya5Zg=; b=B+8FETRNYWv1IQpLmERf755SmNQPg9wIgJ+0WlReh9u9qrmEf4GeaULHWaP/WGoI6NqVwg br/B8rhdBdNyYKips4Hqh+EDTlMmHO0Hp84LhtulyUNiWuoLLm6YDty0e8GFq9t9UP4c5T oFj5pv66U1pggjKT70kIyqb0rp6ck5gFl/X5uRK34jhNYSZRS1beTstPCzFTYTVyTZMrvi g6wykiOiMs5A50nD80ueEX1226Tdd0RgKyh1Jbjg3H0YavXnWX1R6QGD0i8olWJx4ikzzG GMebRwb2QV5pWHPUBVy+nvg/M/O9wClt3KdqauNV1GPPdQ9XG0X8GhKOgomNZQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CUY+X91MtS5sqFzNBN+KlUOYWoIRlN0bK845o2Ya5Zg=; b=T1Yaeif079k5Bz/lO8BAixhxEcf51YCNtPZMtRZEJPvnFP45K8h2tVxTfubWELWMrgtfY1 GNzWEcHFumJDmsDw== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 37/44] x86/cpuid: Parse CPUID(0x80000005) and CPUID(0x80000006) Date: Fri, 13 Jun 2025 01:40:03 +0200 Message-ID: <20250612234010.572636-38-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Parse AMD cacheinfo CPUID(0x80000005) and CPUID(0x80000006), if available, using the generic CPUID parser read function cpuid_read_generic(). The x86/cacheinfo AMD CPUID(0x4)-emulation logic will be swithced next to the parsed CPUID table APIs instead of invoking direct CPUID queries. Signed-off-by: Ahmed S. Darwish --- arch/x86/include/asm/cpuid/types.h | 2 ++ arch/x86/kernel/cpu/cpuid_parser.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/x86/include/asm/cpuid/types.h b/arch/x86/include/asm/cpui= d/types.h index 89c399629e58..63d2569e2821 100644 --- a/arch/x86/include/asm/cpuid/types.h +++ b/arch/x86/include/asm/cpuid/types.h @@ -218,6 +218,8 @@ struct cpuid_leaves { CPUID_LEAF(0x2, 0, 1); CPUID_LEAF(0x4, 0, 8); CPUID_LEAF(0x80000000, 0, 1); + CPUID_LEAF(0x80000005, 0, 1); + CPUID_LEAF(0x80000006, 0, 1); CPUID_LEAF(0x8000001d, 0, 8); }; =20 diff --git a/arch/x86/kernel/cpu/cpuid_parser.h b/arch/x86/kernel/cpu/cpuid= _parser.h index be4ef64c48b6..e4b34f0946ec 100644 --- a/arch/x86/kernel/cpu/cpuid_parser.h +++ b/arch/x86/kernel/cpu/cpuid_parser.h @@ -99,6 +99,8 @@ struct cpuid_parse_entry { CPUID_PARSE_ENTRY(0x2, 0, 0x2), \ CPUID_PARSE_ENTRY(0x4, 0, deterministic_cache), \ CPUID_PARSE_ENTRY(0x80000000, 0, 0x80000000), \ + CPUID_PARSE_ENTRY(0x80000005, 0, generic), \ + CPUID_PARSE_ENTRY(0x80000006, 0, generic), \ CPUID_PARSE_ENTRY(0x8000001d, 0, deterministic_cache), =20 extern const struct cpuid_parse_entry cpuid_common_parse_entries[]; --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 E36072EBDC2 for ; Thu, 12 Jun 2025 23:42:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771749; cv=none; b=TG8nzIJUkJU6FdRLsiRSgc31Efyeft6uRPu0R/PRYyKHsJRO9jp+1x13yaa6hjc4Mm9M0i3NNT/hhz+rYwCpSQHzskb1b2EmmlUnMqUVbwl5hdOFpfnT+Jt1ui3so82c6VjK8lmSFlDapaTCTqix1ypOhwP4VYquqE8GJ2+X+Hg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771749; c=relaxed/simple; bh=o474ANeWJVZlzcrSMV5Ed/SZ1EjEIgzsMfOO8j2h6aQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BUhQqpMzJpv1RgZcr1a8ifgZ4NxFPQEA6dqiLL0Ojp+DX8PbYj+p1fzQ7v5UJ5wph1H1Hdslh6HlZStoutsT1+qWn12/T6bcLnlcoxYxsTXT34KO86lJbR0vihxKYAYMs28Qu53mThhcgnZMf8t5RrpIklidlFtNZnNmytc+MmM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=hTK0CsKV; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=jT9YiE4E; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="hTK0CsKV"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="jT9YiE4E" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2ec7o83d4fyhY5AOtDVdz8zKCDhFmAcZqf5S8EoVtgQ=; b=hTK0CsKVvHJh50DpcGXZ8637rmVDSFdTZvIBpj+68wGLS8XHa8wwyE90czXNOdgfCZTqYJ dOss08hfYjcD+vdf33Puimh9e79Xef9faJIFeusNojDe8yja5oX6M5gLK1FAFrjti6DTgW nyLXGXPoHwF+pyZUAj87LKRUmcodJ8dl7yAt+8UIfBUwx4LejWOsRSxvrfmBo3ExK47Ucq J/wEPCRliNOmOJjkPI+vBmm0M1Wao5a2okcuJJdAX7kWey0kkYxwcm/JNCshhnpY/+QLrk IFjzsUnfUUdfGQOTM4rlV7sFSFCZ023J76sk9BxibLwWYAMd2cRCAiP1zERFUw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2ec7o83d4fyhY5AOtDVdz8zKCDhFmAcZqf5S8EoVtgQ=; b=jT9YiE4EK2Od3RBz1Zo/N8fyH26K14YRZcwqhzdJwP+s6+ne3O+2UltXmWtkbIvEN7GcAo +mPohsafw9It7MCw== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 38/44] x86/cacheinfo: Use auto-generated data types Date: Fri, 13 Jun 2025 01:40:04 +0200 Message-ID: <20250612234010.572636-39-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For the AMD CPUID(0x4) emulation logic, use the auto-generated data type: struct leaf_0x4_0 instead of the manually-defined: union _cpuid4_leaf_{eax,ebx,ecx} ones. Remove such unions entirely as they are no longer used. Signed-off-by: Ahmed S. Darwish Link: https://gitlab.com/x86-cpuid.org/x86-cpuid-db --- arch/x86/kernel/cpu/cacheinfo.c | 130 +++++++++++--------------------- 1 file changed, 42 insertions(+), 88 deletions(-) diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinf= o.c index 05a3fbd0d849..f0540cba4bd4 100644 --- a/arch/x86/kernel/cpu/cacheinfo.c +++ b/arch/x86/kernel/cpu/cacheinfo.c @@ -41,39 +41,8 @@ enum _cache_type { CTYPE_UNIFIED =3D 3 }; =20 -union _cpuid4_leaf_eax { - struct { - enum _cache_type type :5; - unsigned int level :3; - unsigned int is_self_initializing :1; - unsigned int is_fully_associative :1; - unsigned int reserved :4; - unsigned int num_threads_sharing :12; - unsigned int num_cores_on_die :6; - } split; - u32 full; -}; - -union _cpuid4_leaf_ebx { - struct { - unsigned int coherency_line_size :12; - unsigned int physical_line_partition :10; - unsigned int ways_of_associativity :10; - } split; - u32 full; -}; - -union _cpuid4_leaf_ecx { - struct { - unsigned int number_of_sets :32; - } split; - u32 full; -}; - struct _cpuid4_info { - union _cpuid4_leaf_eax eax; - union _cpuid4_leaf_ebx ebx; - union _cpuid4_leaf_ecx ecx; + struct leaf_0x4_0 regs; unsigned int id; unsigned long size; }; @@ -148,17 +117,14 @@ static const unsigned short assocs[] =3D { static const unsigned char levels[] =3D { 1, 1, 2, 3 }; static const unsigned char types[] =3D { 1, 2, 3, 3 }; =20 -static void legacy_amd_cpuid4(int index, union _cpuid4_leaf_eax *eax, - union _cpuid4_leaf_ebx *ebx, union _cpuid4_leaf_ecx *ecx) +static void legacy_amd_cpuid4(int index, struct leaf_0x4_0 *regs) { unsigned int dummy, line_size, lines_per_tag, assoc, size_in_kb; union l1_cache l1i, l1d, *l1; union l2_cache l2; union l3_cache l3; =20 - eax->full =3D 0; - ebx->full =3D 0; - ecx->full =3D 0; + *regs =3D (struct leaf_0x4_0){ }; =20 cpuid(0x80000005, &dummy, &dummy, &l1d.val, &l1i.val); cpuid(0x80000006, &dummy, &dummy, &l2.val, &l3.val); @@ -204,65 +170,53 @@ static void legacy_amd_cpuid4(int index, union _cpuid= 4_leaf_eax *eax, return; } =20 - eax->split.is_self_initializing =3D 1; - eax->split.type =3D types[index]; - eax->split.level =3D levels[index]; - eax->split.num_threads_sharing =3D 0; - eax->split.num_cores_on_die =3D topology_num_cores_per_package(); + regs->cache_self_init =3D 1; + regs->cache_type =3D types[index]; + regs->cache_level =3D levels[index]; + regs->num_threads_sharing =3D 0; + regs->num_cores_on_die =3D topology_num_cores_per_package(); =20 if (assoc =3D=3D AMD_CPUID4_FULLY_ASSOCIATIVE) - eax->split.is_fully_associative =3D 1; + regs->fully_associative =3D 1; =20 - ebx->split.coherency_line_size =3D line_size - 1; - ebx->split.ways_of_associativity =3D assoc - 1; - ebx->split.physical_line_partition =3D lines_per_tag - 1; - ecx->split.number_of_sets =3D (size_in_kb * 1024) / line_size / - (ebx->split.ways_of_associativity + 1) - 1; + regs->cache_linesize =3D line_size - 1; + regs->cache_nways =3D assoc - 1; + regs->cache_npartitions =3D lines_per_tag - 1; + regs->cache_nsets =3D (size_in_kb * 1024) / line_size / + (regs->cache_nways + 1) - 1; } =20 -static int cpuid4_info_fill_done(struct _cpuid4_info *id4, union _cpuid4_l= eaf_eax eax, - union _cpuid4_leaf_ebx ebx, union _cpuid4_leaf_ecx ecx) +static int cpuid4_info_fill_done(struct _cpuid4_info *id4, const struct le= af_0x4_0 *regs) { - if (eax.split.type =3D=3D CTYPE_NULL) + if (regs->cache_type =3D=3D CTYPE_NULL) return -EIO; =20 - id4->eax =3D eax; - id4->ebx =3D ebx; - id4->ecx =3D ecx; - id4->size =3D (ecx.split.number_of_sets + 1) * - (ebx.split.coherency_line_size + 1) * - (ebx.split.physical_line_partition + 1) * - (ebx.split.ways_of_associativity + 1); + id4->regs =3D *regs; + id4->size =3D (regs->cache_nsets + 1) * + (regs->cache_linesize + 1) * + (regs->cache_npartitions + 1) * + (regs->cache_nways + 1); =20 return 0; } =20 static int amd_fill_cpuid4_info(struct cpuinfo_x86 *c, int index, struct _= cpuid4_info *id4) { - union _cpuid4_leaf_eax eax; - union _cpuid4_leaf_ebx ebx; - union _cpuid4_leaf_ecx ecx; + struct leaf_0x4_0 regs; =20 - if (boot_cpu_has(X86_FEATURE_TOPOEXT) || boot_cpu_data.x86_vendor =3D=3D = X86_VENDOR_HYGON) { - const struct cpuid_regs *regs =3D cpuid_subleaf_index_regs(c, 0x8000001d= , index); - - eax.full =3D regs->eax; - ebx.full =3D regs->ebx; - ecx.full =3D regs->ecx; - } else - legacy_amd_cpuid4(index, &eax, &ebx, &ecx); + if (boot_cpu_has(X86_FEATURE_TOPOEXT) || boot_cpu_data.x86_vendor =3D=3D = X86_VENDOR_HYGON) + regs =3D *(struct leaf_0x4_0 *)cpuid_subleaf_index(c, 0x8000001d, index); + else + legacy_amd_cpuid4(index, ®s); =20 - return cpuid4_info_fill_done(id4, eax, ebx, ecx); + return cpuid4_info_fill_done(id4, ®s); } =20 static int intel_fill_cpuid4_info(struct cpuinfo_x86 *c, int index, struct= _cpuid4_info *id4) { - const struct cpuid_regs *regs =3D cpuid_subleaf_index_regs(c, 0x4, index); + const struct leaf_0x4_0 *regs =3D cpuid_subleaf_index(c, 0x4, index); =20 - return cpuid4_info_fill_done(id4, - (union _cpuid4_leaf_eax)(regs->eax), - (union _cpuid4_leaf_ebx)(regs->ebx), - (union _cpuid4_leaf_ecx)(regs->ecx)); + return cpuid4_info_fill_done(id4, regs); } =20 static int fill_cpuid4_info(struct cpuinfo_x86 *c, int index, struct _cpui= d4_info *id4) @@ -388,7 +342,7 @@ static unsigned int calc_cache_topo_id(struct cpuinfo_x= 86 *c, const struct _cpui unsigned int num_threads_sharing; int index_msb; =20 - num_threads_sharing =3D 1 + id4->eax.split.num_threads_sharing; + num_threads_sharing =3D 1 + id4->regs.num_threads_sharing; index_msb =3D get_count_order(num_threads_sharing); return c->topo.apicid & ~((1 << index_msb) - 1); } @@ -420,11 +374,11 @@ static bool intel_cacheinfo_0x4(struct cpuinfo_x86 *c) if (ret < 0) continue; =20 - switch (id4.eax.split.level) { + switch (id4.regs.cache_level) { case 1: - if (id4.eax.split.type =3D=3D CTYPE_DATA) + if (id4.regs.cache_type =3D=3D CTYPE_DATA) l1d =3D id4.size / 1024; - else if (id4.eax.split.type =3D=3D CTYPE_INST) + else if (id4.regs.cache_type =3D=3D CTYPE_INST) l1i =3D id4.size / 1024; break; case 2: @@ -485,7 +439,7 @@ static int __cache_amd_cpumap_setup(unsigned int cpu, i= nt index, } else if (boot_cpu_has(X86_FEATURE_TOPOEXT)) { unsigned int apicid, nshared, first, last; =20 - nshared =3D id4->eax.split.num_threads_sharing + 1; + nshared =3D id4->regs.num_threads_sharing + 1; apicid =3D cpu_data(cpu).topo.apicid; first =3D apicid - (apicid % nshared); last =3D first + nshared - 1; @@ -532,7 +486,7 @@ static void __cache_cpumap_setup(unsigned int cpu, int = index, } =20 ci =3D this_cpu_ci->info_list + index; - num_threads_sharing =3D 1 + id4->eax.split.num_threads_sharing; + num_threads_sharing =3D 1 + id4->regs.num_threads_sharing; =20 cpumask_set_cpu(cpu, &ci->shared_cpu_map); if (num_threads_sharing =3D=3D 1) @@ -559,13 +513,13 @@ static void ci_info_init(struct cacheinfo *ci, const = struct _cpuid4_info *id4, { ci->id =3D id4->id; ci->attributes =3D CACHE_ID; - ci->level =3D id4->eax.split.level; - ci->type =3D cache_type_map[id4->eax.split.type]; - ci->coherency_line_size =3D id4->ebx.split.coherency_line_size + 1; - ci->ways_of_associativity =3D id4->ebx.split.ways_of_associativity + 1; + ci->level =3D id4->regs.cache_level; + ci->type =3D cache_type_map[id4->regs.cache_type]; + ci->coherency_line_size =3D id4->regs.cache_linesize + 1; + ci->ways_of_associativity =3D id4->regs.cache_nways + 1; ci->size =3D id4->size; - ci->number_of_sets =3D id4->ecx.split.number_of_sets + 1; - ci->physical_line_partition =3D id4->ebx.split.physical_line_partition + = 1; + ci->number_of_sets =3D id4->regs.cache_nsets + 1; + ci->physical_line_partition =3D id4->regs.cache_npartitions + 1; ci->priv =3D nb; } =20 @@ -591,7 +545,7 @@ static void get_cache_id(int cpu, struct _cpuid4_info *= id4) unsigned long num_threads_sharing; int index_msb; =20 - num_threads_sharing =3D 1 + id4->eax.split.num_threads_sharing; + num_threads_sharing =3D 1 + id4->regs.num_threads_sharing; index_msb =3D get_count_order(num_threads_sharing); id4->id =3D c->topo.apicid >> index_msb; } --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 325D92E2EEA for ; Thu, 12 Jun 2025 23:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771753; cv=none; b=PqJVQaWHlISZ+I1mx4JcpNr+bR/BoDP4coqR+RUZxcoZ1s3Ps01UwP+jrDb4WW7uJOgFt8n/QFaY3nks6aOC8B9Y5lm85yyqHxzmWyF/nL6/xXWcywSxuM94KicgZfXDMe44mbcwHPpbJHlWgBtb6MUBfWKlL4Btfp8alJRugYE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771753; c=relaxed/simple; bh=0knIiJed+iM6apE2X1ooD/hv8cZ0HlCGEf+9pv5NZO0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=juiKSlmZfRYm3fdWvCzvakgBtAp7B44PnTWGlppOJrLhhGT5JDQbwCo59Z6QAyIPAKBvtRYmcbj03d+Dh6m5MhN3tZKP+gm+H/axBOW9zp9iRqAra5f9nBHSUI/kJ/pc+mXCAdUagcoA+DaQq4vVWTOl3UEaJ2mwHVjUyTD1/bs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Y5qVy9tp; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=xGhSosqj; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Y5qVy9tp"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="xGhSosqj" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771749; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rJmOsBqP7pyCXVJh5L49zJK7w0MxhCEoQ8Qk5wVIKow=; b=Y5qVy9tpPkqfgjxssambEegRvhVITm3AUVQYbaPNRM5RrTDwSqwPUB2neppXqeInpN0YU6 lvIiI6bilLm7lt3WeMqyycef6dFMuGOKgxQC3mjwR9JWAIGabkww5pgk5l5KfWIL8UUHni shJrE2J7nil2Ss3o0ls0n+diP0avUVIvz/sN+r5jDLfEvhP86u8yWbHY/+/Ai9yCEIxA8+ g4zNSR4ibTXHtMzcAlmnkndr1YwqMUmhZS08hl2ynkAsSwkrBkzPT9cYKWfzmez/4Od0W8 HnMccCIYLv64L2Tq6Tb3i9mOCJF5SXW5hV3rMkbslLykmtmI39Kg0o/gOFIMeQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771749; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rJmOsBqP7pyCXVJh5L49zJK7w0MxhCEoQ8Qk5wVIKow=; b=xGhSosqjSpjnukJiRO1lfCO8+80QNQ2u7+5dGEzXXfV11ri4Z6W9+ehvTS3Ex8Xk80mVQN nmWO3zj7g5EsgUAw== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 39/44] x86/cacheinfo: Use parsed CPUID(0x80000005) and CPUID(0x80000006) Date: Fri, 13 Jun 2025 01:40:05 +0200 Message-ID: <20250612234010.572636-40-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For the AMD CPUID(0x4)-emulation logic, use parsed CPUID(0x80000005) and CPUID(0x80000006) APID access instead of invoking direct CPUID queries. Beside centralizing CPUID access, this allows using the auto-generated 'struct leaf_0x80000005_0' and 'struct leaf_0x80000006_0' data types. Remove the 'union {l1,l2,l3}_cache' definitions as they are no longer needed. Note, the expression: ci->num_leaves =3D (cpuid_edx(0x80000006) & 0xf000) ? 4 : 3; is replaced with: ci->num_leaves =3D cpuid_leaf(c, 0x80000006)->l3_assoc ? 4 : 3; which is the same logic, since the 'l3_assoc' bitfield is 4 bits wide at EDX offset 12. Per AMD manuals, an L3 associativity of zero implies the absence of an L3 cache on the CPU. While at it, separate the 'Fallback AMD CPUID(0x4) emulation' comment from the '@AMD_L2_L3_INVALID_ASSOC' one, since the former acts as a source code section header. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/cacheinfo.c | 105 ++++++++++++-------------------- 1 file changed, 40 insertions(+), 65 deletions(-) diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinf= o.c index f0540cba4bd4..de8e7125eedd 100644 --- a/arch/x86/kernel/cpu/cacheinfo.c +++ b/arch/x86/kernel/cpu/cacheinfo.c @@ -56,47 +56,17 @@ static const enum cache_type cache_type_map[] =3D { }; =20 /* - * Fallback AMD CPUID(0x4) emulation + * Fallback AMD CPUID(0x4) emulation: * AMD CPUs with TOPOEXT can just use CPUID(0x8000001d) - * + */ + +/* * @AMD_L2_L3_INVALID_ASSOC: cache info for the respective L2/L3 cache sho= uld * be determined from CPUID(0x8000001d) instead of CPUID(0x80000006). */ - #define AMD_CPUID4_FULLY_ASSOCIATIVE 0xffff #define AMD_L2_L3_INVALID_ASSOC 0x9 =20 -union l1_cache { - struct { - unsigned line_size :8; - unsigned lines_per_tag :8; - unsigned assoc :8; - unsigned size_in_kb :8; - }; - unsigned int val; -}; - -union l2_cache { - struct { - unsigned line_size :8; - unsigned lines_per_tag :4; - unsigned assoc :4; - unsigned size_in_kb :16; - }; - unsigned int val; -}; - -union l3_cache { - struct { - unsigned line_size :8; - unsigned lines_per_tag :4; - unsigned assoc :4; - unsigned res :2; - unsigned size_encoded :14; - }; - unsigned int val; -}; - /* L2/L3 associativity mapping */ static const unsigned short assocs[] =3D { [1] =3D 1, @@ -117,50 +87,52 @@ static const unsigned short assocs[] =3D { static const unsigned char levels[] =3D { 1, 1, 2, 3 }; static const unsigned char types[] =3D { 1, 2, 3, 3 }; =20 -static void legacy_amd_cpuid4(int index, struct leaf_0x4_0 *regs) +static void legacy_amd_cpuid4(struct cpuinfo_x86 *c, int index, struct lea= f_0x4_0 *regs) { - unsigned int dummy, line_size, lines_per_tag, assoc, size_in_kb; - union l1_cache l1i, l1d, *l1; - union l2_cache l2; - union l3_cache l3; + const struct leaf_0x80000005_0 *el5 =3D cpuid_leaf(c, 0x80000005); + const struct leaf_0x80000006_0 *el6 =3D cpuid_leaf(c, 0x80000006); + const struct cpuid_regs *el5_raw =3D (const struct cpuid_regs *)el5; + unsigned int line_size, lines_per_tag, assoc, size_in_kb; =20 *regs =3D (struct leaf_0x4_0){ }; =20 - cpuid(0x80000005, &dummy, &dummy, &l1d.val, &l1i.val); - cpuid(0x80000006, &dummy, &dummy, &l2.val, &l3.val); - - l1 =3D &l1d; switch (index) { - case 1: - l1 =3D &l1i; - fallthrough; case 0: - if (!l1->val) + if (!el5 || !el5_raw->ecx) return; =20 - assoc =3D (l1->assoc =3D=3D 0xff) ? AMD_CPUID4_FULLY_ASSOCIATIVE : l1->= assoc; - line_size =3D l1->line_size; - lines_per_tag =3D l1->lines_per_tag; - size_in_kb =3D l1->size_in_kb; + assoc =3D el5->l1_dcache_assoc; + line_size =3D el5->l1_dcache_line_size; + lines_per_tag =3D el5->l1_dcache_nlines; + size_in_kb =3D el5->l1_dcache_size_kb; + break; + case 1: + if (!el5 || !el5_raw->edx) + return; + + assoc =3D el5->l1_icache_assoc; + line_size =3D el5->l1_icache_line_size; + lines_per_tag =3D el5->l1_icache_nlines; + size_in_kb =3D el5->l1_icache_size_kb; break; case 2: - if (!l2.assoc || l2.assoc =3D=3D AMD_L2_L3_INVALID_ASSOC) + if (!el6 || !el6->l2_assoc || el6->l2_assoc =3D=3D AMD_L2_L3_INVALID_ASS= OC) return; =20 /* Use x86_cache_size as it might have K7 errata fixes */ - assoc =3D assocs[l2.assoc]; - line_size =3D l2.line_size; - lines_per_tag =3D l2.lines_per_tag; + assoc =3D assocs[el6->l2_assoc]; + line_size =3D el6->l2_line_size; + lines_per_tag =3D el6->l2_nlines; size_in_kb =3D __this_cpu_read(cpu_info.x86_cache_size); break; case 3: - if (!l3.assoc || l3.assoc =3D=3D AMD_L2_L3_INVALID_ASSOC) + if (!el6 || !el6->l3_assoc || el6->l3_assoc =3D=3D AMD_L2_L3_INVALID_ASS= OC) return; =20 - assoc =3D assocs[l3.assoc]; - line_size =3D l3.line_size; - lines_per_tag =3D l3.lines_per_tag; - size_in_kb =3D l3.size_encoded * 512; + assoc =3D assocs[el6->l3_assoc]; + line_size =3D el6->l3_line_size; + lines_per_tag =3D el6->l3_nlines; + size_in_kb =3D el6->l3_size_range * 512; if (boot_cpu_has(X86_FEATURE_AMD_DCM)) { size_in_kb =3D size_in_kb >> 1; assoc =3D assoc >> 1; @@ -170,6 +142,10 @@ static void legacy_amd_cpuid4(int index, struct leaf_0= x4_0 *regs) return; } =20 + /* For L1d and L1i caches, 0xff is the full associativity marker */ + if ((index =3D=3D 0 || index =3D=3D 1) && assoc =3D=3D 0xff) + assoc =3D AMD_CPUID4_FULLY_ASSOCIATIVE; + regs->cache_self_init =3D 1; regs->cache_type =3D types[index]; regs->cache_level =3D levels[index]; @@ -207,7 +183,7 @@ static int amd_fill_cpuid4_info(struct cpuinfo_x86 *c, = int index, struct _cpuid4 if (boot_cpu_has(X86_FEATURE_TOPOEXT) || boot_cpu_data.x86_vendor =3D=3D = X86_VENDOR_HYGON) regs =3D *(struct leaf_0x4_0 *)cpuid_subleaf_index(c, 0x8000001d, index); else - legacy_amd_cpuid4(index, ®s); + legacy_amd_cpuid4(c, index, ®s); =20 return cpuid4_info_fill_done(id4, ®s); } @@ -279,10 +255,9 @@ void init_amd_cacheinfo(struct cpuinfo_x86 *c) { struct cpu_cacheinfo *ci =3D get_cpu_cacheinfo(c->cpu_index); =20 - if (boot_cpu_has(X86_FEATURE_TOPOEXT)) - ci->num_leaves =3D cpuid_subleaf_count(c, 0x8000001d); - else if (c->extended_cpuid_level >=3D 0x80000006) - ci->num_leaves =3D (cpuid_edx(0x80000006) & 0xf000) ? 4 : 3; + ci->num_leaves =3D boot_cpu_has(X86_FEATURE_TOPOEXT) ? + cpuid_subleaf_count(c, 0x8000001d) : + cpuid_leaf(c, 0x80000006)->l3_assoc ? 4 : 3; } =20 void init_hygon_cacheinfo(struct cpuinfo_x86 *c) --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 741452EBDFF for ; Thu, 12 Jun 2025 23:42:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771756; cv=none; b=q6TErFTgePGZmnp2AaQaPeLYQFnO+FZLH5chRiYXNN0bdxE8zUpSV4NY6L6MZi1mKyDM6gjhPKClPaIoPb8AIwx7LBhUCDoEBgw2QdjH5JqFsrR/EYAytcF6xFeEn2wnq7HPRrnrkytomFUBzeSOjkzZZmc2OdEc+rZbZXCVzm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771756; c=relaxed/simple; bh=MgMz0yYc3aNrLivaiDnkV7wvYq4izEq26RKCDhQOEwU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g90cU2QxfYI341WwegQy9VKhKaS1pI602xt+lR9gM1GMfyca3pMjI0WTq2+c4JH3rum/ULoAWm6bUhis+gI8rOy4C6/bfRifMQprT4fFJGzp5rhTSVEmqBmg6uE6G/l++hIZK5otHrCNQ3heXatVLYUSP/jbwyUfWVITIiNAwqw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=KtPoPzgb; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=NTe/386f; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="KtPoPzgb"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NTe/386f" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Vhf1GwgXj/r4oy29qh5M4jDcvHAYWmgXdBqd4lDq2c=; b=KtPoPzgb8TP780uZ0shDsVnpKm8ye5OQlXCXAq7upKDoKM5gyCUmFaBOntZ2j45xrTT2A6 PdpmrjjLXD4oDthFKl+0wX4RRlyZS3NEyCh/AP05T5jMv/nmIxN8YbFpMsWo7HDOFbBCAr mWpcDS88xQyRzq48gKVpU3I6Q7vUeOweF+k9qGfx50uNd7lvfuNvqCGdgFOaFWbv7BB0pC XQW4OsRrM6uoVkYqKFu5+BAgWZqLO7DkvetwxV0kQCyI+9xVklGCu61vCZ4HeWUIsl+iY+ eEURxldsrfd69HB9qewRrm6nDvpiaSEFeLQdrT1WbmyOcEvt4VDpijQLHTJB7A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Vhf1GwgXj/r4oy29qh5M4jDcvHAYWmgXdBqd4lDq2c=; b=NTe/386f8LN+3tSi0oLhCWGrUrbKCWKwv8OxbJFfzcdbqttBgSmUBIHJ48Jb2fuPrasxEU /fyNlYHaBCEjIWDg== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 40/44] x86/amd_nb: Trickle down 'struct cpuinfo_x86' reference Date: Fri, 13 Jun 2025 01:40:06 +0200 Message-ID: <20250612234010.572636-41-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Prepare cpuid_amd_hygon_has_l3_cache(), which is internally a CPUID(0x80000006) call site, for using the parsed CPUID API instead of invoking direct CPUID queries. Since such an API requires a 'struct cpuinfo_x86' reference, trickle it down from the start of the amd_nb initcall. Note, accessing the CPUID tables at initcall_5 using this_cpu_ptr() should be safe, since the 'struct cpuinfo_x86' per-CPU presentation is finalized at arch/x86/kernel/cpu/common.c :: arch_cpu_finalize_init(). Meanwhile, at kernel init/main.c, do_initcalls() are done much later. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/amd_nb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c index c1acead6227a..a8809778b208 100644 --- a/arch/x86/kernel/amd_nb.c +++ b/arch/x86/kernel/amd_nb.c @@ -16,6 +16,7 @@ =20 #include #include +#include =20 static u32 *flush_words; =20 @@ -58,7 +59,7 @@ struct amd_northbridge *node_to_amd_nb(int node) } EXPORT_SYMBOL_GPL(node_to_amd_nb); =20 -static int amd_cache_northbridges(void) +static int amd_cache_northbridges(struct cpuinfo_x86 *c) { struct amd_northbridge *nb; u16 i; @@ -315,11 +316,13 @@ static __init void fix_erratum_688(void) =20 static __init int init_amd_nbs(void) { + struct cpuinfo_x86 *c =3D this_cpu_ptr(&cpu_info); + if (boot_cpu_data.x86_vendor !=3D X86_VENDOR_AMD && boot_cpu_data.x86_vendor !=3D X86_VENDOR_HYGON) return 0; =20 - amd_cache_northbridges(); + amd_cache_northbridges(c); amd_cache_gart(); =20 fix_erratum_688(); --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 D08212ECE9C for ; Thu, 12 Jun 2025 23:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771759; cv=none; b=pMLBGkaNoaB1RUrITpE2pZ50oLNz2pQ/jab35b/31jeOHNw2CqocpT4D78AXb7V74J4emId8e4iXWisOK6GtLAlLvQoxtBYRe4pmToezYPEyLyepJ+HoPcgVogcd1woVVAupjZ738W18lGhoFMEnch1fZ8B2ZJ5FoheMmddUhP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771759; c=relaxed/simple; bh=FTESbv55VSuQPuAp2vy1/V9XHlZBZKHsuwSmEztqyPo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jwh1Z/Oa7/vdMUe6oU+y1sGTkSOvEceNJEDwEUwVzSA/qaGp1nALnQEQnDKwpp7y9IiZK8LN53gEyONu5S8C+nI27FIi7jSXKjd7GDYc8hYDC8g/UGx/6tS07zwLrBlXxJC67dNvUlBEP1WJIQXj7plxHLB/Oqr7nY+S7gqMaks= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=E4HADOp7; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=+OBFs0tk; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="E4HADOp7"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="+OBFs0tk" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fFZQmugutsviUyhvi1xQJowcmdC20YjG3suPpqwyY4s=; b=E4HADOp7Bw+WDYz5MuYnIl4E4uUNIl4dTAeA14AZ4Auoq3I3Aw3oSwJvkB30v9N2CYsnfm jB6SeE51Pj2qiExuve5GIfF/thvlFlvcwSowg7NpocbM1mPILQx4u6omsvZ2rCb3haYgR8 fcfakJNnPaVVAdlNVy5CybT8VDqsuOiZcLYWD9Qtx4poDKSx1fdA8s+TjX5jn6ff7du5IH xIVSnWmZ4T6HjbjqgbiuiLByr/auUe8/5rYLJ16NqrqVapwpHf/Wv5SdilG3MXZxHS6Z83 wMvzcVlFRNo1A/RLG4PWvv4lQ7BV3sPmxsTXUDpe060BanJiWj5F1Cp3CY5p4A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fFZQmugutsviUyhvi1xQJowcmdC20YjG3suPpqwyY4s=; b=+OBFs0tkHRkO2grtUs0lm8+N1KzGdboqBtC+JmE2p2nny3jk+cpbeKSvEKT+H0FkMJcvgy pJIUR/QWOGFPoFAA== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 41/44] x86/cpu: : Do not include CPUID API header Date: Fri, 13 Jun 2025 01:40:07 +0200 Message-ID: <20250612234010.572636-42-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" includes the CPUID API header , but all what it actually needs are data types from . Modify the header to include instead. Note, this allows the CPUID API header to include next, without inducing a circular dependency. This will be needed by the upcoming centralized CPUID model APIs. Note, a large number of call sites were already using the CPUID APIs without including . They directly or indirectly included , which included the CPUID API header. Such call sites have been modified, by parent commits, to explicitly include the CPUID API header instead. Signed-off-by: Ahmed S. Darwish --- arch/x86/include/asm/processor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/proces= sor.h index b5d90b60191b..88f8ee33bfca 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -16,7 +16,7 @@ struct vm86; #include #include #include -#include +#include #include #include #include --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 1CA5D2ECE9D for ; Thu, 12 Jun 2025 23:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771762; cv=none; b=PapgZKJgPtg7QMMPYeiCbBllEgc3CoyL+E8j/YZzR8oJhp37AQUzLrOnTGLk9qhQmQu3NLChnziSbkIRSCoMo2125H3AeAj11We8mlkm8vWApxCJeOMYrCbGUqwxEsoVd3XELyruVf47v9rAe5hv0Ykl94J9QBzardR+q82NxOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771762; c=relaxed/simple; bh=o6Bbz5lQ615J4ru0a/N+eq20jvp8zjlPf71idMnzQY4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aLTBosFISv6SjGxnbC033uMEidlZZgIDSRCcZ6eIPv8pxzlUzzYonvim2/XWeVsRZvbiu2XjenzvelQvmBZl04o6o7gx2sGQUJWL+vKtHlfnei4IZsjfCjE7mtSNXoPod0G0VE4WsHcA/BAR8JULmdv7qt5bxKUjAjKPeLrspLg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=T13hYi1c; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=N12RORi/; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="T13hYi1c"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="N12RORi/" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nsczU9Cnv76lV78TZ5tdmxGG7/e4mNUxWgTJZQGdiA0=; b=T13hYi1cp2uDHJxyuL2G14Y4iZXeOtv8NtQrldkj48L4ZOZj8OfqCNm39W7eFiyTc7ejmx pvzr9nA9oiWyYPuDJxh1Q+SLzAVIkaQ/vDO9SkMmayqhZveUhsLxJiImDA+hmeFdOv+InA 5zOioQ60fDJZpMafpkX+eg8HHw+eaQCXytnxJcSaJEUnD+WPpbtF/npPcuB3w47z7MqS0J aSYNpAD1gTyVQ+2ace0L7zpG7wSFiwEDNqO3mA2snRHCaybrxd9JIxbdtgNCf1Ud0cj2CZ pcDqWxEIDRT40+fVCilVoH7F82EGtbRtMBhKNaXi+9UBvbES+4x7hT+AItmwcA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nsczU9Cnv76lV78TZ5tdmxGG7/e4mNUxWgTJZQGdiA0=; b=N12RORi/jE/zf6Tt1F9psWgvk5BXj1JaxEkysgWhYsKWYaa3oYN0levdRFSvMWlkAN3BFk 03DYMfN2bYMvMpBw== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 42/44] x86/cpuid: Use parsed CPUID(0x80000006) Date: Fri, 13 Jun 2025 01:40:08 +0200 Message-ID: <20250612234010.572636-43-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For cpuid_amd_hygon_has_l3_cache(), use parsed CPUID access instead of a direct CPUID query. The new API offers centralization benefits and avoids bit fiddling at call sites. For testing L3 cache availability, just check if the EDX.l3_assoc output is not zero. Per AMD manuals, an L3 associativity of zero implies the absence of an L3 cache on the CPU. Note, since this function is now using parsed CPUID API, move it under the section: 'Convenience leaf-specific functions (using parsed CPUID data)' Signed-off-by: Ahmed S. Darwish --- arch/x86/include/asm/cpuid/api.h | 18 +++++++++--------- arch/x86/kernel/amd_nb.c | 2 +- arch/x86/kernel/cpu/cacheinfo.c | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/arch/x86/include/asm/cpuid/api.h b/arch/x86/include/asm/cpuid/= api.h index 9f9c035a9e73..92366de5e490 100644 --- a/arch/x86/include/asm/cpuid/api.h +++ b/arch/x86/include/asm/cpuid/api.h @@ -212,15 +212,6 @@ static inline u32 cpuid_base_hypervisor(const char *si= g, u32 leaves) return 0; } =20 -/* - * CPUID(0x80000006) parsing: - */ - -static inline bool cpuid_amd_hygon_has_l3_cache(void) -{ - return cpuid_edx(0x80000006); -} - /* * 'struct cpuid_leaves' accessors: * @@ -518,6 +509,15 @@ static inline bool cpuid_amd_hygon_has_l3_cache(void) _ptr < &((union leaf_0x2_regs *)(_regs))->desc[16] && (_desc =3D &cp= uid_0x2_table[*_ptr]);\ _ptr++) =20 +/* + * CPUID(0x80000006) + */ + +static inline bool cpuid_amd_hygon_has_l3_cache(struct cpuinfo_x86 *c) +{ + return cpuid_leaf(c, 0x80000006)->l3_assoc; +} + /* * CPUID parser exported APIs: */ diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c index a8809778b208..a5d022e15a6b 100644 --- a/arch/x86/kernel/amd_nb.c +++ b/arch/x86/kernel/amd_nb.c @@ -94,7 +94,7 @@ static int amd_cache_northbridges(struct cpuinfo_x86 *c) if (amd_gart_present()) amd_northbridges.flags |=3D AMD_NB_GART; =20 - if (!cpuid_amd_hygon_has_l3_cache()) + if (!cpuid_amd_hygon_has_l3_cache(c)) return 0; =20 /* diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinf= o.c index de8e7125eedd..dc28ffdbdc7f 100644 --- a/arch/x86/kernel/cpu/cacheinfo.c +++ b/arch/x86/kernel/cpu/cacheinfo.c @@ -210,7 +210,7 @@ static int fill_cpuid4_info(struct cpuinfo_x86 *c, int = index, struct _cpuid4_inf =20 void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c, u16 die_id) { - if (!cpuid_amd_hygon_has_l3_cache()) + if (!cpuid_amd_hygon_has_l3_cache(c)) return; =20 if (c->x86 < 0x17) { @@ -241,7 +241,7 @@ void cacheinfo_amd_init_llc_id(struct cpuinfo_x86 *c, u= 16 die_id) =20 void cacheinfo_hygon_init_llc_id(struct cpuinfo_x86 *c) { - if (!cpuid_amd_hygon_has_l3_cache()) + if (!cpuid_amd_hygon_has_l3_cache(c)) return; =20 /* @@ -257,7 +257,7 @@ void init_amd_cacheinfo(struct cpuinfo_x86 *c) =20 ci->num_leaves =3D boot_cpu_has(X86_FEATURE_TOPOEXT) ? cpuid_subleaf_count(c, 0x8000001d) : - cpuid_leaf(c, 0x80000006)->l3_assoc ? 4 : 3; + cpuid_amd_hygon_has_l3_cache(c) ? 4 : 3; } =20 void init_hygon_cacheinfo(struct cpuinfo_x86 *c) --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 6EF842ECEB6 for ; Thu, 12 Jun 2025 23:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771765; cv=none; b=qZboH/GOzLLTTKB4IGmkd75ZHUeDpO2l5sCaqQR9eWfr3YMNpKXstI9OOEMxeSOJPGvVuXNyTeH8dHsYTju7JRV68lOCCawL8A5zeyuX7RrxQvYPdU04xzIm+y5IQjkz0AW5WSYOevz2sMMq01z8oInxkTRb+W8Gq6MqMwV5ZE8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771765; c=relaxed/simple; bh=8Z8DzIpBi/ZkYTVyIpXYybxgXpT2m2QXqkLWK+een1E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U8zoPUmyKPZ/tYXD183+JSn+vRLixWVX7vPVY8xE9QBQFJyfdwkEUSbpPIgJ+lCrekYqZAadSeGL0iGMpkBHnLPLnvWyHEv7MHlyq1J/mqVfCr4IeHz+zrH78gFpVGcY0hSntqlPnX0dJJtEpkZPVzZNL60/Z/YzT1dcBL/nn1Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=koyNiSky; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=qecpKycV; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="koyNiSky"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qecpKycV" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771763; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=83xWVTLv2SQJxvrNZ04ptTVzV4QN6q1DpfqyN70JUP4=; b=koyNiSkyItfgN21wZ52plZgloDg04BdN0czDB0LUZmopP9mO3REPme+HhW8UuIrCJtiaId rU4YXwLUf/kN180QD6Oc0gbzpL7CdtICpeMw8Evpx+8m1dujolFoLdTi4P8JSWnVl4dEDy CaTaVvDCSVeW77oe4PyuGmcOoglbBrHMO9hN5+ZSHskE8xamksipb1XmhH4D87vqlwGC0O kQ2lkiFtRxN/Vm1tgte8tzGsi49hufqs6tr59Z327pwQngeSDFHCCVYJa5yyeIk23yxfzg 6GWr0L45YkrXRmev7GxleH1f94jpfRDJ5y9uZl+z50WCPcazclOct3gFDV4zAw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771763; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=83xWVTLv2SQJxvrNZ04ptTVzV4QN6q1DpfqyN70JUP4=; b=qecpKycVIH5xSb8z8RyimQ2uHF/ERCLrjrLSMygVVcMU6++hjCpkJ3NpwywYzZchhtkYnW 7DuD9PvKQWNFmHBw== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 43/44] x86/cpu: Rescan CPUID table after PSN disable Date: Fri, 13 Jun 2025 01:40:09 +0200 Message-ID: <20250612234010.572636-44-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On Pentium-III and Transmeta CPUs, disabling the CPUID(0x3) Processor Serial Number (PSN) can affect the maximum valid CPUID standard leaf. Rescan the CPU's CPUID table in that case, not to have stale cached data. Use parsed CPUID(0x0) access, instead of direct CPUID query, afterwards. Rename squash_the_stupid_serial_number() to disable_cpu_serial_number() and explain the rational for disabling the CPU's PSN. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/common.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 023613698b15..81fe33976ceb 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -327,15 +327,17 @@ bool cpuid_feature(void) return flag_is_changeable_p(X86_EFLAGS_ID); } =20 -static void squash_the_stupid_serial_number(struct cpuinfo_x86 *c) +/* + * For privacy concerns, disable legacy Intel and Transmeta CPUID(0x3) + * feature, Processor Serial Number, by default. + */ +static void disable_cpu_serial_number(struct cpuinfo_x86 *c) { unsigned long lo, hi; =20 if (!cpu_has(c, X86_FEATURE_PN) || !disable_x86_serial_nr) return; =20 - /* Disable processor serial number: */ - rdmsr(MSR_IA32_BBL_CR_CTL, lo, hi); lo |=3D 0x200000; wrmsr(MSR_IA32_BBL_CR_CTL, lo, hi); @@ -343,8 +345,12 @@ static void squash_the_stupid_serial_number(struct cpu= info_x86 *c) pr_notice("CPU serial number disabled.\n"); clear_cpu_cap(c, X86_FEATURE_PN); =20 - /* Disabling the serial number may affect the cpuid level */ - c->cpuid_level =3D cpuid_eax(0); + /* + * Disabling CPUID(0x3) might have affected the maximum standard + * CPUID level. Rescan the CPU's CPUID table afterwards. + */ + cpuid_parser_scan_cpu(c); + c->cpuid_level =3D cpuid_leaf(c, 0x0)->max_std_leaf; } =20 static int __init x86_serial_nr_setup(char *s) @@ -354,7 +360,7 @@ static int __init x86_serial_nr_setup(char *s) } __setup("serialnumber", x86_serial_nr_setup); #else -static inline void squash_the_stupid_serial_number(struct cpuinfo_x86 *c) +static inline void disable_cpu_serial_number(struct cpuinfo_x86 *c) { } #endif @@ -1968,7 +1974,7 @@ static void identify_cpu(struct cpuinfo_x86 *c) bus_lock_init(); =20 /* Disable the PN if appropriate */ - squash_the_stupid_serial_number(c); + disable_cpu_serial_number(c); =20 /* Set up SMEP/SMAP/UMIP */ setup_smep(c); --=20 2.49.0 From nobody Fri Oct 10 18:18:31 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 0F2002E6D38 for ; Thu, 12 Jun 2025 23:42:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771769; cv=none; b=Oqyp3VwDzIOQRqOJtwSZcFiUICHrfUH+XZFvUIuiss1y3Vs+ZF7s82nRCM6cL9YwV6Zb90nBccMGYTI46NVZUsGk4CPwLTLvNrnnGj6YH6cE1xY47N0OEa3/X7kN3gcjLTyH8mFNi6AOqwF4igKtWN3hWSZ2D3BfFu2P7cQt4Bk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749771769; c=relaxed/simple; bh=99/rmdC76lXafxdI59q/csW0I07ujjJoHzTFBs1h2jw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aEVUYl6dcnpthvrs1Jtw6Xx7BtO67TpXl/9oXYS0LZ6yvGc1HLlbo/WVisAn7yuIFBsovaLImTL3aItC73UpNxpz0xM8ExZ/vDau/Qbf7qOcz7SZjmPFiKjwIb9nhKysKXaA2VIsKoBDryNPTkP8d+YPxaDCsQMgxmRfsfCc8Ds= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=HDb1LTTo; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=fJONCEj+; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HDb1LTTo"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fJONCEj+" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1749771766; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3xM6jpBCj2QZBxsvLfh5xBbyT4OKBSIAuCLE2scKBOQ=; b=HDb1LTToIapoL0ZHw/7LThym1XYWFC5Y9jnmB/b3iFElVQcCox5E/41OQsLz3hCXReE/JP CVinsPOzUjEgROe5Fxrb7avvgzkJUDNhBlAdEU7hsmqhQ/ftVbvyB0i1VkK5cOITltcGTs 5eQUNoSMvV7H51++kXF0uC0rHRCyUYs2Y7PJ/O+Rf7ib2REM0KOZ916AzBXiPDZn8T42Lo T4567W5oalPB88qe4ygNuHIYdnl5CALMIfupvnW5Slf5i+RA2gwmDn1yloEUbpYgEGXqzY o27PfGHSMBbvua8J+QFBKLcd0FyPtPuwxbanp3Th5FDMkO6HpF3ZELxyN6v4ew== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1749771766; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3xM6jpBCj2QZBxsvLfh5xBbyT4OKBSIAuCLE2scKBOQ=; b=fJONCEj+g3/5PxMAOmQVCsTiC25VKf0r2DwfxLeYAQKa0XsV+DCp4tWg3S99TKKCIsxWwX bWlWQ48cPlaX1bCA== To: Ingo Molnar , Borislav Petkov , Dave Hansen Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Peter Zijlstra , Sean Christopherson , Sohil Mehta , Ard Biesheuvel , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v3 44/44] x86/cpu: Rescan CPUID table after unlocking full CPUID range Date: Fri, 13 Jun 2025 01:40:10 +0200 Message-ID: <20250612234010.572636-45-darwi@linutronix.de> In-Reply-To: <20250612234010.572636-1-darwi@linutronix.de> References: <20250612234010.572636-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Intel CPUs have an MSR bit to limit CPUID enumeration to leaf two, which can be set by old BIOSen before booting Linux. Rescan the CPUID table after unlocking the CPU's full CPUID range. Use parsed CPUID(0x0) access, instead of a direct CPUID query, afterwards. References: 066941bd4eeb ("x86: unmask CPUID levels on Intel CPUs") References: 0c2f6d04619e ("x86/topology/intel: Unlock CPUID before evaluati= ng anything") Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/intel.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 06c249110c8b..fe4d1cf479c2 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -192,11 +192,14 @@ void intel_unlock_cpuid_leafs(struct cpuinfo_x86 *c) return; =20 /* - * The BIOS can have limited CPUID to leaf 2, which breaks feature - * enumeration. Unlock it and update the maximum leaf info. + * Intel CPUs have an MSR bit to limit CPUID enumeration to CPUID(0x2), + * which can be set by old BIOSes before booting Linux. If enabled, + * unlock the CPU's full CPUID range and rescan its CPUID table. */ - if (msr_clear_bit(MSR_IA32_MISC_ENABLE, MSR_IA32_MISC_ENABLE_LIMIT_CPUID_= BIT) > 0) - c->cpuid_level =3D cpuid_eax(0); + if (msr_clear_bit(MSR_IA32_MISC_ENABLE, MSR_IA32_MISC_ENABLE_LIMIT_CPUID_= BIT) > 0) { + cpuid_parser_scan_cpu(c); + c->cpuid_level =3D cpuid_leaf(c, 0x0)->max_std_leaf; + } } =20 static void early_init_intel(struct cpuinfo_x86 *c) --=20 2.49.0