x86: capabilities handling adjustments
cover x86: capabilities handling adjustments
1: remove unused x87 remnants of 32-bit days 2: drop further constant cpu_has_* predicates 3: don't use FPU instructions when there is no FPU 4: capabilities: set/clear them using non-locked bitops
PATCH 1/4 x86: remove unused x87 remnants of 32-bit days
x86-64 requires FXSR, XMM, and XMM2, so there's no point in hiding respective code behind conditionals.
xen/arch/x86/hvm/emulate.c +1 -2
@@ -1542,8 +1542,7 @@ static int hvmemul_get_fpu(return X86EMUL_UNHANDLEABLE ;break ;case X86EMUL_FPU_xmm: -if ( !cpu_has_xmm || - (curr->arch.hvm_vcpu.guest_cr[0 ] &X86_CR0_EM ) || +if ( (curr->arch.hvm_vcpu.guest_cr[0 ] &X86_CR0_EM ) || !(curr->arch.hvm_vcpu.guest_cr[4 ] &X86_CR4_OSFXSR ) )return X86EMUL_UNHANDLEABLE ;break ;
xen/arch/x86/i387.c +6 -33
@@ -19,15 +19,12 @@static void fpu_init (void ) { -unsigned long val; +uint32_t val =MXCSR_DEFAULT ; asmvolatile ("fninit" ); -if ( cpu_has_xmm ) - { -/* load default value into MXCSR control/status register */ - val =MXCSR_DEFAULT ; - asmvolatile ("ldmxcsr %0" : :"m" (val) ); - } + +/* load default value into MXCSR control/status register */ + asmvolatile ("ldmxcsr %0" : :"m" (val) ); }/*******************************/
@@ -122,14 +119,6 @@ static inline void fpu_fxrstor(struct vc } } -/* Restore x87 extended state */ -static inline void fpu_frstor (struct vcpu *v) -{ -const char *fpu_ctxt = v->arch.fpu_ctxt; - - asmvolatile ("frstor %0" : :"m" (*fpu_ctxt) ); -} -/*******************************/ /* FPU Save Functions */ /*******************************/
@@ -206,15 +195,6 @@ static inline void fpu_fxsave(struct vcp fpu_ctxt->x[FPU_WORD_SIZE_OFFSET ] = word_size; } -/* Save x87 FPU state */ -static inline void fpu_fsave (struct vcpu *v) -{ -char *fpu_ctxt = v->arch.fpu_ctxt; - -/* FWAIT is required to make FNSAVE synchronous. */ - asmvolatile ("fnsave %0 ; fwait" :"=m" (*fpu_ctxt) ); -} -/*******************************/ /* VCPU FPU Functions */ /*******************************/
@@ -249,12 +229,7 @@ void vcpu_restore_fpu_lazy(struct vcpu *if ( cpu_has_xsave )fpu_xrstor (v,XSTATE_LAZY );else if ( v->fpu_initialised ) - { -if ( cpu_has_fxsr ) -fpu_fxrstor (v); -else -fpu_frstor (v); - } +fpu_fxrstor (v);else fpu_init ();
@@ -278,10 +253,8 @@ static bool_t _vcpu_save_fpu(struct vcpuif ( cpu_has_xsave )fpu_xsave (v); -else if ( cpu_has_fxsr ) -fpu_fxsave (v);else -fpu_fsave (v); +fpu_fxsave (v); v->fpu_dirtied =0 ;
xen/arch/x86/setup.c +2 -4
@@ -1295,10 +1295,8 @@ void __init noreturn __start_xen(unsigneidentify_cpu (&boot_cpu_data); -if ( cpu_has_fxsr ) -set_in_cr4 (X86_CR4_OSFXSR ); -if ( cpu_has_xmm ) -set_in_cr4 (X86_CR4_OSXMMEXCPT ); +set_in_cr4 (X86_CR4_OSFXSR ); +set_in_cr4 (X86_CR4_OSXMMEXCPT );if ( disable_smep )setup_clear_cpu_cap (X86_FEATURE_SMEP );
xen/include/asm-x86/cpufeature.h +0 -3
@@ -184,9 +184,6 @@#define cpu_has_sep boot_cpu_has(X86_FEATURE_SEP)#define cpu_has_mtrr 1#define cpu_has_mmx 1 -#define cpu_has_fxsr 1 -#define cpu_has_xmm 1 -#define cpu_has_xmm2 1#define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3)#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT)#define cpu_has_syscall 1
xen/include/asm-x86/i387.h +9 -16
@@ -17,22 +17,15 @@/* Byte offset of the stored word size within the FXSAVE area/portion. */ #define FPU_WORD_SIZE_OFFSET 511 -struct ix87_state { -struct ix87_env { -uint16_t fcw, _res0; -uint16_t fsw, _res1; -uint16_t ftw, _res2; -uint32_t fip; -uint16_t fcs; -uint16_t fop; -uint32_t fdp; -uint16_t fds, _res6; - } env; - struct __packed ix87_reg { -uint64_t mantissa; -uint16_t exponent:15 ; -uint16_t sign:1 ; - } r[8 ]; +struct ix87_env { +uint16_t fcw, _res0; +uint16_t fsw, _res1; +uint16_t ftw, _res2; +uint32_t fip; +uint16_t fcs; +uint16_t fop; +uint32_t fdp; +uint16_t fds, _res6; };void vcpu_restore_fpu_eager (struct vcpu *v);
xen/include/asm-x86/page.h +3 -6
@@ -206,13 +206,10 @@ typedef struct { u64 pfn; } pagetable_t;#define pagetable_null () pagetable_from_pfn(0)void clear_page_sse2 (void *); -#define clear_page (_p) (cpu_has_xmm2 ? \ - clear_page_sse2((void *)(_p)) : \ - (void)memset((void *)(_p), 0, PAGE_SIZE))void copy_page_sse2 (void *,const void *); -#define copy_page (_t,_f) (cpu_has_xmm2 ? \ - copy_page_sse2(_t, _f) : \ - (void)memcpy(_t, _f, PAGE_SIZE)) + +#define clear_page (_p) clear_page_sse2(_p) +#define copy_page (_t,_f) copy_page_sse2(_t, _f)/* Convert between Xen-heap virtual addresses and machine addresses. */ #define __pa (x) (virt_to_maddr(x))
x86: remove unused x87 remnants of 32-bit days
x86-64 requires FXSR, XMM, and XMM2, so there's no point in hiding respective code behind conditionals.
xen/arch/x86/hvm/emulate.c +1 -2
@@ -1542,8 +1542,7 @@ static int hvmemul_get_fpu(return X86EMUL_UNHANDLEABLE ;break ;case X86EMUL_FPU_xmm: -if ( !cpu_has_xmm || - (curr->arch.hvm_vcpu.guest_cr[0 ] &X86_CR0_EM ) || +if ( (curr->arch.hvm_vcpu.guest_cr[0 ] &X86_CR0_EM ) || !(curr->arch.hvm_vcpu.guest_cr[4 ] &X86_CR4_OSFXSR ) )return X86EMUL_UNHANDLEABLE ;break ;
xen/arch/x86/i387.c +6 -33
@@ -19,15 +19,12 @@static void fpu_init (void ) { -unsigned long val; +uint32_t val =MXCSR_DEFAULT ; asmvolatile ("fninit" ); -if ( cpu_has_xmm ) - { -/* load default value into MXCSR control/status register */ - val =MXCSR_DEFAULT ; - asmvolatile ("ldmxcsr %0" : :"m" (val) ); - } + +/* load default value into MXCSR control/status register */ + asmvolatile ("ldmxcsr %0" : :"m" (val) ); }/*******************************/
@@ -122,14 +119,6 @@ static inline void fpu_fxrstor(struct vc } } -/* Restore x87 extended state */ -static inline void fpu_frstor (struct vcpu *v) -{ -const char *fpu_ctxt = v->arch.fpu_ctxt; - - asmvolatile ("frstor %0" : :"m" (*fpu_ctxt) ); -} -/*******************************/ /* FPU Save Functions */ /*******************************/
@@ -206,15 +195,6 @@ static inline void fpu_fxsave(struct vcp fpu_ctxt->x[FPU_WORD_SIZE_OFFSET ] = word_size; } -/* Save x87 FPU state */ -static inline void fpu_fsave (struct vcpu *v) -{ -char *fpu_ctxt = v->arch.fpu_ctxt; - -/* FWAIT is required to make FNSAVE synchronous. */ - asmvolatile ("fnsave %0 ; fwait" :"=m" (*fpu_ctxt) ); -} -/*******************************/ /* VCPU FPU Functions */ /*******************************/
@@ -249,12 +229,7 @@ void vcpu_restore_fpu_lazy(struct vcpu *if ( cpu_has_xsave )fpu_xrstor (v,XSTATE_LAZY );else if ( v->fpu_initialised ) - { -if ( cpu_has_fxsr ) -fpu_fxrstor (v); -else -fpu_frstor (v); - } +fpu_fxrstor (v);else fpu_init ();
@@ -278,10 +253,8 @@ static bool_t _vcpu_save_fpu(struct vcpuif ( cpu_has_xsave )fpu_xsave (v); -else if ( cpu_has_fxsr ) -fpu_fxsave (v);else -fpu_fsave (v); +fpu_fxsave (v); v->fpu_dirtied =0 ;
xen/arch/x86/setup.c +2 -4
@@ -1295,10 +1295,8 @@ void __init noreturn __start_xen(unsigneidentify_cpu (&boot_cpu_data); -if ( cpu_has_fxsr ) -set_in_cr4 (X86_CR4_OSFXSR ); -if ( cpu_has_xmm ) -set_in_cr4 (X86_CR4_OSXMMEXCPT ); +set_in_cr4 (X86_CR4_OSFXSR ); +set_in_cr4 (X86_CR4_OSXMMEXCPT );if ( disable_smep )setup_clear_cpu_cap (X86_FEATURE_SMEP );
xen/include/asm-x86/cpufeature.h +0 -3
@@ -184,9 +184,6 @@#define cpu_has_sep boot_cpu_has(X86_FEATURE_SEP)#define cpu_has_mtrr 1#define cpu_has_mmx 1 -#define cpu_has_fxsr 1 -#define cpu_has_xmm 1 -#define cpu_has_xmm2 1#define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3)#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT)#define cpu_has_syscall 1
xen/include/asm-x86/i387.h +9 -16
@@ -17,22 +17,15 @@/* Byte offset of the stored word size within the FXSAVE area/portion. */ #define FPU_WORD_SIZE_OFFSET 511 -struct ix87_state { -struct ix87_env { -uint16_t fcw, _res0; -uint16_t fsw, _res1; -uint16_t ftw, _res2; -uint32_t fip; -uint16_t fcs; -uint16_t fop; -uint32_t fdp; -uint16_t fds, _res6; - } env; - struct __packed ix87_reg { -uint64_t mantissa; -uint16_t exponent:15 ; -uint16_t sign:1 ; - } r[8 ]; +struct ix87_env { +uint16_t fcw, _res0; +uint16_t fsw, _res1; +uint16_t ftw, _res2; +uint32_t fip; +uint16_t fcs; +uint16_t fop; +uint32_t fdp; +uint16_t fds, _res6; };void vcpu_restore_fpu_eager (struct vcpu *v);
xen/include/asm-x86/page.h +3 -6
@@ -206,13 +206,10 @@ typedef struct { u64 pfn; } pagetable_t;#define pagetable_null () pagetable_from_pfn(0)void clear_page_sse2 (void *); -#define clear_page (_p) (cpu_has_xmm2 ? \ - clear_page_sse2((void *)(_p)) : \ - (void)memset((void *)(_p), 0, PAGE_SIZE))void copy_page_sse2 (void *,const void *); -#define copy_page (_t,_f) (cpu_has_xmm2 ? \ - copy_page_sse2(_t, _f) : \ - (void)memcpy(_t, _f, PAGE_SIZE)) + +#define clear_page (_p) clear_page_sse2(_p) +#define copy_page (_t,_f) copy_page_sse2(_t, _f)/* Convert between Xen-heap virtual addresses and machine addresses. */ #define __pa (x) (virt_to_maddr(x))
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 1/4] x86: remove unused x87 remnants of 32-bit days
Quoted 4 lines · Jan Beulich
x86-64 requires FXSR, XMM, and XMM2, so there's no point in hiding respective code behind conditionals.
Signed-off-by Jan Beulich <[email protected]>
suggestions.
xen/arch/x86/setup.c void __init noreturn __start_xen(unsigne · line 1299
Quoted 12 lines
xen/arch/x86/setup.c +2
-4@@ -1295,10 +1295,8 @@ void __init noreturn __start_xen(unsigneidentify_cpu (&boot_cpu_data); -if ( cpu_has_fxsr ) -set_in_cr4 (X86_CR4_OSFXSR ); -if ( cpu_has_xmm ) -set_in_cr4 (X86_CR4_OSXMMEXCPT ); +set_in_cr4 (X86_CR4_OSFXSR ); +set_in_cr4 (X86_CR4_OSXMMEXCPT );
set_in_cr4() takes a mask, so could take both of these at once, to be slightly more efficient.
If the bsp path gained an unconditional write_cr4(mmu_cr4_features) then it might be better to fold them into the initialiser for mmu_cr4_features.
Quoted 6 lines
xen/include/asm-x86/page.h +0
-0@@ -206,13 +206,10 @@ typedef struct { u64 pfn; } pagetable_t;#define pagetable_null () pagetable_from_pfn(0)void clear_page_sse2 (void *);
xen/include/asm-x86/page.h typedef struct { u64 pfn; } pagetable_t; · line 212
Quoted 10 lines
xen/include/asm-x86/page.h +3
-6-#define clear_page (_p) (cpu_has_xmm2 ? \ - clear_page_sse2((void *)(_p)) : \ - (void)memset((void *)(_p), 0, PAGE_SIZE))void copy_page_sse2 (void *,const void *); -#define copy_page (_t,_f) (cpu_has_xmm2 ? \ - copy_page_sse2(_t, _f) : \ - (void)memcpy(_t, _f, PAGE_SIZE)) + +#define clear_page (_p) clear_page_sse2(_p) +#define copy_page (_t,_f) copy_page_sse2(_t, _f)
As you are changing this, an extra space following the comma.
~Andrew
Re: [PATCH 1/4] x86: remove unused x87 remnants of 32-bit days
Quoted 44 lines · Andrew Cooper
Quoted 4 lines · Jan Beulich
x86-64 requires FXSR, XMM, and XMM2, so there's no point in hiding respective code behind conditionals.
Signed-off-by Jan Beulich <[email protected]>Reviewed-by Andrew Cooper <[email protected]>, with twosuggestions.
xen/arch/x86/setup.c void __init noreturn __start_xen(unsigne · line 1299
Quoted 12 lines
xen/arch/x86/setup.c +2
-4@@ -1295,10 +1295,8 @@ void __init noreturn __start_xen(unsigneidentify_cpu (&boot_cpu_data); -if ( cpu_has_fxsr ) -set_in_cr4 (X86_CR4_OSFXSR ); -if ( cpu_has_xmm ) -set_in_cr4 (X86_CR4_OSXMMEXCPT ); +set_in_cr4 (X86_CR4_OSFXSR ); +set_in_cr4 (X86_CR4_OSXMMEXCPT );
set_in_cr4()takes a mask, so could take both of these at once, to be slightly more efficient.If the bsp path gained an unconditional
write_cr4(mmu_cr4_features)then it might be better to fold them into the initialiser formmu_cr4_features.Quoted 6 lines
xen/include/asm-x86/page.h +0
-0@@ -206,13 +206,10 @@ typedef struct { u64 pfn; } pagetable_t;#define pagetable_null () pagetable_from_pfn(0)void clear_page_sse2 (void *);xen/include/asm-x86/page.h typedef struct { u64 pfn; } pagetable_t; · line 212
Quoted 10 lines
xen/include/asm-x86/page.h +3
-6-#define clear_page (_p) (cpu_has_xmm2 ? \ - clear_page_sse2((void *)(_p)) : \ - (void)memset((void *)(_p), 0, PAGE_SIZE))void copy_page_sse2 (void *,const void *); -#define copy_page (_t,_f) (cpu_has_xmm2 ? \ - copy_page_sse2(_t, _f) : \ - (void)memcpy(_t, _f, PAGE_SIZE)) + +#define clear_page (_p) clear_page_sse2(_p) +#define copy_page (_t,_f) copy_page_sse2(_t, _f)As you are changing this, an extra space following the comma.
Quoted 1 line
~Andrew
A third suggestion to delete the trailing whitespace before fninit in the following hunk.
xen/arch/x86/i387.c +4 -7
@@ -19,15 +19,12 @@static void fpu_init (void ) { -unsigned long val; +uint32_t val =MXCSR_DEFAULT ; asmvolatile ("fninit" ); -if ( cpu_has_xmm ) - { -/* load default value into MXCSR control/status register */ - val =MXCSR_DEFAULT ; - asmvolatile ("ldmxcsr %0" : :"m" (val) ); - } + +/* load default value into MXCSR control/status register */ + asmvolatile ("ldmxcsr %0" : :"m" (val) ); }
~Andrew
PATCH 2/4 x86: drop further constant cpu_has_* predicates
In reply to Jan BeulichEFER and SYSCALL are required on x86-64, and I think there's no point in assuming there might be no TSC. A few other predicates are simply unused. Of the ones left but constant I'm not convinced we should drop them; for some of them we may actually better make them non-constant (see also next patch in this series).
xen/arch/x86/acpi/power.c +1 -2
@@ -194,8 +194,7 @@ static int enter_state(u32 state)/* Restore CR4 and EFER from cached values. */ cr4 =read_cr4 ();write_cr4 (cr4 & ~X86_CR4_MCE ); -if ( cpu_has_efer ) -write_efer (read_efer ()); +write_efer (read_efer ());device_power_up ();
xen/arch/x86/apic.c +9 -15
@@ -1130,7 +1130,7 @@ static void __devinit setup_APIC_timer(vstatic int __init calibrate_APIC_clock (void ) { -unsigned long long t1 =0 , t2 =0 ; +unsigned long long t1, t2;long tt1, tt2;long result;int i;
@@ -1157,8 +1157,7 @@ static int __init calibrate_APIC_clock(v/* * We wrapped around just now. Let's start: */ -if (cpu_has_tsc) - t1 =rdtsc (); + t1 =rdtsc (); tt1 =apic_read (APIC_TMCCT );/*
@@ -1168,8 +1167,7 @@ static int __init calibrate_APIC_clock(vwait_8254_wraparound (); tt2 =apic_read (APIC_TMCCT ); -if (cpu_has_tsc) - t2 =rdtsc (); + t2 =rdtsc ();/* * The APIC bus clock counter is 32 bits only, it
@@ -1181,16 +1179,12 @@ static int __init calibrate_APIC_clock(v result = (tt1-tt2)*APIC_DIVISOR /LOOPS ; -if (cpu_has_tsc) -apic_printk (APIC_VERBOSE ,"..... CPU clock speed is " -"%ld.%04ld MHz.\n" , - ((long )(t2-t1)/LOOPS )/(1000000 /HZ ), - ((long )(t2-t1)/LOOPS )%(1000000 /HZ )); - -apic_printk (APIC_VERBOSE ,"..... host bus clock speed is " -"%ld.%04ld MHz.\n" , - result/(1000000 /HZ ), - result%(1000000 /HZ )); +apic_printk (APIC_VERBOSE ,"..... CPU clock speed is %ld.%04ld MHz.\n" , + ((long )(t2 - t1) /LOOPS ) / (1000000 /HZ ), + ((long )(t2 - t1) /LOOPS ) % (1000000 /HZ )); + +apic_printk (APIC_VERBOSE ,"..... host bus clock speed is %ld.%04ld MHz.\n" , + result / (1000000 /HZ ), result % (1000000 /HZ ));/* set up multipliers for accurate timer code */ bus_freq = result*HZ ;
xen/arch/x86/boot/trampoline.S +2 -6
@@ -86,17 +86,13 @@ trampoline_protmode_entry: /* Set up EFER (Extended Feature Enable Register). */ mov bootsym_rel(cpuid_ext_features,4,%edi) - test $0x20100800,%edi /* SYSCALL/SYSRET, No Execute, Long Mode? */ - jz .Lskip_efer movl $MSR_EFER,%ecx rdmsr - btsl $_EFER_LME,%eax /* Long Mode */ - btsl $_EFER_SCE,%eax /* SYSCALL/SYSRET */ - btl $20,%edi /* No Execute? */ + or $EFER_LME|EFER_SCE,%eax /* Long Mode + SYSCALL/SYSRET */ + bt $X86_FEATURE_NX % 32,%edi /* No Execute? */ jnc 1f btsl $_EFER_NX,%eax /* No Execute */ 1: wrmsr -.Lskip_efer: mov $(X86_CR0_PG | X86_CR0_AM | X86_CR0_WP | X86_CR0_NE |\ X86_CR0_ET | X86_CR0_MP | X86_CR0_PE), %eax
xen/arch/x86/setup.c +1 -2
@@ -625,8 +625,7 @@ void __init noreturn __start_xen(unsigneparse_video_info (); -if ( cpu_has_efer ) -rdmsrl (MSR_EFER ,this_cpu (efer)); +rdmsrl (MSR_EFER ,this_cpu (efer)); asmvolatile ("mov %%cr4,%0" :"=r" (this_cpu (cr4)) );/* We initialise the serial devices very early so we can get debugging. */
xen/arch/x86/smpboot.c +1 -2
@@ -332,8 +332,7 @@ void start_secondary(void *unused)set_processor_id (cpu);set_current (idle_vcpu[cpu]);this_cpu (curr_vcpu) = idle_vcpu[cpu]; -if ( cpu_has_efer ) -rdmsrl (MSR_EFER ,this_cpu (efer)); +rdmsrl (MSR_EFER ,this_cpu (efer));/* * Just as during early bootstrap, it is convenient here to disable
xen/include/asm-x86/cpufeature.h +0 -7
@@ -174,10 +174,8 @@#define CPUID5_ECX_EXTENSIONS_SUPPORTED 0x1#define CPUID5_ECX_INTERRUPT_BREAK 0x2 -#define cpu_has_vme 0#define cpu_has_de 1#define cpu_has_pse 1 -#define cpu_has_tsc 1#define cpu_has_pge 1#define cpu_has_pat 1#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC)
@@ -186,15 +184,10 @@#define cpu_has_mmx 1#define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3)#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT) -#define cpu_has_syscall 1#define cpu_has_mp 1#define cpu_has_nx boot_cpu_has(X86_FEATURE_NX) -#define cpu_has_k6_mtrr 0 -#define cpu_has_cyrix_arr 0 -#define cpu_has_centaur_mcr 0#define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLSH)#define cpu_has_page1gb boot_cpu_has(X86_FEATURE_PAGE1GB) -#define cpu_has_efer 1#define cpu_has_fsgsbase boot_cpu_has(X86_FEATURE_FSGSBASE)#define cpu_has_smep boot_cpu_has(X86_FEATURE_SMEP)
x86: drop further constant cpu_has_* predicates
EFER and SYSCALL are required on x86-64, and I think there's no point in assuming there might be no TSC. A few other predicates are simply unused. Of the ones left but constant I'm not convinced we should drop them; for some of them we may actually better make them non-constant (see also next patch in this series).
xen/arch/x86/acpi/power.c +1 -2
@@ -194,8 +194,7 @@ static int enter_state(u32 state)/* Restore CR4 and EFER from cached values. */ cr4 =read_cr4 ();write_cr4 (cr4 & ~X86_CR4_MCE ); -if ( cpu_has_efer ) -write_efer (read_efer ()); +write_efer (read_efer ());device_power_up ();
xen/arch/x86/apic.c +9 -15
@@ -1130,7 +1130,7 @@ static void __devinit setup_APIC_timer(vstatic int __init calibrate_APIC_clock (void ) { -unsigned long long t1 =0 , t2 =0 ; +unsigned long long t1, t2;long tt1, tt2;long result;int i;
@@ -1157,8 +1157,7 @@ static int __init calibrate_APIC_clock(v/* * We wrapped around just now. Let's start: */ -if (cpu_has_tsc) - t1 =rdtsc (); + t1 =rdtsc (); tt1 =apic_read (APIC_TMCCT );/*
@@ -1168,8 +1167,7 @@ static int __init calibrate_APIC_clock(vwait_8254_wraparound (); tt2 =apic_read (APIC_TMCCT ); -if (cpu_has_tsc) - t2 =rdtsc (); + t2 =rdtsc ();/* * The APIC bus clock counter is 32 bits only, it
@@ -1181,16 +1179,12 @@ static int __init calibrate_APIC_clock(v result = (tt1-tt2)*APIC_DIVISOR /LOOPS ; -if (cpu_has_tsc) -apic_printk (APIC_VERBOSE ,"..... CPU clock speed is " -"%ld.%04ld MHz.\n" , - ((long )(t2-t1)/LOOPS )/(1000000 /HZ ), - ((long )(t2-t1)/LOOPS )%(1000000 /HZ )); - -apic_printk (APIC_VERBOSE ,"..... host bus clock speed is " -"%ld.%04ld MHz.\n" , - result/(1000000 /HZ ), - result%(1000000 /HZ )); +apic_printk (APIC_VERBOSE ,"..... CPU clock speed is %ld.%04ld MHz.\n" , + ((long )(t2 - t1) /LOOPS ) / (1000000 /HZ ), + ((long )(t2 - t1) /LOOPS ) % (1000000 /HZ )); + +apic_printk (APIC_VERBOSE ,"..... host bus clock speed is %ld.%04ld MHz.\n" , + result / (1000000 /HZ ), result % (1000000 /HZ ));/* set up multipliers for accurate timer code */ bus_freq = result*HZ ;
xen/arch/x86/boot/trampoline.S +2 -6
@@ -86,17 +86,13 @@ trampoline_protmode_entry: /* Set up EFER (Extended Feature Enable Register). */ mov bootsym_rel(cpuid_ext_features,4,%edi) - test $0x20100800,%edi /* SYSCALL/SYSRET, No Execute, Long Mode? */ - jz .Lskip_efer movl $MSR_EFER,%ecx rdmsr - btsl $_EFER_LME,%eax /* Long Mode */ - btsl $_EFER_SCE,%eax /* SYSCALL/SYSRET */ - btl $20,%edi /* No Execute? */ + or $EFER_LME|EFER_SCE,%eax /* Long Mode + SYSCALL/SYSRET */ + bt $X86_FEATURE_NX % 32,%edi /* No Execute? */ jnc 1f btsl $_EFER_NX,%eax /* No Execute */ 1: wrmsr -.Lskip_efer: mov $(X86_CR0_PG | X86_CR0_AM | X86_CR0_WP | X86_CR0_NE |\ X86_CR0_ET | X86_CR0_MP | X86_CR0_PE), %eax
xen/arch/x86/setup.c +1 -2
@@ -625,8 +625,7 @@ void __init noreturn __start_xen(unsigneparse_video_info (); -if ( cpu_has_efer ) -rdmsrl (MSR_EFER ,this_cpu (efer)); +rdmsrl (MSR_EFER ,this_cpu (efer)); asmvolatile ("mov %%cr4,%0" :"=r" (this_cpu (cr4)) );/* We initialise the serial devices very early so we can get debugging. */
xen/arch/x86/smpboot.c +1 -2
@@ -332,8 +332,7 @@ void start_secondary(void *unused)set_processor_id (cpu);set_current (idle_vcpu[cpu]);this_cpu (curr_vcpu) = idle_vcpu[cpu]; -if ( cpu_has_efer ) -rdmsrl (MSR_EFER ,this_cpu (efer)); +rdmsrl (MSR_EFER ,this_cpu (efer));/* * Just as during early bootstrap, it is convenient here to disable
xen/include/asm-x86/cpufeature.h +0 -7
@@ -174,10 +174,8 @@#define CPUID5_ECX_EXTENSIONS_SUPPORTED 0x1#define CPUID5_ECX_INTERRUPT_BREAK 0x2 -#define cpu_has_vme 0#define cpu_has_de 1#define cpu_has_pse 1 -#define cpu_has_tsc 1#define cpu_has_pge 1#define cpu_has_pat 1#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC)
@@ -186,15 +184,10 @@#define cpu_has_mmx 1#define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3)#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT) -#define cpu_has_syscall 1#define cpu_has_mp 1#define cpu_has_nx boot_cpu_has(X86_FEATURE_NX) -#define cpu_has_k6_mtrr 0 -#define cpu_has_cyrix_arr 0 -#define cpu_has_centaur_mcr 0#define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLSH)#define cpu_has_page1gb boot_cpu_has(X86_FEATURE_PAGE1GB) -#define cpu_has_efer 1#define cpu_has_fsgsbase boot_cpu_has(X86_FEATURE_FSGSBASE)#define cpu_has_smep boot_cpu_has(X86_FEATURE_SMEP)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 2/4] x86: drop further constant cpu_has_* predicates
Quoted 7 lines · Jan Beulich
EFER and SYSCALL are required on x86-64, and I think there's no point in assuming there might be no TSC. A few other predicates are simply unused. Of the ones left but constant I'm not convinced we should drop them; for some of them we may actually better make them non-constant (see also next patch in this series).
Signed-off-by Jan Beulich <[email protected]>
PATCH 3/4 x86: don't use FPU instructions when there is no FPU
In reply to Jan BeulichOne of the many things we need to do if we want to eventually be able to run on e.g. Xeon Phi.
xen/arch/x86/cpu/common.c +3 -0
@@ -261,6 +261,9 @@ static void __cpuinit generic_identify(scpuid_count (0x00000007 ,0 , &dummy, &ebx, &dummy, &dummy); c->x86_capability[X86_FEATURE_FSGSBASE /32 ] = ebx; } + +if ( !cpu_has_fpu ) +__set_bit (X86_FEATURE_NO_FPU_SEL , c->x86_capability); }/*
xen/arch/x86/i387.c +3 -2
@@ -21,7 +21,8 @@ static void fpu_init(void) {uint32_t val =MXCSR_DEFAULT ; - asmvolatile ("fninit" ); +if ( cpu_has_fpu || cpu_has_mmx ) + asmvolatile ("fninit" );/* load default value into MXCSR control/status register */ asmvolatile ("ldmxcsr %0" : :"m" (val) );
@@ -59,7 +60,7 @@ static inline void fpu_fxrstor(struct vc* sometimes new user value. Both should be ok. Use the FPU saved * data block as a safe address because it should be in L1. */ -if ( !(fpu_ctxt->fsw &0x0080 ) && +if ( cpu_has_fpu && !(fpu_ctxt->fsw &0x0080 ) && boot_cpu_data.x86_vendor ==X86_VENDOR_AMD ) { asm volatile ( "fnclex\n\t"
xen/include/asm-x86/cpufeature.h +2 -1
@@ -170,6 +170,7 @@#define CPUID5_ECX_EXTENSIONS_SUPPORTED 0x1#define CPUID5_ECX_INTERRUPT_BREAK 0x2 +#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)#define cpu_has_de 1#define cpu_has_pse 1#define cpu_has_pge 1
@@ -177,7 +178,7 @@#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC)#define cpu_has_sep boot_cpu_has(X86_FEATURE_SEP)#define cpu_has_mtrr 1 -#define cpu_has_mmx 1 +#define cpu_has_mmx boot_cpu_has(X86_FEATURE_MMX)#define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3)#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT)#define cpu_has_mp 1
x86: don't use FPU instructions when there is no FPU
One of the many things we need to do if we want to eventually be able to run on e.g. Xeon Phi.
xen/arch/x86/cpu/common.c +3 -0
@@ -261,6 +261,9 @@ static void __cpuinit generic_identify(scpuid_count (0x00000007 ,0 , &dummy, &ebx, &dummy, &dummy); c->x86_capability[X86_FEATURE_FSGSBASE /32 ] = ebx; } + +if ( !cpu_has_fpu ) +__set_bit (X86_FEATURE_NO_FPU_SEL , c->x86_capability); }/*
xen/arch/x86/i387.c +3 -2
@@ -21,7 +21,8 @@ static void fpu_init(void) {uint32_t val =MXCSR_DEFAULT ; - asmvolatile ("fninit" ); +if ( cpu_has_fpu || cpu_has_mmx ) + asmvolatile ("fninit" );/* load default value into MXCSR control/status register */ asmvolatile ("ldmxcsr %0" : :"m" (val) );
@@ -59,7 +60,7 @@ static inline void fpu_fxrstor(struct vc* sometimes new user value. Both should be ok. Use the FPU saved * data block as a safe address because it should be in L1. */ -if ( !(fpu_ctxt->fsw &0x0080 ) && +if ( cpu_has_fpu && !(fpu_ctxt->fsw &0x0080 ) && boot_cpu_data.x86_vendor ==X86_VENDOR_AMD ) { asm volatile ( "fnclex\n\t"
xen/include/asm-x86/cpufeature.h +2 -1
@@ -170,6 +170,7 @@#define CPUID5_ECX_EXTENSIONS_SUPPORTED 0x1#define CPUID5_ECX_INTERRUPT_BREAK 0x2 +#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)#define cpu_has_de 1#define cpu_has_pse 1#define cpu_has_pge 1
@@ -177,7 +178,7 @@#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC)#define cpu_has_sep boot_cpu_has(X86_FEATURE_SEP)#define cpu_has_mtrr 1 -#define cpu_has_mmx 1 +#define cpu_has_mmx boot_cpu_has(X86_FEATURE_MMX)#define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3)#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT)#define cpu_has_mp 1
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/4] x86: don't use FPU instructions when there is no FPU
xen/include/asm-x86/cpufeature.h line 173
Quoted 7 lines · Jan Beulich
xen/include/asm-x86/cpufeature.h +1
-0@@ -170,6 +170,7 @@#define CPUID5_ECX_EXTENSIONS_SUPPORTED 0x1#define CPUID5_ECX_INTERRUPT_BREAK 0x2 +#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
This distinguishes only between an onboard fpu or an original x87 co-processor. It does not represent the presence or absence of an fpu.
Looking at the Xeon Phi documentation
(http://download-software.intel.com/sites/default/files/forum/278102/327364001en.pdf),
it has this feature bit set, although it does have MMX clear.
Interestingly however, a Phi's default MXCSR value ix 0x20000h and will #GP at any attempt to clear bit 21, which means fpu_init() will unconditionally blow up on such a system.
I am not aware of a bit which signifies the absence of FPU capabilities. Until there is, I don't think changes along these lines are a safe way to go.
~Andrew
Re: [PATCH 3/4] x86: don't use FPU instructions when there is no FPU
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 14.10.15 at 16:30, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
xen/include/asm-x86/cpufeature.h +0
-0@@ -170,6 +170,7 @@#define CPUID5_ECX_EXTENSIONS_SUPPORTED 0x1#define CPUID5_ECX_INTERRUPT_BREAK 0x2
Quoted 4 lines
xen/include/asm-x86/cpufeature.h line 173
Quoted 1 line
xen/include/asm-x86/cpufeature.h +1
-0+#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)This distinguishes only between an onboard fpu or an original x87 co-processor. It does not represent the presence or absence of an fpu.
That's a very odd statement with off-chip FPUs having disappeared with the Pentium. We don't care about x87 co-processors at all in Xen.
Quoted 7 lines
Looking at the Xeon Phi documentation
(http://download-software.intel.com/sites/default/files/forum/278102/327364001en.pdf),
it has this feature bit set, although it does have MMX clear.Interestingly however, a Phi's default MXCSR value ix 0x20000h and will #GP at any attempt to clear bit 21, which means
fpu_init()will unconditionally blow up on such a system.
"... one of the many things ..."
Quoted 3 lines
I am not aware of a bit which signifies the absence of FPU capabilities. Until there is, I don't think changes along these lines are a safe way to go.
See above; I continue to think this is the right thing at this point. Going forward we'll have to see whether co-processors re-appear.
Jan
PATCH 4/4 x86/capabilities: set/clear them using non-locked bitops
In reply to Jan BeulichTheir initialization happens without races, so there's no point in using atomic (locked) operations to update the respective flags. (There's one case where the clear_bit() was completely pointless.)
Also drop a neighboring stale comment from AMD code.
xen/arch/x86/apic.c +2 -3
@@ -872,7 +872,7 @@ static int __init detect_init_APIC (voidreturn -1 ; } -set_bit (X86_FEATURE_APIC , boot_cpu_data.x86_capability); +__set_bit (X86_FEATURE_APIC , boot_cpu_data.x86_capability); mp_lapic_addr =APIC_DEFAULT_PHYS_BASE ;/* The BIOS may have set up the APIC at some other address */
@@ -1369,7 +1369,7 @@ void pmu_apic_interrupt(struct cpu_user_int __init APIC_init_uniprocessor (void ) {if (enable_local_apic <0 ) -clear_bit (X86_FEATURE_APIC , boot_cpu_data.x86_capability); +__clear_bit (X86_FEATURE_APIC , boot_cpu_data.x86_capability);if (!smp_found_config && !cpu_has_apic) { skip_ioapic_setup =1 ;
@@ -1382,7 +1382,6 @@ int __init APIC_init_uniprocessor (void)if (!cpu_has_apic &&APIC_INTEGRATED (apic_version[boot_cpu_physical_apicid])) {printk (KERN_ERR "BIOS bug, local APIC #%d not detected!...\n" , boot_cpu_physical_apicid); -clear_bit (X86_FEATURE_APIC , boot_cpu_data.x86_capability); skip_ioapic_setup =1 ;return -1 ; }
xen/arch/x86/cpu/amd.c +10 -15
@@ -442,15 +442,9 @@ static void __devinit init_amd(struct cpwrmsrl (MSR_K7_HWCR , value); } -/* -* FIXME: We should handle the K5 here. Set up the write -* range and also turn on MSR 83 bits 4 and 31 (write alloc, -* no bus pipeline) -*/ -/* Bit 31 in normal CPUID used for nonstandard 3DNow ID; 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway */ -clear_bit (0 *32 +31 , c->x86_capability); +__clear_bit (0 *32 +31 , c->x86_capability);if (c->x86 ==0xf && c->x86_model <0x14 &&cpu_has (c,X86_FEATURE_LAHF_LM )) {
@@ -459,7 +453,7 @@ static void __devinit init_amd(struct cp* revision D (model = 0x14) and later actually support it. * (AMD Erratum #110, docId: 25759). */ -clear_bit (X86_FEATURE_LAHF_LM , c->x86_capability); +__clear_bit (X86_FEATURE_LAHF_LM , c->x86_capability);if (!rdmsr_amd_safe (0xc001100d , &l, &h))wrmsr_amd_safe (0xc001100d , l, h & ~1 ); }
@@ -482,10 +476,11 @@ static void __devinit init_amd(struct cpif (c->extended_cpuid_level >=0x80000007 ) { c->x86_power =cpuid_edx (0x80000007 );if (c->x86_power & (1 <<8 )) { -set_bit (X86_FEATURE_CONSTANT_TSC , c->x86_capability); -set_bit (X86_FEATURE_NONSTOP_TSC , c->x86_capability); +__set_bit (X86_FEATURE_CONSTANT_TSC , c->x86_capability); +__set_bit (X86_FEATURE_NONSTOP_TSC , c->x86_capability);if (c->x86 !=0x11 ) -set_bit (X86_FEATURE_TSC_RELIABLE , c->x86_capability); +__set_bit (X86_FEATURE_TSC_RELIABLE , + c->x86_capability); } }
@@ -498,7 +493,7 @@ static void __devinit init_amd(struct cpwrmsr_safe (MSR_K8_EXT_FEATURE_MASK , value);rdmsrl (MSR_K8_EXT_FEATURE_MASK , value);if (value & (1ULL <<54 )) { -set_bit (X86_FEATURE_TOPOEXT , c->x86_capability); +__set_bit (X86_FEATURE_TOPOEXT , c->x86_capability);printk (KERN_INFO "CPU: Re-enabling disabled " "Topology Extensions Support\n" ); }
@@ -516,7 +511,7 @@ static void __devinit init_amd(struct cp/* Pointless to use MWAIT on Family10 as it does not deep sleep. */ if (c->x86 >=0x10 && !force_mwait) -clear_bit (X86_FEATURE_MWAIT , c->x86_capability); +__clear_bit (X86_FEATURE_MWAIT , c->x86_capability);if (!cpu_has_amd_erratum (c,AMD_ERRATUM_121 )) opt_allow_unsafe =1 ;
@@ -566,7 +561,7 @@ static void __devinit init_amd(struct cp }/* AMD CPUs do not support SYSENTER outside of legacy mode. */ -clear_bit (X86_FEATURE_SEP , c->x86_capability); +__clear_bit (X86_FEATURE_SEP , c->x86_capability);if (c->x86 ==0x10 ) {/* do this for boot cpu */
@@ -592,7 +587,7 @@ static void __devinit init_amd(struct cp* running in deep C states. */ if ( opt_arat && c->x86 >0x11 ) -set_bit (X86_FEATURE_ARAT , c->x86_capability); +__set_bit (X86_FEATURE_ARAT , c->x86_capability);/* * Prior to Family 0x14, perf counters are not reset during warm reboot.
xen/arch/x86/cpu/centaur.c +1 -1
@@ -47,7 +47,7 @@ static void __init init_c3(struct cpuinfif (c->x86 ==0x6 && c->x86_model >=0xf ) { c->x86_cache_alignment = c->x86_clflush_size *2 ; -set_bit (X86_FEATURE_CONSTANT_TSC , c->x86_capability); +__set_bit (X86_FEATURE_CONSTANT_TSC , c->x86_capability); }get_model_name (c);
xen/arch/x86/cpu/common.c +2 -2
@@ -312,7 +312,7 @@ void __cpuinit identify_cpu(struct cpuin/* Initialize xsave/xrstor features */ if ( !use_xsave ) -clear_bit (X86_FEATURE_XSAVE , boot_cpu_data.x86_capability); +__clear_bit (X86_FEATURE_XSAVE , boot_cpu_data.x86_capability);if ( cpu_has_xsave )xstate_init (c);
@@ -392,7 +392,7 @@ void __cpuinit detect_extended_topology(if ( ebx ==0 || (LEAFB_SUBTYPE (ecx) !=SMT_TYPE ) )return ; -set_bit (X86_FEATURE_XTOPOLOGY , c->x86_capability); +__set_bit (X86_FEATURE_XTOPOLOGY , c->x86_capability); initial_apicid = edx;
xen/arch/x86/cpu/intel.c +10 -9
@@ -209,7 +209,7 @@ static void __devinit Intel_errata_workaif (c->x86 ==6 && cpu_has_clflush && (c->x86_model ==29 || c->x86_model ==46 || c->x86_model ==47 )) -set_bit (X86_FEATURE_CLFLUSH_MONITOR , c->x86_capability); +__set_bit (X86_FEATURE_CLFLUSH_MONITOR , c->x86_capability); }
@@ -244,7 +244,7 @@ static void __devinit init_intel(structunsigned eax =cpuid_eax (10 );/* Check for version and the number of counters */ if ((eax &0xff ) && (((eax>>8 ) &0xff ) >1 )) -set_bit (X86_FEATURE_ARCH_PERFMON , c->x86_capability); +__set_bit (X86_FEATURE_ARCH_PERFMON , c->x86_capability); }if ( !cpu_has (c,X86_FEATURE_XTOPOLOGY ) )
@@ -255,10 +255,11 @@ static void __devinit init_intel(structif (c == &boot_cpu_data && c->x86 ==6 ) {if (probe_intel_cpuid_faulting ()) -set_bit (X86_FEATURE_CPUID_FAULTING , c->x86_capability); +__set_bit (X86_FEATURE_CPUID_FAULTING , + c->x86_capability); }else if (boot_cpu_has (X86_FEATURE_CPUID_FAULTING )) {BUG_ON (!probe_intel_cpuid_faulting ()); -set_bit (X86_FEATURE_CPUID_FAULTING , c->x86_capability); +__set_bit (X86_FEATURE_CPUID_FAULTING , c->x86_capability); }if (!cpu_has_cpuid_faulting)
@@ -274,16 +275,16 @@ static void __devinit init_intel(structif ((c->x86 ==0xf && c->x86_model >=0x03 ) || (c->x86 ==0x6 && c->x86_model >=0x0e )) -set_bit (X86_FEATURE_CONSTANT_TSC , c->x86_capability); +__set_bit (X86_FEATURE_CONSTANT_TSC , c->x86_capability);if (cpuid_edx (0x80000007 ) & (1u <<8 )) { -set_bit (X86_FEATURE_CONSTANT_TSC , c->x86_capability); -set_bit (X86_FEATURE_NONSTOP_TSC , c->x86_capability); -set_bit (X86_FEATURE_TSC_RELIABLE , c->x86_capability); +__set_bit (X86_FEATURE_CONSTANT_TSC , c->x86_capability); +__set_bit (X86_FEATURE_NONSTOP_TSC , c->x86_capability); +__set_bit (X86_FEATURE_TSC_RELIABLE , c->x86_capability); }if ( opt_arat && ( c->cpuid_level >=0x00000006 ) && (cpuid_eax (0x00000006 ) & (1u <<2 ) ) ) -set_bit (X86_FEATURE_ARAT , c->x86_capability); +__set_bit (X86_FEATURE_ARAT , c->x86_capability); }static const struct cpu_dev intel_cpu_dev = {
x86/capabilities: set/clear them using non-locked bitops
Their initialization happens without races, so there's no point in using atomic (locked) operations to update the respective flags. (There's one case where the clear_bit() was completely pointless.)
Also drop a neighboring stale comment from AMD code.
xen/arch/x86/apic.c +2 -3
@@ -872,7 +872,7 @@ static int __init detect_init_APIC (voidreturn -1 ; } -set_bit (X86_FEATURE_APIC , boot_cpu_data.x86_capability); +__set_bit (X86_FEATURE_APIC , boot_cpu_data.x86_capability); mp_lapic_addr =APIC_DEFAULT_PHYS_BASE ;/* The BIOS may have set up the APIC at some other address */
@@ -1369,7 +1369,7 @@ void pmu_apic_interrupt(struct cpu_user_int __init APIC_init_uniprocessor (void ) {if (enable_local_apic <0 ) -clear_bit (X86_FEATURE_APIC , boot_cpu_data.x86_capability); +__clear_bit (X86_FEATURE_APIC , boot_cpu_data.x86_capability);if (!smp_found_config && !cpu_has_apic) { skip_ioapic_setup =1 ;
@@ -1382,7 +1382,6 @@ int __init APIC_init_uniprocessor (void)if (!cpu_has_apic &&APIC_INTEGRATED (apic_version[boot_cpu_physical_apicid])) {printk (KERN_ERR "BIOS bug, local APIC #%d not detected!...\n" , boot_cpu_physical_apicid); -clear_bit (X86_FEATURE_APIC , boot_cpu_data.x86_capability); skip_ioapic_setup =1 ;return -1 ; }
xen/arch/x86/cpu/amd.c +10 -15
@@ -442,15 +442,9 @@ static void __devinit init_amd(struct cpwrmsrl (MSR_K7_HWCR , value); } -/* -* FIXME: We should handle the K5 here. Set up the write -* range and also turn on MSR 83 bits 4 and 31 (write alloc, -* no bus pipeline) -*/ -/* Bit 31 in normal CPUID used for nonstandard 3DNow ID; 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway */ -clear_bit (0 *32 +31 , c->x86_capability); +__clear_bit (0 *32 +31 , c->x86_capability);if (c->x86 ==0xf && c->x86_model <0x14 &&cpu_has (c,X86_FEATURE_LAHF_LM )) {
@@ -459,7 +453,7 @@ static void __devinit init_amd(struct cp* revision D (model = 0x14) and later actually support it. * (AMD Erratum #110, docId: 25759). */ -clear_bit (X86_FEATURE_LAHF_LM , c->x86_capability); +__clear_bit (X86_FEATURE_LAHF_LM , c->x86_capability);if (!rdmsr_amd_safe (0xc001100d , &l, &h))wrmsr_amd_safe (0xc001100d , l, h & ~1 ); }
@@ -482,10 +476,11 @@ static void __devinit init_amd(struct cpif (c->extended_cpuid_level >=0x80000007 ) { c->x86_power =cpuid_edx (0x80000007 );if (c->x86_power & (1 <<8 )) { -set_bit (X86_FEATURE_CONSTANT_TSC , c->x86_capability); -set_bit (X86_FEATURE_NONSTOP_TSC , c->x86_capability); +__set_bit (X86_FEATURE_CONSTANT_TSC , c->x86_capability); +__set_bit (X86_FEATURE_NONSTOP_TSC , c->x86_capability);if (c->x86 !=0x11 ) -set_bit (X86_FEATURE_TSC_RELIABLE , c->x86_capability); +__set_bit (X86_FEATURE_TSC_RELIABLE , + c->x86_capability); } }
@@ -498,7 +493,7 @@ static void __devinit init_amd(struct cpwrmsr_safe (MSR_K8_EXT_FEATURE_MASK , value);rdmsrl (MSR_K8_EXT_FEATURE_MASK , value);if (value & (1ULL <<54 )) { -set_bit (X86_FEATURE_TOPOEXT , c->x86_capability); +__set_bit (X86_FEATURE_TOPOEXT , c->x86_capability);printk (KERN_INFO "CPU: Re-enabling disabled " "Topology Extensions Support\n" ); }
@@ -516,7 +511,7 @@ static void __devinit init_amd(struct cp/* Pointless to use MWAIT on Family10 as it does not deep sleep. */ if (c->x86 >=0x10 && !force_mwait) -clear_bit (X86_FEATURE_MWAIT , c->x86_capability); +__clear_bit (X86_FEATURE_MWAIT , c->x86_capability);if (!cpu_has_amd_erratum (c,AMD_ERRATUM_121 )) opt_allow_unsafe =1 ;
@@ -566,7 +561,7 @@ static void __devinit init_amd(struct cp }/* AMD CPUs do not support SYSENTER outside of legacy mode. */ -clear_bit (X86_FEATURE_SEP , c->x86_capability); +__clear_bit (X86_FEATURE_SEP , c->x86_capability);if (c->x86 ==0x10 ) {/* do this for boot cpu */
@@ -592,7 +587,7 @@ static void __devinit init_amd(struct cp* running in deep C states. */ if ( opt_arat && c->x86 >0x11 ) -set_bit (X86_FEATURE_ARAT , c->x86_capability); +__set_bit (X86_FEATURE_ARAT , c->x86_capability);/* * Prior to Family 0x14, perf counters are not reset during warm reboot.
xen/arch/x86/cpu/centaur.c +1 -1
@@ -47,7 +47,7 @@ static void __init init_c3(struct cpuinfif (c->x86 ==0x6 && c->x86_model >=0xf ) { c->x86_cache_alignment = c->x86_clflush_size *2 ; -set_bit (X86_FEATURE_CONSTANT_TSC , c->x86_capability); +__set_bit (X86_FEATURE_CONSTANT_TSC , c->x86_capability); }get_model_name (c);
xen/arch/x86/cpu/common.c +2 -2
@@ -312,7 +312,7 @@ void __cpuinit identify_cpu(struct cpuin/* Initialize xsave/xrstor features */ if ( !use_xsave ) -clear_bit (X86_FEATURE_XSAVE , boot_cpu_data.x86_capability); +__clear_bit (X86_FEATURE_XSAVE , boot_cpu_data.x86_capability);if ( cpu_has_xsave )xstate_init (c);
@@ -392,7 +392,7 @@ void __cpuinit detect_extended_topology(if ( ebx ==0 || (LEAFB_SUBTYPE (ecx) !=SMT_TYPE ) )return ; -set_bit (X86_FEATURE_XTOPOLOGY , c->x86_capability); +__set_bit (X86_FEATURE_XTOPOLOGY , c->x86_capability); initial_apicid = edx;
xen/arch/x86/cpu/intel.c +10 -9
@@ -209,7 +209,7 @@ static void __devinit Intel_errata_workaif (c->x86 ==6 && cpu_has_clflush && (c->x86_model ==29 || c->x86_model ==46 || c->x86_model ==47 )) -set_bit (X86_FEATURE_CLFLUSH_MONITOR , c->x86_capability); +__set_bit (X86_FEATURE_CLFLUSH_MONITOR , c->x86_capability); }
@@ -244,7 +244,7 @@ static void __devinit init_intel(structunsigned eax =cpuid_eax (10 );/* Check for version and the number of counters */ if ((eax &0xff ) && (((eax>>8 ) &0xff ) >1 )) -set_bit (X86_FEATURE_ARCH_PERFMON , c->x86_capability); +__set_bit (X86_FEATURE_ARCH_PERFMON , c->x86_capability); }if ( !cpu_has (c,X86_FEATURE_XTOPOLOGY ) )
@@ -255,10 +255,11 @@ static void __devinit init_intel(structif (c == &boot_cpu_data && c->x86 ==6 ) {if (probe_intel_cpuid_faulting ()) -set_bit (X86_FEATURE_CPUID_FAULTING , c->x86_capability); +__set_bit (X86_FEATURE_CPUID_FAULTING , + c->x86_capability); }else if (boot_cpu_has (X86_FEATURE_CPUID_FAULTING )) {BUG_ON (!probe_intel_cpuid_faulting ()); -set_bit (X86_FEATURE_CPUID_FAULTING , c->x86_capability); +__set_bit (X86_FEATURE_CPUID_FAULTING , c->x86_capability); }if (!cpu_has_cpuid_faulting)
@@ -274,16 +275,16 @@ static void __devinit init_intel(structif ((c->x86 ==0xf && c->x86_model >=0x03 ) || (c->x86 ==0x6 && c->x86_model >=0x0e )) -set_bit (X86_FEATURE_CONSTANT_TSC , c->x86_capability); +__set_bit (X86_FEATURE_CONSTANT_TSC , c->x86_capability);if (cpuid_edx (0x80000007 ) & (1u <<8 )) { -set_bit (X86_FEATURE_CONSTANT_TSC , c->x86_capability); -set_bit (X86_FEATURE_NONSTOP_TSC , c->x86_capability); -set_bit (X86_FEATURE_TSC_RELIABLE , c->x86_capability); +__set_bit (X86_FEATURE_CONSTANT_TSC , c->x86_capability); +__set_bit (X86_FEATURE_NONSTOP_TSC , c->x86_capability); +__set_bit (X86_FEATURE_TSC_RELIABLE , c->x86_capability); }if ( opt_arat && ( c->cpuid_level >=0x00000006 ) && (cpuid_eax (0x00000006 ) & (1u <<2 ) ) ) -set_bit (X86_FEATURE_ARAT , c->x86_capability); +__set_bit (X86_FEATURE_ARAT , c->x86_capability); }static const struct cpu_dev intel_cpu_dev = {
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 4/4] x86/capabilities: set/clear them using non-locked bitops
Quoted 7 lines · Jan Beulich
Their initialization happens without races, so there's no point in using atomic (locked) operations to update the respective flags. (There's one case where the
clear_bit()was completely pointless.)Also drop a neighboring stale comment from AMD code.
Signed-off-by Jan Beulich <[email protected]>