On 7/21/25 12:43, Mark Johnston wrote:
On Mon, Jul 21, 2025 at 12:37:23PM -0400, John Baldwin wrote:
On 7/21/25 10:58, Mark Johnston wrote:
The branch main has been updated by markj:
URL:
https://cgit.FreeBSD.org/src/commit/?id=cc21f6e53f43f0e4c082222460d90ea581f3e2d6
commit cc21f6e53f43f0e4c082222460d90ea581f3e2d6
Author: Mark Johnston <ma...@freebsd.org>
AuthorDate: 2025-07-21 13:33:31 +0000
Commit: Mark Johnston <ma...@freebsd.org>
CommitDate: 2025-07-21 14:57:58 +0000
amd64: Make a comment less confusing
Also merge two printf()s. No functional change intended.
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D51452
---
sys/amd64/amd64/trap.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index d9a5f7096a6e..f3469ed5e2bc 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -37,7 +37,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
/*
* AMD64 Trap and System call handling
*/
@@ -898,9 +897,9 @@ trap_diag(struct trapframe *frame, vm_offset_t eva)
printf("\n\nFatal trap %d: %s while in %s mode\n", type,
type < nitems(trap_msg) ? trap_msg[type] : UNKNOWN,
TRAPF_USERMODE(frame) ? "user" : "kernel");
- /* two separate prints in case of a trap on an unmapped page */
- printf("cpuid = %d; ", PCPU_GET(cpuid));
- printf("apic id = %02x\n", PCPU_GET(apic_id));
+ /* Print these separately in case pcpu accesses trap. */
+ printf("cpuid = %d; apic id = %02x\n", PCPU_GET(cpuid),
+ PCPU_GET(apic_id));
if (type == T_PAGEFLT) {
printf("fault virtual address = 0x%lx\n", eva);
printf("fault code = %s %s %s%s%s, %s\n",
@@ -1021,9 +1020,9 @@ dblfault_handler(struct trapframe *frame)
frame->tf_cs, frame->tf_ss, frame->tf_ds, frame->tf_es,
frame->tf_fs, frame->tf_gs,
rdmsr(MSR_FSBASE), rdmsr(MSR_GSBASE), rdmsr(MSR_KGSBASE));
- /* two separate prints in case of a trap on an unmapped page */
- printf("cpuid = %d; ", PCPU_GET(cpuid));
- printf("apic id = %02x\n", PCPU_GET(apic_id));
+ /* Print these separately in case pcpu accesses trap. */
+ printf("cpuid = %d; apic id = %02x\n", PCPU_GET(cpuid),
+ PCPU_GET(apic_id));
panic("double fault");
Eh, if any of the accesses fault you don't get any of the printf,
Right, but I believe the comment is referring to the preceding printf,
which doesn't print any PCPU fields. In what situation would
PCPU_GET(apic_id) fault while PCPU_GET(cpuid) succeeds?
(Yes, my commit message here should have been better.)
Oh, woof. The second printf used to read from the lapic directly instead
of per-CPU data. I changed it here:
https://svnweb.freebsd.org/base?view=revision&revision=121986
So prior to that each printf was indeed reading from separate pages:
#ifdef SMP
/* two separate prints in case of a trap on an unmapped page */
printf("cpuid = %d; ", PCPU_GET(cpuid));
printf("lapic.id = %08x\n", lapic.id);
#endif
The comment used to reference _three_ printfs prior to the SMPng commit:
https://svnweb.freebsd.org/base/head/sys/i386/i386/trap.c?r1=65556&r2=65557&
The original comment (referencing 3) was added by peter@ here:
https://svnweb.freebsd.org/base?view=revision&revision=29128
It certainly seems to only apply to the printfs under #ifdef SMP.
Removing the comment has the additional property of fixing the style bug
of not having a blank line before the comment that was previously provided
by the #ifdef SMP. :)
--
John Baldwin