mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
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@suse.com> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
This commit is contained in:
1 parent
751235f6d1
commit
4086857cc1
3 files changed
+4
-10
No files matched your search
@@ -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;
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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(
|
||||
|
||||