From nobody Wed Dec 25 01:37:25 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 4YHvWp0XcQz5h08D; Wed, 25 Dec 2024 01:37:26 +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 4YHvWn6s9rz4qZk; Wed, 25 Dec 2024 01:37:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735090646; 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=pJJeJlGaV6FdEDQs/mrmzt0PMzX7gBdxsSoJCjCx77M=; b=nw9AnvZDch6sosENLmofc4D2Ru2mjSswca+abdrrxhWqya3zE4U7GJuKf8715T03DSukKL nxSCyB7C7MB+7iSWpjPpVI7lM8Jahy6lvuOUbYfYF+vMK7AY8QsqWjjS1IUxtK0mTe4I1R 11Wku2EOLj7+VlWyp8tkbsUByRWVuI+G2aSfYz/ljAjXMbt0GgwDCmkSVO3AJVKf0AhEzD JvEjsQ8MEEFkuC6orJTS7gT6xx2VTTjA23XiJpRtksrkQeIF2PugTIseJLcShZs4gLcaAD X5tERB4eTrEm1v1TjSYRpV6ZC7xjIuIUoQL9x8cp5ST7dwGesRwQGGIzWKR1Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735090646; 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=pJJeJlGaV6FdEDQs/mrmzt0PMzX7gBdxsSoJCjCx77M=; b=ZrYyxp/d1AiKEjg0tg1vNymg7E3VGvQbHl8VPADxnyQs4t7PupcimqLo/Z4rnXqhxatsYz xojT5UgQcmbcVkmaQaFnoKajFGwtuNWS5aqr3G3hT427do3pNzghjeqvW4znIInXh2v16v WXWe1FYGE/wDDst5KIUH+guuaLh0+2pzgjxu4sej5Jy9KqyuBmvAPAegZU+n44AB3IKm9p LVbOWmC+h8QcSphz7K/yKDQlblEWFIVSN1IpwlAwxCzNPnXejkqA9RuvcKpnLoNINcyIr8 wxq7SIIrAjq4aB8ol+VfeumoJSIUYT52BW0wRUYrjuayXHCqzT3Yg3bb6fG/AQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1735090646; a=rsa-sha256; cv=none; b=PNEQNXkQBP4ICohEUrP9XNZ8Eogo9XwyktJFT5E1weEOKwvF7JHXXlJd24GlMqXAW+sJhS tYbbqdjWu9DHkPONAiO9rTJ1hKEgQP/lGii4TkoFeqEmyKkiHwsqrSCN4ie18FB+QK7TrS hJYg0bU16orJmn9eENu5wH54sCzQp/SoVpqSxpdsvL76INOXT2uU0MvmcxVJPzASIzT8PX FKxBT7EM4KVJ0YDvvuFlGEDLyz9Ov23aolH+hUmzIl6suAcciusG0GGaQOwap3YH5Ui8Dz PcqnygDlTq0Zr3n213XaviCjvJrgtWgbufgiABrFvfTb3lKFV5RbVr8t0dhn9w== 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 4YHvWn62Ncz13nY; Wed, 25 Dec 2024 01:37:25 +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 4BP1bPTn004394; Wed, 25 Dec 2024 01:37:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BP1bPiL004391; Wed, 25 Dec 2024 01:37:25 GMT (envelope-from git) Date: Wed, 25 Dec 2024 01:37:25 GMT Message-Id: <202412250137.4BP1bPiL004391@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: 5e3ab1894e1e - main - amd64: extract code to print fault details from trap_fatal() into a new helper 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: 5e3ab1894e1ef0520925038f8d4e4a451e841345 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=5e3ab1894e1ef0520925038f8d4e4a451e841345 commit 5e3ab1894e1ef0520925038f8d4e4a451e841345 Author: Konstantin Belousov AuthorDate: 2024-12-24 16:39:38 +0000 Commit: Konstantin Belousov CommitDate: 2024-12-25 01:37:18 +0000 amd64: extract code to print fault details from trap_fatal() into a new helper Suggested by: markj 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 | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index 4590be501d64..3b23a34662d5 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -107,6 +107,7 @@ void trap_check(struct trapframe *frame); void dblfault_handler(struct trapframe *frame); static int trap_pfault(struct trapframe *, bool, int *, int *); +static void trap_diag(struct trapframe *, vm_offset_t); static void trap_fatal(struct trapframe *, vm_offset_t); #ifdef KDTRACE_HOOKS static bool trap_user_dtrace(struct trapframe *, @@ -150,6 +151,13 @@ static const char *const trap_msg[] = { [T_DTRACE_RET] = "DTrace pid return trap", }; +static const char * +traptype_to_msg(u_int type) +{ + return (type < nitems(trap_msg) ? trap_msg[type] : + "unknown/reserved trap"); +} + static int uprintf_signal; SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG_RWTUN, &uprintf_signal, 0, @@ -857,15 +865,12 @@ after_vmfault: } static void -trap_fatal(struct trapframe *frame, vm_offset_t eva) +trap_diag(struct trapframe *frame, vm_offset_t eva) { int code, ss; u_int type; struct soft_segment_descriptor softseg; struct user_segment_descriptor *gdt; -#ifdef KDB - bool handled; -#endif code = frame->tf_err; type = frame->tf_trapno; @@ -925,8 +930,20 @@ trap_fatal(struct trapframe *frame, vm_offset_t eva) printf("r13: %016lx r14: %016lx r15: %016lx\n", frame->tf_r13, frame->tf_r14, frame->tf_r15); + printf("trap number = %d\n", type); +} + +static void +trap_fatal(struct trapframe *frame, vm_offset_t eva) +{ + u_int type; + + type = frame->tf_trapno; + trap_diag(frame, eva); #ifdef KDB if (debugger_on_trap) { + bool handled; + kdb_why = KDB_WHY_TRAP; handled = kdb_trap(type, 0, frame); kdb_why = KDB_WHY_UNSET; @@ -934,9 +951,7 @@ trap_fatal(struct trapframe *frame, vm_offset_t eva) return; } #endif - printf("trap number = %d\n", type); - panic("%s", type < nitems(trap_msg) ? trap_msg[type] : - "unknown/reserved trap"); + panic("%s", traptype_to_msg(type)); } #ifdef KDTRACE_HOOKS