x86, xsave: xsave/xrstor support
Subsystems (14)
cover x86, xsave: xsave/xrstor support
This patchset adds the support for xsave/xrstor infrastructure for x86. xsave/xrstor manages the existing and future processor extended states in x86 architecutre.
More info on xsave/xrstor can be found in the Intel SDM's located at
http://www.intel.com/products/processor/manuals/index.htm
The layout of the xsave/xrstor area extends from the 512-byte FXSAVE/FXRSTOR layout. xsave/xrstor area layout consists of:
- fxsave/fxrstor area (512 bytes)
- xsave header area (64 bytes)
- set of save areas, each corresponding to a processor extended state
The number of save areas, the offset and the size of each save area is enumerated by CPUID leaf function 0xd.
This patch includes the basic xsave/xrstor infrastructure(supporting FP/SSE), which includes:
- context switch support, extending traditional lazy restore mechanism
- signal handling support, extending(using the software reserved bytes 464..511 in the current 512byte layout of fxsave frame) the memory layout pointed out by the fpstate pointer in the sigcontext
More details in the patches to follow.
---
PATCH 1/9 x86, xsave: xsave cpuid feature bits
---
arch/x86/kernel/cpu/feature_names.c +1 -1
@@ -46,7 +46,7 @@"pni" ,NULL ,NULL ,"monitor" ,"ds_cpl" ,"vmx" ,"smx" ,"est" ,"tm2" ,"ssse3" ,"cid" ,NULL ,NULL ,"cx16" ,"xtpr" ,NULL ,NULL ,NULL ,"dca" ,"sse4_1" ,"sse4_2" ,"x2apic" ,NULL ,"popcnt" , -NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL , +NULL ,NULL ,"xsave" ,NULL ,NULL ,NULL ,NULL ,NULL ,/* VIA/Cyrix/Centaur-defined */ NULL, NULL, "rng", "rng_en", NULL, NULL, "ace", "ace_en",
include/asm-x86/cpufeature.h +2 -0
@@ -92,6 +92,7 @@#define X86_FEATURE_XTPR (4*32+14)/* Send Task Priority Messages */ #define X86_FEATURE_DCA (4*32+18)/* Direct Cache Access */ #define X86_FEATURE_X2APIC (4*32+21)/* x2APIC */ +#define X86_FEATURE_XSAVE (4*32+26)/* XSAVE */ /* VIA/Cyrix/Centaur-defined CPU features, CPUID level 0xC0000001, word 5 */ #define X86_FEATURE_XSTORE (5*32+ 2)/* on-CPU RNG present (xstore insn) */
@@ -191,6 +192,7 @@#define cpu_has_arch_perfmon boot_cpu_has(X86_FEATURE_ARCH_PERFMON)#define cpu_has_pat boot_cpu_has(X86_FEATURE_PAT)#define cpu_has_x2apic boot_cpu_has(X86_FEATURE_X2APIC) +#define cpu_has_xsave boot_cpu_has(X86_FEATURE_XSAVE)#if defined(CONFIG_X86_INVLPG ) || defined(CONFIG_X86_64 )# define cpu_has_invlpg 1
PATCH 2/9 x86, xsave: enable xsave/xrstor on cpus with xsave support
In reply to Suresh SiddhaEnables xsave/xrstor by turning on cr4.osxsave on cpu's which have the xsave support. For now, features that OS supports/enabled are FP and SSE.
---
arch/x86/kernel/Makefile +1 -1
@@ -39,7 +39,7 @@ obj-$(CONFIG_X86_TRAMPOLINE) += trampoline.o obj-y += process.o -obj-y += i387.o +obj-y += i387.o xsave.o obj-y += ptrace.o obj-y += ds.o obj-$(CONFIG_X86_32) += tls.o
arch/x86/kernel/cpu/common.c +8 -0
@@ -712,6 +712,14 @@current_thread_info ()->status =0 ;clear_used_math ();mxcsr_feature_mask_init (); + +/* +* Boot processor to setup the FP and extended state context info. +*/ +if (!smp_processor_id ()) +init_thread_xstate (); + +xsave_init (); }#ifdef CONFIG_HOTPLUG_CPU
arch/x86/kernel/i387.c +12 -0
@@ -61,6 +61,11 @@return ; } +if (cpu_has_xsave) { +xsave_cntxt_init (); +return ; + } +if (cpu_has_fxsr) xstate_size =sizeof (struct i387_fxsave_struct );#ifdef CONFIG_X86_32
@@ -83,6 +88,13 @@write_cr0 (oldcr0 & ~(X86_CR0_TS |X86_CR0_EM ));/* clear TS and EM */ +/* +* Boot processor to setup the FP and extended state context info. +*/ +if (!smp_processor_id ()) +init_thread_xstate (); +xsave_init (); +mxcsr_feature_mask_init ();/* clean state in init */ current_thread_info ()->status =0 ;
arch/x86/kernel/traps_64.c +0 -4
@@ -1186,10 +1186,6 @@set_system_gate (IA32_SYSCALL_VECTOR , ia32_syscall);#endif /* -* initialize the per thread extended state: -*/ -init_thread_xstate (); -/* * Should be a barrier for any external CPU state: */ cpu_init ();
include/asm-x86/processor-flags.h +1 -0
@@ -59,6 +59,7 @@#define X86_CR4_OSFXSR 0x00000200/* enable fast FPU save and restore */ #define X86_CR4_OSXMMEXCPT 0x00000400/* enable unmasked SSE exceptions */ #define X86_CR4_VMXE 0x00002000/* enable VMX virtualization */ +#define X86_CR4_OSXSAVE 0x00040000/* enable xsave and xrestore */ /* * x86-64 Task Priority Register, CR8
arch/x86/kernel/xsave.c new file +87 -0
87 lines not on this page · raw message
include/asm-x86/xsave.h new file +26 -0
@@ -0,0 +1,26 @@ +#ifndef __ASM_X86_XSAVE_H +#define __ASM_X86_XSAVE_H + +#include <asm/processor.h> +#include <asm/i387.h> + +#define XSTATE_FP 0x1 +#define XSTATE_SSE 0x2 + +#define XSTATE_FPSSE (XSTATE_FP | XSTATE_SSE) + +#define FXSAVE_SIZE 512 + +/* +* These are the features that the OS can handle currently. +*/ +#define XCNTXT_LMASK (XSTATE_FP | XSTATE_SSE) +#define XCNTXT_HMASK 0x0 + +extern unsigned int xstate_size, pcntxt_hmask, pcntxt_lmask; +extern struct xsave_struct *init_xstate_buf; + +extern void xsave_cntxt_init (void ); +extern void xsave_init (void ); + +#endif
arch/x86/kernel/traps_32.c +0 -1
@@ -1240,7 +1240,6 @@set_bit (SYSCALL_VECTOR , used_vectors); -init_thread_xstate ();/* * Should be a barrier for any external CPU state: */
include/asm-x86/i387.h +1 -0
@@ -18,6 +18,7 @@#include <asm/sigcontext.h> #include <asm/user.h> #include <asm/uaccess.h> +#include <asm/xsave.h> extern void fpu_init (void );extern void mxcsr_feature_mask_init (void );
include/asm-x86/processor.h +12 -0
@@ -351,6 +351,18 @@u32 entry_eip; }; +struct xsave_hdr_struct { +u64 xstate_bv; +u64 reserved1[2 ]; +u64 reserved2[5 ]; +} __attribute__((packed)); + +struct xsave_struct { +struct i387_fxsave_struct i387; +struct xsave_hdr_struct xsave_hdr; +/* new processor state extensions will go here */ +} __attribute__ ((packed,aligned (64 ))); +union thread_xstate {struct i387_fsave_struct fsave;struct i387_fxsave_struct fxsave;
PATCH 3/9 x86, xsave: context switch support using xsave/xrstor
In reply to Suresh SiddhaUses xsave/xrstor (instead of traditional fxsave/fxrstor) in context switch when available.
Introduces TS_XSAVE flag, which determine the need to use xsave/xrstor instructions during context switch instead of the legacy fxsave/fxrstor instructions. Thread-synchronous status word is already in L1 cache during this code patch and thus minimizes the performance penality compared to (cpu_has_xsave) checks.
---
arch/x86/kernel/cpu/common.c +4 -1
@@ -709,7 +709,10 @@/* * Force FPU initialization: */ -current_thread_info ()->status =0 ; +if (cpu_has_xsave) +current_thread_info ()->status =TS_XSAVE ; +else +current_thread_info ()->status =0 ;clear_used_math ();mxcsr_feature_mask_init ();
arch/x86/kernel/i387.c +4 -1
@@ -97,7 +97,10 @@mxcsr_feature_mask_init ();/* clean state in init */ -current_thread_info ()->status =0 ; +if (cpu_has_xsave) +current_thread_info ()->status =TS_XSAVE ; +else +current_thread_info ()->status =0 ; clear_used_math(); }#endif /* CONFIG_X86_64 */
include/asm-x86/i387.h +59 -5
125 lines not on this page · raw message
include/asm-x86/processor.h +1 -0
@@ -367,6 +367,7 @@struct i387_fsave_struct fsave;struct i387_fxsave_struct fxsave;struct i387_soft_struct soft; +struct xsave_struct xsave; };#ifdef CONFIG_X86_64
include/asm-x86/thread_info.h +1 -0
@@ -241,6 +241,7 @@#define TS_POLLING 0x0004/* true if in idle loop and not sleeping */ #define TS_RESTORE_SIGMASK 0x0008/* restore signal mask in do_signal() */ +#define TS_XSAVE 0x0010/* Use xsave/xrstor */ #define tsk_is_polling (t) (task_thread_info(t)->status & TS_POLLING)
include/asm-x86/xsave.h +33 -0
@@ -17,10 +17,43 @@#define XCNTXT_LMASK (XSTATE_FP | XSTATE_SSE)#define XCNTXT_HMASK 0x0 +#ifdef CONFIG_X86_64 +#define REX_PREFIX "0x48, " +#else +#define REX_PREFIX +#endif +extern unsigned int xstate_size, pcntxt_hmask, pcntxt_lmask;extern struct xsave_struct *init_xstate_buf;extern void xsave_cntxt_init (void );extern void xsave_init (void ); +extern int init_fpu (struct task_struct *child); + +static inline int xrstor_checking (struct xsave_struct *fx) +{ +int err; + + asmvolatile ("1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n\t" +"2:\n" +".section .fixup,\"ax\"\n" +"3: movl $-1,%[err]\n" +" jmp 2b\n" +".previous\n" + _ASM_EXTABLE(1b, 3b) + : [err] "=r" (err) + : "D" (fx), "m" (*fx), "a" (-1), "d" (-1), "0" (0) + : "memory"); + + return err; +} +static inline void xsave (struct task_struct *tsk) +{ +/* This, however, we can work around by forcing the compiler to select +an addressing mode that doesn't require extended registers. */ + __asm__ __volatile__(".byte " REX_PREFIX "0x0f,0xae,0x27" + ::"D" (&(tsk->thread.xstate->xsave)), +"a" (-1 ),"d" (-1 ) :"memory" ); +}#endif
arch/x86/kernel/traps_64.c +1 -1
@@ -1147,7 +1147,7 @@/* * Paranoid restore. send a SIGSEGV if we fail to restore the state. */ -if (unlikely (restore_fpu_checking (&me->thread.xstate->fxsave))) { +if (unlikely (restore_fpu_checking (me))) {stts ();force_sig (SIGSEGV , me);return ;
PATCH 4/9 x86, xsave: dynamically allocate sigframes fpstate instead of static allocation
In reply to Suresh Siddhadynamically allocate fpstate on the stack, instead of static allocation in the current sigframe layout on the user stack. This will allow the fpstate structure to grow in the future, which includes extended state information supporting xsave/xrstor.
signal handlers will be able to access the fpstate pointer from the sigcontext structure asusual, with no change. For the non RT sigframe's (which are supported only for 32bit apps), current static fpstate layout in the sigframe will be unused(so that we don't change the extramask[] offset in the sigframe and thus prevent breaking app's which modify extramask[]).
---
arch/x86/ia32/ia32_signal.c +16 -8
@@ -179,9 +179,10 @@u32 pretcode;int sig;struct sigcontext_ia32 sc; -struct _fpstate_ia32 fpstate; +struct _fpstate_ia32 fpstate_unused;/* look at kernel/sigframe.h */ unsigned int extramask[_COMPAT_NSIG_WORDS-1 ];char retcode[8 ]; +/* fp state follows here */ };struct rt_sigframe
@@ -192,8 +193,8 @@u32 puc;compat_siginfo_t info;struct ucontext_ia32 uc; -struct _fpstate_ia32 fpstate;char retcode[8 ]; +/* fp state follows here */ };#define COPY (x) { \
@@ -402,7 +403,8 @@* Determine which stack to use.. */ static void __user *get_sigframe (struct k_sigaction *ka,struct pt_regs *regs, -size_t frame_size) +size_t frame_size, +struct _fpstate_ia32 **fpstate) {unsigned long sp;
@@ -421,6 +423,11 @@ ka->sa.sa_restorer) sp = (unsigned long ) ka->sa.sa_restorer; +if (used_math ()) { + sp = sp - sig_xstate_ia32_size; + *fpstate = (struct _fpstate_ia32 *) sp; + } + sp -= frame_size;/* Align the stack pointer according to the i386 ABI, * i.e. so that on function entry ((sp + 4) & 15) == 0. */
@@ -434,6 +441,7 @@struct sigframe __user *frame;void __user *restorer;int err =0 ; +struct _fpstate_ia32 __user *fpstate =NULL ;/* copy_to_user optimizes that into a single 8 byte store */ static const struct {
@@ -448,7 +456,7 @@ 0, }; - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (ka, regs,sizeof (*frame), &fpstate);if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) goto give_sigsegv;
@@ -457,8 +465,7 @@if (err) goto give_sigsegv; - err |=ia32_setup_sigcontext (&frame->sc, &frame->fpstate, regs, - set->sig[0 ]); + err |=ia32_setup_sigcontext (&frame->sc, fpstate, regs, set->sig[0 ]);if (err) goto give_sigsegv;
@@ -522,6 +529,7 @@struct rt_sigframe __user *frame;void __user *restorer;int err =0 ; +struct _fpstate_ia32 __user *fpstate =NULL ;/* __copy_to_user optimizes that into a single 8 byte store */ static const struct {
@@ -537,7 +545,7 @@ 0, }; - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (ka, regs,sizeof (*frame), &fpstate);if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) goto give_sigsegv;
@@ -556,7 +564,7 @@ err |=__put_user (sas_ss_flags (regs->sp), &frame->uc.uc_stack.ss_flags); err |=__put_user (current->sas_ss_size, &frame->uc.uc_stack.ss_size); - err |=ia32_setup_sigcontext (&frame->uc.uc_mcontext, &frame->fpstate, + err |=ia32_setup_sigcontext (&frame->uc.uc_mcontext, fpstate, regs, set->sig[0 ]); err |=__copy_to_user (&frame->uc.uc_sigmask, set,sizeof (*set));if (err)
arch/x86/kernel/sigframe.h +12 -2
@@ -3,9 +3,18 @@char __user *pretcode;int sig;struct sigcontext sc; -struct _fpstate fpstate; +/* +* fpstate is unused. fpstate is moved/allocated after +* retcode[] below. This movement allows to have the FP state and the +* future state extensions (xsave) stay together. +* And at the same time retaining the unused fpstate, prevents changing +* the offset of extramask[] in the sigframe and thus prevent any +* legacy application accessing/modifying it. +*/ +struct _fpstate fpstate_unused;unsigned long extramask[_NSIG_WORDS-1 ];char retcode[8 ]; +/* fp state follows here */ };struct rt_sigframe {
@@ -15,13 +24,14 @@void __user *puc;struct siginfo info;struct ucontext uc; -struct _fpstate fpstate;char retcode[8 ]; + /* fp state follows here */ };#else struct rt_sigframe {char __user *pretcode;struct ucontext uc;struct siginfo info; +/* fp state follows here */ };#endif
arch/x86/kernel/signal_32.c +13 -5
@@ -308,7 +308,8 @@* Determine which stack to use.. */ static inline void __user * -get_sigframe (struct k_sigaction *ka,struct pt_regs *regs,size_t frame_size) +get_sigframe (struct k_sigaction *ka,struct pt_regs *regs,size_t frame_size, +struct _fpstate **fpstate) {unsigned long sp;
@@ -334,6 +335,11 @@ sp = (unsigned long ) ka->sa.sa_restorer; } +if (used_math ()) { + sp = sp - sig_xstate_size; + *fpstate = (struct _fpstate *) sp; + } + sp -= frame_size;/* * Align the stack pointer according to the i386 ABI,
@@ -352,8 +358,9 @@void __user *restorer;int err =0 ;int usig; +struct _fpstate __user *fpstate =NULL ; - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (ka, regs,sizeof (*frame), &fpstate);if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) goto give_sigsegv;
@@ -368,7 +375,7 @@if (err) goto give_sigsegv; - err =setup_sigcontext (&frame->sc, &frame->fpstate, regs, set->sig[0 ]); + err =setup_sigcontext (&frame->sc, fpstate, regs, set->sig[0 ]);if (err) goto give_sigsegv;
@@ -429,8 +436,9 @@void __user *restorer;int err =0 ;int usig; +struct _fpstate __user *fpstate =NULL ; - frame =get_sigframe (ka, regs,sizeof (*frame)); + frame =get_sigframe (ka, regs,sizeof (*frame), &fpstate);if (!access_ok (VERIFY_WRITE , frame,sizeof (*frame))) goto give_sigsegv;
@@ -455,7 +463,7 @@ err |=__put_user (sas_ss_flags (regs->sp), &frame->uc.uc_stack.ss_flags); err |=__put_user (current->sas_ss_size, &frame->uc.uc_stack.ss_size); - err |=setup_sigcontext (&frame->uc.uc_mcontext, &frame->fpstate, + err |=setup_sigcontext (&frame->uc.uc_mcontext, fpstate, regs, set->sig[0 ]); err |=__copy_to_user (&frame->uc.uc_sigmask, set,sizeof (*set));if (err)
arch/x86/kernel/i387.c +2 -0
@@ -24,6 +24,7 @@# define save_i387_ia32 save_i387# define restore_i387_ia32 restore_i387# define _fpstate_ia32 _fpstate +# define sig_xstate_ia32_size sig_xstate_size# define user_i387_ia32_struct user_i387_struct# define user32_fxsr_struct user_fxsr_struct#endif
@@ -36,6 +37,7 @@static unsigned int mxcsr_feature_mask__read_mostly =0xffffffffu ;unsigned int xstate_size; +unsigned int sig_xstate_ia32_size =sizeof (struct _fpstate_ia32 );static struct i387_fxsave_struct fx_scratch__cpuinitdata ;void __cpuinit mxcsr_feature_mask_init (void )
arch/x86/kernel/signal_64.c +1 -1
@@ -284,7 +284,7 @@struct task_struct *me = current;if (used_math ()) { - fp =get_stack (ka, regs,sizeof (struct _fpstate )); + fp =get_stack (ka, regs, sig_xstate_size); frame = (void __user *)round_down ( (unsigned long )fp -sizeof (struct rt_sigframe ),16 ) -8 ;
arch/x86/kernel/xsave.c +4 -0
@@ -17,6 +17,10 @@*/ struct xsave_struct *init_xstate_buf; +#ifdef CONFIG_X86_64 +unsigned int sig_xstate_size =sizeof (struct _fpstate ); +#endif +/* * Enable the extended processor state save/restore feature */
include/asm-x86/i387.h +2 -0
@@ -20,6 +20,7 @@#include <asm/uaccess.h> #include <asm/xsave.h> +extern unsigned int sig_xstate_size;extern void fpu_init (void );extern void mxcsr_feature_mask_init (void );extern int init_fpu (struct task_struct *child);
@@ -32,6 +33,7 @@extern user_regset_set_fn fpregs_set, xfpregs_set, fpregs_soft_set;#ifdef CONFIG_IA32_EMULATION +extern unsigned int sig_xstate_ia32_size;struct _fpstate_ia32 ;extern int save_i387_ia32 (struct _fpstate_ia32 __user *buf);extern int restore_i387_ia32 (struct _fpstate_ia32 __user *buf);
PATCH 5/9 x86, xsave: reorganization of signal save/restore fpstate code layout
In reply to Suresh Siddhamove 64bit routines that saves/restores fpstate in/from user stack from signal_64.c to xsave.c
restore_i387_xstate() now handles the condition when user passes NULL fpstate.
Other misc changes for prepartion of xsave/xrstor sigcontext support.
---
arch/x86/kernel/i387.c +31 -13
@@ -21,9 +21,10 @@# include <asm/sigcontext32.h> # include <asm/user32.h> #else -# define save_i387_ia32 save_i387 -# define restore_i387_ia32 restore_i387 +# define save_i387_xstate_ia32 save_i387_xstate +# define restore_i387_xstate_ia32 restore_i387_xstate# define _fpstate_ia32 _fpstate +# define _xstate_ia32 _xstate# define sig_xstate_ia32_size sig_xstate_size# define user_i387_ia32_struct user_i387_struct# define user32_fxsr_struct user_fxsr_struct
@@ -424,7 +425,6 @@struct task_struct *tsk = current;struct i387_fsave_struct *fp = &tsk->thread.xstate->fsave; -unlazy_fpu (tsk); fp->status = fp->swd;if (__copy_to_user (buf, fp,sizeof (struct i387_fsave_struct )))return -1 ;
@@ -438,8 +438,6 @@struct user_i387_ia32_struct env;int err =0 ; -unlazy_fpu (tsk); -convert_from_fxsr (&env, tsk);if (__copy_to_user (buf, &env,sizeof (env)))return -1 ;
@@ -455,10 +453,16 @@return 1 ; } -int save_i387_ia32 (struct _fpstate_ia32 __user *buf) +int save_i387_xstate_ia32 (void __user *buf) { +struct _fpstate_ia32 __user *fp = (struct _fpstate_ia32 __user *) buf; +struct task_struct *tsk = current; +if (!used_math ())return 0 ; + +if (!access_ok (VERIFY_WRITE , buf, sig_xstate_ia32_size)) +return -EACCES ;/* * This will cause a "finit" to be triggered by the next * attempted FPU operation by the 'current' process.
@@ -468,13 +472,15 @@if (!HAVE_HWFP ) {return fpregs_soft_get (current,NULL ,0 ,sizeof (struct user_i387_ia32_struct ), -NULL , buf) ?-1 :1 ; +NULL , fp) ?-1 :1 ; } +unlazy_fpu (tsk); +if (cpu_has_fxsr) -return save_i387_fxsave (buf); +return save_i387_fxsave (fp);else -return save_i387_fsave (buf); +return save_i387_fsave (fp); }static inline int restore_i387_fsave (struct _fpstate_ia32 __user *buf)
@@ -502,14 +508,26 @@return 0 ; } -int restore_i387_ia32 (struct _fpstate_ia32 __user *buf) +int restore_i387_xstate_ia32 (void __user *buf) {int err;struct task_struct *tsk = current; +struct _fpstate_ia32 __user *fp = (struct _fpstate_ia32 __user *) buf;if (HAVE_HWFP )clear_fpu (tsk); +if (!buf) { +if (used_math ()) { +clear_fpu (tsk); +clear_used_math (); + } + +return 0 ; + }else +if (!access_ok (VERIFY_READ , buf, sig_xstate_ia32_size)) +return -EACCES ; +if (!used_math ()) { err =init_fpu (tsk);if (err)
@@ -518,13 +536,13 @@if (HAVE_HWFP ) {if (cpu_has_fxsr) - err =restore_i387_fxsave (buf); + err =restore_i387_fxsave (fp);else - err =restore_i387_fsave (buf); + err =restore_i387_fsave (fp); }else { err =fpregs_soft_set (current,NULL ,0 ,sizeof (struct user_i387_ia32_struct ), -NULL , buf) !=0 ; +NULL , fp) !=0 ; }set_used_math ();
arch/x86/kernel/xsave.c +79 -0
85 lines not on this page · raw message
include/asm-x86/i387.h +7 -6
@@ -35,8 +35,9 @@#ifdef CONFIG_IA32_EMULATION extern unsigned int sig_xstate_ia32_size;struct _fpstate_ia32 ; -extern int save_i387_ia32 (struct _fpstate_ia32 __user *buf); -extern int restore_i387_ia32 (struct _fpstate_ia32 __user *buf); +struct _xstate_ia32 ; +extern int save_i387_xstate_ia32 (void __user *buf); +extern int restore_i387_xstate_ia32 (void __user *buf);#endif #define X87_FSW_ES (1 << 7)/* Exception Summary */
@@ -250,13 +251,13 @@ task_thread_info(tsk)->status &= ~TS_USEDFPU; } +#endif /* CONFIG_X86_64 */ +/* * Signal frame handlers... */ -extern int save_i387 (struct _fpstate __user *buf); -extern int restore_i387 (struct _fpstate __user *buf); - -#endif /* CONFIG_X86_64 */ +extern int save_i387_xstate (void __user *buf); +extern int restore_i387_xstate (void __user *buf);static inline void __unlazy_fpu (struct task_struct *tsk) {
arch/x86/ia32/ia32_signal.c +7 -21
@@ -216,7 +216,7 @@ unsigned int *peax) {unsigned int tmpflags, gs, oldgs, err =0 ; -struct _fpstate_ia32 __user *buf; +void __user *buf;u32 tmp;/* Always make any pending restarted system calls return -EINTR */
@@ -260,26 +260,12 @@ err |=__get_user (tmp, &sc->fpstate); buf =compat_ptr (tmp); -if (buf) { -if (!access_ok (VERIFY_READ , buf,sizeof (*buf))) - goto badframe; - err |=restore_i387_ia32 (buf); - }else { -struct task_struct *me = current; - -if (used_math ()) { -clear_fpu (me); -clear_used_math (); - } - } + err |=restore_i387_xstate_ia32 (buf); err |=__get_user (tmp, &sc->ax); *peax = tmp;return err; - -badframe: -return 1 ; }asmlinkage long sys32_sigreturn (struct pt_regs *regs)
@@ -351,7 +337,7 @@*/ static int ia32_setup_sigcontext (struct sigcontext_ia32 __user *sc, -struct _fpstate_ia32 __user *fpstate, +void __user *fpstate,struct pt_regs *regs,unsigned int mask) {int tmp, err =0 ;
@@ -382,7 +368,7 @@ err |=__put_user ((u32 )regs->flags, &sc->flags); err |=__put_user ((u32 )regs->sp, &sc->sp_at_signal); - tmp =save_i387_ia32 (fpstate); + tmp =save_i387_xstate_ia32 (fpstate);if (tmp <0 ) err = -EFAULT ;else {
@@ -404,7 +390,7 @@*/ static void __user *get_sigframe (struct k_sigaction *ka,struct pt_regs *regs,size_t frame_size, -struct _fpstate_ia32 **fpstate) +void **fpstate) {unsigned long sp;
@@ -441,7 +427,7 @@struct sigframe __user *frame;void __user *restorer;int err =0 ; -struct _fpstate_ia32 __user *fpstate =NULL ; +void __user *fpstate =NULL ;/* copy_to_user optimizes that into a single 8 byte store */ static const struct {
@@ -529,7 +515,7 @@struct rt_sigframe __user *frame;void __user *restorer;int err =0 ; -struct _fpstate_ia32 __user *fpstate =NULL ; +void __user *fpstate =NULL ;/* __copy_to_user optimizes that into a single 8 byte store */ static const struct {
arch/x86/kernel/signal_32.c +7 -21
@@ -161,28 +161,14 @@ } { -struct _fpstate __user *buf; +void __user *buf; err |=__get_user (buf, &sc->fpstate); -if (buf) { -if (!access_ok (VERIFY_READ , buf,sizeof (*buf))) - goto badframe; - err |=restore_i387 (buf); - }else { -struct task_struct *me = current; - -if (used_math ()) { -clear_fpu (me); -clear_used_math (); - } - } + err |=restore_i387_xstate (buf); } err |=__get_user (*pax, &sc->ax);return err; - -badframe: -return 1 ; }asmlinkage unsigned long sys_sigreturn (unsigned long __unused)
@@ -264,7 +250,7 @@* Set up a signal frame. */ static int -setup_sigcontext (struct sigcontext __user *sc,struct _fpstate __user *fpstate, +setup_sigcontext (struct sigcontext __user *sc,void __user *fpstate,struct pt_regs *regs,unsigned long mask) {int tmp, err =0 ;
@@ -291,7 +277,7 @@ err |=__put_user (regs->sp, &sc->sp_at_signal); err |=__put_user (regs->ss, (unsigned int __user *)&sc->ss); - tmp =save_i387 (fpstate); + tmp =save_i387_xstate (fpstate);if (tmp <0 ) err =1 ;else
@@ -309,7 +295,7 @@*/ static inline void __user *get_sigframe (struct k_sigaction *ka,struct pt_regs *regs,size_t frame_size, -struct _fpstate **fpstate) +void **fpstate) {unsigned long sp;
@@ -358,7 +344,7 @@void __user *restorer;int err =0 ;int usig; -struct _fpstate __user *fpstate =NULL ; +void __user *fpstate =NULL ; frame =get_sigframe (ka, regs,sizeof (*frame), &fpstate);
@@ -436,7 +422,7 @@void __user *restorer;int err =0 ;int usig; -struct _fpstate __user *fpstate =NULL ; +void __user *fpstate =NULL ; frame =get_sigframe (ka, regs,sizeof (*frame), &fpstate);
arch/x86/kernel/signal_64.c +3 -80
111 lines not on this page · raw message
PATCH 6/9 x86, xsave: xsave/xrstor specific routines
In reply to Suresh Siddha---
include/asm-x86/xsave.h +52 -0
@@ -48,6 +48,58 @@return err; } +static inline int xsave_check (struct xsave_struct __user *buf) +{ +int err; + __asm__ __volatile__("1: .byte " REX_PREFIX "0x0f,0xae,0x27\n" +"2:\n" +".section .fixup,\"ax\"\n" +"3: movl $-1,%[err]\n" +" jmp 2b\n" +".previous\n" +".section __ex_table,\"a\"\n" + _ASM_ALIGN"\n" + _ASM_PTR"1b,3b\n" +".previous" + : [err]"=r" (err) + :"D" (buf),"a" (-1 ),"d" (-1 ),"0" (0 ) + :"memory" ); +if (unlikely (err) &&__clear_user (buf, xstate_size)) + err = -EFAULT ; +/* No need to clear here because the caller clears USED_MATH */ +return err; +} + +static inline int xrestore_user (struct xsave_struct __user *buf, +unsigned int lmask, +unsigned int hmask) +{ +int err; +struct xsave_struct *xstate = ((__force struct xsave_struct *)buf); + + __asm__ __volatile__("1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n" +"2:\n" +".section .fixup,\"ax\"\n" +"3: movl $-1,%[err]\n" +" jmp 2b\n" +".previous\n" +".section __ex_table,\"a\"\n" + _ASM_ALIGN"\n" + _ASM_PTR"1b,3b\n" +".previous" + : [err]"=r" (err) + :"D" (xstate),"a" (lmask),"d" (hmask),"0" (0 ) + :"memory" );//memory required? +return err; +} + +static inline void xrstor_state (struct xsave_struct *fx,int lmask,int hmask) +{ + asmvolatile (".byte " REX_PREFIX "0x0f,0xae,0x2f\n\t" + ::"D" (fx),"m" (*fx),"a" (lmask),"d" (hmask) + :"memory" ); +} +static inline void xsave (struct task_struct *tsk) {/* This, however, we can work around by forcing the compiler to select
PATCH 7/9 x86, xsave: struct _fpstate extensions to include extended state information
In reply to Suresh SiddhaBytes 464..511 in the current 512byte layout of fxsave/fxrstor frame, are reserved for SW usage. On cpu's supporting xsave/xrstor, these bytes are used to extended the fpstate pointer in the sigcontext, which now includes the extended state information along with fpstate information.
---
include/asm-x86/sigcontext.h +81 -4
@@ -4,6 +4,40 @@#include <linux/compiler.h> #include <asm/types.h> +#define FP_XSTATE_MAGIC1 0x46505853U +#define FP_XSTATE_MAGIC2 0x46505845U +#define FP_XSTATE_MAGIC2_SIZE sizeof(FP_XSTATE_MAGIC2) + +/* +* bytes 464..511 in the current 512byte layout of fxsave/fxrstor frame +* are reserved for SW usage. On cpu's supporting xsave/xrstor, these bytes +* are used to extended the fpstate pointer in the sigcontext, which now +* includes the extended state information along with fpstate information. +* +* Presence of FP_XSTATE_MAGIC1 at the beginning of this SW reserved +* area and FP_XSTATE_MAGIC2 at the end of memory layout +* (extended_size - FP_XSTATE_MAGIC2_SIZE) indicates the presence of the +* extended state information in the memory layout pointed by the fpstate +* pointer in sigcontext. +*/ +struct _fpx_sw_bytes { +__u32 magic1;/* FP_XSTATE_MAGIC1 */ +__u32 extended_size;/* total size of the layout referred by +* fpstate pointer in the sigcontext. +*/ +__u64 xstate_bv; +/* feature bit mask (including fp/sse/extended +* state) that is present in the memory +* layout. +*/ +__u32 xstate_size;/* actual xsave state size, based on the +* features saved in the layout. +* 'extended_size' will be greater than +* 'xstate_size'. +*/ +__u32 padding[7 ];/* for future use. */ +}; +#ifdef __i386__/* * As documented in the iBCS2 standard..
@@ -53,7 +87,13 @@unsigned long reserved;struct _fpxreg _fxsr_st[8 ];/* FXSR FPU reg data is ignored */ struct _xmmreg _xmm[8 ]; -unsigned long padding[56 ]; +unsigned long padding1[44 ]; + +union { +unsigned long padding2[12 ]; +struct _fpx_sw_bytes sw_reserved;/* represents the extended +* state info */ + }; };#define X86_FXSR_MAGIC 0x0000
@@ -79,7 +119,14 @@unsigned long flags;unsigned long sp_at_signal;unsigned short ss, __ssh; -struct _fpstate __user *fpstate; + +/* fpstate is really (struct _fpstate *) or (struct _xstate *) +* depending on the FP_XSTATE_MAGIC1 encoded in the SW reserved +* bytes of (struct _fpstate) and FP_XSTATE_MAGIC2 present at the end +* of extended memory layout. See comments at the defintion of +* (struct _fpx_sw_bytes) +*/ +void __user *fpstate;/* zero when no FPU/extended context */ unsigned long oldmask;unsigned long cr2; };
@@ -130,7 +177,12 @@__u32 mxcsr_mask;__u32 st_space[32 ];/* 8*16 bytes for each FP-reg */ __u32 xmm_space[64 ];/* 16*16 bytes for each XMM-reg */ -__u32 reserved2[24 ]; +__u32 reserved2[12 ]; +union { +__u32 reserved3[12 ]; +struct _fpx_sw_bytes sw_reserved;/* represents the extended +* state information */ + }; };#ifdef __KERNEL__
@@ -161,7 +213,14 @@unsigned long trapno;unsigned long oldmask;unsigned long cr2; -struct _fpstate __user *fpstate;/* zero when no FPU context */ + +/* fpstate is really (struct _fpstate *) or (struct _xstate *) +* depending on the FP_XSTATE_MAGIC1 encoded in the SW reserved +* bytes of (struct _fpstate) and FP_XSTATE_MAGIC2 present at the end +* of extended memory layout. See comments at the defintion of +* (struct _fpx_sw_bytes) +*/ +void __user *fpstate;/* zero when no FPU/extended context */ unsigned long reserved1[8]; };#else /* __KERNEL__ */
@@ -202,4 +261,22 @@#endif /* !__i386__ */ +struct _xsave_hdr { +u64 xstate_bv; +u64 reserved1[2 ]; +u64 reserved2[5 ]; +}; + +/* +* Extended state pointed by the fpstate pointer in the sigcontext. +* In addition to the fpstate, information encoded in the xstate_hdr +* indicates the presence of other extended state information +* supported by the processor and OS. +*/ +struct _xstate { +struct _fpstate fpstate; +struct _xsave_hdr xstate_hdr; +/* new processor state extensions go here */ +}; +#endif /* ASM_X86__SIGCONTEXT_H */
include/asm-x86/sigcontext32.h +5 -1
@@ -40,7 +40,11 @@__u32 reserved;struct _fpxreg _fxsr_st[8 ];struct _xmmreg _xmm[8 ];/* It's actually 16 */ -__u32 padding[56 ]; +__u32 padding[44 ]; +union { +__u32 padding2[12 ]; +struct _fpx_sw_bytes sw_reserved; + }; };struct sigcontext_ia32 {
include/asm-x86/processor.h +6 -1
@@ -327,7 +327,12 @@/* 16*16 bytes for each XMM-reg = 256 bytes: */ u32 xmm_space[64 ]; -u32 padding[24 ]; +u32 padding[12 ]; + +union { +u32 padding1[12 ]; +u32 sw_reserved[12 ]; + }; } __attribute__((aligned(16)));
PATCH 8/9 x86, xsave: save/restore the extended state context in sigframe
In reply to Suresh SiddhaOn cpu's supporting xsave/xrstor, fpstate pointer in the sigcontext, will include the extended state information along with fpstate information. Presence of extended state information is indicated by the presence
of FP_XSTATE_MAGIC1 at fpstate.sw_reserved.magic1 and FP_XSTATE_MAGIC2 at fpstate + (fpstate.sw_reserved.extended_size - FP_XSTATE_MAGIC2_SIZE).
Extended feature bit mask that is saved in the memory layout is represented by the fpstate.sw_reserved.xstate_bv
For RT signal frames, UC_FP_XSTATE in the uc_flags also indicate the presence of extended state information in the sigcontext's fpstate pointer.
---
arch/x86/kernel/xsave.c +162 -10
@@ -6,12 +6,68 @@#include <linux/bootmem.h> #include <linux/compat.h> #include <asm/i387.h> +#ifdef CONFIG_IA32_EMULATION +#include <asm/sigcontext32.h> +#endif /* * Supported feature mask by the CPU and the kernel. */ unsigned int pcntxt_hmask, pcntxt_lmask; +struct _fpx_sw_bytes fx_sw_reserved; +#ifdef CONFIG_IA32_EMULATION +struct _fpx_sw_bytes fx_sw_reserved_ia32; +#endif + +/* +* Check for the presence of extended state information in the +* user fpstate pointer in the sigcontext. +*/ +int check_for_xstate (struct i387_fxsave_struct __user *buf, +void __user *fpstate, +struct _fpx_sw_bytes *fx_sw_user) +{ +int min_xstate_size =sizeof (struct i387_fxsave_struct ) + +sizeof (struct xsave_hdr_struct ); +unsigned int magic2; +int err; + + err =__copy_from_user (fx_sw_user, &buf->sw_reserved[0 ], +sizeof (struct _fpx_sw_bytes )); + +if (err) +return err; + +/* +* First Magic check failed. +*/ +if (fx_sw_user->magic1 !=FP_XSTATE_MAGIC1 ) +return -1 ; + +/* +* Check for error scenarios. +*/ +if (fx_sw_user->xstate_size < min_xstate_size || + fx_sw_user->xstate_size > xstate_size || + fx_sw_user->xstate_size > fx_sw_user->extended_size) +return -1 ; + + err =__get_user (magic2, (__u32 *) (((void *)fpstate) + + fx_sw_user->extended_size - +FP_XSTATE_MAGIC2_SIZE )); +/* +* Check for the presence of second magic word at the end of memory +* layout. This detects the case where the user just copied the legacy +* fpstate layout with out copying the extended state information +* in the memory layout. +*/ +if (err || magic2 !=FP_XSTATE_MAGIC2 ) +return -1 ; + +return 0 ; +} +#ifdef CONFIG_X86_64 /* * Signal frame handlers.
@@ -28,15 +84,18 @@BUILD_BUG_ON (sizeof (struct user_i387_struct ) !=sizeof (tsk->thread.xstate->fxsave)); -if ((unsigned long )buf %16 ) +if ((unsigned long )buf %64 )printk ("save_i387_xstate: bad fpstate %p\n" , buf);if (!used_math ())return 0 ;clear_used_math ();/* trigger finit */ if (task_thread_info (tsk)->status &TS_USEDFPU ) { - err =save_i387_checking ((struct i387_fxsave_struct __user *) - buf); +if (task_thread_info (tsk)->status &TS_XSAVE ) + err =xsave_user (buf); +else + err =fxsave_user (buf); +if (err)return err;task_thread_info (tsk)->status &= ~TS_USEDFPU ;
@@ -46,23 +105,77 @@ xstate_size))return -1 ; } + +if (task_thread_info (tsk)->status &TS_XSAVE ) { +struct _fpstate __user *fx = buf; + + err =__copy_to_user (&fx->sw_reserved, &fx_sw_reserved, +sizeof (struct _fpx_sw_bytes )); + + err |=__put_user (FP_XSTATE_MAGIC2 , + (__u32 __user *) (buf + sig_xstate_size + -FP_XSTATE_MAGIC2_SIZE )); + } +return 1 ; }/* +* Restore the extended state if present. Otherwise, restore the FP/SSE +* state. +*/ +int restore_user_xstate (void __user *buf) +{ +struct _fpx_sw_bytes fx_sw_user; +unsigned int lmask, hmask; +int err; + +if (((unsigned long )buf %64 ) || +check_for_xstate (buf, buf, &fx_sw_user)) + goto fx_only; + + lmask = fx_sw_user.xstate_bv; + hmask = fx_sw_user.xstate_bv >>32 ; + +/* +* restore the state passed by the user. +*/ + err =xrestore_user (buf, lmask, hmask); +if (err) +return err; + +/* +* init the state skipped by the user. +*/ + lmask = pcntxt_lmask & ~lmask; + hmask = pcntxt_hmask & ~hmask; + +xrstor_state (init_xstate_buf, lmask, hmask); + +return 0 ; + +fx_only: +/* +* couldn't find the extended state information in the +* memory layout. Restore just the FP/SSE and init all +* the other extended state. +*/ +xrstor_state (init_xstate_buf, pcntxt_lmask & ~XSTATE_FPSSE , + pcntxt_hmask); +return fxrstor_checking ((__force struct i387_fxsave_struct *)buf); +} + +/* * This restores directly out of user space. Exceptions are handled. */ int restore_i387_xstate (void __user *buf) {struct task_struct *tsk = current; -int err; +int err =0 ;if (!buf) { -if (used_math ()) { -clear_fpu (tsk); -clear_used_math (); - } - +if (used_math ()) + goto clear;return 0 ; }else if (!access_ok (VERIFY_READ , buf, sig_xstate_size))
@@ -78,12 +191,17 @@clts ();task_thread_info (current)->status |=TS_USEDFPU ; } - err =fxrstor_checking ((__force struct i387_fxsave_struct *)buf); +if (task_thread_info (tsk)->status &TS_XSAVE ) + err =restore_user_xstate (buf); +else + err =fxrstor_checking ((__force struct i387_fxsave_struct *) + buf);if (unlikely (err)) {/* * Encountered an error while doing the restore from the * user buffer, clear the fpu state. */ +clear:clear_fpu (tsk);clear_used_math (); }
@@ -92,6 +210,38 @@#endif /* +* Prepare the SW reserved portion of the fxsave memory layout, indicating +* the presence of the extended state information in the memory layout +* pointed by the fpstate pointer in the sigcontext. +* This will be saved when ever the FP and extended state context is +* saved on the user stack during the signal handler delivery to the user. +*/ +void prepare_fx_sw_frame (void ) +{ +int size_extended = (xstate_size -sizeof (struct i387_fxsave_struct )) + +FP_XSTATE_MAGIC2_SIZE ; + + sig_xstate_size =sizeof (struct _fpstate ) + size_extended; + +#ifdef CONFIG_IA32_EMULATION + sig_xstate_ia32_size =sizeof (struct _fpstate_ia32 ) + size_extended; +#endif + +memset (&fx_sw_reserved,0 ,sizeof (fx_sw_reserved)); + + fx_sw_reserved.magic1 =FP_XSTATE_MAGIC1 ; + fx_sw_reserved.extended_size = sig_xstate_size; + fx_sw_reserved.xstate_bv = pcntxt_lmask | + (((u64) (pcntxt_hmask)) <<32 ); + fx_sw_reserved.xstate_size = xstate_size; +#ifdef CONFIG_IA32_EMULATION +memcpy (&fx_sw_reserved_ia32, &fx_sw_reserved, +sizeof (struct _fpx_sw_bytes )); + fx_sw_reserved_ia32.extended_size = sig_xstate_ia32_size; +#endif +} + +/* * Represents init state for the supported extended state. */ struct xsave_struct *init_xstate_buf;
@@ -162,6 +312,8 @@ xstate_size = ebx; +prepare_fx_sw_frame (); +setup_xstate_init (); printk(KERN_INFO "xsave/xrstor: enabled xstate_bv %Lx, cntxt size %x\n",
arch/x86/kernel/i387.c +76 -6
128 lines not on this page · raw message
arch/x86/kernel/signal_64.c +5 -2
@@ -195,7 +195,7 @@ sp = current->sas_ss_sp + current->sas_ss_size; } -return (void __user *)round_down (sp - size,16 ); +return (void __user *)round_down (sp - size,64 ); } static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
@@ -229,7 +229,10 @@ }/* Create the ucontext. */ - err |=__put_user (0 , &frame->uc.uc_flags); +if (cpu_has_xsave) + err |=__put_user (UC_FP_XSTATE , &frame->uc.uc_flags); +else + err |=__put_user (0 , &frame->uc.uc_flags); err |=__put_user (0 , &frame->uc.uc_link); err |=__put_user (me->sas_ss_sp, &frame->uc.uc_stack.ss_sp); err |= __put_user(sas_ss_flags(regs->sp),
include/asm-x86/i387.h +3 -1
@@ -32,8 +32,10 @@extern user_regset_get_fn fpregs_get, xfpregs_get, fpregs_soft_get;extern user_regset_set_fn fpregs_set, xfpregs_set, fpregs_soft_set; +extern struct _fpx_sw_bytes fx_sw_reserved;#ifdef CONFIG_IA32_EMULATION extern unsigned int sig_xstate_ia32_size; +extern struct _fpx_sw_bytes fx_sw_reserved_ia32;struct _fpstate_ia32 ;struct _xstate_ia32 ;extern int save_i387_xstate_ia32 (void __user *buf);
@@ -105,7 +107,7 @@ X86_FEATURE_FXSAVE_LEAK); } -static inline int save_i387_checking (struct i387_fxsave_struct __user *fx) +static inline int fxsave_user (struct i387_fxsave_struct __user *fx) {int err;
include/asm-x86/xsave.h +4 -1
@@ -29,6 +29,9 @@extern void xsave_cntxt_init (void );extern void xsave_init (void );extern int init_fpu (struct task_struct *child); +extern int check_for_xstate (struct i387_fxsave_struct __user *buf, +void __user *fpstate, +struct _fpx_sw_bytes *sw);static inline int xrstor_checking (struct xsave_struct *fx) {
@@ -48,7 +51,7 @@return err; } -static inline int xsave_check (struct xsave_struct __user *buf) +static inline int xsave_user (struct xsave_struct __user *buf) {int err; __asm__ __volatile__("1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
include/asm-x86/ucontext.h +6 -0
@@ -1,6 +1,12 @@ #ifndef ASM_X86__UCONTEXT_H #define ASM_X86__UCONTEXT_H +#define UC_FP_XSTATE 0x1 /* indicates the presence of extended state + * information in the memory layout pointed + * by the fpstate pointer in the ucontext's + * sigcontext struct (uc_mcontext). + */ + struct ucontext { unsigned long uc_flags; struct ucontext *uc_link;
arch/x86/ia32/ia32_signal.c +4 -1
@@ -544,7 +544,10 @@ goto give_sigsegv;/* Create the ucontext. */ - err |=__put_user (0 , &frame->uc.uc_flags); +if (cpu_has_xsave) + err |=__put_user (UC_FP_XSTATE , &frame->uc.uc_flags); +else + err |=__put_user (0 , &frame->uc.uc_flags); err |=__put_user (0 , &frame->uc.uc_link); err |=__put_user (current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); err |= __put_user(sas_ss_flags(regs->sp),
arch/x86/kernel/signal_32.c +4 -1
@@ -443,7 +443,10 @@ goto give_sigsegv;/* Create the ucontext. */ - err |=__put_user (0 , &frame->uc.uc_flags); +if (cpu_has_xsave) + err |=__put_user (UC_FP_XSTATE , &frame->uc.uc_flags); +else + err |=__put_user (0 , &frame->uc.uc_flags); err |=__put_user (0 , &frame->uc.uc_link); err |=__put_user (current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); err |= __put_user(sas_ss_flags(regs->sp),
PATCH 9/9 x86, xsave: update xsave header bits during ptrace fpregs set
In reply to Suresh SiddhaFP/SSE bits may be zero in the xsave header(representing the init state). Update these bits during the ptrace fpregs set operation, to indicate the non-init state.
---
arch/x86/kernel/i387.c +13 -0
@@ -214,6 +214,13 @@*/ target->thread.xstate->fxsave.mxcsr &= mxcsr_feature_mask; +/* +* update the header bits in the xsave header, indicating the +* presence of FP and SSE state. +*/ +if (cpu_has_xsave) + target->thread.xstate->xsave.xsave_hdr.xstate_bv |=XSTATE_FPSSE ; +return ret; }
@@ -414,6 +421,12 @@if (!ret)convert_to_fxsr (target, &env); +/* +* update the header bit in the xsave header, indicating the +* presence of FP. +*/ +if (cpu_has_xsave) + target->thread.xstate->xsave.xsave_hdr.xstate_bv |=XSTATE_FP ;return ret; }
Quoted 24 lines · Suresh Siddha
This patchset adds the support for xsave/xrstor infrastructure for x86. xsave/xrstor manages the existing and future processor extended states in x86 architecutre.
More info on xsave/xrstor can be found in the Intel SDM's located at
http://www.intel.com/products/processor/manuals/index.htmThe layout of the xsave/xrstor area extends from the 512-byte FXSAVE/FXRSTOR layout. xsave/xrstor area layout consists of:
- fxsave/fxrstor area (512 bytes)
- xsave header area (64 bytes)
- set of save areas, each corresponding to a processor extended stateThe number of save areas, the offset and the size of each save area is enumerated by CPUID leaf function
0xd.This patch includes the basic xsave/xrstor infrastructure(supporting FP/SSE), which includes:
- context switch support, extending traditional lazy restore mechanism
- signal handling support, extending(using the software reserved bytes 464..511 in the current 512byte layout of fxsave frame) the memory layout pointed out by the fpstate pointer in the sigcontext
Quoted 3 lines
More details in the patches to follow.
Signed-off-by Suresh Siddha <[email protected]>
Applied as tip:x86/xsave.
I should warn I had to do quite a bit of manual fixup in order to disentangle it from other changes in -tip, so please test it out; I compile-tested it but for obvious reasons can't do more than that at the moment.
-hpa
Quoted 6 lines · H. Peter Anvin
Applied as tip:x86/xsave.
I should warn I had to do quite a bit of manual fixup in order to disentangle it from other changes in -tip, so please test it out; I compile-tested it but for obvious reasons can't do more than that at the moment.
hpa, these patches just apply fine to tip/master. Can you please arrange the tip/x86/xsave tree accordingly? or do I need to do something else to smooth this process?
thanks,
suresh
H. Peter Anvin
reviewerQuoted 11 lines · Suresh Siddha
Quoted 6 lines · H. Peter Anvin
Applied as tip:x86/xsave.
I should warn I had to do quite a bit of manual fixup in order to disentangle it from other changes in -tip, so please test it out; I compile-tested it but for obvious reasons can't do more than that at the moment.
hpa, these patches just apply fine to tip/master. Can you please arrange the tip/x86/xsave tree accordingly? or do I need to do something else to smooth this process?
This is awkward, since that means this is "derived topic". Most of the changes are orthogonal and relatively trivial to fix up at merge time, so I would prefer to keep them separate.
-hpa
Quoted 7 lines · H. Peter Anvin
Quoted 3 lines
hpa, these patches just apply fine to tip/master. Can you please arrange the tip/x86/xsave tree accordingly? or do I need to do something else to smooth this process?
This is awkward, since that means this is "derived topic". Most of the changes are orthogonal and relatively trivial to fix up at merge time, so I would prefer to keep them separate.
Well, in this case the conflicts seem to be quite heavy, so i'd suggest to use the method we have used for x86/x2apic and for xen-64bit:
Merge the affected topics into tip/x86/core. Then merge x86/core into x86/xsave, and put the xsave patches ontop of that base.
This way x86/xsave is a 'derived' topic and optional until it's proven, but one that is still mergable once all the dependent topics go upstream. We'd only have to rebase it in the (unlikely) event of there being some major problem with any of the topics merged into x86/core.
ok?
Ingo
H. Peter Anvin
reviewerQuoted 5 lines · Ingo Molnar
Quoted 2 lines · H. Peter Anvin
Quoted 1 line
hpa, these patches just apply fine to tip/master. Can you please arrange the tip/x86/xsave tree accordingly? or do I need to do something else to smooth this process?
This is awkward, since that means this is "derived topic". Most of the changes are orthogonal and relatively trivial to fix up at merge time, so I would prefer to keep them separate.
Quoted 7 lines
Well, in this case the conflicts seem to be quite heavy, so i'd suggest to use the method we have used for x86/x2apic and for xen-64bit:
Merge the affected topics into tip/x86/core. Then merge x86/core into x86/xsave, and put the xsave patches ontop of that base.
This way x86/xsave is a 'derived' topic and optional until it's proven, but one that is still mergable once all the dependent topics go upstream. We'd only have to rebase it in the (unlikely) event of there being some major problem with any of the topics merged into x86/core.
ok?
It somewhat concerns me, because one of the conflicts is generated by collision with x2apic. The rest of them I don't think are too problematic.
Most of the conflicts are of the type "orthogonal transformations to the same chunk of code", which doesn't make them less annoying.
-hpa
Quoted 21 lines · H. Peter Anvin
Quoted 20 lines · Ingo Molnar
Quoted 6 lines · H. Peter Anvin
Quoted 3 lines
hpa, these patches just apply fine to tip/master. Can you please arrange the tip/x86/xsave tree accordingly? or do I need to do something else to smooth this process?
This is awkward, since that means this is "derived topic". Most of the changes are orthogonal and relatively trivial to fix up at merge time, so I would prefer to keep them separate.
Well, in this case the conflicts seem to be quite heavy, so i'd suggest to use the method we have used for x86/x2apic and for xen-64bit:
Merge the affected topics into tip/x86/core. Then merge x86/core into x86/xsave, and put the xsave patches ontop of that base.
This way x86/xsave is a 'derived' topic and optional until it's proven, but one that is still mergable once all the dependent topics go upstream. We'd only have to rebase it in the (unlikely) event of there being some major problem with any of the topics merged into x86/core.
Quoted 4 lines
Quoted 1 line
ok?
It somewhat concerns me, because one of the conflicts is generated by collision with x2apic. The rest of them I don't think are too problematic.
hpa, confilicts with x2apic branch are very small and related to cpuid bits.
commit 04df16d2465cbb59b84c9c57ad865dbbeebadad8
Author: Suresh Siddha <[email protected]> Date: Tue Jul 29 10:29:18 2008 -0700
x86, xsave: xsave cpuid feature bits
Add xsave CPU feature bits.
and
commit 32e1d0a0651004f5fe47f85a2a5c725ad579a90c
Author: Suresh Siddha <[email protected]> Date: Thu Jul 10 11:16:50 2008 -0700
x64, x2apic/intr-remap: cpuid bits for x2apic feature
cpuid feature for x2apic.
Both of these patches are straight forward, simple and can be moved to x86/core(?) now, if that helps.
thanks,
suresh
H. Peter Anvin
reviewerQuoted 19 lines · Suresh Siddha
Quoted 2 lines
It somewhat concerns me, because one of the conflicts is generated by collision with x2apic. The rest of them I don't think are too problematic.
hpa, confilicts with x2apic branch are very small and related to cpuid bits.
commit
04df16d2465cbb59b84c9c57ad865dbbeebadad8Author: Suresh Siddha <[email protected]> Date: Tue Jul 29 10:29:18 2008 -0700x86, xsave: xsave cpuid feature bits
Add xsave CPU feature bits.
and
commit
32e1d0a0651004f5fe47f85a2a5c725ad579a90cAuthor: Suresh Siddha <[email protected]> Date: Thu Jul 10 11:16:50 2008 -0700
Quoted 6 lines
x64, x2apic/intr-remap: cpuid bits for x2apic feature
cpuid feature for x2apic.
Both of these patches are straight forward, simple and can be moved to x86/core(?) now, if that helps.
This is true. Cherry-picking those to the x86/core branch is probably the easiest, even if that means they're duplicated in the x2apic branch (I presume we don't want to rebase x2apic).
-hpa
Quoted 4 lines · Ingo Molnar
Well, in this case the conflicts seem to be quite heavy, so i'd suggest to use the method we have used for x86/x2apic and for xen-64bit:
Quoted 8 lines
Merge the affected topics into tip/x86/core. Then merge x86/core into x86/xsave, and put the xsave patches ontop of that base.
This way x86/xsave is a 'derived' topic and optional until it's proven, but one that is still mergable once all the dependent topics go upstream. We'd only have to rebase it in the (unlikely) event of there being some major problem with any of the topics merged into x86/core.
I've restructured tip/x86/xsave to be like this, and it can now be merged into tip/master without conficts.
I briefly merged it into tip/master to test it, but after about 10 randconfig iterations it ran into a spontaneous reboot crash. There's nothing in the log, the box (an Athlon64 X2) just reboots spontaneously. Removing the x86/xsave changes makes the system boot up fine.
I've pushed out the tree i tested into the tip/tmp.x86/xsave.broken branch. The bad config is:
http://redhat.com/~mingo/misc/config-Wed_Jul_30_20_09_12_CEST_2008.bad
Two crashlogs are here:
http://redhat.com/~mingo/misc/crash-Wed_Jul_30_20_09_12_CEST_2008.log
the serial log just stops at a certain point. It's not at a specific point, but the crash happened both times i tried to boot it.
Ingo
Quoted 3 lines · Ingo Molnar
I've restructured tip/x86/xsave to be like this, and it can now be merged into tip/master without conficts.
thanks.
Quoted 4 lines
I briefly merged it into tip/master to test it, but after about 10 randconfig iterations it ran into a spontaneous reboot crash. There's nothing in the log, the box (an Athlon64 X2) just reboots spontaneously. Removing the x86/xsave changes makes the system boot up fine.
I am also seeing this reboot issue and am hitting this both on tip/master aswell as the tip/tmp.x86/xsave.broken
It seems to be timing related. Will look further.
thanks,
suresh
Quoted 9 lines · Ingo Molnar
I briefly merged it into tip/master to test it, but after about 10 randconfig iterations it ran into a spontaneous reboot crash. There's nothing in the log, the box (an Athlon64 X2) just reboots spontaneously. Removing the x86/xsave changes makes the system boot up fine.
I've pushed out the tree i tested into the tip/tmp.x86/xsave.broken branch. The bad config is:
http://redhat.com/~mingo/misc/config-Wed_Jul_30_20_09_12_CEST_2008.bad
Ingo, 2.6.25, 2.6.26 also reboots randomly with this config on my dual-socket system.
Quoted 6 lines · Suresh Siddha
Quoted 5 lines · Ingo Molnar
I briefly merged it into tip/master to test it, but after about 10 randconfig iterations it ran into a spontaneous reboot crash. There's nothing in the log, the box (an Athlon64 X2) just reboots spontaneously. Removing the x86/xsave changes makes the system boot up fine.
Quoted 7 lines
Quoted 4 lines
I've pushed out the tree i tested into the tip/tmp.x86/xsave.broken branch. The bad config is:
http://redhat.com/~mingo/misc/config-Wed_Jul_30_20_09_12_CEST_2008.bad
Ingo, 2.6.25, 2.6.26 also reboots randomly with this config on my dual-socket system.
hmmm ....
a few guesses: perhaps I2C related (the randconfig turned on I2C bits)? Do you have any way (hw test-kit) to figure out where the reboot comes from - is it a triple fault caused by the kernel? Or some hardware event?
Ingo
Quoted 9 lines · Ingo Molnar
Quoted 2 lines
Ingo, 2.6.25, 2.6.26 also reboots randomly with this config on my dual-socket system.
hmmm ....
a few guesses: perhaps I2C related (the randconfig turned on I2C bits)? Do you have any way (hw test-kit) to figure out where the reboot comes from - is it a triple fault caused by the kernel? Or some hardware event?
Doh! I knew something was wrong with your randconfig :)
#
# Watchdog Device Drivers
#
....
CONFIG_PC87413_WDT=yCONFIG_60XX_WDT=y
# CONFIG_SBC8360_WDT is not setCONFIG_CPU5_WDT=yCONFIG_SMSC37B787_WDT=yCONFIG_W83627HF_WDT=yCONFIG_W83697HF_WDT=yCONFIG_W83877F_WDT=yCONFIG_W83977F_WDT=yCONFIG_MACHZ_WDT=yCONFIG_SBC_EPX_C3_WATCHDOG=y
Kernel was enabling watchdog, with out the userspace having the heartbeat daemon....
randconfig is really not a good way to test! I can't even ssh to the box with this config (something else is missing in the config!)
Anyhow, with watchdog removed, it works just fine. (both xsave and non-xsave kernels)
thanks,
suresh
Quoted 2 lines
Kernel was enabling watchdog, with out the userspace having the heartbeat daemon....
Watchdog are normally only armed when someone opens the device first.
-Andi
Quoted 5 lines · Andi Kleen
Quoted 2 lines
Kernel was enabling watchdog, with out the userspace having the heartbeat daemon....
Watchdog are normally only armed when someone opens the device first.
But thats not what I see with for ex with, w83627hf_wdt.c
Its done at the module_init time. (while I thought it should be really done when some user level app opens the device, probably its poorly written to take care if the kernel panics before starting userland. but kernel can even die before the watchdog driver load aswell ;-)
Quoted 7 lines · Suresh Siddha
Quoted 5 lines · Andi Kleen
Quoted 2 lines
Kernel was enabling watchdog, with out the userspace having the heartbeat daemon....
Watchdog are normally only armed when someone opens the device first.
Quoted 6 lines
But thats not what I see with for ex with,
w83627hf_wdt.cIts done at the
module_inittime. (while I thought it should be really done when some user level app opens the device, probably its poorly written to take care if the kernel panics before starting userland. but kernel can even die before the watchdog driver load aswell ;-)
Ok that watchdog driver is just broken then. Putting the watchdog maintainer into cc.
-Andi
Quoted 1 line
Quoted 7 lines · Suresh Siddha
Quoted 5 lines · Andi Kleen
Quoted 2 lines
Kernel was enabling watchdog, with out the userspace having the heartbeat daemon....
Watchdog are normally only armed when someone opens the device first.
Quoted 6 lines
But thats not what I see with for ex with,
w83627hf_wdt.cIts done at the
module_inittime. (while I thought it should be really done when some user level app opens the device, probably its poorly written to take care if the kernel panics before starting userland. but kernel can even die before the watchdog driver load aswell ;-)
Yeah, that's a _really_ broken watchdog timer driver. There's no way that it's correct to start the watchdog at init time, at least when compiled in.
It also looks to me like it's not even probing for the hardware - it's just assuming it's there. That's scary. Am I missing something?
It really shouldn't be activated until it's opened. And it really shouldn't just write to ports randomly without checking that they make sense...
Linus
Quoted 12 lines · Linus Torvalds
Quoted 7 lines
But thats not what I see with for ex with,
w83627hf_wdt.cIts done at the
module_inittime. (while I thought it should be really done when some user level app opens the device, probably its poorly written to take care if the kernel panics before starting userland. but kernel can even die before the watchdog driver load aswell ;-)Yeah, that's a _really_ broken watchdog timer driver. There's no way that it's correct to start the watchdog at init time, at least when compiled in.
Quoted 6 lines
It also looks to me like it's not even probing for the hardware - it's just assuming it's there. That's scary. Am I missing something?
It really shouldn't be activated until it's opened. And it really shouldn't just write to ports randomly without checking that they make sense...
there are a handful of old ISA-ish drivers that can crash randconfig kernels in various ways. [indefinite lockups, crashes, stomped-over hardware, non-working keyboard, etc.]
I mapped most of them out via many months of trial-and-error - but it would still be nice to have some separate config option to disable the known ones. CONFIG_ALLOW_NON_GENERIC or something like that - which i would unset in the randconfig runs.
( They are not CONFIG_BROKEN per se, because often it's hardware that
cannot be probed in any reliable way - the driver just assumes it's there. )
Ingo
Quoted 7 lines · Ingo Molnar
there are a handful of old ISA-ish drivers that can crash randconfig kernels in various ways. [indefinite lockups, crashes, stomped-over hardware, non-working keyboard, etc.]
I mapped most of them out via many months of trial-and-error - but it would still be nice to have some separate config option to disable the known ones.
CONFIG_ALLOW_NON_GENERICor something like that - which i would unset in the randconfig runs.( They are not
CONFIG_BROKENper se, because often it's hardware that
cannot be probed in any reliable way - the driver just assumes it's there. )
If you have a list, I might be able to do something about some of them.
Rene.
Quoted 11 lines · Rene Herman
Quoted 9 lines · Ingo Molnar
there are a handful of old ISA-ish drivers that can crash randconfig kernels in various ways. [indefinite lockups, crashes, stomped-over hardware, non-working keyboard, etc.]
I mapped most of them out via many months of trial-and-error - but it would still be nice to have some separate config option to disable the known ones.
CONFIG_ALLOW_NON_GENERICor something like that - which i would unset in the randconfig runs.
Quoted 6 lines
Quoted 3 lines
( They are not
CONFIG_BROKENper se, because often it's hardware that
cannot be probed in any reliable way - the driver just assumes it's
there. )If you have a list, I might be able to do something about some of them.
find attached below a newer version of the original list i published half a year ago:
http://people.redhat.com/mingo/auto-qa-patches/Kconfig-qa.patch
these are just pragmatic local hacks to get things going. (There are more per machine quirks as well.)
i have not used a BROKEN annotation because CONFIG_BROKEN is
impractical: it just kills code altogether, indiscriminately. There's no way for users to enable CONFIG_BROKEN in the upstream kernel - nothing selects it and it's not an interactive option either.
So by all means if we mark a driver or a kernel feature as CONFIG_BROKEN, it's killed altogether for all practical purposes.
What we'd need is some more gradual approach: for example a way to mark "drivers that are not expected to boot on a whitebox PC", without removing them altogether via a CONFIG_BROKEN dependency - often it's hardware that cannot be probed safely.
Ingo
------------------>
security/smack/Kconfig +3 -0
@@ -1,6 +1,9 @@ config SECURITY_SMACK bool "Simplified Mandatory Access Control Kernel Support" depends on NETLABEL && SECURITY_NETWORK + # breaks networking (TCP connections) + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT default n help This selects the Simplified Mandatory Access Control Kernel.
drivers/block/Kconfig +5 -0
@@ -71,6 +71,11 @@ config BLK_DEV_XD config PARIDE tristate "Parallel port IDE device support" depends on PARPORT_PC + + # the probe can hang during bootup on non-PARIDE boxes + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT if PARIDE = y + ---help--- There are many external CD-ROM and disk devices that connect through your computer's parallel port. Most of them are actually IDE devices
drivers/i2c/busses/Kconfig +5 -0
@@ -610,6 +610,11 @@ config I2C_ELEKTOR config I2C_PCA_ISA tristate "PCA9564 on an ISA bus" depends on ISA + + # takes away IRQ10 on venus and thus breaks e1000 + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT + select I2C_ALGOPCA default n help
drivers/ide/Kconfig +5 -0
@@ -9,6 +9,11 @@ config HAVE_IDE menuconfig IDE tristate "ATA/ATAPI/MFM/RLL support" depends on HAVE_IDE + + # my test box expects /dev/sda, not /dev/hda + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT if IDE = y + depends on BLOCK ---help--- If you say Y here, your kernel will be able to manage low cost mass
drivers/isdn/icn/Kconfig +5 -0
@@ -4,6 +4,11 @@ config ISDN_DRV_ICN tristate "ICN 2B and 4B support" depends on ISA + + # crashed on venus, see config-Sun_May_25_11_00_41_CEST_2008.bad + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT + help This enables support for two kinds of ISDN-cards made by a German company called ICN. 2B is the standard version for a single ISDN
drivers/media/video/Kconfig +3 -0
@@ -481,6 +481,9 @@ config VIDEO_SAA6588 config VIDEO_PMS tristate "Mediavision Pro Movie Studio Video For Linux" depends on ISA && VIDEO_V4L1 + # hung on bootup on mars, see config-Wed_Jun__4_14_33_56_CEST_2008.bad + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT help Say Y if you have such a thing.
drivers/mtd/Kconfig +5 -0
@@ -1,6 +1,11 @@ menuconfig MTD tristate "Memory Technology Device (MTD) support" depends on HAS_IOMEM + + # dangerous to enable - sometimes hangs on probe + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT if MTD = y + help Memory Technology Devices are flash, RAM and similar chips, often used for solid state file systems on embedded devices. This option
drivers/net/appletalk/Kconfig +5 -0
@@ -52,6 +52,11 @@ config LTPC config COPS tristate "COPS LocalTalk PC support" depends on DEV_APPLETALK && (ISA || EISA) + # + # Can hang + # + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT if COPS = y help This allows you to use COPS AppleTalk cards to connect to LocalTalk networks. You also need version 1.3.3 or later of the netatalk
drivers/scsi/Kconfig +5 -0
@@ -1520,6 +1520,11 @@ config SCSI_NSP32 config SCSI_DEBUG tristate "SCSI debugging host simulator" depends on SCSI + + # this creates a fake /dev/sda which confuses the bzImage bootup + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT if SCSI_DEBUG = y + help This is a host adapter simulator that can simulate multiple hosts each with multiple dummy SCSI devices (disks). It defaults to one
drivers/video/Kconfig +35 -0
@@ -236,6 +236,11 @@ comment "Frame buffer hardware drivers" config FB_CIRRUS tristate "Cirrus Logic support" + + # can hang on a box without this hardware + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT if FB_CIRRUS = y + depends on FB && (ZORRO || PCI) select FB_CFB_FILLRECT select FB_CFB_COPYAREA
@@ -546,6 +551,11 @@ config FB_CT65550 config FB_ASILIANT bool "Asiliant (Chips) 69000 display support" + + # can hang on a box without this hardware + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT if FB_ASILIANT = y + depends on (FB = y) && PCI select FB_CFB_FILLRECT select FB_CFB_COPYAREA
@@ -564,6 +574,11 @@ config FB_IMSTT config FB_VGA16 tristate "VGA 16-color graphics support" + + # can hang on a box without this hardware + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT if FB_VGA16 = y + depends on FB && (X86 || PPC) select FB_CFB_FILLRECT select FB_CFB_COPYAREA
@@ -674,6 +689,11 @@ config FB_UVESA config FB_VESA bool "VESA VGA graphics support" + + # can hang on a box without this hardware + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT if FB_VESA = y + depends on (FB = y) && X86 select FB_CFB_FILLRECT select FB_CFB_COPYAREA
@@ -1299,6 +1319,11 @@ config FB_MATROX_MULTIHEAD config FB_RADEON tristate "ATI Radeon display support" + + # can hang on a box without this hardware + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT if FB_RADEON = y + depends on FB && PCI select FB_BACKLIGHT if FB_RADEON_BACKLIGHT select FB_MODE_HELPERS
@@ -1581,6 +1606,11 @@ config FB_VT8623 config FB_CYBLA tristate "Cyberblade/i1 support" + + # can hang on a box without this hardware + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT if FB_CYBLA = y + depends on FB && PCI && X86_32 && !64BIT select FB_CFB_IMAGEBLIT select VIDEO_SELECT
@@ -2006,6 +2036,11 @@ config FB_SH7760 config FB_VIRTUAL tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)" + + # can hang on a box without this hardware + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT if FB_VIRTUAL = y + depends on FB select FB_SYS_FILLRECT select FB_SYS_COPYAREA
drivers/video/console/Kconfig +9 -0
@@ -61,6 +61,11 @@ config VIDEO_SELECT config MDA_CONSOLE depends on !M68K && !PARISC && ISA + + # can hang on a box without this hardware + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT if MDA_CONSOLE = y + tristate "MDA text console (dual-headed) (EXPERIMENTAL)" ---help--- Say Y here if you have an old MDA or monochrome Hercules graphics
@@ -113,6 +118,10 @@ config DUMMY_CONSOLE_ROWS config FRAMEBUFFER_CONSOLE tristate "Framebuffer Console support" + + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT if FRAMEBUFFER_CONSOLE = y + depends on FB select CRC32 help
drivers/watchdog/Kconfig +11 -0
@@ -324,6 +324,12 @@ config SC520_WDT config EUROTECH_WDT tristate "Eurotech CPU-1220/1410 Watchdog Timer" depends on X86 + + # this ISA driver puts itself on IRQ10 - if IRQ10 happens to + # trigger then that will cause a watchdog-initiated reboot + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT if EUROTECH_WDT = y + help Enable support for the watchdog timer on the Eurotech CPU-1220 and CPU-1410 cards. These are PC/104 SBCs. Spec sheets and product
@@ -830,6 +836,11 @@ config MIXCOMWD config WDT tristate "WDT Watchdog timer" depends on ISA + + # this ISA driver sits on IRQ11 by default - blocking forcedeth + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT if WDT = y + ---help--- If you have a WDT500P or WDT501P watchdog board, say Y here, otherwise N. It is not possible to probe for this board, which means
fs/Kconfig +5 -0
@@ -1636,6 +1636,11 @@ config NFS_V4 config ROOT_NFS bool "Root file system on NFS" depends on NFS_FS=y && IP_PNP + + # hangs a non-root-NFS box during bootup + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT + help If you want your system to mount its root file system via NFS, choose Y here. This is common practice for managing systems
security/Kconfig +5 -0
@@ -85,6 +85,11 @@ config SECURITY_FILE_CAPABILITIES config SECURITY_ROOTPLUG bool "Root Plug Support" depends on USB=y && SECURITY + + # fails with hard-to-debug "could not find init" boot failure + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT + help This is a sample LSM module that should only be used as such. It prevents any programs running with egid == 0 if a specific
security/selinux/Kconfig +5 -0
@@ -100,6 +100,11 @@ config SECURITY_SELINUX_CHECKREQPROT_VAL config SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT bool "NSA SELinux enable new secmark network controls by default" depends on SECURITY_SELINUX + + # old system booted up with this cannot ssh out + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT + default n help This option determines whether the new secmark-based network
Quoted 11 lines · Ingo Molnar
find attached below a newer version of the original list i published half a year ago:
http://people.redhat.com/mingo/auto-qa-patches/Kconfig-qa.patch
these are just pragmatic local hacks to get things going. (There are more per machine quirks as well.)
i have not used a BROKEN annotation because
CONFIG_BROKENis impractical: it just kills code altogether, indiscriminately. There's no way for users to enableCONFIG_BROKENin the upstream kernel - nothing selects it and it's not an interactive option either.So by all means if we mark a driver or a kernel feature as
CONFIG_BROKEN, it's killed altogether for all practical purposes.What we'd need is some more gradual approach: for example a way to mark "drivers that are not expected to boot on a whitebox PC", without removing them altogether via a
CONFIG_BROKENdependency - often it's hardware that cannot be probed safely.
For real ISA at the least, the best fix I feel is just not go grabbing resources without anything (ie, ISAPnP) or anyone (ie, the user) telling us that's where the hardware's at.
For example, for the first real ISA driver in the list:
drivers/i2c/busses/Kconfig config I2C_ELEKTOR · line 617
Quoted 13 lines
Index: linux/drivers/i2c/busses/Kconfig
===================================================================drivers/i2c/busses/Kconfig +5
-0@@ -610,6 +610,11 @@ config I2C_ELEKTOR config I2C_PCA_ISA tristate "PCA9564 on an ISA bus" depends on ISA + + # takes away IRQ10 on venus and thus breaks e1000 + depends on BROKEN_BOOT_ALLOWED + select BROKEN_BOOT +
The attached would be my preffered approach to this.
(to avoid an IRQ 0 discussion -- the middle hunk is unrelated, just makes it consistent with the rest of the file)
(and this uses the isa_bus match() method as intended; the idea of the isa_bus is to make it look at least somewhat like a sane bus such as PCI which includes only failing a load if there's no way a later bind could conceivably succeed. somewhat debatable merit sometimes, but such is the device model, and it's actually fairly nice once you get used to it for quickly switching drivers for a single piece of hardware)
A user of this hardware is a one-time
$ echo options i2c-pca-isa base=0x330 irq=10 >> /etc/modprobe.conf
away from the old behaviour. Given the hackish nature of all this kind of hardware these days its users tend to not mind. In fact, what with getting old hardware to play nice with modern systems, I myself at least very much welcome having to be explicit about these things.
(and just saw the CC list on this thing while adding Wolfram. ouch. will be dropping all from any followups...)
Rene.
Quoted 1 line
From
58f25a608b827426bf5c110795dd7e917e9cc568Mon Sep 17 00:00:00 2001
From: Rene Herman <[email protected]>
Date: Fri, 1 Aug 2008 15:35:31 +0200
Subject: [PATCH] i2c: don't autograb i2c-pca-isa
Grabbing resources without anything telling us we should can break randconfig builds by keeping them busy. Insist that when hardware is not capable of telling us, the user does.
--- drivers/i2c/busses/i2c-pca-isa.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-pca-isa.c +17 -3
@@ -36,8 +36,8 @@#define DRIVER "i2c-pca-isa"#define IO_SIZE 4 -static unsigned long base =0x330 ; -static int irq =10 ; +static unsigned long base; +static int irq =-1 ;/* Data sheet recommends 59kHz for 100kHz operation due to variation * in the actual clock rate */
@@ -107,6 +107,19 @@ static struct i2c_adapter pca_isa_ops = { .timeout = 100, }; +static int __devinit pca_isa_match (struct device *dev,unsigned int id) +{ +int match = base !=0 ; + +if (match) { +if (irq ==-1 ) +dev_warn (dev,"using poling mode (specify irq)\n" ); + }else +dev_err (dev,"please specify base\n" ); + +return match; +} +static int __devinit pca_isa_probe (struct device *dev,unsigned int id) {init_waitqueue_head (&pca_wait);
@@ -153,7 +166,7 @@ static int __devexit pca_isa_remove(struct device *dev, unsigned int id) {i2c_del_adapter (&pca_isa_ops); -if (irq >0 ) { +if (irq >-1 ) {disable_irq (irq);free_irq (irq, &pca_isa_ops); }
@@ -163,6 +176,7 @@ static int __devexit pca_isa_remove(struct device *dev, unsigned int id) }static struct isa_driver pca_isa_driver = { + .match = pca_isa_match, .probe = pca_isa_probe, .remove =__devexit_p (pca_isa_remove), .driver = {
Signature · 1 line
1.5.5
Quoted 18 lines · Rene Herman
Quoted 16 lines · Ingo Molnar
find attached below a newer version of the original list i published half a year ago:
http://people.redhat.com/mingo/auto-qa-patches/Kconfig-qa.patch
these are just pragmatic local hacks to get things going. (There are more per machine quirks as well.)
i have not used a BROKEN annotation because
CONFIG_BROKENis
impractical: it just kills code altogether, indiscriminately. There's no way for users to enableCONFIG_BROKENin the upstream kernel - nothing selects it and it's not an interactive option either.So by all means if we mark a driver or a kernel feature as
CONFIG_BROKEN, it's killed altogether for all practical purposes.
Quoted 7 lines
Quoted 4 lines
What we'd need is some more gradual approach: for example a way to mark "drivers that are not expected to boot on a whitebox PC", without removing them altogether via a
CONFIG_BROKENdependency - often it's hardware that cannot be probed safely.For real ISA at the least, the best fix I feel is just not go grabbing resources without anything (ie, ISAPnP) or anyone (ie, the user) telling
Really old systems don't have isapnp. Neither have smbus devices.
Quoted 1 line
us that's where the hardware's at.
That would mean the users on these systems would need to add tons of obscure command line options.
-Andi
Quoted 8 lines · Andi Kleen
Quoted 1 line
For real ISA at the least, the best fix I feel is just not go grabbing resources without anything (ie, ISAPnP) or anyone (ie, the user) telling
Really old systems don't have isapnp. Neither have smbus devices.
Quoted 1 line
us that's where the hardware's at.
That would mean the users on these systems would need to add tons of obscure command line options.
No, it means users on those 1% of systems that are using drivers that break the other 99% would have to for those one or two drivers that do.
And as said, we don't care.
Rene.
Quoted 9 lines · Rene Herman
Quoted 7 lines · Andi Kleen
Quoted 2 lines
For real ISA at the least, the best fix I feel is just not go grabbing resources without anything (ie, ISAPnP) or anyone (ie, the user) telling
Really old systems don't have isapnp. Neither have smbus devices.
Quoted 1 line
us that's where the hardware's at.
Quoted 7 lines
Quoted 2 lines
That would mean the users on these systems would need to add tons of obscure command line options.
No, it means users on those 1% of systems that are using drivers that break the other 99% would have to for those one or two drivers that do.
And as said, we don't care.
Not sure who "we" is in this context.
Especially dropping easy support for all smbus devices (which are often like
this) would seem quite wrong to me. And for real ISA devices there tends to
be a surprisingly large user base left for those.
The config option Ingo proposed is a good idea though.
Or they can just use 64bit which never defines CONFIG_ISA, but of course still has to support all the similar smbus drivers.
-Andi
Quoted 6 lines · Andi Kleen
Quoted 5 lines · Rene Herman
Quoted 3 lines · Andi Kleen
Quoted 1 line
For real ISA at the least, the best fix I feel is just not go grabbing resources without anything (ie, ISAPnP) or anyone (ie, the user) telling
Really old systems don't have isapnp. Neither have smbus devices.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
us that's where the hardware's at.
That would mean the users on these systems would need to add tons of obscure command line options.
No, it means users on those 1% of systems that are using drivers that break the other 99% would have to for those one or two drivers that do.
And as said, we don't care.
Not sure who "we" is in this context.
We, the old crap hardware users the drivers for which break sensible systems by default.
Really, look at the patch I posted -- it's a patch to make passing in a base (and irq if you want one) to i2c-pca-isa needed. Right now, the thing just grabs those resources and breaks the boot on systems that don't have it as per Ingo's testing.
On plain technical grounds mucking with resources you don't own is bad (on those old systems, 0x330 might even be a NE2000 which gets confused really quickly) and even more importantly; let's take a wild guess and assume that that specific ISA driver has, oh let's say, less than 3 users in the world all of whom wouldn't care one bit about sticking in an options line in their modprobe.conf.
There is no reason drivers like that should be allowed to break all the _other_ systems instead of making those users do that. Not a single one.
Quoted 2 lines
Especially dropping easy support for all smbus devices (which are often like
this) would seem quite wrong to me. And for real ISA devices there tends to be a surprisingly large user base left for those.
Fortunately, smbus devices tend to not grab IRQs and go poking around the general I/O space willy-nilly (they go poking around the smbus I/O space willy-nilly). Note again, this specific case is a _bus_ driver for a bus on an ISA card.
Rene
Quoted 6 lines
But thats not what I see with for ex with,
w83627hf_wdt.cIts done at the
module_inittime. (while I thought it should be really done when some user level app opens the device, probably its poorly written to take care if the kernel panics before starting userland. but kernel can even die before the watchdog driver load aswell ;-)
Various watchdogs fail to conform in assorted differing ways. Wim did some patches to build a common watchdog library and I sent him a rework of it a while ago. Once that is adopted this should all get cleaned up. Right now Wim is a bit busy however.
Alan
Quoted 30 lines · Suresh Siddha
Quoted 9 lines · Ingo Molnar
Quoted 2 lines
Ingo, 2.6.25, 2.6.26 also reboots randomly with this config on my dual-socket system.
hmmm ....
a few guesses: perhaps I2C related (the randconfig turned on I2C bits)? Do you have any way (hw test-kit) to figure out where the reboot comes from - is it a triple fault caused by the kernel? Or some hardware event?
Doh! I knew something was wrong with your randconfig :)
#
# Watchdog Device Drivers
#
....
CONFIG_PC87413_WDT=yCONFIG_60XX_WDT=y
#CONFIG_SBC8360_WDTis not setCONFIG_CPU5_WDT=yCONFIG_SMSC37B787_WDT=yCONFIG_W83627HF_WDT=yCONFIG_W83697HF_WDT=yCONFIG_W83877F_WDT=yCONFIG_W83977F_WDT=yCONFIG_MACHZ_WDT=yCONFIG_SBC_EPX_C3_WATCHDOG=y
Quoted 2 lines
Kernel was enabling watchdog, with out the userspace having the heartbeat daemon....
I never had function hw watchdog support on this box - so i guess the 2.6.27-rc1 kernel started supporting it - cool.
This was unfortunate timing i guess - when i removed xsave i didnt get the reboot :-/
Quoted 2 lines
randconfig is really not a good way to test! I can't even ssh to the box with this config (something else is missing in the config!)
it is a randconfig tailored to my testboxes, it might not work out of box on yours :-)
randconfig is an excellent way of testing kernels, that testbox can run strings of hundreds (sometimes thousands) of random kernels without hitting any kernel bug. I had to resolve a large number of real kernel bugs (and a handful of glitches like this hardware watchdog thing) to get so far though.
Quoted 2 lines
Anyhow, with watchdog removed, it works just fine. (both xsave and non-xsave kernels)
Great, thanks. I've re-integrated tip/x86/xsave into x86/master and have pushed out the result.
Ingo
Quoted 5 lines · Ingo Molnar
Quoted 2 lines
Anyhow, with watchdog removed, it works just fine. (both xsave and non-xsave kernels)
Great, thanks. I've re-integrated tip/x86/xsave into x86/master and have pushed out the result.
FYI, small tip/x86/xsave build fixlet below - user-space exposed interfaces need to use __u64 not u64.
Ingo
-------------->
Quoted 1 line
From
26d809af6397ce5c37f5c44d89734d19cce1ad25Mon Sep 17 00:00:00 2001
From: Ingo Molnar <[email protected]>
Date: Wed, 13 Aug 2008 12:46:26 +0200
Subject: [PATCH] x86: fix xsave build error
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
fix this build failure with certain glibc versions:
In file included from /usr/include/bits/sigcontext.h:28,
from /usr/include/signal.h:333,
from Documentation/accounting/getdelays.c:24:/home/mingo/tip/usr/include/asm/sigcontext.h:191: error: expected specifier-qualifier-list before ‘u64’
--- include/asm-x86/sigcontext.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
include/asm-x86/sigcontext.h +3 -3
@@ -264,9 +264,9 @@ struct sigcontext {#endif /* !__i386__ */ struct _xsave_hdr { -u64 xstate_bv; -u64 reserved1[2 ]; -u64 reserved2[5 ]; +__u64 xstate_bv; +__u64 reserved1[2 ]; +__u64 reserved2[5 ]; };/*