UefiCpuPkg/MpInitLib: Disable interrupt at ExitBootServices AP Mwait

Within function ApWakeupFunction():

When source level debugger is enabled, AP interrupts will be enabled by
EnableDebugAgent(). Then the AP function will be executed by:

Procedure (Parameter);

After the AP function returns, AP interrupts will be disabled when the
APs are placed in loop mode (both HltLoop and MwaiLoop).

However, at ExitBootServices, ApWakeupFunction() is called with
'Procedure' equals to RelocateApLoop().

(ExitBootServices callback registered within InitMpGlobalData())

RelocateApLoop() never returns, so it has to disable the AP interrupts by
itself. However, we find that interrupts are only disabled for the
HltLoop case, but not for the MwaitLoop case (within file MpFuncs.nasm).

This commit adds the missing disabling of AP interrupts for MwaitLoop.

Also, for X64, this commit will disable the interrupts before switching to
32-bit mode.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Jeff Fan <vanjeff_919@hotmail.com>
This commit is contained in:
Hao Wu 2018-03-19 13:00:13 +08:00
parent e46440360e
commit a7bbe9d20b
2 changed files with 5 additions and 2 deletions

View File

@ -1,5 +1,5 @@
;------------------------------------------------------------------------------ ; ;------------------------------------------------------------------------------ ;
; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> ; Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials ; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License ; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at ; which accompanies this distribution. The full text of the license may be found at
@ -239,6 +239,7 @@ AsmRelocateApLoopStart:
cmp cl, 1 ; Check mwait-monitor support cmp cl, 1 ; Check mwait-monitor support
jnz HltLoop jnz HltLoop
MwaitLoop: MwaitLoop:
cli
mov eax, esp mov eax, esp
xor ecx, ecx xor ecx, ecx
xor edx, edx xor edx, edx

View File

@ -1,5 +1,5 @@
;------------------------------------------------------------------------------ ; ;------------------------------------------------------------------------------ ;
; Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR> ; Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials ; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License ; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at ; which accompanies this distribution. The full text of the license may be found at
@ -253,6 +253,7 @@ RendezvousFunnelProcEnd:
global ASM_PFX(AsmRelocateApLoop) global ASM_PFX(AsmRelocateApLoop)
ASM_PFX(AsmRelocateApLoop): ASM_PFX(AsmRelocateApLoop):
AsmRelocateApLoopStart: AsmRelocateApLoopStart:
cli ; Disable interrupt before switching to 32-bit mode
mov rax, [rsp + 40] ; CountTofinish mov rax, [rsp + 40] ; CountTofinish
lock dec dword [rax] ; (*CountTofinish)-- lock dec dword [rax] ; (*CountTofinish)--
mov rsp, r9 mov rsp, r9
@ -288,6 +289,7 @@ PmEntry:
jnz HltLoop jnz HltLoop
mov ebx, edx ; Save C-State to ebx mov ebx, edx ; Save C-State to ebx
MwaitLoop: MwaitLoop:
cli
mov eax, esp ; Set Monitor Address mov eax, esp ; Set Monitor Address
xor ecx, ecx ; ecx = 0 xor ecx, ecx ; ecx = 0
xor edx, edx ; edx = 0 xor edx, edx ; edx = 0