aboutsummaryrefslogtreecommitdiff
path: root/sys/arm64/arm64
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2017-08-12 18:42:54 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2017-08-12 18:42:54 +0000
commit992029ba105f46bd43949987d402d406866c58b0 (patch)
treeb46baf486faefeb61b6861463dc76364b1b471ec /sys/arm64/arm64
parentc9ee3caf19f0e058f0b14d7afe421fddd7fe8fc7 (diff)
downloadsrc-992029ba105f46bd43949987d402d406866c58b0.tar.gz
src-992029ba105f46bd43949987d402d406866c58b0.zip
Reliably enable debug exceptions on all CPUs.
Previously, debug exceptions were only enabled on the boot CPU if DDB was enabled in the dbg_monitor_init() function. APs also called this function, but since mp_machdep.c doesn't include opt_ddb.h, the APs ended up calling an empty stub defined in <machine/debug_monitor.h> instead of the real function. Also, if DDB was not enabled in the kernel, the boot CPU would not enable debug exceptions. Fix this by adding a new dbg_init() function that always clears the OS lock to enable debug exceptions which the boot CPU and the APs call. This function also calls dbg_monitor_init() to enable hardware breakpoints from DDB on all CPUs if DDB is enabled. Eventually base support for hardware breakpoints/watchpoints will need to move out of the DDB-only debug_monitor.c for use by userland debuggers. Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D12001
Notes
Notes: svn path=/head/; revision=322437
Diffstat (limited to 'sys/arm64/arm64')
-rw-r--r--sys/arm64/arm64/debug_monitor.c5
-rw-r--r--sys/arm64/arm64/machdep.c15
-rw-r--r--sys/arm64/arm64/mp_machdep.c3
3 files changed, 16 insertions, 7 deletions
diff --git a/sys/arm64/arm64/debug_monitor.c b/sys/arm64/arm64/debug_monitor.c
index 4d458fc58060..4f0e29daadfb 100644
--- a/sys/arm64/arm64/debug_monitor.c
+++ b/sys/arm64/arm64/debug_monitor.c
@@ -453,15 +453,12 @@ dbg_monitor_init(void)
{
u_int i;
- /* Clear OS lock */
- WRITE_SPECIALREG(OSLAR_EL1, 0);
-
/* Find out many breakpoints and watchpoints we can use */
dbg_watchpoint_num = ((READ_SPECIALREG(ID_AA64DFR0_EL1) >> 20) & 0xf) + 1;
dbg_breakpoint_num = ((READ_SPECIALREG(ID_AA64DFR0_EL1) >> 12) & 0xf) + 1;
if (bootverbose && PCPU_GET(cpuid) == 0) {
- db_printf("%d watchpoints and %d breakpoints supported\n",
+ printf("%d watchpoints and %d breakpoints supported\n",
dbg_watchpoint_num, dbg_breakpoint_num);
}
diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index 300498f608f1..5e658d3a041b 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -1051,13 +1051,26 @@ initarm(struct arm64_bootparams *abp)
mutex_init();
init_param2(physmem);
- dbg_monitor_init();
+ dbg_init();
kdb_init();
pan_enable();
early_boot = 0;
}
+void
+dbg_init(void)
+{
+
+ /* Clear OS lock */
+ WRITE_SPECIALREG(OSLAR_EL1, 0);
+
+ /* This permits DDB to use debug registers for watchpoints. */
+ dbg_monitor_init();
+
+ /* TODO: Eventually will need to initialize debug registers here. */
+}
+
#ifdef DDB
#include <ddb/ddb.h>
diff --git a/sys/arm64/arm64/mp_machdep.c b/sys/arm64/arm64/mp_machdep.c
index c7e8a8df1e9d..ab1171c777d3 100644
--- a/sys/arm64/arm64/mp_machdep.c
+++ b/sys/arm64/arm64/mp_machdep.c
@@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_extern.h>
#include <vm/vm_kern.h>
-#include <machine/debug_monitor.h>
#include <machine/machdep.h>
#include <machine/intr.h>
#include <machine/smp.h>
@@ -272,7 +271,7 @@ init_secondary(uint64_t cpu)
vfp_init();
#endif
- dbg_monitor_init();
+ dbg_init();
pan_enable();
/* Enable interrupts */