git: 5f5b47e37416 - stable/14 - amd64 efi rt: handle #BP

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Thu, 28 Nov 2024 13:30:10 UTC
The branch stable/14 has been updated by kib:

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

commit 5f5b47e37416df46b52e0d43b94d9c2f37d15397
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-11-21 04:57:58 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-11-28 12:53:17 +0000

    amd64 efi rt: handle #BP
    
    PR:     282860
    
    (cherry picked from commit e6ec41fa86d88f80bd663e55455a6844619a9b24)
---
 sys/amd64/amd64/trap.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index f5ea035b3e3c..d7e365f6874e 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -600,6 +600,18 @@ trap(struct trapframe *frame)
 			 * FALLTHROUGH (TRCTRAP kernel mode, kernel address)
 			 */
 		case T_BPTFLT:
+			/*
+			 * Most likely, EFI RT hitting INT3.  This
+			 * check prevents kdb from handling
+			 * breakpoints set on the BIOS text, if such
+			 * option is ever needed.
+			 */
+			if ((td->td_pflags2 & TDP2_EFIRT) != 0 &&
+			    curpcb->pcb_onfault != NULL) {
+				frame->tf_rip = (long)curpcb->pcb_onfault;
+				return;
+			}
+
 			/*
 			 * If KDB is enabled, let it handle the debugger trap.
 			 * Otherwise, debugger traps "can't happen".