From nobody Wed Dec 17 16:11:43 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 E8F1D18F2D8 for ; Fri, 13 Dec 2024 20:50:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123030; cv=none; b=CsQu/iAtioQ41Y2g4B6KA3LFRNSHvl4phFlqpv6GsTtRl6lXJBhtyP0kWiRDbeuYNEUkg0dHSG+lj4Y4vw5GbZcFz+KDHwEYVtNGxQjphwJ3FkNLffMuzUOEYn5hvrEFaihRSIAxkHZUNFZosGvciTjq3hU3WqgKYfu/ynGp6Jo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123030; c=relaxed/simple; bh=PdNE16znsAXToRM9EAaV0MfSOv4mBd2IprSp1pNlFn8=; h=Subject:To:Cc:From:Date:References:In-Reply-To:Message-Id; b=QYV/32bGtf4/XAHyo0rw7n4GZar2+hapzNd0bnUrwm5VcrMZyVm7qZ+TuR3ThawPXFSzwCQgycnMZ2hFnCLN4OwW4oTfRP7yrAnKS0ko77XYlfS6XzdcPuiQ2OBWjBMSwQPlDo+QklnlwJzTJPhLUKGJe8M21mWk0gCLljgmCUM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=huJyY7sA; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="huJyY7sA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734123029; x=1765659029; h=subject:to:cc:from:date:references:in-reply-to: message-id; bh=PdNE16znsAXToRM9EAaV0MfSOv4mBd2IprSp1pNlFn8=; b=huJyY7sAxOb9z8ZL3fX0YfgwVVODtssxkVhVE5wZxTeP6XbA25did1gQ Wz1/sMNAnls2CAX+ieQ+1x9KfCT96OetwMsMZ9FsS+xO/FfrJQHQa3zKB RQZSWa4sLy5l9KrkwuTQqT3o+Pb61j9LjYY63pEy12a+kmZeJTpMNGPuP qwRH3bHkIzhmHP7W4ZbhLWMOvPU2I4GJAl9ErvmkZNaT5stEQ7/2RAWAM RGyARskA78fIIWV6lHG0KlyDoP8eH4Kj6ANUNn8DXip/L186aZiZRhm95 5CtDH67A3++kmOsq6rCcb1Qyflm9FWZh1a5g8LE+frs/hvnqJrqTqj+eh w==; X-CSE-ConnectionGUID: gqEs5cJZSV6mKXCluGSNOQ== X-CSE-MsgGUID: uwnOOCiiRom59sJIEMvZtQ== X-IronPort-AV: E=McAfee;i="6700,10204,11285"; a="34820482" X-IronPort-AV: E=Sophos;i="6.12,232,1728975600"; d="scan'208";a="34820482" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2024 12:50:28 -0800 X-CSE-ConnectionGUID: 8xKfJzhRRmq59ANzfE4ydQ== X-CSE-MsgGUID: 9msi18D3S7O+8frqDgu7YQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="96501675" Received: from davehans-spike.ostc.intel.com (HELO localhost.localdomain) ([10.165.164.11]) by orviesa010.jf.intel.com with ESMTP; 13 Dec 2024 12:50:29 -0800 Subject: [PATCH 01/10] x86/cpu: Move MWAIT leaf definition to common header To: linux-kernel@vger.kernel.org Cc: x86@kernel.org,tglx@linutronix.de,bp@alien8.de,rafael@kernel.org,lenb@kernel.org,dave.jiang@intel.com,irenic.rajneesh@gmail.com,david.e.box@intel.com,Dave Hansen ,zhao1.liu@intel.com From: Dave Hansen Date: Fri, 13 Dec 2024 12:50:28 -0800 References: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> In-Reply-To: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> Message-Id: <20241213205028.EE94D02A@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Dave Hansen Begin constructing a common place to keep all CPUID leaf definitions. Move CPUID_MWAIT_LEAF to the CPUID header and include it where needed. Signed-off-by: Dave Hansen Reviewed-by: Zhao Liu --- b/arch/x86/include/asm/cpuid.h | 2 ++ b/arch/x86/include/asm/mwait.h | 1 - b/arch/x86/kernel/acpi/cstate.c | 1 + b/arch/x86/kernel/hpet.c | 1 + b/arch/x86/kernel/process.c | 1 + b/arch/x86/kernel/smpboot.c | 1 + b/arch/x86/xen/enlighten_pv.c | 1 + b/drivers/acpi/acpi_pad.c | 1 + b/drivers/idle/intel_idle.c | 1 + 9 files changed, 9 insertions(+), 1 deletion(-) diff -puN arch/x86/include/asm/cpuid.h~mwait-leaf-checks-0 arch/x86/include= /asm/cpuid.h --- a/arch/x86/include/asm/cpuid.h~mwait-leaf-checks-0 2024-12-13 12:45:32.= 547041911 -0800 +++ b/arch/x86/include/asm/cpuid.h 2024-12-13 12:45:32.563042590 -0800 @@ -21,6 +21,8 @@ enum cpuid_regs_idx { CPUID_EDX, }; =20 +#define CPUID_MWAIT_LEAF 5 + #ifdef CONFIG_X86_32 bool have_cpuid_p(void); #else diff -puN arch/x86/include/asm/mwait.h~mwait-leaf-checks-0 arch/x86/include= /asm/mwait.h --- a/arch/x86/include/asm/mwait.h~mwait-leaf-checks-0 2024-12-13 12:45:32.= 547041911 -0800 +++ b/arch/x86/include/asm/mwait.h 2024-12-13 12:45:32.563042590 -0800 @@ -15,7 +15,6 @@ #define MWAIT_HINT2SUBSTATE(hint) ((hint) & MWAIT_CSTATE_MASK) #define MWAIT_C1_SUBSTATE_MASK 0xf0 =20 -#define CPUID_MWAIT_LEAF 5 #define CPUID5_ECX_EXTENSIONS_SUPPORTED 0x1 #define CPUID5_ECX_INTERRUPT_BREAK 0x2 =20 diff -puN arch/x86/kernel/acpi/cstate.c~mwait-leaf-checks-0 arch/x86/kernel= /acpi/cstate.c --- a/arch/x86/kernel/acpi/cstate.c~mwait-leaf-checks-0 2024-12-13 12:45:32= .551042081 -0800 +++ b/arch/x86/kernel/acpi/cstate.c 2024-12-13 12:45:32.563042590 -0800 @@ -13,6 +13,7 @@ #include =20 #include +#include #include #include =20 diff -puN arch/x86/kernel/hpet.c~mwait-leaf-checks-0 arch/x86/kernel/hpet.c --- a/arch/x86/kernel/hpet.c~mwait-leaf-checks-0 2024-12-13 12:45:32.551042= 081 -0800 +++ b/arch/x86/kernel/hpet.c 2024-12-13 12:45:32.563042590 -0800 @@ -7,6 +7,7 @@ #include #include =20 +#include #include #include #include diff -puN arch/x86/kernel/process.c~mwait-leaf-checks-0 arch/x86/kernel/pro= cess.c --- a/arch/x86/kernel/process.c~mwait-leaf-checks-0 2024-12-13 12:45:32.551= 042081 -0800 +++ b/arch/x86/kernel/process.c 2024-12-13 12:45:32.563042590 -0800 @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include diff -puN arch/x86/kernel/smpboot.c~mwait-leaf-checks-0 arch/x86/kernel/smp= boot.c --- a/arch/x86/kernel/smpboot.c~mwait-leaf-checks-0 2024-12-13 12:45:32.555= 042251 -0800 +++ b/arch/x86/kernel/smpboot.c 2024-12-13 12:45:32.563042590 -0800 @@ -64,6 +64,7 @@ =20 #include #include +#include #include #include #include diff -puN arch/x86/xen/enlighten_pv.c~mwait-leaf-checks-0 arch/x86/xen/enli= ghten_pv.c --- a/arch/x86/xen/enlighten_pv.c~mwait-leaf-checks-0 2024-12-13 12:45:32.5= 55042251 -0800 +++ b/arch/x86/xen/enlighten_pv.c 2024-12-13 12:45:32.563042590 -0800 @@ -49,6 +49,7 @@ #include #include =20 +#include #include #include #include diff -puN drivers/acpi/acpi_pad.c~mwait-leaf-checks-0 drivers/acpi/acpi_pad= .c --- a/drivers/acpi/acpi_pad.c~mwait-leaf-checks-0 2024-12-13 12:45:32.55504= 2251 -0800 +++ b/drivers/acpi/acpi_pad.c 2024-12-13 12:45:32.563042590 -0800 @@ -19,6 +19,7 @@ #include #include #include +#include #include #include =20 diff -puN drivers/idle/intel_idle.c~mwait-leaf-checks-0 drivers/idle/intel_= idle.c --- a/drivers/idle/intel_idle.c~mwait-leaf-checks-0 2024-12-13 12:45:32.559= 042421 -0800 +++ b/drivers/idle/intel_idle.c 2024-12-13 12:45:32.563042590 -0800 @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include _ From nobody Wed Dec 17 16:11:43 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 CB6CA1917CD for ; Fri, 13 Dec 2024 20:50:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123031; cv=none; b=kLFYDS3jGdd/VL1bD7ZmA+w4S2QNvt/SLuMzK41IuTA2TJhI/zq1powIs54Yw6yaU2UbUJykSdOuzr1f5XOkTKx8Msium9WMlwhCKO/Bc9iYpnnXBKD8cl8LdzEOwbsm5M9mwRNdxoecqnmQ/77dhR1xf5xmU1IRecYF4CjUIBg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123031; c=relaxed/simple; bh=88UGnMCyuLdp374UNJMyhK04Kwhaf6mQ7GYjqxXB7rc=; h=Subject:To:Cc:From:Date:References:In-Reply-To:Message-Id; b=JJVMGzEJkETmmGjp2WQxjNds8Ktncrf9fAaufeOKLdVWfo+AFvi8ks4ofr2zazvrWiSrn86fPtDspYqK/B/XcC3hV62Xp6rDQdZGRYU5DJa3jjKWEtPpCbXIcSCKGhn1UK5gmaOL0KFEu5EKK4xeu4UYcMWxtgR6tws8pU/cMIM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CGC4HyZ5; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CGC4HyZ5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734123030; x=1765659030; h=subject:to:cc:from:date:references:in-reply-to: message-id; bh=88UGnMCyuLdp374UNJMyhK04Kwhaf6mQ7GYjqxXB7rc=; b=CGC4HyZ5swPbM+9HffkYvmRW+hHyxzrS2IklnBxZJZCystWEoM3iY9IE bqqqrXHvaFOczKC/oS28VnPZzyngZwy0Y0e5DKxzxFCxmO99P5tnmAgSf XJhPfq6YgLTGOheVlIUNldTr4S6ls2QISG9OSpU1/ZPqRoT3nr6kUUZwZ PQzUfgFG/m5I1IQELotjA2+gB7slrJAG8G3BJL5IxDMfgIZLJRsZEaMxD pu9/eOtLYX6TkIxEf8Sw4SCHBiLHie+jJm86U61fAfSRQXuOa1bS/8K+J lp1B2u3lX8PoALCk1/Fz7WobTQZa8ls1q/MF6eD3IkuU7NlTKMOngdNlv w==; X-CSE-ConnectionGUID: 5t5dQaw/QamCXTCBTEFESA== X-CSE-MsgGUID: k5D5XORrT5mEIJ0sf5trXQ== X-IronPort-AV: E=McAfee;i="6700,10204,11285"; a="34820487" X-IronPort-AV: E=Sophos;i="6.12,232,1728975600"; d="scan'208";a="34820487" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2024 12:50:30 -0800 X-CSE-ConnectionGUID: A7MJixjdQwS436Am6P1meA== X-CSE-MsgGUID: GVI67gCgTBScibKanP81pA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="96501685" Received: from davehans-spike.ostc.intel.com (HELO localhost.localdomain) ([10.165.164.11]) by orviesa010.jf.intel.com with ESMTP; 13 Dec 2024 12:50:30 -0800 Subject: [PATCH 02/10] x86/cpu: Use MWAIT leaf definition To: linux-kernel@vger.kernel.org Cc: x86@kernel.org,tglx@linutronix.de,bp@alien8.de,rafael@kernel.org,lenb@kernel.org,dave.jiang@intel.com,irenic.rajneesh@gmail.com,david.e.box@intel.com,Dave Hansen ,zhao1.liu@intel.com From: Dave Hansen Date: Fri, 13 Dec 2024 12:50:29 -0800 References: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> In-Reply-To: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> Message-Id: <20241213205029.5B055D6E@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Dave Hansen The leaf-to-feature dependency array uses hard-coded leaf numbers. Use the new common header definition for the MWAIT leaf. Signed-off-by: Dave Hansen Reviewed-by: Zhao Liu --- b/arch/x86/kernel/cpu/common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff -puN arch/x86/kernel/cpu/common.c~mwait-leaf-checks-1 arch/x86/kernel/= cpu/common.c --- a/arch/x86/kernel/cpu/common.c~mwait-leaf-checks-1 2024-12-13 12:45:33.= 207069895 -0800 +++ b/arch/x86/kernel/cpu/common.c 2024-12-13 12:45:33.211070065 -0800 @@ -29,6 +29,7 @@ =20 #include #include +#include #include #include #include @@ -636,7 +637,7 @@ struct cpuid_dependent_feature { =20 static const struct cpuid_dependent_feature cpuid_dependent_features[] =3D { - { X86_FEATURE_MWAIT, 0x00000005 }, + { X86_FEATURE_MWAIT, CPUID_MWAIT_LEAF }, { X86_FEATURE_DCA, 0x00000009 }, { X86_FEATURE_XSAVE, 0x0000000d }, { 0, 0 } _ From nobody Wed Dec 17 16:11:43 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 A0A10192B60 for ; Fri, 13 Dec 2024 20:50:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123033; cv=none; b=tdg6Otd+E0/GY7GWA16U52MxeVEGOuntgvmpjGxaluunFfwn7gmnHMl2hfJIPw95MWGNFM6I+NBxvH+slgc5aTz/OUGnVx4nrABQ89pBRu3ov5cRcMWV7A353AIjKQrqZO0HKSMcgq9diYw4N4HS08QU79wsxjRk6Q91m2BHA6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123033; c=relaxed/simple; bh=WNrCorcx1ZaHvjLY90LjCW7fx9Wt16wHLtzNcRvz+qI=; h=Subject:To:Cc:From:Date:References:In-Reply-To:Message-Id; b=mRSxOOdwuoTXzbULfgn21njr1A89/fsy1KKo/Q4LzGpRYJM2dTZ9aNWctTrouISh4ZGPQXdXbrDAoCQ68gpbHLooXk6+KldV/SaQPAegRgl85snHsoqlGUYH3ThQ+Ik0zoZeCLlkw1DhJSQsL8XjXa87gyvaupGiu+nbkHSEDbs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=nbYaqotg; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nbYaqotg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734123031; x=1765659031; h=subject:to:cc:from:date:references:in-reply-to: message-id; bh=WNrCorcx1ZaHvjLY90LjCW7fx9Wt16wHLtzNcRvz+qI=; b=nbYaqotgSNmXLRnsXURceKLw9hkPssHMhbWBCtYTwwktEiH8As/pYrqb IV3PZ2LLyld/J9Qu08KlK51SC/CD0/saFYNBZumLl3d6S/0q99IWgfnjE +/AtoxKXWyyeO5j0K3Dz6XAmLFs6eI88gTegZ9CNbzc4HLDiQALF9tVdN Vlna+KFVQFD/mq9KmE92QFN/o5uV0Tx+dzvopgpI2ZeQmKMzpt0usWUVL Fwb+7RvHoOKuRW0WzKZFxkCuBJe69lS6qrzmwsatEZrWpewIBeUE5pUgF /BI4eBL+p6gfakkN5ulr43G0ZbeEdbCCDq53/grIEvusilJsBOCGqyRT+ w==; X-CSE-ConnectionGUID: ra3iXvwBTHe4pHplcZvabg== X-CSE-MsgGUID: 3MTaXYw5TyKgqXXBa6KCyw== X-IronPort-AV: E=McAfee;i="6700,10204,11278"; a="45973124" X-IronPort-AV: E=Sophos;i="6.12,214,1728975600"; d="scan'208";a="45973124" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2024 12:50:31 -0800 X-CSE-ConnectionGUID: ct4snp1CQzWJ6uXah5zH4g== X-CSE-MsgGUID: l09zwUm9Q+SDXmzpVzyalg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="101599672" Received: from davehans-spike.ostc.intel.com (HELO localhost.localdomain) ([10.165.164.11]) by orviesa005.jf.intel.com with ESMTP; 13 Dec 2024 12:50:31 -0800 Subject: [PATCH 03/10] x86/cpu: Remove unnecessary MwAIT leaf checks To: linux-kernel@vger.kernel.org Cc: x86@kernel.org,tglx@linutronix.de,bp@alien8.de,rafael@kernel.org,lenb@kernel.org,dave.jiang@intel.com,irenic.rajneesh@gmail.com,david.e.box@intel.com,Dave Hansen From: Dave Hansen Date: Fri, 13 Dec 2024 12:50:30 -0800 References: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> In-Reply-To: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> Message-Id: <20241213205030.9B42B458@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Dave Hansen The CPUID leaf dependency checker will remove X86_FEATURE_MWAIT if the CPUID level is below the required level (CPUID_MWAIT_LEAF). Thus, if you check X86_FEATURE_MWAIT you do not need to also check the CPUID level. Signed-off-by: Dave Hansen --- b/arch/x86/kernel/hpet.c | 3 --- b/arch/x86/kernel/smpboot.c | 2 -- b/drivers/acpi/acpi_pad.c | 2 -- b/drivers/idle/intel_idle.c | 3 --- 4 files changed, 10 deletions(-) diff -puN arch/x86/kernel/hpet.c~mwait-leaf-checks-2 arch/x86/kernel/hpet.c --- a/arch/x86/kernel/hpet.c~mwait-leaf-checks-2 2024-12-13 12:45:33.699090= 754 -0800 +++ b/arch/x86/kernel/hpet.c 2024-12-13 12:45:33.707091093 -0800 @@ -928,9 +928,6 @@ static bool __init mwait_pc10_supported( if (!cpu_feature_enabled(X86_FEATURE_MWAIT)) return false; =20 - if (boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF) - return false; - cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &mwait_substates); =20 return (ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) && diff -puN arch/x86/kernel/smpboot.c~mwait-leaf-checks-2 arch/x86/kernel/smp= boot.c --- a/arch/x86/kernel/smpboot.c~mwait-leaf-checks-2 2024-12-13 12:45:33.703= 090924 -0800 +++ b/arch/x86/kernel/smpboot.c 2024-12-13 12:45:33.707091093 -0800 @@ -1292,8 +1292,6 @@ static inline void mwait_play_dead(void) return; if (!this_cpu_has(X86_FEATURE_CLFLUSH)) return; - if (__this_cpu_read(cpu_info.cpuid_level) < CPUID_MWAIT_LEAF) - return; =20 eax =3D CPUID_MWAIT_LEAF; ecx =3D 0; diff -puN drivers/acpi/acpi_pad.c~mwait-leaf-checks-2 drivers/acpi/acpi_pad= .c --- a/drivers/acpi/acpi_pad.c~mwait-leaf-checks-2 2024-12-13 12:45:33.70309= 0924 -0800 +++ b/drivers/acpi/acpi_pad.c 2024-12-13 12:45:33.707091093 -0800 @@ -47,8 +47,6 @@ static void power_saving_mwait_init(void =20 if (!boot_cpu_has(X86_FEATURE_MWAIT)) return; - if (boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF) - return; =20 cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx); =20 diff -puN drivers/idle/intel_idle.c~mwait-leaf-checks-2 drivers/idle/intel_= idle.c --- a/drivers/idle/intel_idle.c~mwait-leaf-checks-2 2024-12-13 12:45:33.703= 090924 -0800 +++ b/drivers/idle/intel_idle.c 2024-12-13 12:45:33.707091093 -0800 @@ -2317,9 +2317,6 @@ static int __init intel_idle_init(void) return -ENODEV; } =20 - if (boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF) - return -ENODEV; - cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &mwait_substates); =20 if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) || _ From nobody Wed Dec 17 16:11:43 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 AC6591946A2 for ; Fri, 13 Dec 2024 20:50:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123034; cv=none; b=KqKCVoC4Cxuvv+b/bBefhr3q4LtrXUmhqT8w3NKXq6vGRwv9Mlm9JH+l16nu5A1rmTdEqkm1BzZRbmXh70249nkUSZCJqZZwX+198SXaI0Btp96XL6V0M4qAhfBN1eYKVAp6nMhxtmzP6jzMGcs8ELYVKCQsMCIX1128HO6oTs8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123034; c=relaxed/simple; bh=oB0v2MYpnGsqE49e3Y8Uuiz8v0EzXXxHO4R8LvmtTus=; h=Subject:To:Cc:From:Date:References:In-Reply-To:Message-Id; b=uA1o3hc9dlYe8R8IcSmMD0fduNDgblsgBHMn2Ve1oujzXIFnQ3eYYXmbad5z0wf/m6A/3RM7QFAvaRHzYfYSXLufRLByb7JCdZzcCHDSPHCk9o+cBEQsAenkRGFx+PEsSl6fNlJxyu8PWtYbzEERDI9ISOYwEh06vsC5GYwdY8k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=GgfS+ueN; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GgfS+ueN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734123032; x=1765659032; h=subject:to:cc:from:date:references:in-reply-to: message-id; bh=oB0v2MYpnGsqE49e3Y8Uuiz8v0EzXXxHO4R8LvmtTus=; b=GgfS+ueNNyfPtebpHSGo8l6s5R8Btae00iuwypwMRlcMx+N6U9QrvpKt Nnt2ZN0gnJ2B3MjkYW+6FIdQE0MvRceshgYImPhJQ8MNoxD2OWWG9Y9hu r9Iv0fvKpDbH2H1yT0g73ZUnKYye25tzx3bx95C2xman+/PWcNRB0sh7i BtQW3iHLN8wyrzbBHLDT8TjJy/Mvi6j7/67xefjpGQS8o3wcEs7bndh3q hkyzFLcUf2KDYG2PM/zCcjJksPYt+gNnggN8oCd/+xpjFLLGq0u/7q/Vn nzWi+XXtBwUUNDz24RIAtLAUv/7Am6ZEpgoZhbEub8JT36faTwBn43W0X g==; X-CSE-ConnectionGUID: K/OrHAhgSS+M4RLkdnj7uw== X-CSE-MsgGUID: MiHPUQ0SRImk2GPkHW39LA== X-IronPort-AV: E=McAfee;i="6700,10204,11278"; a="45973130" X-IronPort-AV: E=Sophos;i="6.12,214,1728975600"; d="scan'208";a="45973130" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2024 12:50:32 -0800 X-CSE-ConnectionGUID: oV4ldtheQeu2r720zr7PFw== X-CSE-MsgGUID: Vzm5mNOSQhi1GrYOq0oXDQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="101599676" Received: from davehans-spike.ostc.intel.com (HELO localhost.localdomain) ([10.165.164.11]) by orviesa005.jf.intel.com with ESMTP; 13 Dec 2024 12:50:32 -0800 Subject: [PATCH 04/10] x86/cpu: Refresh DCA leaf reading code To: linux-kernel@vger.kernel.org Cc: x86@kernel.org,tglx@linutronix.de,bp@alien8.de,rafael@kernel.org,lenb@kernel.org,dave.jiang@intel.com,irenic.rajneesh@gmail.com,david.e.box@intel.com,Dave Hansen ,zhao1.liu@intel.com From: Dave Hansen Date: Fri, 13 Dec 2024 12:50:32 -0800 References: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> In-Reply-To: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> Message-Id: <20241213205032.476A30FE@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Dave Hansen The DCA leaf number is also hard-coded in the CPUID level dependency table. Move its definition to common code and use it. While at it, fix up the naming and types in the probe code. All CPUID data is provided in 32-bit registers, not 'unsigned long'. Also stop referring to "level_9". Move away from test_bit() because the type is no longer an 'unsigned long'. Signed-off-by: Dave Hansen Reviewed-by: Zhao Liu --- b/arch/x86/include/asm/cpuid.h | 3 ++- b/arch/x86/kernel/cpu/common.c | 2 +- b/drivers/dma/ioat/dca.c | 8 +++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff -puN arch/x86/include/asm/cpuid.h~dca-leaf-checks-1 arch/x86/include/a= sm/cpuid.h --- a/arch/x86/include/asm/cpuid.h~dca-leaf-checks-1 2024-12-13 12:45:34.24= 7113987 -0800 +++ b/arch/x86/include/asm/cpuid.h 2024-12-13 12:45:34.255114326 -0800 @@ -21,7 +21,8 @@ enum cpuid_regs_idx { CPUID_EDX, }; =20 -#define CPUID_MWAIT_LEAF 5 +#define CPUID_MWAIT_LEAF 0x5 +#define CPUID_DCA_LEAF 0x9 =20 #ifdef CONFIG_X86_32 bool have_cpuid_p(void); diff -puN arch/x86/kernel/cpu/common.c~dca-leaf-checks-1 arch/x86/kernel/cp= u/common.c --- a/arch/x86/kernel/cpu/common.c~dca-leaf-checks-1 2024-12-13 12:45:34.25= 1114156 -0800 +++ b/arch/x86/kernel/cpu/common.c 2024-12-13 12:45:34.255114326 -0800 @@ -638,7 +638,7 @@ struct cpuid_dependent_feature { static const struct cpuid_dependent_feature cpuid_dependent_features[] =3D { { X86_FEATURE_MWAIT, CPUID_MWAIT_LEAF }, - { X86_FEATURE_DCA, 0x00000009 }, + { X86_FEATURE_DCA, CPUID_DCA_LEAF }, { X86_FEATURE_XSAVE, 0x0000000d }, { 0, 0 } }; diff -puN drivers/dma/ioat/dca.c~dca-leaf-checks-1 drivers/dma/ioat/dca.c --- a/drivers/dma/ioat/dca.c~dca-leaf-checks-1 2024-12-13 12:45:34.25111415= 6 -0800 +++ b/drivers/dma/ioat/dca.c 2024-12-13 12:45:34.255114326 -0800 @@ -10,6 +10,8 @@ #include #include =20 +#include + /* either a kernel change is needed, or we need something like this in ker= nel */ #ifndef CONFIG_SMP #include @@ -58,11 +60,11 @@ static int dca_enabled_in_bios(struct pc { /* CPUID level 9 returns DCA configuration */ /* Bit 0 indicates DCA enabled by the BIOS */ - unsigned long cpuid_level_9; + u32 eax; int res; =20 - cpuid_level_9 =3D cpuid_eax(9); - res =3D test_bit(0, &cpuid_level_9); + eax =3D cpuid_eax(CPUID_DCA_LEAF); + res =3D eax & BIT(0); if (!res) dev_dbg(&pdev->dev, "DCA is disabled in BIOS\n"); =20 _ From nobody Wed Dec 17 16:11:43 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 C7FC51957E2 for ; Fri, 13 Dec 2024 20:50:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123035; cv=none; b=ex7/A1RlO9jnMpDjB/diPEPNtQlFIZ2OycaFj2rLupgBMhSUxWAQ7cHp4bXDyFpNsKLhVCKfPCkkAKBlhMFy1DqOIkgcXeWsieRhwA3JNRTdTJYL2cPOU7k4W4Mdyf7Lagw5yO+ozuftbXPr0A5j7GhOVxzzfOj3oxT43MK6YeE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123035; c=relaxed/simple; bh=URfoHTLKbqY+f/Je1GHdBwfgPB1IkkIRnziSQJJR87k=; h=Subject:To:Cc:From:Date:References:In-Reply-To:Message-Id; b=Gg5iXeFMtjqNCboJONFa+r6tEx83HroqgmVlMByhU7olrnfmKOWNtAqd9A2cbYgaYA+SdHyAQzA22PI6g2zlC0Lcq5Z4lsF8MYtFPOi5xjd0nzwiyMuv5anK6PGIUcNW1Cjh0L6Kf5lgWjsoXkJASHCxAoTeWv4eVQdosOc6S1g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hsXUDgdI; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hsXUDgdI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734123033; x=1765659033; h=subject:to:cc:from:date:references:in-reply-to: message-id; bh=URfoHTLKbqY+f/Je1GHdBwfgPB1IkkIRnziSQJJR87k=; b=hsXUDgdIHALOhP8j8IMkAQH9HTTlE/P9LzoF7Sk8HImhfC5u7RW15zQ3 am3Qr9zWUGQ13/L4/X5GTNO1ig/lFy2vKP+hCkmpo+jUWZYQ5RpZoE0fO ighJkdS/NqqN/cERkXeaFUT1whd8FhT19PU4c/R5K65SpI3DV9oTpu1M0 R0nHZi6irPUHSijmQOTlKCTTuvfSGqGrV/qvBx7PEnxIocaFOav23MeBc 9Tsrxh5vdSuMzvIQHmOYjp2ZujwIkaA+QNrkwvglaTB0cBU8okjyof177 DMFRomgYFoDcLKq8hL+Uw/dpk123w7Gkr1rabArx6OMtgZvoMqAm4Usdi w==; X-CSE-ConnectionGUID: WqdNBNVbQd+Vuxo2TeQiPw== X-CSE-MsgGUID: Z5GCgQJoSeuzvJqeJRgA2A== X-IronPort-AV: E=McAfee;i="6700,10204,11278"; a="45973136" X-IronPort-AV: E=Sophos;i="6.12,214,1728975600"; d="scan'208";a="45973136" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2024 12:50:33 -0800 X-CSE-ConnectionGUID: o3bBv8OeQ/OjzsmWVY4UFw== X-CSE-MsgGUID: bT4JOmtQQQGHLolo3pV2lg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="101599680" Received: from davehans-spike.ostc.intel.com (HELO localhost.localdomain) ([10.165.164.11]) by orviesa005.jf.intel.com with ESMTP; 13 Dec 2024 12:50:33 -0800 Subject: [PATCH 05/10] x86/cpu: Move TSC CPUID leaf definition To: linux-kernel@vger.kernel.org Cc: x86@kernel.org,tglx@linutronix.de,bp@alien8.de,rafael@kernel.org,lenb@kernel.org,dave.jiang@intel.com,irenic.rajneesh@gmail.com,david.e.box@intel.com,Dave Hansen ,zhao1.liu@intel.com From: Dave Hansen Date: Fri, 13 Dec 2024 12:50:33 -0800 References: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> In-Reply-To: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> Message-Id: <20241213205033.68799E53@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Dave Hansen Prepare to use the TSC CPUID leaf definition more widely by moving it to the common header. Signed-off-by: Dave Hansen Reviewed-by: Zhao Liu --- b/arch/x86/events/intel/pt.c | 1 + b/arch/x86/events/intel/pt.h | 3 --- b/arch/x86/include/asm/cpuid.h | 1 + 3 files changed, 2 insertions(+), 3 deletions(-) diff -puN arch/x86/events/intel/pt.c~tsc-leaf-checks-1 arch/x86/events/inte= l/pt.c --- a/arch/x86/events/intel/pt.c~tsc-leaf-checks-1 2024-12-13 12:45:34.7791= 36538 -0800 +++ b/arch/x86/events/intel/pt.c 2024-12-13 12:45:34.787136878 -0800 @@ -18,6 +18,7 @@ #include #include =20 +#include #include #include #include diff -puN arch/x86/events/intel/pt.h~tsc-leaf-checks-1 arch/x86/events/inte= l/pt.h --- a/arch/x86/events/intel/pt.h~tsc-leaf-checks-1 2024-12-13 12:45:34.7791= 36538 -0800 +++ b/arch/x86/events/intel/pt.h 2024-12-13 12:45:34.787136878 -0800 @@ -37,9 +37,6 @@ struct topa_entry { u64 rsvd4 : 12; }; =20 -/* TSC to Core Crystal Clock Ratio */ -#define CPUID_TSC_LEAF 0x15 - struct pt_pmu { struct pmu pmu; u32 caps[PT_CPUID_REGS_NUM * PT_CPUID_LEAVES]; diff -puN arch/x86/include/asm/cpuid.h~tsc-leaf-checks-1 arch/x86/include/a= sm/cpuid.h --- a/arch/x86/include/asm/cpuid.h~tsc-leaf-checks-1 2024-12-13 12:45:34.78= 3136707 -0800 +++ b/arch/x86/include/asm/cpuid.h 2024-12-13 12:45:34.787136878 -0800 @@ -23,6 +23,7 @@ enum cpuid_regs_idx { =20 #define CPUID_MWAIT_LEAF 0x5 #define CPUID_DCA_LEAF 0x9 +#define CPUID_TSC_LEAF 0x15 =20 #ifdef CONFIG_X86_32 bool have_cpuid_p(void); _ From nobody Wed Dec 17 16:11:43 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 0CB0E198E84 for ; Fri, 13 Dec 2024 20:50:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123036; cv=none; b=Wbo03zPJZQrC+zyKevVCdKAMd8x7wdG9Q+j3/xQJEgt/CmH4yWYE933LvnajstM5eemL9NM2Z7lfkISpCNYn/6wjP7N4aFpUao5EXeEIhv30csXgom++ldqPEoLQ403kr5T1U5C4FAKmBcRdL1HR1eRe7zACa/VQJceOyTKoiUs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123036; c=relaxed/simple; bh=bvg3kykeix6Mr8rmCZKJX42XZ45C4+yD/p8ki5CTO9E=; h=Subject:To:Cc:From:Date:References:In-Reply-To:Message-Id; b=Z4KzoqFUZ4mAkhXBhIQIOPmJ9EeBBjUFguuQY9Z48sdhGDvvlN3Aye5vaASDAfQo5VU7GEs34N8bCfZnNvz/aCQ+JJaJvQrYz4qehN7zFRVyiX9sWcB4obx0LUyJRb7nwGZ1HYrxMC7g/zeGRlE4LEYpRM1u46U0xzeidfGJI2I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=dbYJMYRO; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dbYJMYRO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734123035; x=1765659035; h=subject:to:cc:from:date:references:in-reply-to: message-id; bh=bvg3kykeix6Mr8rmCZKJX42XZ45C4+yD/p8ki5CTO9E=; b=dbYJMYRO/h5GhKEPOA34hkhAcaPf/Us+ZWmrBk2DDFmb7TKSfRgkMbV9 VbnlIcHfGYsNe3VQxZ5zcQp3t3nrdke6+Bk+zCd7bKnWkWLDUU4Y5eFP5 geAQjfyqQqpZ+HtENHluieIkGHp1/ckKjNZyXOu7AUNzHABH4BZTlbhW7 mhZtU1G5+HiWcTWHwWPdP+82OXs/8RKbpJ0LyE+RcUBKp3LVqgV9rzSAq Bo1eHFcIU7s5hBlJyjYXol9CBavjrth2L8g10y+NcFx4xPqNEXaKXmen+ QT2sBYourZ4wXTVbA05QFYD3E2bcT8A7ptPJCaFpkQyiSb6MdXh1ZFLnx A==; X-CSE-ConnectionGUID: 2vnm7mFCSRCI1AYnepMnlA== X-CSE-MsgGUID: nOtvetrcQ+ip2+Pow51e6A== X-IronPort-AV: E=McAfee;i="6700,10204,11278"; a="45973144" X-IronPort-AV: E=Sophos;i="6.12,214,1728975600"; d="scan'208";a="45973144" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2024 12:50:34 -0800 X-CSE-ConnectionGUID: i/LFahFJTJ614yCAi+EKMg== X-CSE-MsgGUID: kyzr+AigQQSxOpYm92PYhw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="101599683" Received: from davehans-spike.ostc.intel.com (HELO localhost.localdomain) ([10.165.164.11]) by orviesa005.jf.intel.com with ESMTP; 13 Dec 2024 12:50:35 -0800 Subject: [PATCH 06/10] x86/tsc: Move away from TSC leaf magic numbers To: linux-kernel@vger.kernel.org Cc: x86@kernel.org,tglx@linutronix.de,bp@alien8.de,rafael@kernel.org,lenb@kernel.org,dave.jiang@intel.com,irenic.rajneesh@gmail.com,david.e.box@intel.com,Dave Hansen From: Dave Hansen Date: Fri, 13 Dec 2024 12:50:34 -0800 References: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> In-Reply-To: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> Message-Id: <20241213205034.B79D6224@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Dave Hansen The TSC code has a bunch of hard-coded references to leaf 0x15. Change them over to the symbolic name. Also zap the 'ART_CPUID_LEAF' definition. It was a duplicate of 'CPUID_TSC_LEAF'. Signed-off-by: Dave Hansen --- b/arch/x86/kernel/tsc.c | 11 +++++------ b/drivers/platform/x86/intel/pmc/core.c | 7 ++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff -puN arch/x86/kernel/tsc.c~tsc-leaf-checks-2 arch/x86/kernel/tsc.c --- a/arch/x86/kernel/tsc.c~tsc-leaf-checks-2 2024-12-13 12:45:35.323159598= -0800 +++ b/arch/x86/kernel/tsc.c 2024-12-13 12:45:35.331159936 -0800 @@ -16,6 +16,7 @@ #include #include =20 +#include #include #include #include @@ -665,13 +666,13 @@ unsigned long native_calibrate_tsc(void) if (boot_cpu_data.x86_vendor !=3D X86_VENDOR_INTEL) return 0; =20 - if (boot_cpu_data.cpuid_level < 0x15) + if (boot_cpu_data.cpuid_level < CPUID_TSC_LEAF) return 0; =20 eax_denominator =3D ebx_numerator =3D ecx_hz =3D edx =3D 0; =20 /* CPUID 15H TSC/Crystal ratio, plus optionally Crystal Hz */ - cpuid(0x15, &eax_denominator, &ebx_numerator, &ecx_hz, &edx); + cpuid(CPUID_TSC_LEAF, &eax_denominator, &ebx_numerator, &ecx_hz, &edx); =20 if (ebx_numerator =3D=3D 0 || eax_denominator =3D=3D 0) return 0; @@ -1067,10 +1068,8 @@ core_initcall(cpufreq_register_tsc_scali =20 #endif /* CONFIG_CPU_FREQ */ =20 -#define ART_CPUID_LEAF (0x15) #define ART_MIN_DENOMINATOR (1) =20 - /* * If ART is present detect the numerator:denominator to convert to TSC */ @@ -1078,7 +1077,7 @@ static void __init detect_art(void) { unsigned int unused; =20 - if (boot_cpu_data.cpuid_level < ART_CPUID_LEAF) + if (boot_cpu_data.cpuid_level < CPUID_TSC_LEAF) return; =20 /* @@ -1091,7 +1090,7 @@ static void __init detect_art(void) tsc_async_resets) return; =20 - cpuid(ART_CPUID_LEAF, &art_base_clk.denominator, + cpuid(CPUID_TSC_LEAF, &art_base_clk.denominator, &art_base_clk.numerator, &art_base_clk.freq_khz, &unused); =20 art_base_clk.freq_khz /=3D KHZ; diff -puN drivers/platform/x86/intel/pmc/core.c~tsc-leaf-checks-2 drivers/p= latform/x86/intel/pmc/core.c --- a/drivers/platform/x86/intel/pmc/core.c~tsc-leaf-checks-2 2024-12-13 12= :45:35.327159767 -0800 +++ b/drivers/platform/x86/intel/pmc/core.c 2024-12-13 12:45:35.331159936 -= 0800 @@ -22,6 +22,7 @@ #include #include =20 +#include #include #include #include @@ -935,13 +936,13 @@ static unsigned int pmc_core_get_crystal { unsigned int eax_denominator, ebx_numerator, ecx_hz, edx; =20 - if (boot_cpu_data.cpuid_level < 0x15) + if (boot_cpu_data.cpuid_level < CPUID_TSC_LEAF) return 0; =20 eax_denominator =3D ebx_numerator =3D ecx_hz =3D edx =3D 0; =20 - /* CPUID 15H TSC/Crystal ratio, plus optionally Crystal Hz */ - cpuid(0x15, &eax_denominator, &ebx_numerator, &ecx_hz, &edx); + /* TSC/Crystal ratio, plus optionally Crystal Hz */ + cpuid(CPUID_TSC_LEAF, &eax_denominator, &ebx_numerator, &ecx_hz, &edx); =20 if (ebx_numerator =3D=3D 0 || eax_denominator =3D=3D 0) return 0; _ From nobody Wed Dec 17 16:11:43 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 57EDB19048A for ; Fri, 13 Dec 2024 20:50:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123037; cv=none; b=dmRNj4NhQvyjAgAYmOienwfQv02a2i5rITrA9veYGH74gFdiSZj0PWyHOpTxiVT5AbiUSLHsbpFQrjWVhgdUREqUC5+oaA4nMKDy6U30zuk2eAVyWevliYFkAY1A6kuIq2l0Mb+g4e3VUBxp1Q+YMnq4RrMiXMZNadJVKKr6Cm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123037; c=relaxed/simple; bh=Vy9ACxVbR5UiMJdUo2ernIhjxEJ9urdstlK2zG54xWM=; h=Subject:To:Cc:From:Date:References:In-Reply-To:Message-Id; b=mQmjTE/cWXtQvjo937Urc6EM6WuRX4uE/yfVjolddoSQ75NqCEh5JY5/AcD92fuDd3ibLLVL41kmb3IJ6LmQdKTrgDlzoxIwhFHTKIhfUj+muWuaUSam4iO2T/IpiNoZWNPRISOVXr/v2Ip6zaTXR3mEVw8y3yQyjJ+reNkdcxg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=OsnSbxWc; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OsnSbxWc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734123036; x=1765659036; h=subject:to:cc:from:date:references:in-reply-to: message-id; bh=Vy9ACxVbR5UiMJdUo2ernIhjxEJ9urdstlK2zG54xWM=; b=OsnSbxWcz9L3TgR/hr5aFClxprZFzMRiVnGRmkC7hkScAHTG4ZAiJAC3 W/oQMju9q68KwiSeBxdHvh+2nnJcSSKztUfYDWjH7438akVBmuedRejsX HuceqvV9FL7Fz0zJwqIg9YGeRNedxBiqf1ocWaYU/D3KGNBzJOcTOvnBY bODdsgib6yxSUi8byXrgCZoRE8UR36H3o50AbHrysC9BbWz2W4i/Af1iy rqjiD1q3VsKFNDJqkcAgQXUcRMOmCNGtRCApQD6t6eLHLudYCr/NqI8Dr xXAhTTGCPKO3tpVZET+ulVCy7OKcbK4KHarK4pQbKQwCRoAmr1rg4tI7u A==; X-CSE-ConnectionGUID: GnKNouunRY6IitTcT9TmeA== X-CSE-MsgGUID: EGIClttMTy6CrnOUwKc7/Q== X-IronPort-AV: E=McAfee;i="6700,10204,11278"; a="45973153" X-IronPort-AV: E=Sophos;i="6.12,214,1728975600"; d="scan'208";a="45973153" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2024 12:50:36 -0800 X-CSE-ConnectionGUID: 6dassuF+SJeBSxQu3BPfUw== X-CSE-MsgGUID: HfLbkrqKTOC/1Cj19psUEQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="101599688" Received: from davehans-spike.ostc.intel.com (HELO localhost.localdomain) ([10.165.164.11]) by orviesa005.jf.intel.com with ESMTP; 13 Dec 2024 12:50:36 -0800 Subject: [PATCH 07/10] x86/tsc: Remove CPUID "frequency" leaf magic numbers. To: linux-kernel@vger.kernel.org Cc: x86@kernel.org,tglx@linutronix.de,bp@alien8.de,rafael@kernel.org,lenb@kernel.org,dave.jiang@intel.com,irenic.rajneesh@gmail.com,david.e.box@intel.com,Dave Hansen ,zhao1.liu@intel.com From: Dave Hansen Date: Fri, 13 Dec 2024 12:50:36 -0800 References: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> In-Reply-To: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> Message-Id: <20241213205036.4397658F@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Dave Hansen All the code that reads the CPUID frequency information leaf hard-codes a magic number. Give it a symbolic name and use it. Signed-off-by: Dave Hansen Reviewed-by: Zhao Liu --- b/arch/x86/include/asm/cpuid.h | 1 + b/arch/x86/kernel/tsc.c | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff -puN arch/x86/include/asm/cpuid.h~tsc-leaf-checks-3 arch/x86/include/a= sm/cpuid.h --- a/arch/x86/include/asm/cpuid.h~tsc-leaf-checks-3 2024-12-13 12:45:35.83= 9181468 -0800 +++ b/arch/x86/include/asm/cpuid.h 2024-12-13 12:45:35.843181638 -0800 @@ -24,6 +24,7 @@ enum cpuid_regs_idx { #define CPUID_MWAIT_LEAF 0x5 #define CPUID_DCA_LEAF 0x9 #define CPUID_TSC_LEAF 0x15 +#define CPUID_FREQ_LEAF 0x16 =20 #ifdef CONFIG_X86_32 bool have_cpuid_p(void); diff -puN arch/x86/kernel/tsc.c~tsc-leaf-checks-3 arch/x86/kernel/tsc.c --- a/arch/x86/kernel/tsc.c~tsc-leaf-checks-3 2024-12-13 12:45:35.839181468= -0800 +++ b/arch/x86/kernel/tsc.c 2024-12-13 12:45:35.843181638 -0800 @@ -681,8 +681,8 @@ unsigned long native_calibrate_tsc(void) =20 /* * Denverton SoCs don't report crystal clock, and also don't support - * CPUID.0x16 for the calculation below, so hardcode the 25MHz crystal - * clock. + * CPUID_FREQ_LEAF for the calculation below, so hardcode the 25MHz + * crystal clock. */ if (crystal_khz =3D=3D 0 && boot_cpu_data.x86_vfm =3D=3D INTEL_ATOM_GOLDMONT_D) @@ -701,10 +701,10 @@ unsigned long native_calibrate_tsc(void) * clock, but we can easily calculate it to a high degree of accuracy * by considering the crystal ratio and the CPU speed. */ - if (crystal_khz =3D=3D 0 && boot_cpu_data.cpuid_level >=3D 0x16) { + if (crystal_khz =3D=3D 0 && boot_cpu_data.cpuid_level >=3D CPUID_FREQ_LEA= F) { unsigned int eax_base_mhz, ebx, ecx, edx; =20 - cpuid(0x16, &eax_base_mhz, &ebx, &ecx, &edx); + cpuid(CPUID_FREQ_LEAF, &eax_base_mhz, &ebx, &ecx, &edx); crystal_khz =3D eax_base_mhz * 1000 * eax_denominator / ebx_numerator; } @@ -739,12 +739,12 @@ static unsigned long cpu_khz_from_cpuid( if (boot_cpu_data.x86_vendor !=3D X86_VENDOR_INTEL) return 0; =20 - if (boot_cpu_data.cpuid_level < 0x16) + if (boot_cpu_data.cpuid_level < CPUID_FREQ_LEAF) return 0; =20 eax_base_mhz =3D ebx_max_mhz =3D ecx_bus_mhz =3D edx =3D 0; =20 - cpuid(0x16, &eax_base_mhz, &ebx_max_mhz, &ecx_bus_mhz, &edx); + cpuid(CPUID_FREQ_LEAF, &eax_base_mhz, &ebx_max_mhz, &ecx_bus_mhz, &edx); =20 return eax_base_mhz * 1000; } _ From nobody Wed Dec 17 16:11:43 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 B46C51A8F7C for ; Fri, 13 Dec 2024 20:50:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123039; cv=none; b=ZbB7fCmAKq1WOGpDE9oun7UJc5zcELFSzEE0oQv1PixYYKDmV1skjA2UQnzKvq4TVYYQHJ357q35sPVfDIpjlmTL8UU7x5sg48ttRfH4tX8G+Gng4TdYq8iRzNHIRcY1cWNtDZjPJaNOXVsydW9AafYTC33yBg07tDuF9Xk46vI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123039; c=relaxed/simple; bh=cEgyYpgh94K2l0H//C1sGA4R+ovA75LZEUl6JlnC9ro=; h=Subject:To:Cc:From:Date:References:In-Reply-To:Message-Id; b=F4aKQtvQxxl++1Rbh07hDjo7aToPJX1Vztp/pnHYG+9W8Rbrul/zx6AO1zlCTpv8u2C/DY/rcjtbVM5tu+/vlHiS6rV7MqKJbCVUUdf2kE8MoTXKb4i4LfcjhqtFkO+s1LuPwWVXpWr9Jb063ZwUwmTL1YU5Bh2Cdu5izE8T2Zk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HXP08Gyu; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HXP08Gyu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734123037; x=1765659037; h=subject:to:cc:from:date:references:in-reply-to: message-id; bh=cEgyYpgh94K2l0H//C1sGA4R+ovA75LZEUl6JlnC9ro=; b=HXP08Gyu/KcE2Yp9610oy5lbtMEnm1+MZu1yA7UeE+P429QSSim0itGp /KfFD0gn3ImTwsytX1ug3CZVXaL90zWfciPJfZ2MhzClvUrybF3H86jb2 M9t7EgVahWU6cvbdFuBCuNLmiwnVf5FIT0d+eIKBAlE2iqMwwIRq/PjeH PIsi2y3mxOvjpy2zFsYrafwWshtw2L0/i3G5bBqRWy0uze9h5Xa2Zzssu Bya/rWBnU92PaLxqf+/AgGw0+PjJpA0Ea0qHRUq5C7eKfbHgEXn8OApxO 8Xrdw1HeYQ4/SEboUukTJrrRjfHCTbcMjWAJM0BCRY9USnP9uA1k/ONZL Q==; X-CSE-ConnectionGUID: spXHovGARcKu+sW749JoWw== X-CSE-MsgGUID: nhzEjj8zQ3SKBck7my96oA== X-IronPort-AV: E=McAfee;i="6700,10204,11278"; a="45973163" X-IronPort-AV: E=Sophos;i="6.12,214,1728975600"; d="scan'208";a="45973163" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2024 12:50:37 -0800 X-CSE-ConnectionGUID: ybx7ynE9Q5ukOWVM55ZbDQ== X-CSE-MsgGUID: rUFRP4ePRdK1k3cOvQCroQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="101599692" Received: from davehans-spike.ostc.intel.com (HELO localhost.localdomain) ([10.165.164.11]) by orviesa005.jf.intel.com with ESMTP; 13 Dec 2024 12:50:37 -0800 Subject: [PATCH 08/10] x86/fpu: Move CPUID leaf definitions to common code To: linux-kernel@vger.kernel.org Cc: x86@kernel.org,tglx@linutronix.de,bp@alien8.de,rafael@kernel.org,lenb@kernel.org,dave.jiang@intel.com,irenic.rajneesh@gmail.com,david.e.box@intel.com,Dave Hansen ,zhao1.liu@intel.com From: Dave Hansen Date: Fri, 13 Dec 2024 12:50:37 -0800 References: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> In-Reply-To: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> Message-Id: <20241213205037.43C57CDE@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Dave Hansen Move the XSAVE-related CPUID leaf definitions to common code. Then, use the new definition to remove the last magic number from the CPUID level dependency table. Signed-off-by: Dave Hansen Reviewed-by: Zhao Liu --- b/arch/x86/include/asm/cpuid.h | 2 ++ b/arch/x86/include/asm/fpu/xstate.h | 4 ---- b/arch/x86/kernel/cpu/common.c | 2 +- b/arch/x86/kernel/fpu/xstate.c | 1 + 4 files changed, 4 insertions(+), 5 deletions(-) diff -puN arch/x86/include/asm/cpuid.h~xsave-leaf-checks-1 arch/x86/include= /asm/cpuid.h --- a/arch/x86/include/asm/cpuid.h~xsave-leaf-checks-1 2024-12-13 12:45:36.= 351203168 -0800 +++ b/arch/x86/include/asm/cpuid.h 2024-12-13 12:45:36.359203508 -0800 @@ -23,8 +23,10 @@ enum cpuid_regs_idx { =20 #define CPUID_MWAIT_LEAF 0x5 #define CPUID_DCA_LEAF 0x9 +#define XSTATE_CPUID 0x0d #define CPUID_TSC_LEAF 0x15 #define CPUID_FREQ_LEAF 0x16 +#define TILE_CPUID 0x1d =20 #ifdef CONFIG_X86_32 bool have_cpuid_p(void); diff -puN arch/x86/include/asm/fpu/xstate.h~xsave-leaf-checks-1 arch/x86/in= clude/asm/fpu/xstate.h --- a/arch/x86/include/asm/fpu/xstate.h~xsave-leaf-checks-1 2024-12-13 12:4= 5:36.355203337 -0800 +++ b/arch/x86/include/asm/fpu/xstate.h 2024-12-13 12:45:36.359203508 -0800 @@ -12,10 +12,6 @@ /* Bit 63 of XCR0 is reserved for future expansion */ #define XFEATURE_MASK_EXTEND (~(XFEATURE_MASK_FPSSE | (1ULL << 63))) =20 -#define XSTATE_CPUID 0x0000000d - -#define TILE_CPUID 0x0000001d - #define FXSAVE_SIZE 512 =20 #define XSAVE_HDR_SIZE 64 diff -puN arch/x86/kernel/cpu/common.c~xsave-leaf-checks-1 arch/x86/kernel/= cpu/common.c --- a/arch/x86/kernel/cpu/common.c~xsave-leaf-checks-1 2024-12-13 12:45:36.= 355203337 -0800 +++ b/arch/x86/kernel/cpu/common.c 2024-12-13 12:45:36.359203508 -0800 @@ -639,7 +639,7 @@ static const struct cpuid_dependent_feat cpuid_dependent_features[] =3D { { X86_FEATURE_MWAIT, CPUID_MWAIT_LEAF }, { X86_FEATURE_DCA, CPUID_DCA_LEAF }, - { X86_FEATURE_XSAVE, 0x0000000d }, + { X86_FEATURE_XSAVE, XSTATE_CPUID }, { 0, 0 } }; =20 diff -puN arch/x86/kernel/fpu/xstate.c~xsave-leaf-checks-1 arch/x86/kernel/= fpu/xstate.c --- a/arch/x86/kernel/fpu/xstate.c~xsave-leaf-checks-1 2024-12-13 12:45:36.= 359203508 -0800 +++ b/arch/x86/kernel/fpu/xstate.c 2024-12-13 12:45:36.359203508 -0800 @@ -20,6 +20,7 @@ #include #include =20 +#include #include #include #include _ From nobody Wed Dec 17 16:11:43 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 08C2C1E3791 for ; Fri, 13 Dec 2024 20:50:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123040; cv=none; b=pT7VaK7xE0b5eSn2+oTwoIB5EzS8BkZMQRh6ptnk6e46XNUgZ+I3eBQF1Ym/HO77IQZEtAVgkC/BNkCfCM3Cw+rJ3CSHSBRkvu6vxluJusAc/gd+evdMCcMqg0P1NIXvfquEJwvpnO8cpo9/aADMTnAOvnXoL7USpJ+ny4zO7JY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123040; c=relaxed/simple; bh=xJ9tlm9UP77Tpl5VZzjFo0c/uI4CPdW7hzDDC10dl5Q=; h=Subject:To:Cc:From:Date:References:In-Reply-To:Message-Id; b=Lst758wSzqNe5264mdHpuT1hinNqk08CGDKNSPsp3p23YyzdYJDdw0NUIXL0m9OjrZyWBTtCfSF3ruANnatlHCLYsD22PMBT5NI0K2Mv8L8PdHfV+5+uC68JIKgmz8iczlC3cg50yNOZlMOhPV2u2VXq2zcEZpon6CewP15HwT0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Nty+gaI9; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Nty+gaI9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734123039; x=1765659039; h=subject:to:cc:from:date:references:in-reply-to: message-id; bh=xJ9tlm9UP77Tpl5VZzjFo0c/uI4CPdW7hzDDC10dl5Q=; b=Nty+gaI9k9Q5195zCMfbdl6gr887ZldOXjmfRlGo+LI8PYDToUb5/eHS B6JroHepTl311ybAEsUM94eAKXvdalAk6lAn34HaPcTiz7Cz05z9i2XY5 MSKDe7QjcvIDV8Y0Ze0ED9yvz4TSi0JMLU+EVyIbE46g8NZooxqPIpeDH PvIEm/ICX6IpCS0vCBf2DA2y9M2oJIicO4c934hrRwKJec31GBqOt6MTR UcRP6kmuDGbhVocfjLK1LgcGgFE1fpNSHFkihms0Ng32szl6xI0Yc1jni mzbqV2tQrLDx3Vm4QvpSbwO5XnQ5UOiQfFreId4cuHWhgrTYpnB0gJl4b Q==; X-CSE-ConnectionGUID: eCgNuOgkRcuM/JMJiQmmcQ== X-CSE-MsgGUID: zEoJeQojRfqVE4luuK6A4A== X-IronPort-AV: E=McAfee;i="6700,10204,11278"; a="45973171" X-IronPort-AV: E=Sophos;i="6.12,214,1728975600"; d="scan'208";a="45973171" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2024 12:50:38 -0800 X-CSE-ConnectionGUID: 0iJnRf4XSb+fQrmW6/tQLQ== X-CSE-MsgGUID: ZJZW7GQTSSiBo00szh/VDA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="101599695" Received: from davehans-spike.ostc.intel.com (HELO localhost.localdomain) ([10.165.164.11]) by orviesa005.jf.intel.com with ESMTP; 13 Dec 2024 12:50:39 -0800 Subject: [PATCH 09/10] x86/fpu: Remove unnecessary CPUID level check To: linux-kernel@vger.kernel.org Cc: x86@kernel.org,tglx@linutronix.de,bp@alien8.de,rafael@kernel.org,lenb@kernel.org,dave.jiang@intel.com,irenic.rajneesh@gmail.com,david.e.box@intel.com,Dave Hansen From: Dave Hansen Date: Fri, 13 Dec 2024 12:50:38 -0800 References: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> In-Reply-To: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> Message-Id: <20241213205038.6E71F9A4@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Dave Hansen The CPUID level dependency table will entirely zap X86_FEATURE_XSAVE if the CPUID level is too low. This code is unreachable. Kill it. Signed-off-by: Dave Hansen --- b/arch/x86/kernel/fpu/xstate.c | 5 ----- 1 file changed, 5 deletions(-) diff -puN arch/x86/kernel/fpu/xstate.c~xsave-leaf-checks-2 arch/x86/kernel/= fpu/xstate.c --- a/arch/x86/kernel/fpu/xstate.c~xsave-leaf-checks-2 2024-12-13 12:45:36.= 903226562 -0800 +++ b/arch/x86/kernel/fpu/xstate.c 2024-12-13 12:45:36.907226732 -0800 @@ -764,11 +764,6 @@ void __init fpu__init_system_xstate(unsi return; } =20 - if (boot_cpu_data.cpuid_level < XSTATE_CPUID) { - WARN_ON_FPU(1); - return; - } - /* * Find user xstates supported by the processor. */ _ From nobody Wed Dec 17 16:11:43 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 56D5B1E883E for ; Fri, 13 Dec 2024 20:50:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123042; cv=none; b=R5uPYrfRgWHgT3oHrhnOOko8otxryktIoFrFgm6HAVR5d9rKQEXIZbQTvFHAihGlvnMheiBUsvkTAYz5XRWqcDLJprfEqj/EjUrJkaZsusQG4ZjAJXzg7j8GK+kmH6S8lj8SnvD91/87xq611NWoACyxjYw+Xn9qqta11Is8r+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734123042; c=relaxed/simple; bh=wOkZ2Cd6tvpRViWyim+Anso+2fUgqhM+9n5NySmVDS0=; h=Subject:To:Cc:From:Date:References:In-Reply-To:Message-Id; b=cV5w7medLXyBpF03me0Gce3z/kGCwUjuooVVZ4xF/0KJ+jlAbHDJaxKX2Dx4bZF0lHGyefoMVCQ7TXI4WutG8wz2a2zR5HaDVnQtFvPfCnDb68/S8mbV+EzwX19kH8xtZRYcmSI68ZbECQ2KQCkybssgruE/KKhiEor8kOG7yH8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=N09TSjrK; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="N09TSjrK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734123040; x=1765659040; h=subject:to:cc:from:date:references:in-reply-to: message-id; bh=wOkZ2Cd6tvpRViWyim+Anso+2fUgqhM+9n5NySmVDS0=; b=N09TSjrKPnn89e8cBjR15P8A7NU5fpIyFumGlZfo5Ul2CNddv75/ZP1+ LQVyX1+ETUdq8MKiEywUuhisyLQ3ni/jAr+s62UN8pno8Y/CUEc+MKMOB lHFeAUzoFYNMUKHAXcWTyMjUMwWeSgv96e4jZo9zep5EbPW+rHRbhocjh +XRmFHC+YTpSYO9t2S9L9FPteBBpdHbcueocxnG3AbC2pGsyQwr8ITYPA LNG9e07IeoUpIdu2LDgAHGKZJA00RMqvqImvKycqEBiseer4SXOt9jtsZ l8n0cO7jvq//s4Sj7tfXnRSZemS8EgnQbuis+Z0Xc5stc5FFTm1W/Cl7r g==; X-CSE-ConnectionGUID: hLwQOumBSe+Lt51pzBdrIg== X-CSE-MsgGUID: dd41XMLoS9uuQav8nBrirg== X-IronPort-AV: E=McAfee;i="6700,10204,11278"; a="45973176" X-IronPort-AV: E=Sophos;i="6.12,214,1728975600"; d="scan'208";a="45973176" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2024 12:50:40 -0800 X-CSE-ConnectionGUID: NlYcZSlLTHOjAFhNtWRKrQ== X-CSE-MsgGUID: Ff4HubECRGmbH6s76/0aTA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="101599698" Received: from davehans-spike.ostc.intel.com (HELO localhost.localdomain) ([10.165.164.11]) by orviesa005.jf.intel.com with ESMTP; 13 Dec 2024 12:50:40 -0800 Subject: [PATCH 10/10] x86/cpu: Make all all CPUID leaf names consistent To: linux-kernel@vger.kernel.org Cc: x86@kernel.org,tglx@linutronix.de,bp@alien8.de,rafael@kernel.org,lenb@kernel.org,dave.jiang@intel.com,irenic.rajneesh@gmail.com,david.e.box@intel.com,Dave Hansen From: Dave Hansen Date: Fri, 13 Dec 2024 12:50:40 -0800 References: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> In-Reply-To: <20241213205026.25B1D283@davehans-spike.ostc.intel.com> Message-Id: <20241213205040.7B0C3241@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Dave Hansen The leaf names are not consistent. Give them all a CPUID_LEAF_ prefix for consistency and vertical alignment. Signed-off-by: Dave Hansen Acked-by: Dave Jiang # for ioatdma bits --- b/arch/x86/events/intel/pt.c | 4 ++-- b/arch/x86/include/asm/cpuid.h | 12 ++++++------ b/arch/x86/kernel/acpi/cstate.c | 4 ++-- b/arch/x86/kernel/cpu/common.c | 6 +++--- b/arch/x86/kernel/fpu/xstate.c | 20 ++++++++++---------- b/arch/x86/kernel/hpet.c | 2 +- b/arch/x86/kernel/process.c | 2 +- b/arch/x86/kernel/smpboot.c | 2 +- b/arch/x86/kernel/tsc.c | 18 +++++++++--------- b/arch/x86/xen/enlighten_pv.c | 4 ++-- b/drivers/acpi/acpi_pad.c | 2 +- b/drivers/dma/ioat/dca.c | 2 +- b/drivers/idle/intel_idle.c | 2 +- b/drivers/platform/x86/intel/pmc/core.c | 4 ++-- 14 files changed, 42 insertions(+), 42 deletions(-) diff -puN arch/x86/events/intel/pt.c~xsave-leaf-checks-3 arch/x86/events/in= tel/pt.c --- a/arch/x86/events/intel/pt.c~xsave-leaf-checks-3 2024-12-13 12:45:37.39= 1247243 -0800 +++ b/arch/x86/events/intel/pt.c 2024-12-13 12:45:37.415248260 -0800 @@ -202,10 +202,10 @@ static int __init pt_pmu_hw_init(void) * otherwise, zero for numerator stands for "not enumerated" * as per SDM */ - if (boot_cpu_data.cpuid_level >=3D CPUID_TSC_LEAF) { + if (boot_cpu_data.cpuid_level >=3D CPUID_LEAF_TSC) { u32 eax, ebx, ecx, edx; =20 - cpuid(CPUID_TSC_LEAF, &eax, &ebx, &ecx, &edx); + cpuid(CPUID_LEAF_TSC, &eax, &ebx, &ecx, &edx); =20 pt_pmu.tsc_art_num =3D ebx; pt_pmu.tsc_art_den =3D eax; diff -puN arch/x86/include/asm/cpuid.h~xsave-leaf-checks-3 arch/x86/include= /asm/cpuid.h --- a/arch/x86/include/asm/cpuid.h~xsave-leaf-checks-3 2024-12-13 12:45:37.= 395247412 -0800 +++ b/arch/x86/include/asm/cpuid.h 2024-12-13 12:45:37.415248260 -0800 @@ -21,12 +21,12 @@ enum cpuid_regs_idx { CPUID_EDX, }; =20 -#define CPUID_MWAIT_LEAF 0x5 -#define CPUID_DCA_LEAF 0x9 -#define XSTATE_CPUID 0x0d -#define CPUID_TSC_LEAF 0x15 -#define CPUID_FREQ_LEAF 0x16 -#define TILE_CPUID 0x1d +#define CPUID_LEAF_MWAIT 0x5 +#define CPUID_LEAF_DCA 0x9 +#define CPUID_LEAF_XSTATE 0x0d +#define CPUID_LEAF_TSC 0x15 +#define CPUID_LEAF_FREQ 0x16 +#define CPUID_LEAF_TILE 0x1d =20 #ifdef CONFIG_X86_32 bool have_cpuid_p(void); diff -puN arch/x86/kernel/acpi/cstate.c~xsave-leaf-checks-3 arch/x86/kernel= /acpi/cstate.c --- a/arch/x86/kernel/acpi/cstate.c~xsave-leaf-checks-3 2024-12-13 12:45:37= .395247412 -0800 +++ b/arch/x86/kernel/acpi/cstate.c 2024-12-13 12:45:37.415248260 -0800 @@ -129,7 +129,7 @@ static long acpi_processor_ffh_cstate_pr unsigned int cstate_type; /* C-state type and not ACPI C-state type */ unsigned int num_cstate_subtype; =20 - cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx); + cpuid(CPUID_LEAF_MWAIT, &eax, &ebx, &ecx, &edx); =20 /* Check whether this particular cx_type (in CST) is supported or not */ cstate_type =3D (((cx->address >> MWAIT_SUBSTATE_SIZE) & @@ -173,7 +173,7 @@ int acpi_processor_ffh_cstate_probe(unsi struct cpuinfo_x86 *c =3D &cpu_data(cpu); long retval; =20 - if (!cpu_cstate_entry || c->cpuid_level < CPUID_MWAIT_LEAF) + if (!cpu_cstate_entry || c->cpuid_level < CPUID_LEAF_MWAIT) return -1; =20 if (reg->bit_offset !=3D NATIVE_CSTATE_BEYOND_HALT) diff -puN arch/x86/kernel/cpu/common.c~xsave-leaf-checks-3 arch/x86/kernel/= cpu/common.c --- a/arch/x86/kernel/cpu/common.c~xsave-leaf-checks-3 2024-12-13 12:45:37.= 395247412 -0800 +++ b/arch/x86/kernel/cpu/common.c 2024-12-13 12:45:37.415248260 -0800 @@ -637,9 +637,9 @@ struct cpuid_dependent_feature { =20 static const struct cpuid_dependent_feature cpuid_dependent_features[] =3D { - { X86_FEATURE_MWAIT, CPUID_MWAIT_LEAF }, - { X86_FEATURE_DCA, CPUID_DCA_LEAF }, - { X86_FEATURE_XSAVE, XSTATE_CPUID }, + { X86_FEATURE_MWAIT, CPUID_LEAF_MWAIT }, + { X86_FEATURE_DCA, CPUID_LEAF_DCA }, + { X86_FEATURE_XSAVE, CPUID_LEAF_XSTATE }, { 0, 0 } }; =20 diff -puN arch/x86/kernel/fpu/xstate.c~xsave-leaf-checks-3 arch/x86/kernel/= fpu/xstate.c --- a/arch/x86/kernel/fpu/xstate.c~xsave-leaf-checks-3 2024-12-13 12:45:37.= 399247581 -0800 +++ b/arch/x86/kernel/fpu/xstate.c 2024-12-13 12:45:37.415248260 -0800 @@ -233,7 +233,7 @@ static void __init setup_xstate_cache(vo xmm_space); =20 for_each_extended_xfeature(i, fpu_kernel_cfg.max_features) { - cpuid_count(XSTATE_CPUID, i, &eax, &ebx, &ecx, &edx); + cpuid_count(CPUID_LEAF_XSTATE, i, &eax, &ebx, &ecx, &edx); =20 xstate_sizes[i] =3D eax; xstate_flags[i] =3D ecx; @@ -399,7 +399,7 @@ int xfeature_size(int xfeature_nr) u32 eax, ebx, ecx, edx; =20 CHECK_XFEATURE(xfeature_nr); - cpuid_count(XSTATE_CPUID, xfeature_nr, &eax, &ebx, &ecx, &edx); + cpuid_count(CPUID_LEAF_XSTATE, xfeature_nr, &eax, &ebx, &ecx, &edx); return eax; } =20 @@ -442,9 +442,9 @@ static void __init __xstate_dump_leaves( * just in case there are some goodies up there */ for (i =3D 0; i < XFEATURE_MAX + 10; i++) { - cpuid_count(XSTATE_CPUID, i, &eax, &ebx, &ecx, &edx); + cpuid_count(CPUID_LEAF_XSTATE, i, &eax, &ebx, &ecx, &edx); pr_warn("CPUID[%02x, %02x]: eax=3D%08x ebx=3D%08x ecx=3D%08x edx=3D%08x\= n", - XSTATE_CPUID, i, eax, ebx, ecx, edx); + CPUID_LEAF_XSTATE, i, eax, ebx, ecx, edx); } } =20 @@ -485,7 +485,7 @@ static int __init check_xtile_data_again * Check the maximum palette id: * eax: the highest numbered palette subleaf. */ - cpuid_count(TILE_CPUID, 0, &max_palid, &ebx, &ecx, &edx); + cpuid_count(CPUID_LEAF_TILE, 0, &max_palid, &ebx, &ecx, &edx); =20 /* * Cross-check each tile size and find the maximum number of @@ -499,7 +499,7 @@ static int __init check_xtile_data_again * eax[31:16]: bytes per title * ebx[31:16]: the max names (or max number of tiles) */ - cpuid_count(TILE_CPUID, palid, &eax, &ebx, &edx, &edx); + cpuid_count(CPUID_LEAF_TILE, palid, &eax, &ebx, &edx, &edx); tile_size =3D eax >> 16; max =3D ebx >> 16; =20 @@ -634,7 +634,7 @@ static unsigned int __init get_compacted * are no supervisor states, but XSAVEC still uses compacted * format. */ - cpuid_count(XSTATE_CPUID, 1, &eax, &ebx, &ecx, &edx); + cpuid_count(CPUID_LEAF_XSTATE, 1, &eax, &ebx, &ecx, &edx); return ebx; } =20 @@ -675,7 +675,7 @@ static unsigned int __init get_xsave_siz * containing all the *user* state components * corresponding to bits currently set in XCR0. */ - cpuid_count(XSTATE_CPUID, 0, &eax, &ebx, &ecx, &edx); + cpuid_count(CPUID_LEAF_XSTATE, 0, &eax, &ebx, &ecx, &edx); return ebx; } =20 @@ -767,13 +767,13 @@ void __init fpu__init_system_xstate(unsi /* * Find user xstates supported by the processor. */ - cpuid_count(XSTATE_CPUID, 0, &eax, &ebx, &ecx, &edx); + cpuid_count(CPUID_LEAF_XSTATE, 0, &eax, &ebx, &ecx, &edx); fpu_kernel_cfg.max_features =3D eax + ((u64)edx << 32); =20 /* * Find supervisor xstates supported by the processor. */ - cpuid_count(XSTATE_CPUID, 1, &eax, &ebx, &ecx, &edx); + cpuid_count(CPUID_LEAF_XSTATE, 1, &eax, &ebx, &ecx, &edx); fpu_kernel_cfg.max_features |=3D ecx + ((u64)edx << 32); =20 if ((fpu_kernel_cfg.max_features & XFEATURE_MASK_FPSSE) !=3D XFEATURE_MAS= K_FPSSE) { diff -puN arch/x86/kernel/hpet.c~xsave-leaf-checks-3 arch/x86/kernel/hpet.c --- a/arch/x86/kernel/hpet.c~xsave-leaf-checks-3 2024-12-13 12:45:37.399247= 581 -0800 +++ b/arch/x86/kernel/hpet.c 2024-12-13 12:45:37.415248260 -0800 @@ -928,7 +928,7 @@ static bool __init mwait_pc10_supported( if (!cpu_feature_enabled(X86_FEATURE_MWAIT)) return false; =20 - cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &mwait_substates); + cpuid(CPUID_LEAF_MWAIT, &eax, &ebx, &ecx, &mwait_substates); =20 return (ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) && (ecx & CPUID5_ECX_INTERRUPT_BREAK) && diff -puN arch/x86/kernel/process.c~xsave-leaf-checks-3 arch/x86/kernel/pro= cess.c --- a/arch/x86/kernel/process.c~xsave-leaf-checks-3 2024-12-13 12:45:37.403= 247751 -0800 +++ b/arch/x86/kernel/process.c 2024-12-13 12:45:37.415248260 -0800 @@ -878,7 +878,7 @@ static __init bool prefer_mwait_c1_over_ if (boot_cpu_has_bug(X86_BUG_MONITOR) || boot_cpu_has_bug(X86_BUG_AMD_API= C_C1E)) return false; =20 - cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx); + cpuid(CPUID_LEAF_MWAIT, &eax, &ebx, &ecx, &edx); =20 /* * If MWAIT extensions are not available, it is safe to use MWAIT diff -puN arch/x86/kernel/smpboot.c~xsave-leaf-checks-3 arch/x86/kernel/smp= boot.c --- a/arch/x86/kernel/smpboot.c~xsave-leaf-checks-3 2024-12-13 12:45:37.403= 247751 -0800 +++ b/arch/x86/kernel/smpboot.c 2024-12-13 12:45:37.415248260 -0800 @@ -1293,7 +1293,7 @@ static inline void mwait_play_dead(void) if (!this_cpu_has(X86_FEATURE_CLFLUSH)) return; =20 - eax =3D CPUID_MWAIT_LEAF; + eax =3D CPUID_LEAF_MWAIT; ecx =3D 0; native_cpuid(&eax, &ebx, &ecx, &edx); =20 diff -puN arch/x86/kernel/tsc.c~xsave-leaf-checks-3 arch/x86/kernel/tsc.c --- a/arch/x86/kernel/tsc.c~xsave-leaf-checks-3 2024-12-13 12:45:37.4032477= 51 -0800 +++ b/arch/x86/kernel/tsc.c 2024-12-13 12:45:37.415248260 -0800 @@ -666,13 +666,13 @@ unsigned long native_calibrate_tsc(void) if (boot_cpu_data.x86_vendor !=3D X86_VENDOR_INTEL) return 0; =20 - if (boot_cpu_data.cpuid_level < CPUID_TSC_LEAF) + if (boot_cpu_data.cpuid_level < CPUID_LEAF_TSC) return 0; =20 eax_denominator =3D ebx_numerator =3D ecx_hz =3D edx =3D 0; =20 /* CPUID 15H TSC/Crystal ratio, plus optionally Crystal Hz */ - cpuid(CPUID_TSC_LEAF, &eax_denominator, &ebx_numerator, &ecx_hz, &edx); + cpuid(CPUID_LEAF_TSC, &eax_denominator, &ebx_numerator, &ecx_hz, &edx); =20 if (ebx_numerator =3D=3D 0 || eax_denominator =3D=3D 0) return 0; @@ -681,7 +681,7 @@ unsigned long native_calibrate_tsc(void) =20 /* * Denverton SoCs don't report crystal clock, and also don't support - * CPUID_FREQ_LEAF for the calculation below, so hardcode the 25MHz + * CPUID_LEAF_FREQ for the calculation below, so hardcode the 25MHz * crystal clock. */ if (crystal_khz =3D=3D 0 && @@ -701,10 +701,10 @@ unsigned long native_calibrate_tsc(void) * clock, but we can easily calculate it to a high degree of accuracy * by considering the crystal ratio and the CPU speed. */ - if (crystal_khz =3D=3D 0 && boot_cpu_data.cpuid_level >=3D CPUID_FREQ_LEA= F) { + if (crystal_khz =3D=3D 0 && boot_cpu_data.cpuid_level >=3D CPUID_LEAF_FRE= Q) { unsigned int eax_base_mhz, ebx, ecx, edx; =20 - cpuid(CPUID_FREQ_LEAF, &eax_base_mhz, &ebx, &ecx, &edx); + cpuid(CPUID_LEAF_FREQ, &eax_base_mhz, &ebx, &ecx, &edx); crystal_khz =3D eax_base_mhz * 1000 * eax_denominator / ebx_numerator; } @@ -739,12 +739,12 @@ static unsigned long cpu_khz_from_cpuid( if (boot_cpu_data.x86_vendor !=3D X86_VENDOR_INTEL) return 0; =20 - if (boot_cpu_data.cpuid_level < CPUID_FREQ_LEAF) + if (boot_cpu_data.cpuid_level < CPUID_LEAF_FREQ) return 0; =20 eax_base_mhz =3D ebx_max_mhz =3D ecx_bus_mhz =3D edx =3D 0; =20 - cpuid(CPUID_FREQ_LEAF, &eax_base_mhz, &ebx_max_mhz, &ecx_bus_mhz, &edx); + cpuid(CPUID_LEAF_FREQ, &eax_base_mhz, &ebx_max_mhz, &ecx_bus_mhz, &edx); =20 return eax_base_mhz * 1000; } @@ -1077,7 +1077,7 @@ static void __init detect_art(void) { unsigned int unused; =20 - if (boot_cpu_data.cpuid_level < CPUID_TSC_LEAF) + if (boot_cpu_data.cpuid_level < CPUID_LEAF_TSC) return; =20 /* @@ -1090,7 +1090,7 @@ static void __init detect_art(void) tsc_async_resets) return; =20 - cpuid(CPUID_TSC_LEAF, &art_base_clk.denominator, + cpuid(CPUID_LEAF_TSC, &art_base_clk.denominator, &art_base_clk.numerator, &art_base_clk.freq_khz, &unused); =20 art_base_clk.freq_khz /=3D KHZ; diff -puN arch/x86/xen/enlighten_pv.c~xsave-leaf-checks-3 arch/x86/xen/enli= ghten_pv.c --- a/arch/x86/xen/enlighten_pv.c~xsave-leaf-checks-3 2024-12-13 12:45:37.4= 07247920 -0800 +++ b/arch/x86/xen/enlighten_pv.c 2024-12-13 12:45:37.419248429 -0800 @@ -231,7 +231,7 @@ static void xen_cpuid(unsigned int *ax, or_ebx =3D smp_processor_id() << 24; break; =20 - case CPUID_MWAIT_LEAF: + case CPUID_LEAF_MWAIT: /* Synthesize the values.. */ *ax =3D 0; *bx =3D 0; @@ -301,7 +301,7 @@ static bool __init xen_check_mwait(void) * ecx and edx. The hypercall provides only partial information. */ =20 - ax =3D CPUID_MWAIT_LEAF; + ax =3D CPUID_LEAF_MWAIT; bx =3D 0; cx =3D 0; dx =3D 0; diff -puN drivers/acpi/acpi_pad.c~xsave-leaf-checks-3 drivers/acpi/acpi_pad= .c --- a/drivers/acpi/acpi_pad.c~xsave-leaf-checks-3 2024-12-13 12:45:37.40724= 7920 -0800 +++ b/drivers/acpi/acpi_pad.c 2024-12-13 12:45:37.419248429 -0800 @@ -48,7 +48,7 @@ static void power_saving_mwait_init(void if (!boot_cpu_has(X86_FEATURE_MWAIT)) return; =20 - cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx); + cpuid(CPUID_LEAF_MWAIT, &eax, &ebx, &ecx, &edx); =20 if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) || !(ecx & CPUID5_ECX_INTERRUPT_BREAK)) diff -puN drivers/dma/ioat/dca.c~xsave-leaf-checks-3 drivers/dma/ioat/dca.c --- a/drivers/dma/ioat/dca.c~xsave-leaf-checks-3 2024-12-13 12:45:37.411248= 089 -0800 +++ b/drivers/dma/ioat/dca.c 2024-12-13 12:45:37.419248429 -0800 @@ -63,7 +63,7 @@ static int dca_enabled_in_bios(struct pc u32 eax; int res; =20 - eax =3D cpuid_eax(CPUID_DCA_LEAF); + eax =3D cpuid_eax(CPUID_LEAF_DCA); res =3D eax & BIT(0); if (!res) dev_dbg(&pdev->dev, "DCA is disabled in BIOS\n"); diff -puN drivers/idle/intel_idle.c~xsave-leaf-checks-3 drivers/idle/intel_= idle.c --- a/drivers/idle/intel_idle.c~xsave-leaf-checks-3 2024-12-13 12:45:37.411= 248089 -0800 +++ b/drivers/idle/intel_idle.c 2024-12-13 12:45:37.419248429 -0800 @@ -2317,7 +2317,7 @@ static int __init intel_idle_init(void) return -ENODEV; } =20 - cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &mwait_substates); + cpuid(CPUID_LEAF_MWAIT, &eax, &ebx, &ecx, &mwait_substates); =20 if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) || !(ecx & CPUID5_ECX_INTERRUPT_BREAK) || diff -puN drivers/platform/x86/intel/pmc/core.c~xsave-leaf-checks-3 drivers= /platform/x86/intel/pmc/core.c --- a/drivers/platform/x86/intel/pmc/core.c~xsave-leaf-checks-3 2024-12-13 = 12:45:37.411248089 -0800 +++ b/drivers/platform/x86/intel/pmc/core.c 2024-12-13 12:45:37.419248429 -= 0800 @@ -936,13 +936,13 @@ static unsigned int pmc_core_get_crystal { unsigned int eax_denominator, ebx_numerator, ecx_hz, edx; =20 - if (boot_cpu_data.cpuid_level < CPUID_TSC_LEAF) + if (boot_cpu_data.cpuid_level < CPUID_LEAF_TSC) return 0; =20 eax_denominator =3D ebx_numerator =3D ecx_hz =3D edx =3D 0; =20 /* TSC/Crystal ratio, plus optionally Crystal Hz */ - cpuid(CPUID_TSC_LEAF, &eax_denominator, &ebx_numerator, &ecx_hz, &edx); + cpuid(CPUID_LEAF_TSC, &eax_denominator, &ebx_numerator, &ecx_hz, &edx); =20 if (ebx_numerator =3D=3D 0 || eax_denominator =3D=3D 0) return 0; _