• Kristina Martsenko's avatar
    arm64: hw_breakpoint: fix watchpoint matching for tagged pointers · 4eaef365
    Kristina Martsenko authored
    commit 7dcd9dd8 upstream.
    
    This backport has a few small differences from the upstream commit:
     - The address tag is removed in watchpoint_handler() instead of
       get_distance_from_watchpoint(), because 4.4 does not have commit
       fdfeff0f ("arm64: hw_breakpoint: Handle inexact watchpoint
       addresses").
     - A macro is backported (untagged_addr), as it is not present in 4.4.
    
    Original patch description:
    
    When we take a watchpoint exception, the address that triggered the
    watchpoint is found in FAR_EL1. We compare it to the address of each
    configured watchpoint to see which one was hit.
    
    The configured watchpoint addresses are untagged, while the address in
    FAR_EL1 will have an address tag if the data access was done using a
    tagged address. The tag needs to be removed to compare the address to
    the watchpoints.
    
    Currently we don't remove it, and as a result can report the wrong
    watchpoint as being hit (specifically, always either the highest TTBR0
    watchpoint or lowest TTBR1 watchpoint). This patch removes the tag.
    
    Fixes: d50240a5 ("arm64: mm: permit use of tagged pointers at EL0")
    Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
    Acked-by: default avatarWill Deacon <will.deacon@arm.com>
    Signed-off-by: default avatarKristina Martsenko <kristina.martsenko@arm.com>
    Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    4eaef365
hw_breakpoint.c 23.7 KB