• Ard Biesheuvel's avatar
    ARM: memcpy: use frame pointer as unwind anchor · ba999a04
    Ard Biesheuvel authored
    The memcpy template is a bit unusual in the way it manages the stack
    pointer: depending on the execution path through the function, the SP
    assumes different values as different subsets of the register file are
    preserved and restored again. This is problematic when it comes to EHABI
    unwind info, as it is not instruction accurate, and does not allow
    tracking the SP value as it changes.
    
    Commit 279f487e ("ARM: 8225/1: Add unwinding support for memory
    copy functions") addressed this by carving up the function in different
    chunks as far as the unwinder is concerned, and keeping a set of unwind
    directives for each of them, each corresponding with the state of the
    stack pointer during execution of the chunk in question. This not only
    duplicates unwind info unnecessarily, but it also complicates unwinding
    the stack upon overflow.
    
    Instead, let's do what the compiler does when the SP is updated halfway
    through a function, which is to use a frame pointer and emit the
    appropriate unwind directives to communicate this to the unwinder.
    
    Note that Thumb-2 uses R7 for this, while ARM uses R11 aka FP. So let's
    avoid touching R7 in the body of the template, so that Thumb-2 can use
    it as the frame pointer. R11 was not modified in the first place.
    Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
    Tested-by: default avatarKeith Packard <keithpac@amazon.com>
    Tested-by: default avatarMarc Zyngier <maz@kernel.org>
    Tested-by: Vladimir Murzin <vladimir.murzin@arm.com> # ARMv7M
    ba999a04
copy_template.S 6.23 KB