Skip to content
Snippets Groups Projects
  • Ingo Molnar's avatar
    87b6559d
    x86/fpu: Improve xstate_fault() handling · 87b6559d
    Ingo Molnar authored
    
    There are two problems with xstate_fault handling:
    
     - The xstate_fault() macro takes an argument, but that's
       propagated into the assembly named label as well. This
       is technically correct currently but might result in
       failures if anytime a more complex argument is used.
       So use a separate '_err' name instead for the label.
    
     - All the xstate_fault() using functions have an error
       variable named 'err', which is an output variable to
       the asm() they are using. The problem is, it's not always
       set by the asm(), in which case the compiler might
       optimize out its initialization, so that the C variable
       'err' might become corrupted after the asm() - confusing
       anyone who tries to take advantage of this variable
       after the asm(). Mark it an input variable as well.
    
       This is a latent bug currently, but an upcoming debug
       patch will make use of 'err'.
    
    Cc: Andy Lutomirski <luto@amacapital.net>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Dave Hansen <dave.hansen@linux.intel.com>
    Cc: Fenghua Yu <fenghua.yu@intel.com>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Oleg Nesterov <oleg@redhat.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    87b6559d
    History
    x86/fpu: Improve xstate_fault() handling
    Ingo Molnar authored
    
    There are two problems with xstate_fault handling:
    
     - The xstate_fault() macro takes an argument, but that's
       propagated into the assembly named label as well. This
       is technically correct currently but might result in
       failures if anytime a more complex argument is used.
       So use a separate '_err' name instead for the label.
    
     - All the xstate_fault() using functions have an error
       variable named 'err', which is an output variable to
       the asm() they are using. The problem is, it's not always
       set by the asm(), in which case the compiler might
       optimize out its initialization, so that the C variable
       'err' might become corrupted after the asm() - confusing
       anyone who tries to take advantage of this variable
       after the asm(). Mark it an input variable as well.
    
       This is a latent bug currently, but an upcoming debug
       patch will make use of 'err'.
    
    Cc: Andy Lutomirski <luto@amacapital.net>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Dave Hansen <dave.hansen@linux.intel.com>
    Cc: Fenghua Yu <fenghua.yu@intel.com>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Oleg Nesterov <oleg@redhat.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>