git: fd748c7d5b7a - main - efirt: add a tunable to disable printing faults during EFIRT calls
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 02 Apr 2025 20:22:13 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=fd748c7d5b7aefbeda604403f203637b12ae89df
commit fd748c7d5b7aefbeda604403f203637b12ae89df
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-03-31 18:38:36 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-04-02 20:21:56 +0000
efirt: add a tunable to disable printing faults during EFIRT calls
PR: 285797
Reported and tested by: Bakul Shah <bakul@iitbombay.org>
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D49592
---
sys/amd64/amd64/trap.c | 13 +++++++++++--
sys/arm64/arm64/trap.c | 3 +++
sys/dev/efidev/efirt.c | 11 ++++++++++-
3 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index 8e9b115ef224..1041422b9f92 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -163,6 +163,9 @@ SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG_RWTUN,
&uprintf_signal, 0,
"Print debugging information on trap signal to ctty");
+u_long cnt_efirt_faults;
+int print_efirt_faults = 1;
+
/*
* Control L1D flush on return from NMI.
*
@@ -431,8 +434,14 @@ trap(struct trapframe *frame)
*/
if ((td->td_pflags & TDP_EFIRT) != 0 &&
curpcb->pcb_onfault != NULL && type != T_PAGEFLT) {
- trap_diag(frame, 0);
- printf("EFI RT fault %s\n", traptype_to_msg(type));
+ u_long cnt = atomic_fetchadd_long(&cnt_efirt_faults, 1);
+
+ if ((print_efirt_faults == 1 && cnt == 1) ||
+ print_efirt_faults == 2) {
+ trap_diag(frame, 0);
+ printf("EFI RT fault %s\n",
+ traptype_to_msg(type));
+ }
frame->tf_rip = (long)curpcb->pcb_onfault;
return;
}
diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c
index d612905b77c8..fdcc38cd9a31 100644
--- a/sys/arm64/arm64/trap.c
+++ b/sys/arm64/arm64/trap.c
@@ -85,6 +85,9 @@ static void print_registers(struct trapframe *frame);
int (*dtrace_invop_jump_addr)(struct trapframe *);
+u_long cnt_efirt_faults;
+int print_efirt_faults;
+
typedef void (abort_handler)(struct thread *, struct trapframe *, uint64_t,
uint64_t, int);
diff --git a/sys/dev/efidev/efirt.c b/sys/dev/efidev/efirt.c
index 5dff2258725d..9523ffc7f386 100644
--- a/sys/dev/efidev/efirt.c
+++ b/sys/dev/efidev/efirt.c
@@ -123,11 +123,20 @@ efi_status_to_errno(efi_status status)
}
static struct mtx efi_lock;
-static SYSCTL_NODE(_hw, OID_AUTO, efi, CTLFLAG_RWTUN | CTLFLAG_MPSAFE, NULL,
+SYSCTL_NODE(_hw, OID_AUTO, efi, CTLFLAG_RWTUN | CTLFLAG_MPSAFE, NULL,
"EFI");
static bool efi_poweroff = true;
SYSCTL_BOOL(_hw_efi, OID_AUTO, poweroff, CTLFLAG_RWTUN, &efi_poweroff, 0,
"If true, use EFI runtime services to power off in preference to ACPI");
+extern int print_efirt_faults;
+SYSCTL_INT(_hw_efi, OID_AUTO, print_faults, CTLFLAG_RWTUN,
+ &print_efirt_faults, 0,
+ "Print fault information upon trap from EFIRT calls: "
+ "0 - never, 1 - once, 2 - always");
+extern u_long cnt_efirt_faults;
+SYSCTL_ULONG(_hw_efi, OID_AUTO, total_faults, CTLFLAG_RD,
+ &cnt_efirt_faults, 0,
+ "Total number of faults that occurred during EFIRT calls");
static bool
efi_is_in_map(struct efi_md *map, int ndesc, int descsz, vm_offset_t addr)