From nobody Wed Dec 17 13:51:45 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 91303204C39 for ; Mon, 17 Mar 2025 22:30:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742250657; cv=none; b=TFGMRw40cflIrrT2rtQNETk+V/q7JsMI9GwDEOyPOGLbxpKkVFDldQHxMOxKXcO2tQdLZKGyuZ5UrqccWGqJRhe7DjokawNal3KGZxd4dRCk648v7x9W9WWrMPx47Gu0yWfnxwzZ2mAsbSCb4DU+KYc40cnOmjUZtiHJv5pyLvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742250657; c=relaxed/simple; bh=OPIWwrqa3Yqq6CoPPNn6d5qUoYzQ3042gpCOIQHRUMg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VSx7KcxRvDuJ9VCOb61OCYTsji/mlIaSgnUwqfuiIZ4MLzdb4o+7rxqoqYxccoimge4yRa3Sa3P6+o7gFWDwVOj6MCRPD+yV9JiPsO7SDs2NOOznDYM6XAvkfSh8cOB3k4FM4ij80JH73HIGvNDOyw0gPo7AT2AjB7rKCAVC8WE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZvfvvnHf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZvfvvnHf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32CAEC4CEEF; Mon, 17 Mar 2025 22:30:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742250657; bh=OPIWwrqa3Yqq6CoPPNn6d5qUoYzQ3042gpCOIQHRUMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZvfvvnHfbTQ8TTqUJIFUo4w16o4i5TtWOaktIi274OOi2P7974zYIutGUMrJhqIyT diLBdsluBgbwiWN8oLkvo3wSklMCjfRskJVWD0/uMN7WIRGi91OsskUizcU0p/QkFU wxlf5AaTebkGkq82l5AIuOjnLaf5nhd841sND1tKC3S0qk3/r4nQyOhOFRErv15RyL SPqELSlqWsAKFisxSurV69IrH4fXACP9B+8JHBgvns07HKsLAlDKKpuP7y44gvuQvA I/wRlk79QJ8v9rVkHO0b9uJV10/Ez6VbRnp7ytpjJ9ErJhfSB9HEyYgNNPORySKzgW ruNvQGbaHwUpg== From: mingo@kernel.org To: linux-kernel@vger.kernel.org Cc: Juergen Gross , Stefano Stabellini , "Ahmed S . Darwish" , Andrew Cooper , "H . Peter Anvin" , John Ogness , Linus Torvalds , Peter Zijlstra , Borislav Petkov , Thomas Gleixner Subject: [PATCH 3/5] x86/cpuid: Clean up Date: Mon, 17 Mar 2025 23:30:37 +0100 Message-ID: <20250317223039.3741082-4-mingo@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250317223039.3741082-1-mingo@kernel.org> References: <20250317223039.3741082-1-mingo@kernel.org> 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" From: Ingo Molnar - Include first, as is customary. This also has the side effect of build-testing the header dependency assumptions in the types header. - No newline necessary after the SPDX line - Newline necessary after inline function definitions - Rename native_cpuid_reg() to NATIVE_CPUID_REG(): it's a CPP macro, whose name we capitalize in such cases. - Prettify the CONFIG_PARAVIRT_XXL inclusion block a bit - Standardize register references in comments to EAX/EBX/ECX/etc., from the hodgepodge of references. - s/cpus/CPUs because why add noise to common acronyms? - Use u32 instead of uint32_t in hypervisor_cpuid_base(). Yes, I realize uint32_t is used in Xen code, but this is a core x86 architecture header and we should standardize on the type that is being used overwhelmingly in x86 architecture code. The two types are the same so there should be no build warnings. Signed-off-by: Ingo Molnar Cc: Ahmed S. Darwish Cc: Andrew Cooper Cc: "H. Peter Anvin" Cc: John Ogness Cc: x86-cpuid@lists.linux.dev Link: https://lore.kernel.org/r/20250317164745.4754-3-darwi@linutronix.de --- arch/x86/include/asm/cpuid/api.h | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/arch/x86/include/asm/cpuid/api.h b/arch/x86/include/asm/cpuid/= api.h index 4d1da9cc8b6f..f26926ba5289 100644 --- a/arch/x86/include/asm/cpuid/api.h +++ b/arch/x86/include/asm/cpuid/api.h @@ -1,16 +1,16 @@ /* SPDX-License-Identifier: GPL-2.0 */ - #ifndef _ASM_X86_CPUID_API_H #define _ASM_X86_CPUID_API_H =20 +#include + #include #include =20 -#include #include =20 /* - * Raw CPUID accessors + * Raw CPUID accessors: */ =20 #ifdef CONFIG_X86_32 @@ -21,6 +21,7 @@ static inline bool have_cpuid_p(void) return true; } #endif + static inline void native_cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) { @@ -34,7 +35,7 @@ static inline void native_cpuid(unsigned int *eax, unsign= ed int *ebx, : "memory"); } =20 -#define native_cpuid_reg(reg) \ +#define NATIVE_CPUID_REG(reg) \ static inline unsigned int native_cpuid_##reg(unsigned int op) \ { \ unsigned int eax =3D op, ebx, ecx =3D 0, edx; \ @@ -45,22 +46,23 @@ static inline unsigned int native_cpuid_##reg(unsigned = int op) \ } =20 /* - * Native CPUID functions returning a single datum. + * Native CPUID functions returning a single datum: */ -native_cpuid_reg(eax) -native_cpuid_reg(ebx) -native_cpuid_reg(ecx) -native_cpuid_reg(edx) +NATIVE_CPUID_REG(eax) +NATIVE_CPUID_REG(ebx) +NATIVE_CPUID_REG(ecx) +NATIVE_CPUID_REG(edx) =20 #ifdef CONFIG_PARAVIRT_XXL -#include +# include #else -#define __cpuid native_cpuid +# define __cpuid native_cpuid #endif =20 /* * Generic CPUID function - * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx + * + * Clear ECX since some CPUs (Cyrix MII) do not set or clear ECX * resulting in stale register contents being returned. */ static inline void cpuid(unsigned int op, @@ -72,7 +74,7 @@ static inline void cpuid(unsigned int op, __cpuid(eax, ebx, ecx, edx); } =20 -/* Some CPUID calls want 'count' to be placed in ecx */ +/* Some CPUID calls want 'count' to be placed in ECX */ static inline void cpuid_count(unsigned int op, int count, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) @@ -83,7 +85,7 @@ static inline void cpuid_count(unsigned int op, int count, } =20 /* - * CPUID functions returning a single datum + * CPUID functions returning a single datum: */ =20 static inline unsigned int cpuid_eax(unsigned int op) --=20 2.45.2