Skip to content

Commit 1384022

Browse files
kristina-martsenkoctmarinas
authored andcommitted
arm64: mops: Handle MOPS exceptions from EL1
We will soon be using MOPS instructions in the kernel, so wire up the exception handler to handle exceptions from EL1 caused by the copy/set operation being stopped and resumed on a different type of CPU. Add a helper for advancing the single step state machine, similarly to what the EL0 exception handler does. Signed-off-by: Kristina Martsenko <kristina.martsenko@arm.com> Link: https://lore.kernel.org/r/20240930161051.3777828-3-kristina.martsenko@arm.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent c56c599 commit 1384022

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

arch/arm64/include/asm/debug-monitors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ void kernel_enable_single_step(struct pt_regs *regs);
105105
void kernel_disable_single_step(void);
106106
int kernel_active_single_step(void);
107107
void kernel_rewind_single_step(struct pt_regs *regs);
108+
void kernel_fastforward_single_step(struct pt_regs *regs);
108109

109110
#ifdef CONFIG_HAVE_HW_BREAKPOINT
110111
int reinstall_suspended_bps(struct pt_regs *regs);

arch/arm64/include/asm/exception.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ void do_el0_svc_compat(struct pt_regs *regs);
7373
void do_el0_fpac(struct pt_regs *regs, unsigned long esr);
7474
void do_el1_fpac(struct pt_regs *regs, unsigned long esr);
7575
void do_el0_mops(struct pt_regs *regs, unsigned long esr);
76+
void do_el1_mops(struct pt_regs *regs, unsigned long esr);
7677
void do_serror(struct pt_regs *regs, unsigned long esr);
7778
void do_signal(struct pt_regs *regs);
7879

arch/arm64/kernel/debug-monitors.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,11 @@ void kernel_rewind_single_step(struct pt_regs *regs)
441441
set_regs_spsr_ss(regs);
442442
}
443443

444+
void kernel_fastforward_single_step(struct pt_regs *regs)
445+
{
446+
clear_regs_spsr_ss(regs);
447+
}
448+
444449
/* ptrace API */
445450
void user_enable_single_step(struct task_struct *task)
446451
{

arch/arm64/kernel/entry-common.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,15 @@ static void noinstr el1_bti(struct pt_regs *regs, unsigned long esr)
463463
exit_to_kernel_mode(regs);
464464
}
465465

466+
static void noinstr el1_mops(struct pt_regs *regs, unsigned long esr)
467+
{
468+
enter_from_kernel_mode(regs);
469+
local_daif_inherit(regs);
470+
do_el1_mops(regs, esr);
471+
local_daif_mask();
472+
exit_to_kernel_mode(regs);
473+
}
474+
466475
static void noinstr el1_dbg(struct pt_regs *regs, unsigned long esr)
467476
{
468477
unsigned long far = read_sysreg(far_el1);
@@ -505,6 +514,9 @@ asmlinkage void noinstr el1h_64_sync_handler(struct pt_regs *regs)
505514
case ESR_ELx_EC_BTI:
506515
el1_bti(regs, esr);
507516
break;
517+
case ESR_ELx_EC_MOPS:
518+
el1_mops(regs, esr);
519+
break;
508520
case ESR_ELx_EC_BREAKPT_CUR:
509521
case ESR_ELx_EC_SOFTSTP_CUR:
510522
case ESR_ELx_EC_WATCHPT_CUR:

arch/arm64/kernel/traps.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,13 @@ void do_el0_mops(struct pt_regs *regs, unsigned long esr)
531531
user_fastforward_single_step(current);
532532
}
533533

534+
void do_el1_mops(struct pt_regs *regs, unsigned long esr)
535+
{
536+
arm64_mops_reset_regs(&regs->user_regs, esr);
537+
538+
kernel_fastforward_single_step(regs);
539+
}
540+
534541
#define __user_cache_maint(insn, address, res) \
535542
if (address >= TASK_SIZE_MAX) { \
536543
res = -EFAULT; \

0 commit comments

Comments
 (0)