Skip to content

Commit

Permalink
undo some buggy code for now
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkFire01 committed Nov 25, 2023
1 parent 35576bd commit 1fb5641
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 66 deletions.
59 changes: 4 additions & 55 deletions ntoskrnl/ke/freeze.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,12 @@ KiFreezeTargetExecution(_In_ PKTRAP_FRAME TrapFrame,

/* FUNCTIONS ******************************************************************/


BOOLEAN
NTAPI
KeFreezeExecution(IN PKTRAP_FRAME TrapFrame,
IN PKEXCEPTION_FRAME ExceptionFrame)
{
#ifdef CONFIG_SMP
KAFFINITY TargetAffinity;
PKPRCB TargetPrcb;
KAFFINITY Current;
PKPRCB Prcb;
LONG i;
#endif

BOOLEAN Enable;
KIRQL OldIrql;

Expand All @@ -92,27 +85,7 @@ KeFreezeExecution(IN PKTRAP_FRAME TrapFrame,
#endif

#ifdef CONFIG_SMP
Prcb = KeGetCurrentPrcb();
TargetAffinity = KeActiveProcessors;
TargetAffinity &= ~Prcb->SetMember;
if (TargetAffinity)
{
for (i = 0, Current = 1; i < KeNumberProcessors; i++, Current <<= 1)
{
if (TargetAffinity & Current)
{
/* stop target processor */
KiIpiSend(Current, IPI_FREEZE);
TargetPrcb = KiProcessorBlock[i];

/* Await for this processor to be frozen*/
while (TargetPrcb->IpiFrozen != IPI_FROZEN_HALTED)
{
/* Do nothing, we're trying to synch */
}
}
}
}
// TODO: Add SMP support.
#endif

/* Save the old IRQL to be restored on unfreeze */
Expand All @@ -127,31 +100,7 @@ NTAPI
KeThawExecution(IN BOOLEAN Enable)
{
#ifdef CONFIG_SMP
KAFFINITY TargetAffinity;
PKPRCB TargetPrcb;
KAFFINITY Current;
PKPRCB Prcb;
LONG i;

Prcb = KeGetCurrentPrcb();
TargetAffinity = KeActiveProcessors;
TargetAffinity &= ~Prcb->SetMember;

/* Loop through every processor */
for (i = 0, Current = 1; i < KeNumberProcessors; i++, Current <<= 1)
{
if (TargetAffinity & Current)
{
TargetPrcb = KiProcessorBlock[i];

/* Multiple processors can write this value */
InterlockedExchange((LONG*)&TargetPrcb->IpiFrozen, IPI_FROZEN_THAWING);
while (Prcb->IpiFrozen != IPI_FROZEN_RUNNING)
{
/* Do nothing we're waiting for ready */
}
}
}
// TODO: Add SMP support.
#endif

/* Clear the freeze flag */
Expand All @@ -168,4 +117,4 @@ KeThawExecution(IN BOOLEAN Enable)

/* Re-enable interrupts */
KeRestoreInterrupts(Enable);
}
}
23 changes: 12 additions & 11 deletions ntoskrnl/ke/i386/kiinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,17 +811,6 @@ KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
RtlCopyMemory(&Idt[8], &DoubleFaultEntry, sizeof(KIDTENTRY));

AppCpuInit:
//TODO: We don't setup IPIs yet so freeze other processors here.
if (Cpu)
{
KeMemoryBarrier();
LoaderBlock->Prcb = 0;

for (;;)
{
YieldProcessor();
}
}
/* Setup CPU-related fields */
__writefsdword(KPCR_NUMBER, Cpu);
__writefsdword(KPCR_SET_MEMBER, 1 << Cpu);
Expand All @@ -838,6 +827,18 @@ KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
KeActiveProcessors |= __readfsdword(KPCR_SET_MEMBER);
KeNumberProcessors++;

//TODO: We don't setup IPIs yet so freeze other processors here.
if (Cpu)
{
KeMemoryBarrier();
LoaderBlock->Prcb = 0;

for (;;)
{
YieldProcessor();
}
}

/* Check if this is the boot CPU */
if (!Cpu)
{
Expand Down

0 comments on commit 1fb5641

Please sign in to comment.