[PATCH v1 4/9] x86/cpuid: Rename hypervisor_cpuid_base() to cpuid_hypervisor_base()

Ahmed S. Darwish posted 9 patches 7 months, 1 week ago
There is a newer version of this series
[PATCH v1 4/9] x86/cpuid: Rename hypervisor_cpuid_base() to cpuid_hypervisor_base()
Posted by Ahmed S. Darwish 7 months, 1 week ago
In order to let all the APIs under <cpuid/api.h> have a shared "cpuid_"
namespace, rename hypervisor_cpuid_base() to cpuid_hypervisor_base().

To align with the new style, also rename:

    for_each_possible_hypervisor_cpuid_base(function)

to:

    for_each_possible_cpuid_hypervisor_base(function)

Adjust all call-sites accordingly.

Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
---
 arch/x86/include/asm/acrn.h           | 2 +-
 arch/x86/include/asm/cpuid/api.h      | 6 +++---
 arch/x86/include/asm/xen/hypervisor.h | 2 +-
 arch/x86/kernel/jailhouse.c           | 2 +-
 arch/x86/kernel/kvm.c                 | 2 +-
 arch/x86/kvm/cpuid.c                  | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/acrn.h b/arch/x86/include/asm/acrn.h
index 1dd14381bcb6..b509c622e6f4 100644
--- a/arch/x86/include/asm/acrn.h
+++ b/arch/x86/include/asm/acrn.h
@@ -25,7 +25,7 @@ void acrn_remove_intr_handler(void);
 static inline u32 acrn_cpuid_base(void)
 {
 	if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
-		return hypervisor_cpuid_base("ACRNACRNACRN", 0);
+		return cpuid_hypervisor_base("ACRNACRNACRN", 0);
 
 	return 0;
 }
diff --git a/arch/x86/include/asm/cpuid/api.h b/arch/x86/include/asm/cpuid/api.h
index c0211fcdc706..0e4b53306e99 100644
--- a/arch/x86/include/asm/cpuid/api.h
+++ b/arch/x86/include/asm/cpuid/api.h
@@ -188,14 +188,14 @@ static __always_inline bool cpuid_function_is_indexed(u32 function)
 	return false;
 }
 
-#define for_each_possible_hypervisor_cpuid_base(function) \
+#define for_each_possible_cpuid_hypervisor_base(function) \
 	for (function = 0x40000000; function < 0x40010000; function += 0x100)
 
