git: c3d86d27c3aa - stable/14 - arm64: Always set the debug control and value regs

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Mon, 15 Jul 2024 12:38:03 UTC
The branch stable/14 has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=c3d86d27c3aa5308bc1d9d1a8a95da7efaf34773

commit c3d86d27c3aa5308bc1d9d1a8a95da7efaf34773
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2024-03-12 16:34:41 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-07-15 12:23:38 +0000

    arm64: Always set the debug control and value regs
    
    When listing watchpoints we read the raw registers. To ensure we print
    an accurate list always set the watchpoint and breakpoint registers.
    
    Sponsored by:   Arm Ltd
    
    Reviewed by:    jhb
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D44351
    
    (cherry picked from commit 2e2c983d5234cb5457548fc75608d93b2309b254)
---
 sys/arm64/arm64/debug_monitor.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/sys/arm64/arm64/debug_monitor.c b/sys/arm64/arm64/debug_monitor.c
index 380915d5163a..f3e4b504f15e 100644
--- a/sys/arm64/arm64/debug_monitor.c
+++ b/sys/arm64/arm64/debug_monitor.c
@@ -496,23 +496,24 @@ dbg_register_sync(struct debug_monitor_state *monitor)
 	if (monitor == NULL)
 		monitor = &kernel_monitor;
 
+	for (i = 0; i < dbg_breakpoint_num; i++) {
+		dbg_wb_write_reg(DBG_REG_BASE_BCR, i,
+		    monitor->dbg_bcr[i]);
+		dbg_wb_write_reg(DBG_REG_BASE_BVR, i,
+		    monitor->dbg_bvr[i]);
+	}
+
+	for (i = 0; i < dbg_watchpoint_num; i++) {
+		dbg_wb_write_reg(DBG_REG_BASE_WCR, i,
+		    monitor->dbg_wcr[i]);
+		dbg_wb_write_reg(DBG_REG_BASE_WVR, i,
+		    monitor->dbg_wvr[i]);
+	}
+
 	mdscr = READ_SPECIALREG(mdscr_el1);
 	if ((monitor->dbg_flags & DBGMON_ENABLED) == 0) {
 		mdscr &= ~(MDSCR_MDE | MDSCR_KDE);
 	} else {
-		for (i = 0; i < dbg_breakpoint_num; i++) {
-			dbg_wb_write_reg(DBG_REG_BASE_BCR, i,
-			    monitor->dbg_bcr[i]);
-			dbg_wb_write_reg(DBG_REG_BASE_BVR, i,
-			    monitor->dbg_bvr[i]);
-		}
-
-		for (i = 0; i < dbg_watchpoint_num; i++) {
-			dbg_wb_write_reg(DBG_REG_BASE_WCR, i,
-			    monitor->dbg_wcr[i]);
-			dbg_wb_write_reg(DBG_REG_BASE_WVR, i,
-			    monitor->dbg_wvr[i]);
-		}
 		mdscr |= MDSCR_MDE;
 		if ((monitor->dbg_flags & DBGMON_KERNEL) == DBGMON_KERNEL)
 			mdscr |= MDSCR_KDE;