[HAL/APIC] Fix clock initialization

Previously we enabled the timer interrupt, before the kernel was notified of our time increment, so when a clock interrupt happened, it would increment the tick count, but add 0 to the system time, resulting in an invalid state, in which timers would be inserted into the wrong timer table slot. Fixes CORE-16253
This commit is contained in:
Timo Kreuzer 2021-07-16 11:45:39 +02:00
parent aedb97df47
commit aa3ef4c632
2 changed files with 4 additions and 2 deletions

View file

@ -463,12 +463,12 @@ ApicInitializeIOApic(VOID)
HalpVectorToIndex[Vector] = APIC_FREE_VECTOR;
}
/* Enable the timer interrupt */
/* Enable the timer interrupt (but keep it masked) */
ReDirReg.Vector = APIC_CLOCK_VECTOR;
ReDirReg.DeliveryMode = APIC_MT_Fixed;
ReDirReg.DestinationMode = APIC_DM_Physical;
ReDirReg.TriggerMode = APIC_TGM_Edge;
ReDirReg.Mask = 0;
ReDirReg.Mask = 1;
ReDirReg.Destination = ApicRead(APIC_ID);
ApicWriteIORedirectionEntry(APIC_CLOCK_INDEX, ReDirReg);
}

View file

@ -122,6 +122,8 @@ HalpInitializeClock(VOID)
KeSetTimeIncrement(RtcClockRateToIncrement(RtcMaximumClockRate),
RtcClockRateToIncrement(RtcMinimumClockRate));
/* Enable the timer interrupt */
HalEnableSystemInterrupt(APIC_CLOCK_VECTOR, CLOCK_LEVEL, Latched);
DPRINT1("Clock initialized\n");
}