Disable userland debug communication access while there.
ok patrick@
-/* $OpenBSD: cpu.c,v 1.20 2018/08/03 16:45:17 kettenis Exp $ */
+/* $OpenBSD: cpu.c,v 1.21 2018/08/03 18:36:01 kettenis Exp $ */
/*
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
cpu_node = ci->ci_node;
cpu_cpuspeed = cpu_clockspeed;
}
+
+ /* Initialize debug registers. */
+ WRITE_SPECIALREG(mdscr_el1, DBG_MDSCR_TDCC);
+ WRITE_SPECIALREG(oslar_el1, 0);
#ifdef MULTIPROCESSOR
}
#endif
tcr |= TCR_A1;
WRITE_SPECIALREG(tcr_el1, tcr);
+ /* Initialize debug registers. */
+ WRITE_SPECIALREG(mdscr_el1, DBG_MDSCR_TDCC);
+ WRITE_SPECIALREG(oslar_el1, 0);
+
s = splhigh();
arm_intr_cpu_enable();
cpu_startclock();
-/* $OpenBSD: exception.S,v 1.7 2018/07/19 17:38:12 drahn Exp $ */
+/* $OpenBSD: exception.S,v 1.8 2018/08/03 18:36:01 kettenis Exp $ */
/*-
* Copyright (c) 2014 Andrew Turner
* All rights reserved.
__FBSDID("$FreeBSD: head/sys/arm64/arm64/exception.S 297028 2016-03-18 16:18:29Z andrew $");
#endif
+#include <machine/armreg.h>
+
#include "assym.h"
.text
2:
.endm
+.macro disable_ss
+ mrs x2, mdscr_el1
+ and x2, x2, #(~DBG_MDSCR_SS)
+ msr mdscr_el1, x2
+.endm
+
+.macro allow_ss
+ mrs x2, tpidr_el1
+ ldr x2, [x2, #(CI_CURPCB)]
+ ldr w2, [x2, #(PCB_FLAGS)]
+ tbz w2, #1, 1f /* PCB_SINGLESTEP bit */
+ mrs x2, mdscr_el1
+ orr x2, x2, #(DBG_MDSCR_SS)
+ msr mdscr_el1, x2
+1:
+.endm
+
handle_el1h_sync:
save_registers 1
mov x0, sp
.type handle_el0_sync,@function
handle_el0_sync:
save_registers 0
+ disable_ss
mov x0, sp
bl do_el0_sync
do_ast
bl _C_LABEL(vfp_enable)
+ allow_ss
restore_registers 0
return
.type handle_el0_irq,@function
handle_el0_irq:
save_registers 0
+ disable_ss
bl _C_LABEL(vfp_save)
mov x0, sp
bl arm_cpu_intr
do_ast
bl _C_LABEL(vfp_enable)
+ allow_ss
restore_registers 0
return
.type handle_el0_error,@function
handle_el0_error:
save_registers 0
+ disable_ss
mov x0, sp
bl do_el0_error
brk 0xf23
-/* $OpenBSD: process_machdep.c,v 1.4 2018/07/04 17:52:29 drahn Exp $ */
+/* $OpenBSD: process_machdep.c,v 1.5 2018/08/03 18:36:01 kettenis Exp $ */
/*
* Copyright (c) 2014 Patrick Wildt <patrick@blueri.se>
*
tf->tf_lr = regs->r_lr;
tf->tf_sp = regs->r_sp;
tf->tf_elr = regs->r_pc;
- tf->tf_spsr = (0xff0f0000 & regs->r_spsr) | (tf->tf_spsr & 0x0000ffff);
+ tf->tf_spsr = (0xff0f0000 & regs->r_spsr) | (tf->tf_spsr & 0x0020ffff);
p->p_addr->u_pcb.pcb_tcb = (void *)regs->r_tpidr;
return(0);
}
int
process_sstep(struct proc *p, int sstep)
{
+ struct trapframe *tf = p->p_addr->u_pcb.pcb_tf;
+
if (sstep) {
p->p_addr->u_pcb.pcb_flags |= PCB_SINGLESTEP;
+ tf->tf_spsr |= PSR_SS;
} else {
p->p_addr->u_pcb.pcb_flags &= ~(PCB_SINGLESTEP);
+ tf->tf_spsr &= ~PSR_SS;
}
return 0;
}
-/* $OpenBSD: trap.c,v 1.19 2018/04/12 17:13:43 deraadt Exp $ */
+/* $OpenBSD: trap.c,v 1.20 2018/08/03 18:36:01 kettenis Exp $ */
/*-
* Copyright (c) 2014 Andrew Turner
* All rights reserved.
trapsignal(p, SIGTRAP, 0, TRAP_BRKPT, sv);
KERNEL_UNLOCK();
break;
+ case EXCP_SOFTSTP_EL0:
+ vfp_save();
+ sv.sival_ptr = (void *)frame->tf_elr;
+ KERNEL_LOCK();
+ trapsignal(p, SIGTRAP, 0, TRAP_TRACE, sv);
+ KERNEL_UNLOCK();
+ break;
default:
// panic("Unknown userland exception %x esr_el1 %lx\n", exception,
// esr);
-/* $OpenBSD: armreg.h,v 1.5 2017/08/06 20:05:24 kettenis Exp $ */
+/* $OpenBSD: armreg.h,v 1.6 2018/08/03 18:36:01 kettenis Exp $ */
/*-
* Copyright (c) 2013, 2014 Andrew Turner
* Copyright (c) 2015 The FreeBSD Foundation
#define TCR_T0SZ(x) ((x) << TCR_T0SZ_SHIFT)
#define TCR_TxSZ(x) (TCR_T1SZ(x) | TCR_T0SZ(x))
-/* Saved Program Status Register */
-#define DBG_SPSR_SS (0x1 << 21)
-
/* Monitor Debug System Control Register */
#define DBG_MDSCR_SS (0x1 << 0)
+#define DBG_MDSCR_TDCC (0x1 << 12)
#define DBG_MDSCR_KDE (0x1 << 13)
#define DBG_MDSCR_MDE (0x1 << 15)