-static inline u32 hypervisor_cpuid_base(const char *sig, u32 leaves)
+static inline u32 cpuid_hypervisor_base(const char *sig, u32 leaves)
 {
 	u32 base, eax, signature[3];
 
-	for_each_possible_hypervisor_cpuid_base(base) {
+	for_each_possible_cpuid_hypervisor_base(base) {
 		cpuid(base, &eax, &signature[0], &signature[1], &signature[2]);
 
 		/*
diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/xen/hypervisor.h
index bd0fc69a10a7..09b15a0e2d2e 100644
--- a/arch/x86/include/asm/xen/hypervisor.h
+++ b/arch/x86/include/asm/xen/hypervisor.h
@@ -43,7 +43,7 @@ extern struct start_info *xen_start_info;
 
 static inline uint32_t xen_cpuid_base(void)
 {
-	return hypervisor_cpuid_base(XEN_SIGNATURE, 2);
+	return cpuid_hypervisor_base(XEN_SIGNATURE, 2);
 }
 
 struct pci_dev;
diff --git a/arch/x86/kernel/jailhouse.c b/arch/x86/kernel/jailhouse.c
index cd8ed1edbf9e..07da72de80ba 100644
--- a/arch/x86/kernel/jailhouse.c
+++ b/arch/x86/kernel/jailhouse.c
@@ -49,7 +49,7 @@ static uint32_t jailhouse_cpuid_base(void)
 	    !boot_cpu_has(X86_FEATURE_HYPERVISOR))
 		return 0;
 
-	return hypervisor_cpuid_base("Jailhouse\0\0\0", 0);
+	return cpuid_hypervisor_base("Jailhouse\0\0\0", 0);
 }
 
 static uint32_t __init jailhouse_detect(void)
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 3be9b3342c67..35d3d2803c57 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -874,7 +874,7 @@ static noinline uint32_t __kvm_cpuid_base(void)
 		return 0;	/* So we don't blow up on old processors */
 
 	if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
-		return hypervisor_cpuid_base(KVM_SIGNATURE, 0);
+		return cpuid_hypervisor_base(KVM_SIGNATURE, 0);
 
 	return 0;
 }
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 7f43d8d24fbe..d153719302a2 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -236,7 +236,7 @@ static struct kvm_hypervisor_cpuid kvm_get_hypervisor_cpuid(struct kvm_vcpu *vcp
 	struct kvm_cpuid_entry2 *entry;
 	u32 base;
 
-	for_each_possible_hypervisor_cpuid_base(base) {
+	for_each_possible_cpuid_hypervisor_base(base) {
 		entry = kvm_find_cpuid_entry(vcpu, base);
 
 		if (entry) {
-- 
2.49.0
Re: [PATCH v1 4/9] x86/cpuid: Rename hypervisor_cpuid_base() to cpuid_hypervisor_base()
Posted by Ingo Molnar 7 months ago
* Ahmed S. Darwish <darwi@linutronix.de> wrote:

> In order to let all the APIs under <cpuid/api.h> have a shared "cpuid_"
> namespace, rename hypervisor_cpuid_base() to cpuid_hypervisor_base().
> 
> To align with the new style, also rename:
> 
>     for_each_possible_hypervisor_cpuid_base(function)
> 
> to:
> 
>     for_each_possible_cpuid_hypervisor_base(function)
> 
> Adjust all call-sites accordingly.
> 
> Suggested-by: Ingo Molnar <mingo@kernel.org>
> Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
> ---
>  arch/x86/include/asm/acrn.h           | 2 +-
>  arch/x86/include/asm/cpuid/api.h      | 6 +++---
>  arch/x86/include/asm/xen/hypervisor.h | 2 +-
>  arch/x86/kernel/jailhouse.c           | 2 +-
>  arch/x86/kernel/kvm.c                 | 2 +-
>  arch/x86/kvm/cpuid.c                  | 2 +-
>  6 files changed, 8 insertions(+), 8 deletions(-)

> -#define for_each_possible_hypervisor_cpuid_base(function) \
> +#define for_each_possible_cpuid_hypervisor_base(function) \
>  	for (function = 0x40000000; function < 0x40010000; function += 0x100)


> --- a/arch/x86/include/asm/xen/hypervisor.h
> +++ b/arch/x86/include/asm/xen/hypervisor.h
> @@ -43,7 +43,7 @@ extern struct start_info *xen_start_info;
>  
>  static inline uint32_t xen_cpuid_base(void)
>  {
> -	return hypervisor_cpuid_base(XEN_SIGNATURE, 2);
> +	return cpuid_hypervisor_base(XEN_SIGNATURE, 2);
>  }

So the interaction here looks a bit weird IMO (what is a 'hypervisor 
base'?), and I think the 'CPUID base' phrase should be immutable.

Ie. I think it would be more natural to call this method 
cpuid_base_hypervisor(), which would mix reasonably well with:

	kvm_cpuid_base()
	xen_cpuid_base()
	jailhouse_cpuid_base()

These lower level methods are prefixed with kvm_/xen_/jailhouse_, as 
most of their internal methods are.

Likewise, for_each_possible_cpuid_base_hypervisor()?

Thanks,

	Ingo
Re: [PATCH v1 4/9] x86/cpuid: Rename hypervisor_cpuid_base() to cpuid_hypervisor_base()
Posted by Ahmed S. Darwish 7 months ago
On Thu, 15 May 2025, Ingo Molnar wrote:
>
> So the interaction here looks a bit weird IMO (what is a 'hypervisor
> base'?), and I think the 'CPUID base' phrase should be immutable.
>
> Ie. I think it would be more natural to call this method
> cpuid_base_hypervisor(), which would mix reasonably well with:
>
> 	kvm_cpuid_base()
> 	xen_cpuid_base()
> 	jailhouse_cpuid_base()
>
> These lower level methods are prefixed with kvm_/xen_/jailhouse_, as
> most of their internal methods are.
>
> Likewise, for_each_possible_cpuid_base_hypervisor()?
>

Makes sense; will do.