public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Why need to put AP in HLT/MWAIT in ExitBootServices callback
@ 2022-06-09  8:46 Ni, Ray
  2022-06-09  8:53 ` Yao, Jiewen
  0 siblings, 1 reply; 3+ messages in thread
From: Ni, Ray @ 2022-06-09  8:46 UTC (permalink / raw)
  To: devel@edk2.groups.io
  Cc: Ni, Ray, Kinney, Michael D, Tom Lendacky, Yao, Jiewen

All,
When I am reviewing today's MpInitLib code, I don't understand why below complex logic is there to put AP in HLT or MWAIT on a ExitBootServices event callback.
https://github.com/tianocore/edk2/blob/ff36b2550f94dc5fac838cf298ae5a23cfddf204/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c#L423
https://github.com/tianocore/edk2/blob/ff36b2550f94dc5fac838cf298ae5a23cfddf204/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm#L424

The above code is to put AP in a state that when it's woken up by interrupts or SMIs, it's executing code and using stack in reserved memory.
(not in BootServices memory which might be overwritten by OS.)

But according to the SDM content below, we can simply send a INIT IPI to all APs to let AP enter a wait-for-SIPI state.
Then a simple SendInitIpiAllExcludingSelf() from BSP can replace all the complicated code above.

* The MP protocol will be executed only after a power-up or RESET. If the MP protocol has been completed and a
* BSP has been chosen, subsequent INITs (either to a specific processor or system wide) do not cause the MP
* protocol to be repeated. Instead, each processor examines its BSP flag (in the APIC_BASE MSR) to determine
* whether it should execute the BIOS boot-strap code (if it is the BSP) or enter a wait-for-SIPI state (if it is an
* AP).

Did I miss something here?

Thanks,
Ray

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-09  9:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-09  8:46 Why need to put AP in HLT/MWAIT in ExitBootServices callback Ni, Ray
2022-06-09  8:53 ` Yao, Jiewen
2022-06-09  9:21   ` Ni, Ray

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox