x86: define macros CPUINFO_features and CPUINFO_FEATURE_OFFSET
authorFeng Wu <feng.wu@intel.com>
Tue, 6 May 2014 11:51:27 +0000 (13:51 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 6 May 2014 11:51:27 +0000 (13:51 +0200)
This patch defines macros CPUINFO_features and CPUINFO_FEATURE_OFFSET.
CPUINFO_features can be used as the base of the offset for cpu features,
while CPUINFO_FEATURE_OFFSET is used to define the right offset for
specific CPU feature.

Signed-off-by: Feng Wu <feng.wu@intel.com>
Some further cleanup (both to the patch and to surrounding code).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/boot/head.S
xen/arch/x86/x86_64/asm-offsets.c
xen/include/asm-x86/asm_defns.h
xen/include/asm-x86/cpufeature.h

index ca0e97da3b2733c0f7cc56a4ae80a1188bfee8cf..10ecf51993547d20b447a549854e0574a1b77f46 100644 (file)
@@ -6,6 +6,7 @@
 #include <asm/fixmap.h>
 #include <asm/page.h>
 #include <asm/msr.h>
+#include <asm/cpufeature.h>
 
         .text
         .code32
@@ -137,10 +138,10 @@ __start:
         mov     $0x80000001,%eax
         cpuid
 1:      mov     %edx,sym_phys(cpuid_ext_features)
-        mov     %edx,sym_phys(boot_cpu_data)+CPUINFO86_ext_features
+        mov     %edx,sym_phys(boot_cpu_data)+CPUINFO_FEATURE_OFFSET(X86_FEATURE_LM)
 
         /* Check for availability of long mode. */
-        bt      $29,%edx
+        bt      $X86_FEATURE_LM & 0x1f,%edx
         jnc     bad_cpu
 
         /* Stash TSC to calculate a good approximation of time-since-boot */
index 9acb648427d325ae74975c13b607f254b6b14f67..3994f4df1f1a307bc841a2de25503a06f040af14 100644 (file)
@@ -160,7 +160,7 @@ void __dummy__(void)
     OFFSET(IRQSTAT_softirq_pending, irq_cpustat_t, __softirq_pending);
     BLANK();
 
-    OFFSET(CPUINFO86_ext_features, struct cpuinfo_x86, x86_capability[1]);
+    OFFSET(CPUINFO_features, struct cpuinfo_x86, x86_capability);
     BLANK();
 
     OFFSET(MB_flags, multiboot_info_t, flags);
index a4601bab32a68ab586c1531cad005c8d70e2a2c6..a8d09bf753ad00be8c048732abd0b677af6cf759 100644 (file)
@@ -77,6 +77,9 @@ void ret_from_intr(void);
 #define ASSERT_NOT_IN_ATOMIC
 #endif
 
+#define CPUINFO_FEATURE_OFFSET(feature)           \
+        ((((feature) >> 3) & ~3) + CPUINFO_features)
+
 #else
 
 #ifdef __clang__ /* clang's builtin assember can't do .subsection */
index 6a6b1ab8a816ff0d536bd35e7dd7b845d63fa8b6..20881c044a5898f7b2eb53f680e0daff827602ff 100644 (file)
@@ -7,7 +7,9 @@
 #ifndef __ASM_I386_CPUFEATURE_H
 #define __ASM_I386_CPUFEATURE_H
 
+#ifndef __ASSEMBLY__
 #include <xen/bitops.h>
+#endif
 
 #define NCAPINTS       8       /* N 32-bit words worth of info */
 
 #define X86_FEATURE_ADX                (7*32+19) /* ADCX, ADOX instructions */
 #define X86_FEATURE_SMAP       (7*32+20) /* Supervisor Mode Access Prevention */
 
+#ifndef __ASSEMBLY__
 #define cpu_has(c, bit)                test_bit(bit, (c)->x86_capability)
 #define boot_cpu_has(bit)      test_bit(bit, boot_cpu_data.x86_capability)
 #define cpufeat_mask(idx)       (1u << ((idx) & 31))
 #define cpu_has_vmx            boot_cpu_has(X86_FEATURE_VMXE)
 
 #define cpu_has_cpuid_faulting boot_cpu_has(X86_FEATURE_CPUID_FAULTING)
+#endif
 
 #endif /* __ASM_I386_CPUFEATURE_H */