- Include <asm/cpuid/types.h> 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 <mingo@kernel.org>
Cc: Ahmed S. Darwish <darwi@linutronix.de>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: John Ogness <john.ogness@linutronix.de>
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
+#include <asm/cpuid/types.h>
+
#include <linux/build_bug.h>
#include <linux/types.h>
-#include <asm/cpuid/types.h>
#include <asm/string.h>
/*
- * Raw CPUID accessors
+ * Raw CPUID accessors:
*/
#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, unsigned int *ebx,
: "memory");
}
-#define native_cpuid_reg(reg) \
+#define NATIVE_CPUID_REG(reg) \
static inline unsigned int native_cpuid_##reg(unsigned int op) \
{ \
unsigned int eax = op, ebx, ecx = 0, edx; \
@@ -45,22 +46,23 @@ static inline unsigned int native_cpuid_##reg(unsigned int op) \
}
/*
- * 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)
#ifdef CONFIG_PARAVIRT_XXL
-#include <asm/paravirt.h>
+# include <asm/paravirt.h>
#else
-#define __cpuid native_cpuid
+# define __cpuid native_cpuid
#endif
/*
* 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);
}
-/* 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,
}
/*
- * CPUID functions returning a single datum
+ * CPUID functions returning a single datum:
*/
static inline unsigned int cpuid_eax(unsigned int op)
--
2.45.2
The following commit has been merged into the x86/core branch of tip:
Commit-ID: fb99ed1e00c73dbee2bef77544aa5629edecaae2
Gitweb: https://git.kernel.org/tip/fb99ed1e00c73dbee2bef77544aa5629edecaae2
Author: Ingo Molnar <mingo@kernel.org>
AuthorDate: Mon, 17 Mar 2025 23:18:22 +01:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 19 Mar 2025 11:19:25 +01:00
x86/cpuid: Clean up <asm/cpuid/api.h>
- Include <asm/cpuid/types.h> 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?
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: John Ogness <john.ogness@linutronix.de>
Cc: "Ahmed S. Darwish" <darwi@linutronix.de>
Cc: x86-cpuid@lists.linux.dev
Link: https://lore.kernel.org/r/20250317221824.3738853-4-mingo@kernel.org
---
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 4d1da9c..f26926b 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
+#include <asm/cpuid/types.h>
+
#include <linux/build_bug.h>
#include <linux/types.h>
-#include <asm/cpuid/types.h>
#include <asm/string.h>
/*
- * Raw CPUID accessors
+ * Raw CPUID accessors:
*/
#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, unsigned int *ebx,
: "memory");
}
-#define native_cpuid_reg(reg) \
+#define NATIVE_CPUID_REG(reg) \
static inline unsigned int native_cpuid_##reg(unsigned int op) \
{ \
unsigned int eax = op, ebx, ecx = 0, edx; \
@@ -45,22 +46,23 @@ static inline unsigned int native_cpuid_##reg(unsigned int op) \
}
/*
- * 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)
#ifdef CONFIG_PARAVIRT_XXL
-#include <asm/paravirt.h>
+# include <asm/paravirt.h>
#else
-#define __cpuid native_cpuid
+# define __cpuid native_cpuid
#endif
/*
* 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);
}
-/* 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,
}
/*
- * CPUID functions returning a single datum
+ * CPUID functions returning a single datum:
*/
static inline unsigned int cpuid_eax(unsigned int op)
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: f2f828b547abb37fe60bc3419414c50327b7acff
Gitweb: https://git.kernel.org/tip/f2f828b547abb37fe60bc3419414c50327b7acff
Author: Ingo Molnar <mingo@kernel.org>
AuthorDate: Mon, 17 Mar 2025 23:18:22 +01:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 18 Mar 2025 09:35:58 +01:00
x86/cpuid: Clean up <asm/cpuid/api.h>
- Include <asm/cpuid/types.h> 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?
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: John Ogness <john.ogness@linutronix.de>
Cc: "Ahmed S. Darwish" <darwi@linutronix.de>
Cc: x86-cpuid@lists.linux.dev
Link: https://lore.kernel.org/r/20250317221824.3738853-4-mingo@kernel.org
---
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 4d1da9c..f26926b 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
+#include <asm/cpuid/types.h>
+
#include <linux/build_bug.h>
#include <linux/types.h>
-#include <asm/cpuid/types.h>
#include <asm/string.h>
/*
- * Raw CPUID accessors
+ * Raw CPUID accessors:
*/
#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, unsigned int *ebx,
: "memory");
}
-#define native_cpuid_reg(reg) \
+#define NATIVE_CPUID_REG(reg) \
static inline unsigned int native_cpuid_##reg(unsigned int op) \
{ \
unsigned int eax = op, ebx, ecx = 0, edx; \
@@ -45,22 +46,23 @@ static inline unsigned int native_cpuid_##reg(unsigned int op) \
}
/*
- * 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)
#ifdef CONFIG_PARAVIRT_XXL
-#include <asm/paravirt.h>
+# include <asm/paravirt.h>
#else
-#define __cpuid native_cpuid
+# define __cpuid native_cpuid
#endif
/*
* 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);
}
-/* 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,
}
/*
- * CPUID functions returning a single datum
+ * CPUID functions returning a single datum:
*/
static inline unsigned int cpuid_eax(unsigned int op)
© 2016 - 2025 Red Hat, Inc.