From nobody Wed Dec 25 01:37:26 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YHvWq28Skz5h05X; Wed, 25 Dec 2024 01:37:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YHvWq0HJsz4qd9; Wed, 25 Dec 2024 01:37:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735090647; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=S9bZqNZxK9vSAA6bX4LJ9fk2npm01THQVMazpYiZaL8=; b=C3PQ+uBU3cHh+GJRCBv8IDBq3C+C3BD6OiXHRxjqyXIJZ4jRzeK+7qWm8XPI7lT3r7Shaf uCNNAnhj76dbK0e81j55gli0LssBI+SaSLtQPrE/7GcJevKEZdxQAYspNziG6IYiDfVSZ6 viJcD3DcSlQNP82LrGnI8nfNOHxDrosCWC61FBkqMKKSHqd0COUGUxjZVqtIALe0t1rf8E EN9/hBoRb+OMrMwS7QWB0SJg9Qno3QqX4iv82ck+ypKXCC0C6ilQtT1mBbbsxzIHdaq90V ndpotroCSHJO294K5kPTDI6WQZpkoJ9GhlcIGJoNetT+Aqh8A7t3RKqJ74ZLiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735090647; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=S9bZqNZxK9vSAA6bX4LJ9fk2npm01THQVMazpYiZaL8=; b=API7LUCuQylhpJUUBbGNdrBobULzNWKR7jYStNXQ3sj5xGsSzCzCKzPhAFi5fhEd+c+sPG XQGD9ZXHXRKmN2m92HhsJe2JOmKFWPkVZn40Tpj6+hZZbPBdRtu4NQfJUwoGlY//9lLaQS FlGaxgKjxLMT4HYM3BPQUOIlvSyjPYPTkIVGuKC3PzpRk9cRO5ZmUZyXCRpMiQn3vM1I59 wfqKPIiite9gfRc8xBT3LOuB6zAvpK11Eta0RklqP8HALxv32AIuVcZDhouItDObLl7g5C cZNoMbyQVBM0ektF4vfxJOE2yWYTmCL1VmtXB5sjGRYjzupmhz1AkbuJYNJajg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1735090647; a=rsa-sha256; cv=none; b=AIW61vIGThFyrfmD3vAiO4fhJqXYASS4UIz1JM0+gZZC5ih6om3OV2GTlDOIxaqce3mqok zE3yhH3rZGiVtrBEAMyYMb2/fO+L+umyYABD+zGpQFxqSsVtNtlyE7aUoGVEKJv+8MwnMq Xs1+LY8F61/6Tz2JjHNtlr7DWHQGbOau7V5KBJ+T42HbDh3aQeqJ0W2mM5LT2GG30rgmkG K6DMJ58QRCf6YsAWsLnzwUGm2VHbH8Nwrrolv10sdmh/pK+lmK/lWHCXRQQ9yUG2VZ+Qol 6aMX8E0uK6wx/lKWLySM3JZaK9TjGlCdUQNbYccNfjgG7zhtKu1Tai6bnkoREw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YHvWp6jt6z14LM; Wed, 25 Dec 2024 01:37:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BP1bQ7h004466; Wed, 25 Dec 2024 01:37:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BP1bQYR004463; Wed, 25 Dec 2024 01:37:26 GMT (envelope-from git) Date: Wed, 25 Dec 2024 01:37:26 GMT Message-Id: <202412250137.4BP1bQYR004463@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: dd2b54436445 - main - amd64: on any fault during call to EFI RT, restore execution and print fault details List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dd2b5443644505af51c95503898ab363e7d7c29d Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=dd2b5443644505af51c95503898ab363e7d7c29d commit dd2b5443644505af51c95503898ab363e7d7c29d Author: Konstantin Belousov AuthorDate: 2024-12-24 02:35:16 +0000 Commit: Konstantin Belousov CommitDate: 2024-12-25 01:37:19 +0000 amd64: on any fault during call to EFI RT, restore execution and print fault details The fault info should be useful to see what specifically BIOS tried to do and why it faulted. E.g. it might allow to see which EFI memory segment needs to be mapped in addition to normal runtime segments, to work around the fault. Reviewed by: kevans, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D48186 --- sys/amd64/amd64/trap.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index 3b23a34662d5..8e9b115ef224 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -423,6 +423,20 @@ trap(struct trapframe *frame) KASSERT(cold || td->td_ucred != NULL, ("kernel trap doesn't have ucred")); + + /* + * Most likely, EFI RT faulted. This check prevents + * kdb from handling breakpoints set on the BIOS text, + * if such option is ever needed. + */ + 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)); + frame->tf_rip = (long)curpcb->pcb_onfault; + return; + } + switch (type) { case T_PAGEFLT: /* page fault */ (void)trap_pfault(frame, false, NULL, NULL); @@ -586,18 +600,6 @@ 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_pflags & TDP_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". @@ -857,6 +859,10 @@ trap_pfault(struct trapframe *frame, bool usermode, int *signo, int *ucode) after_vmfault: if (td->td_intr_nesting_level == 0 && curpcb->pcb_onfault != NULL) { + if ((td->td_pflags & TDP_EFIRT) != 0) { + trap_diag(frame, eva); + printf("EFI RT page fault\n"); + } frame->tf_rip = (long)curpcb->pcb_onfault; return (0); }