• D
    arm64: signal: Report signal frame size to userspace via auxv · 94b07c1f
    Dave Martin 提交于
    Stateful CPU architecture extensions may require the signal frame
    to grow to a size that exceeds the arch's MINSIGSTKSZ #define.
    However, changing this #define is an ABI break.
    
    To allow userspace the option of determining the signal frame size
    in a more forwards-compatible way, this patch adds a new auxv entry
    tagged with AT_MINSIGSTKSZ, which provides the maximum signal frame
    size that the process can observe during its lifetime.
    
    If AT_MINSIGSTKSZ is absent from the aux vector, the caller can
    assume that the MINSIGSTKSZ #define is sufficient.  This allows for
    a consistent interface with older kernels that do not provide
    AT_MINSIGSTKSZ.
    
    The idea is that libc could expose this via sysconf() or some
    similar mechanism.
    
    There is deliberately no AT_SIGSTKSZ.  The kernel knows nothing
    about userspace's own stack overheads and should not pretend to
    know.
    
    For arm64:
    
    The primary motivation for this interface is the Scalable Vector
    Extension, which can require at least 4KB or so of extra space
    in the signal frame for the largest hardware implementations.
    
    To determine the correct value, a "Christmas tree" mode (via the
    add_all argument) is added to setup_sigframe_layout(), to simulate
    addition of all possible records to the signal frame at maximum
    possible size.
    
    If this procedure goes wrong somehow, resulting in a stupidly large
    frame layout and hence failure of sigframe_alloc() to allocate a
    record to the frame, then this is indicative of a kernel bug.  In
    this case, we WARN() and no attempt is made to populate
    AT_MINSIGSTKSZ for userspace.
    
    For arm64 SVE:
    
    The SVE context block in the signal frame needs to be considered
    too when computing the maximum possible signal frame size.
    
    Because the size of this block depends on the vector length, this
    patch computes the size based not on the thread's current vector
    length but instead on the maximum possible vector length: this
    determines the maximum size of SVE context block that can be
    observed in any signal frame for the lifetime of the process.
    Signed-off-by: NDave Martin <Dave.Martin@arm.com>
    Acked-by: NWill Deacon <will.deacon@arm.com>
    Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Cc: Alex Bennée <alex.bennee@linaro.org>
    Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
    94b07c1f
processor.h 6.7 KB