git: 6105e8589b2c - main - amd64 FRED: explain why %rax is saved early

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Thu, 29 Oct 2026 01:35:05 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=6105e8589b2cd7f9001df045392c30fc86900633

commit 6105e8589b2cd7f9001df045392c30fc86900633
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-10-29 01:16:49 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-10-29 01:33:47 +0000

    amd64 FRED: explain why %rax is saved early
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
---
 sys/amd64/amd64/exception.S | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/amd64/amd64/exception.S b/sys/amd64/amd64/exception.S
index 6ec37032bc05..b9fc09d7f26f 100644
--- a/sys/amd64/amd64/exception.S
+++ b/sys/amd64/amd64/exception.S
@@ -1639,6 +1639,10 @@ fred_eretu_fault:
 	.globl	fred_events_handlers, fred_events_handlers_end
 fred_events_handlers:
 	subq	$TF_ERR,%rsp
+	/*
+	 * %rax is saved early both to provide a free register and to
+	 * show the right syscall number in ddb backtrace.
+	 */
 	movq	%rax,TF_RAX(%rsp)
 	movq	%rdi,TF_RDI(%rsp)
 	movq	%rsi,TF_RSI(%rsp)