UefiCpuPkg/DxeMpLib: Allocate new safe stack < 4GB
For long mode DXE, we will disable paging on AP to protected mode to execute AP safe loop code in reserved memory range under 4GB. But we forget to allocate stack for AP under 4GB and AP still are using original AP stack. If original AP stack is larger than 4GB, it cannot be used after AP is transferred to protected mode. Besides MwaitSupport == TRUE, AP stack is still required during phase of disabling paging in long mode DXE. Moreover, even though AP stack is always under 4GB (a) in Ia32 DXE and (b) with this patch, after transferring to protected mode from X64 DXE, AP stack (in BootServiceData) maybe crashed by OS after Exit Boot Service event. This fix is to allocate reserved memory range under 4GB together with AP safe loop code. APs will switch to new stack in safe loop code. Cc: Laszlo Ersek <lersek@redhat.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
@@ -215,19 +215,26 @@ CProcedureInvoke:
|
||||
RendezvousFunnelProcEnd:
|
||||
|
||||
;-------------------------------------------------------------------------------------
|
||||
; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment);
|
||||
; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack);
|
||||
;-------------------------------------------------------------------------------------
|
||||
global ASM_PFX(AsmRelocateApLoop)
|
||||
ASM_PFX(AsmRelocateApLoop):
|
||||
AsmRelocateApLoopStart:
|
||||
cmp byte [esp + 4], 1
|
||||
mov eax, esp
|
||||
mov esp, [eax + 16] ; TopOfApStack
|
||||
push dword [eax] ; push return address for stack trace
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
mov ebx, [eax + 8] ; ApTargetCState
|
||||
mov ecx, [eax + 4] ; MwaitSupport
|
||||
cmp cl, 1 ; Check mwait-monitor support
|
||||
jnz HltLoop
|
||||
MwaitLoop:
|
||||
mov eax, esp
|
||||
xor ecx, ecx
|
||||
xor edx, edx
|
||||
monitor
|
||||
mov eax, [esp + 8] ; Mwait Cx, Target C-State per eax[7:4]
|
||||
mov eax, ebx ; Mwait Cx, Target C-State per eax[7:4]
|
||||
shl eax, 4
|
||||
mwait
|
||||
jmp MwaitLoop
|
||||
|
Reference in New Issue
Block a user