From 1d289fec77e2e141ef0cdf43d2d139312c88c5ea Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 30 Nov 2023 20:02:31 +0200 Subject: [PATCH] [NTOS:KE] Improve freeze code in KeBugCheckWithTf - Don't wait 1 second for each processor - Use AFFINITY_MASK - Use Prcb->Number, which is more future proof than KeGetCurrentProcessorNumber - Improve for loop --- ntoskrnl/ke/bug.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ntoskrnl/ke/bug.c b/ntoskrnl/ke/bug.c index 2eea78d0fba..1bf6e7cafbd 100644 --- a/ntoskrnl/ke/bug.c +++ b/ntoskrnl/ke/bug.c @@ -727,9 +727,6 @@ KeBugCheckWithTf(IN ULONG BugCheckCode, PLDR_DATA_TABLE_ENTRY LdrEntry; PULONG_PTR HardErrorParameters; KIRQL OldIrql; -#ifdef CONFIG_SMP - LONG i = 0; -#endif /* Set active bugcheck */ KeBugCheckActive = TRUE; @@ -1083,15 +1080,17 @@ KeBugCheckWithTf(IN ULONG BugCheckCode, KeBugCheckOwner = Prcb->Number; /* Freeze the other CPUs */ - for (i = 0; i < KeNumberProcessors; i++) + for (ULONG i = 0; i < KeNumberProcessors; i++) { - if (i != (LONG)KeGetCurrentProcessorNumber()) + if (i != Prcb->Number) { - /* Send the IPI and give them one second to catch up */ - KiIpiSend(1 << i, IPI_FREEZE); - KeStallExecutionProcessor(1000000); + /* Send the IPI */ + KiIpiSend(AFFINITY_MASK(i), IPI_FREEZE); } } + + /* Give the other CPUs one second to catch up */ + KeStallExecutionProcessor(1000000); #endif /* Display the BSOD */