Skip to content

Commit 541ec87

Browse files
mrutland-armctmarinas
authored andcommitted
arm64: kill ESR_LNX_EXEC
Currently we treat ESR_EL1 bit 24 as software-defined for distinguishing instruction aborts from data aborts, but this bit is architecturally RES0 for instruction aborts, and could be allocated for an arbitrary purpose in future. Additionally, we hard-code the value in entry.S without the mnemonic, making the code difficult to understand. Instead, remove ESR_LNX_EXEC, and distinguish aborts based on the esr, which we already pass to the sole use of ESR_LNX_EXEC. A new helper, is_el0_instruction_abort() is added to make the logic clear. Any instruction aborts taken from EL1 will already have been handled by bad_mode, so we need not handle that case in the helper. For consistency, the existing permission_fault helper is renamed to is_permission_fault, and the return type is changed to bool. There should be no functional changes as the return value was a boolean expression, and the result is only used in another boolean expression. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Cc: Dave P Martin <dave.martin@arm.com> Cc: Huang Shijie <shijie.huang@arm.com> Cc: James Morse <james.morse@arm.com> Cc: Marc Zyngier <marc.zyngier@arm.com> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 561454e commit 541ec87

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

arch/arm64/kernel/entry.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ el0_ia:
532532
enable_dbg_and_irq
533533
ct_user_exit
534534
mov x0, x26
535-
orr x1, x25, #1 << 24 // use reserved ISS bit for instruction aborts
535+
mov x1, x25
536536
mov x2, sp
537537
bl do_mem_abort
538538
b ret_to_user

arch/arm64/mm/fault.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re
202202
#define VM_FAULT_BADMAP 0x010000
203203
#define VM_FAULT_BADACCESS 0x020000
204204

205-
#define ESR_LNX_EXEC (1 << 24)
206-
207205
static int __do_page_fault(struct mm_struct *mm, unsigned long addr,
208206
unsigned int mm_flags, unsigned long vm_flags,
209207
struct task_struct *tsk)
@@ -242,14 +240,19 @@ static int __do_page_fault(struct mm_struct *mm, unsigned long addr,
242240
return fault;
243241
}
244242

245-
static inline int permission_fault(unsigned int esr)
243+
static inline bool is_permission_fault(unsigned int esr)
246244
{
247245
unsigned int ec = ESR_ELx_EC(esr);
248246
unsigned int fsc_type = esr & ESR_ELx_FSC_TYPE;
249247

250248
return (ec == ESR_ELx_EC_DABT_CUR && fsc_type == ESR_ELx_FSC_PERM);
251249
}
252250

251+
static bool is_el0_instruction_abort(unsigned int esr)
252+
{
253+
return ESR_ELx_EC(esr) == ESR_ELx_EC_IABT_LOW;
254+
}
255+
253256
static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
254257
struct pt_regs *regs)
255258
{
@@ -272,14 +275,14 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
272275
if (user_mode(regs))
273276
mm_flags |= FAULT_FLAG_USER;
274277

275-
if (esr & ESR_LNX_EXEC) {
278+
if (is_el0_instruction_abort(esr)) {
276279
vm_flags = VM_EXEC;
277280
} else if ((esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM)) {
278281
vm_flags = VM_WRITE;
279282
mm_flags |= FAULT_FLAG_WRITE;
280283
}
281284

282-
if (permission_fault(esr) && (addr < USER_DS)) {
285+
if (is_permission_fault(esr) && (addr < USER_DS)) {
283286
if (get_fs() == KERNEL_DS)
284287
die("Accessing user space memory with fs=KERNEL_DS", regs, esr);
285288

0 commit comments

Comments
 (0)