From nobody Wed Jan 01 10:38:13 2025 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 4YNRBZ1K17z5jkhr; Wed, 01 Jan 2025 10:38:14 +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 4YNRBY6tPbz4gwH; Wed, 1 Jan 2025 10:38:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735727894; 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=vI6K3i0ncorwPJtvhoJnYVKD2ZJqhoeWHJX9sqXBnHM=; b=YkfIkui/Y9qJr4lBkee0ocL3FQkXp08OUldQ6iYzM4S9eN6l3hXTorwqEp0BOPJcKs5fGO KUPv3hIeFr5OiGiK2NV/pYWx9CPbXbvYqQxEp1XB9kiLPGFgFlfSaMO1K7CvtzYsx+Mejj ay3Vqm0MsyO0QpgItqfsxNak89TwMvhsNhOq0t7SY4cA2Xhchm+cdRxmdPJ4DqgRLQMnNO Z3qMslRpNwejnrrrcc8+CSCVECj6VivsSFPS7BjNveEnhN9n7fn1r7sWB8pAsSqZD7gCFC IIvGnAG+g3ktew0Hqv8D4wV+2l0eWRFlMScxL1EAg+yKlciLoHS6zfiy35nvKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735727894; 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=vI6K3i0ncorwPJtvhoJnYVKD2ZJqhoeWHJX9sqXBnHM=; b=PDrpeWphIYMUp+eamw6VlFTnKkNvOVz02iaSlsIbYFeeW3nw39SP+wpC1C7TadELvztLYt Qm04KEHsBMDLQ2X+DnS5Wjh4CGIqG91UkkvZ5EOUzKh3eJFvy4Q6s6xCSKb4q6oCkWMBMH l37iqwE2MhTEjOkrXweNxsedrZCK53lU+7wAGaaQSr+uk/wUBVXQI1eq9Di1aQbtzEXwe/ YMSDewhlTXrHDKkl1MI0Err4tmIlTotIbZHgmHWVEbARFqXggtKDg+gvzaePGZUZG9UsKX 0N1yW55hyTWc21BwTdtYYJrHnEsSEcAov2L94TF8YsfO6Vg+XWzVzZFO8Xhkow== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1735727894; a=rsa-sha256; cv=none; b=krgSVTIXOWqhkBnI2ZcKEcEWed9ZJgz7cJQBQ/5iCpTbBjIHqWPT5969p+NY1KQ2HyTSgX JAbUj3q1uUepmisbR5t9vumHH30MuT/8eUkUZ0SiAiUT+hP7Q+oK66j4EDrKr7GsXxAqnt WnKaS6xahOirDU3LvOn/LO00GxD+0/wsb4jL9xbk/Dv4Ub+FERW6MUdiZeJT5qstlLoWjl 8n2fqIWAzEKJ7my4p7HTli5saoXFQEDyC4CjT+ADxt+6F+zcsIHcnvNtp0jvX+rpvLMPP3 QRVWfKEzxp5TPTOy4cqKTsMiIxH8uWd1RpHeytIyVnFh5U03VS6CHgbMZ9rdJQ== 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 4YNRBY6MyQzLPs; Wed, 1 Jan 2025 10:38:13 +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 501AcDpq078829; Wed, 1 Jan 2025 10:38:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 501AcDoO078826; Wed, 1 Jan 2025 10:38:13 GMT (envelope-from git) Date: Wed, 1 Jan 2025 10:38:13 GMT Message-Id: <202501011038.501AcDoO078826@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: e27089cda589 - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: e27089cda5897633545d3df6707cd06970f03fae Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e27089cda5897633545d3df6707cd06970f03fae commit e27089cda5897633545d3df6707cd06970f03fae Author: Konstantin Belousov AuthorDate: 2024-12-24 02:35:16 +0000 Commit: Konstantin Belousov CommitDate: 2025-01-01 10:30:20 +0000 amd64: on any fault during call to EFI RT, restore execution and print fault details (cherry picked from commit dd2b5443644505af51c95503898ab363e7d7c29d) --- 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 396c2abd3f1f..7f1175da41df 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -445,6 +445,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_pflags2 & TDP2_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); @@ -608,18 +622,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_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". @@ -883,6 +885,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_pflags2 & TDP2_EFIRT) != 0) { + trap_diag(frame, eva); + printf("EFI RT page fault\n"); + } frame->tf_rip = (long)curpcb->pcb_onfault; return (0); }