git: a0b526b4d56a - stable/13 - arm64, riscv: handle RB_KDB

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Mon, 07 Feb 2022 14:43:01 UTC
The branch stable/13 has been updated by mhorne:

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

commit a0b526b4d56ac1d030e5bad25c7645c986ed6160
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-02-01 17:58:07 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-02-07 14:41:06 +0000

    arm64, riscv: handle RB_KDB
    
    This allows entering the debugger at the earliest possible time, if
    the '-d' argument is passed to the kernel.
    
    Reviewed by:    jhb
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D34120
    
    (cherry picked from commit 4e1bc961bb4467f074e48aa6e710ccd1aa7f2888)
---
 sys/arm64/arm64/machdep.c | 4 ++++
 sys/riscv/riscv/machdep.c | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index 9ade7dde99fa..c3d725800fde 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -847,6 +847,10 @@ initarm(struct arm64_bootparams *abp)
 
 	dbg_init();
 	kdb_init();
+#ifdef KDB
+	if ((boothowto & RB_KDB) != 0)
+		kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger");
+#endif
 	pan_enable();
 
 	kcsan_cpu_init(0);
diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c
index c6b219849e79..d63d11095a7c 100644
--- a/sys/riscv/riscv/machdep.c
+++ b/sys/riscv/riscv/machdep.c
@@ -587,6 +587,10 @@ initriscv(struct riscv_bootparams *rvbp)
 	mutex_init();
 	init_param2(physmem);
 	kdb_init();
+#ifdef KDB
+	if ((boothowto & RB_KDB) != 0)
+		kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger");
+#endif
 
 	env = kern_getenv("kernelname");
 	if (env != NULL)