• Nick Desaulniers's avatar
    drm/amdgpu: fix stack alignment ABI mismatch for Clang · c868868f
    Nick Desaulniers authored
    The x86 kernel is compiled with an 8B stack alignment via
    `-mpreferred-stack-boundary=3` for GCC since 3.6-rc1 via
    commit d9b0cde9 ("x86-64, gcc: Use -mpreferred-stack-boundary=3 if supported")
    or `-mstack-alignment=8` for Clang. Parts of the AMDGPU driver are
    compiled with 16B stack alignment.
    
    Generally, the stack alignment is part of the ABI. Linking together two
    different translation units with differing stack alignment is dangerous,
    particularly when the translation unit with the smaller stack alignment
    makes calls into the translation unit with the larger stack alignment.
    While 8B aligned stacks are sometimes also 16B aligned, they are not
    always.
    
    Multiple users have reported General Protection Faults (GPF) when using
    the AMDGPU driver compiled with Clang. Clang is placing objects in stack
    slots assuming the stack is 16B aligned, and selecting instructions that
    require 16B aligned memory operands.
    
    At runtime, syscall handlers with 8B aligned stack call into code that
    assumes 16B stack alignment.  When the stack is a multiple of 8B but not
    16B, these instructions result in a GPF.
    
    Remove the code that added compatibility between the differing compiler
    flags, as it will result in runtime GPFs when built with Clang. Cleanups
    for GCC will be sent in later patches in the series.
    
    Link: https://github.com/ClangBuiltLinux/linux/issues/735Debugged-by: default avatarYuxuan Shui <yshuiv7@gmail.com>
    Reported-by: default avatarShirish S <shirish.s@amd.com>
    Reported-by: default avatarYuxuan Shui <yshuiv7@gmail.com>
    Suggested-by: default avatarAndrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: default avatarNick Desaulniers <ndesaulniers@google.com>
    Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
    c868868f
Makefile 1.83 KB