On 2015-10-27 23:42:42, Jeff Fan wrote: > There is one dead lock issue between BSP and AP. AP has one logic to enter > into > Sleep state (hlt) if it found its state is Idle state in one loop. > In ProcessorToIdleState() function, AP will get current AP state, if its state > is Sleep state, then it will go into real sleep(hlt) state. > The dead lock may happen if BSP found AP state is Sleep state and send > INIT-SIPI > -SIPI to AP. But AP just acquried the lock to get its state. If AP is reset, > the > lock will not released correctly. > This fix is to let AP enter into real sleep(hlt) state immediately after it > changes its state is set to Sleep and needn't get lock again.
I think the issue is that the BSP is rewaking the AP without the lock held. This leads to the chance that the AP may grab the lock and then get reset. So, I think a better fix would be to have the BSP grab the lock during entire time it decides to restart the AP. It will then need to hold the lock until it hears from the AP that it restarted. Maybe a field in the CpuData struct that the BSP clears before re-waking the AP, and then the AP sets. -Jordan > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Jeff Fan <[email protected]> > Cc: Michael Kinney <[email protected]> > Cc: Jordan Justen <[email protected]> > Cc: Laszlo Ersek <[email protected]> > Cc: Chen Fan <[email protected]> > --- > UefiCpuPkg/CpuDxe/CpuMp.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c > index 3de2aa5..357ee42 100644 > --- a/UefiCpuPkg/CpuDxe/CpuMp.c > +++ b/UefiCpuPkg/CpuDxe/CpuMp.c > @@ -1289,14 +1289,18 @@ ProcessorToIdleState ( > GetMpSpinLock (CpuData); > if (CpuData->State == CpuStateIdle) { > CpuData->State = CpuStateSleeping; > + ReleaseMpSpinLock (CpuData); > + while (TRUE) { > + // > + // Place AP into cli-hlt loop to handle RSM from SMM case > + // > + DisableInterrupts (); > + CpuSleep (); > + } > } > ReleaseMpSpinLock (CpuData); > } > > - if (GetApState (CpuData) == CpuStateSleeping) { > - CpuSleep (); > - } > - > CpuPause (); > } > > -- > 1.9.5.msysgit.0 > _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

