From nobody Tue Sep 16 11:24:50 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 4cR01H0CMtz68nwR; Tue, 16 Sep 2025 11:24:51 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cR01G6W8mz46mG; Tue, 16 Sep 2025 11:24:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758021890; 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=bEVZC0Mermz2e62a/NuoQD0DB/SH9wcnNo5XRTFLq2g=; b=n1U4CY6R1Ze6JTFMMjhZLCbPlfCQX35Tx5x2/TIIogHy4psVNfpLUFXnApw4h+xBP2w+E9 Xnum/HoiqtTMD1CA3Z0rX/+rph3Hqg4SgFiQDLSHTfnEmAgDzp5qZ/MLZe5meH/M2sWd7U CQz+NLXsBEcnmn/GAlY83ST/EbbgaokEtmdDk6Cpkb4KxkiVWpUlka8vCEafkbpJO56832 KzdDv11oeiNh3btuF/ka6p9rIgXHmJpeA1wEiMtDC581k9pXWSSrGVYo9oI6OKbsEGqIAH GJMHTZ0vTdvtZppmx8GcfYknlQ27ZZw6+UcwGGtQ6heLjg3yxtXoUa/dA8pfzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758021890; 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=bEVZC0Mermz2e62a/NuoQD0DB/SH9wcnNo5XRTFLq2g=; b=t1ujUUAfsN+YqX6J/F15+rzZUwfsi8xpapVN85PMRw5GKgoEPNHkCz2wlcPXNaSVcs/Sze 2b+ZAwmx+zgGXPPDY4UbUSlqbJXDwG0LODsVacIlP9cE0KXDrb6JVpKCn5ycY4fAHsehiP VHZMYbdJrJXUmIDHBFJ88NV10x9CIaloP9FvrJ5BVqRzp6Bzap1A0eXFy6mQEXS/aEwntN Cb81KGsY3qbySxZPsy5NSnkKPZXasJiJCd1xgNxQnNbBkLvwpp/Nm0aVAy/1YZWu5iqwur GPdTAfl/H/tGCEUFDsAVRdqXS6OEt1P6CiH7CGprztURl1lADW9A4YxToNLxtQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1758021890; a=rsa-sha256; cv=none; b=OnVutdqjvTh1DFzYHhe+W3Hm5zTJbd8ExhV+/RxHn0hjgpIOw13vZofJiSXiTrH9D213FV xHN2GtgPHfrgarnh5lQiXliCtT801y5zr55BWhvW0qsuRSjPVPgtTQvslDhklZEftdeutC 6jO0dyhjPP5wnZyV5TX23ogyHK9LBPqigSgiajdgIdgE9tDqWWMZRNgAElLo6Gsosrlzud pJQbwPoU8SosHi33rpCXD8itGUKDiLwY7pXgAt/Iao8XWZeuJT9xttkqLzbEkaPxLVJgzN 83WkdMKfNdws/lY4seAmVFgRSKANDfSOkbvk/PZkR3ebym9+Kand4tacaaonPg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cR01G5JPczfb5; Tue, 16 Sep 2025 11:24:50 +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 58GBOorG079976; Tue, 16 Sep 2025 11:24:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58GBOoWr079973; Tue, 16 Sep 2025 11:24:50 GMT (envelope-from git) Date: Tue, 16 Sep 2025 11:24:50 GMT Message-Id: <202509161124.58GBOoWr079973@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 99213b3c352c - main - aarch64: Save correct value of x18 on trapframe for nested faults 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 99213b3c352cdf568ea7cf5b4dddb1879f16a601 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=99213b3c352cdf568ea7cf5b4dddb1879f16a601 commit 99213b3c352cdf568ea7cf5b4dddb1879f16a601 Author: Konrad Witaszczyk AuthorDate: 2025-09-16 11:21:57 +0000 Commit: John Baldwin CommitDate: 2025-09-16 11:23:58 +0000 aarch64: Save correct value of x18 on trapframe for nested faults x18 is overwritten with a temporary copy of the kernel stack pointer when it is saved in the trapframe. This does not matter in terms of function since nested exception return does not restore x18 from the trapframe, but it does mean that examining x18 in a debugger in stack frames above a nested fault outputs the wrong register value. To fix, compute the value of the original stack pointer to save in x18 later after the trapframe has been constructed. Reviewed by: jhb, andrew Sponsored by: AFRL, DARPA Differential Revision: https://reviews.freebsd.org/D52472 --- sys/arm64/arm64/exception.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/arm64/arm64/exception.S b/sys/arm64/arm64/exception.S index 6e673fbe5a43..5a4181348a54 100644 --- a/sys/arm64/arm64/exception.S +++ b/sys/arm64/arm64/exception.S @@ -42,7 +42,6 @@ */ .macro save_registers_head el .if \el == 1 - mov x18, sp stp x0, x1, [sp, #-(TF_SIZE - TF_X + 128)]! .else stp x0, x1, [sp, #-(TF_SIZE - TF_X)]! @@ -61,7 +60,9 @@ stp x24, x25, [sp, #(24 * 8)] stp x26, x27, [sp, #(26 * 8)] stp x28, x29, [sp, #(28 * 8)] -.if \el == 0 +.if \el == 1 + add x18, sp, #(TF_SIZE - TF_X + 128) +.else mrs x18, sp_el0 .endif mrs x10, elr_el1