• Jon Medhurst's avatar
    arm: kprobes: Align stack to 8-bytes in test code · 974310d0
    Jon Medhurst authored
    kprobes test cases need to have a stack that is aligned to an 8-byte
    boundary because they call other functions (and the ARM ABI mandates
    that alignment) and because test cases include 64-bit accesses to the
    stack. Unfortunately, GCC doesn't ensure this alignment for inline
    assembler and for the code in question seems to always misalign it by
    pushing just the LR register onto the stack. We therefore need to
    explicitly perform stack alignment at the start of each test case.
    
    Without this fix, some test cases will generate alignment faults on
    systems where alignment is enforced. Even if the kernel is configured to
    handle these faults in software, triggering them is ugly. It also
    exposes limitations in the fault handling code which doesn't cope with
    writes to the stack. E.g. when handling this instruction
    
       strd r6, [sp, #-64]!
    
    the fault handling code will write to a stack location below the SP
    value at the point the fault occurred, which coincides with where the
    exception handler has pushed the saved register context. This results in
    corruption of those registers.
    Signed-off-by: default avatarJon Medhurst <tixy@linaro.org>
    974310d0
test-core.c 42.4 KB