[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86: implement cpuid() in terms of cpuid_count()



commit 4086857cc15942daa2de962cd2aeaaa5570e4f57
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu Aug 10 15:11:37 2023 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Aug 10 15:11:37 2023 +0200

    x86: implement cpuid() in terms of cpuid_count()
    
    Since as a bug workaround (likely inapplicable to any 64-bit CPUs, but
    it probably doesn't hurt to keep this) we clear %ecx on input anyway,
    we can as well fall back to cpuid_count(). This allows getting rid of
    four risky casts and makes things type-safe. The latter aspect requires
    two type adjustments elsewhere. While adjusting init_intel_cacheinfo(),
    convert three other local variables there as well. For the struct
    cpuinfo_x86 change it is relevant to note that no 64-bit CPU comes
    without CPUID support, and hence cpuid_level is never set to -1; the
    comment there was simply stale.
    
    No functional change intended, yet of course generated code isn't
    identical.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/cpu/intel_cacheinfo.c    | 3 +--
 xen/arch/x86/include/asm/cpufeature.h | 2 +-
 xen/arch/x86/include/asm/processor.h  | 9 ++-------
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/cpu/intel_cacheinfo.c 
b/xen/arch/x86/cpu/intel_cacheinfo.c
index 5624e8056d..1b5c4c553d 100644
--- a/xen/arch/x86/cpu/intel_cacheinfo.c
+++ b/xen/arch/x86/cpu/intel_cacheinfo.c
@@ -172,8 +172,7 @@ void init_intel_cacheinfo(struct cpuinfo_x86 *c)
            c->x86_vendor != X86_VENDOR_SHANGHAI)
        {
                /* supports eax=2  call */
-               int i, j, n;
-               int regs[4];
+               unsigned int i, j, n, regs[4];
                unsigned char *dp = (unsigned char *)regs;
                int only_trace = 0;
 
diff --git a/xen/arch/x86/include/asm/cpufeature.h 
b/xen/arch/x86/include/asm/cpufeature.h
index 4762db79f1..835fcdb27c 100644
--- a/xen/arch/x86/include/asm/cpufeature.h
+++ b/xen/arch/x86/include/asm/cpufeature.h
@@ -23,7 +23,7 @@ struct cpuinfo_x86 {
     unsigned char x86_vendor;          /* CPU vendor */
     unsigned char x86_model;
     unsigned char x86_mask;
-    int cpuid_level;                   /* Maximum supported CPUID level, -1=no 
CPUID */
+    unsigned int cpuid_level;          /* Maximum supported CPUID level */
     unsigned int extended_cpuid_level; /* Maximum supported CPUID extended 
level */
     unsigned int x86_capability[NCAPINTS];
     char x86_vendor_id[16];
diff --git a/xen/arch/x86/include/asm/processor.h 
b/xen/arch/x86/include/asm/processor.h
index 8d1909f73d..b0d2a62c07 100644
--- a/xen/arch/x86/include/asm/processor.h
+++ b/xen/arch/x86/include/asm/processor.h
@@ -131,13 +131,8 @@ static inline int cpu_nr_siblings(unsigned int cpu)
  * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
  * resulting in stale register contents being returned.
  */
-#define cpuid(_op,_eax,_ebx,_ecx,_edx)          \
-    asm volatile ( "cpuid"                      \
-          : "=a" (*(int *)(_eax)),              \
-            "=b" (*(int *)(_ebx)),              \
-            "=c" (*(int *)(_ecx)),              \
-            "=d" (*(int *)(_edx))               \
-          : "0" (_op), "2" (0) )
+#define cpuid(leaf, eax, ebx, ecx, edx)          \
+        cpuid_count(leaf, 0, eax, ebx, ecx, edx)
 
 /* Some CPUID calls want 'count' to be placed in ecx */
 static inline void cpuid_count(
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.