Commit ae91d1e4 authored by Kristina Martsenko's avatar Kristina Martsenko Committed by Greg Kroah-Hartman

arm64: entry: improve data abort handling of tagged pointers

commit 276e9327 upstream.

When handling a data abort from EL0, we currently zero the top byte of
the faulting address, as we assume the address is a TTBR0 address, which
may contain a non-zero address tag. However, the address may be a TTBR1
address, in which case we should not zero the top byte. This patch fixes
that. The effect is that the full TTBR1 address is passed to the task's
signal handler (or printed out in the kernel log).

When handling a data abort from EL1, we leave the faulting address
intact, as we assume it's either a TTBR1 address or a TTBR0 address with
tag 0x00. This is true as far as I'm aware, we don't seem to access a
tagged TTBR0 address anywhere in the kernel. Regardless, it's easy to
forget about address tags, and code added in the future may not always
remember to remove tags from addresses before accessing them. So add tag
handling to the EL1 data abort handler as well. This also makes it
consistent with the EL0 data abort handler.

Fixes: d50240a5 ("arm64: mm: permit use of tagged pointers at EL0")
Reviewed-by: default avatarDave Martin <Dave.Martin@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>
parent d8f0905a
#ifndef __ASM_ASM_UACCESS_H
#define __ASM_ASM_UACCESS_H
/*
* Remove the address tag from a virtual address, if present.
*/
.macro clear_address_tag, dst, addr
tst \addr, #(1 << 55)
bic \dst, \addr, #(0xff << 56)
csel \dst, \dst, \addr, eq
.endm
#endif
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <asm/errno.h> #include <asm/errno.h>
#include <asm/esr.h> #include <asm/esr.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
#include <asm/asm-uaccess.h>
#include <asm/unistd.h> #include <asm/unistd.h>
/* /*
...@@ -307,12 +308,13 @@ el1_da: ...@@ -307,12 +308,13 @@ el1_da:
/* /*
* Data abort handling * Data abort handling
*/ */
mrs x0, far_el1 mrs x3, far_el1
enable_dbg enable_dbg
// re-enable interrupts if they were enabled in the aborted context // re-enable interrupts if they were enabled in the aborted context
tbnz x23, #7, 1f // PSR_I_BIT tbnz x23, #7, 1f // PSR_I_BIT
enable_irq enable_irq
1: 1:
clear_address_tag x0, x3
mov x2, sp // struct pt_regs mov x2, sp // struct pt_regs
bl do_mem_abort bl do_mem_abort
...@@ -472,7 +474,7 @@ el0_da: ...@@ -472,7 +474,7 @@ el0_da:
// enable interrupts before calling the main handler // enable interrupts before calling the main handler
enable_dbg_and_irq enable_dbg_and_irq
ct_user_exit ct_user_exit
bic x0, x26, #(0xff << 56) clear_address_tag x0, x26
mov x1, x25 mov x1, x25
mov x2, sp mov x2, sp
adr lr, ret_to_user adr lr, ret_to_user
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment