UefiCpuPkg: Put APs in 64 bit mode before handoff to OS.
Add the 'AsmRelocateApLoopStartGeneric' for X64 processors except 64-bit AMD processors with SEV-ES. Remove the unused arguments of AsmRelocateApLoopStartGeneric, updated the stack offset. Create PageTable for the allocated reserved memory. Only keep 4GB limitation of memory allocation for the case APs still need to be transferred to 32-bit mode before OS. Cc: Guo Dong <guo.dong@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Sean Rhodes <sean@starlabs.systems> Cc: James Lu <james.lu@intel.com> Cc: Gua Guo <gua.guo@intel.com> Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Tested-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
6bc74286e7
commit
facf52aeb8
23
UefiCpuPkg/Library/MpInitLib/Ia32/CreatePageTable.c
Normal file
23
UefiCpuPkg/Library/MpInitLib/Ia32/CreatePageTable.c
Normal file
@@ -0,0 +1,23 @@
|
||||
/** @file
|
||||
Function to create page talbe.
|
||||
Only create page table for x64, and leave the CreatePageTable empty for Ia32.
|
||||
Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
|
||||
#include <Base.h>
|
||||
|
||||
/**
|
||||
Only create page table for x64, and leave the CreatePageTable empty for Ia32.
|
||||
@param[in] LinearAddress The start of the linear address range.
|
||||
@param[in] Length The length of the linear address range.
|
||||
@return The page table to be created.
|
||||
**/
|
||||
UINTN
|
||||
CreatePageTable (
|
||||
IN UINTN Address,
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
;------------------------------------------------------------------------------ ;
|
||||
; Copyright (c) 2015 - 2022, Intel Corporation. All rights reserved.<BR>
|
||||
; Copyright (c) 2015 - 2023, Intel Corporation. All rights reserved.<BR>
|
||||
; SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
;
|
||||
; Module Name:
|
||||
@@ -219,24 +219,24 @@ SwitchToRealProcEnd:
|
||||
RendezvousFunnelProcEnd:
|
||||
|
||||
;-------------------------------------------------------------------------------------
|
||||
; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack, CountTofinish, Pm16CodeSegment, SevEsAPJumpTable, WakeupBuffer);
|
||||
; AsmRelocateApLoopGeneric (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack, CountTofinish, Pm16CodeSegment, SevEsAPJumpTable, WakeupBuffer);
|
||||
;
|
||||
; The last three parameters (Pm16CodeSegment, SevEsAPJumpTable and WakeupBuffer) are
|
||||
; specific to SEV-ES support and are not applicable on IA32.
|
||||
;-------------------------------------------------------------------------------------
|
||||
AsmRelocateApLoopStart:
|
||||
AsmRelocateApLoopGenericStart:
|
||||
mov eax, esp
|
||||
mov esp, [eax + 16] ; TopOfApStack
|
||||
mov esp, [eax + 12] ; 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
|
||||
mov eax, [eax + 20] ; CountTofinish
|
||||
mov eax, [eax + 16] ; CountTofinish
|
||||
lock dec dword [eax] ; (*CountTofinish)--
|
||||
cmp cl, 1 ; Check mwait-monitor support
|
||||
jnz HltLoop
|
||||
MwaitLoop:
|
||||
jnz HltLoopGeneric
|
||||
MwaitLoopGeneric:
|
||||
cli
|
||||
mov eax, esp
|
||||
xor ecx, ecx
|
||||
@@ -245,12 +245,12 @@ MwaitLoop:
|
||||
mov eax, ebx ; Mwait Cx, Target C-State per eax[7:4]
|
||||
shl eax, 4
|
||||
mwait
|
||||
jmp MwaitLoop
|
||||
HltLoop:
|
||||
jmp MwaitLoopGeneric
|
||||
HltLoopGeneric:
|
||||
cli
|
||||
hlt
|
||||
jmp HltLoop
|
||||
AsmRelocateApLoopEnd:
|
||||
jmp HltLoopGeneric
|
||||
AsmRelocateApLoopGenericEnd:
|
||||
|
||||
;-------------------------------------------------------------------------------------
|
||||
; AsmGetAddressMap (&AddressMap);
|
||||
@@ -264,8 +264,8 @@ ASM_PFX(AsmGetAddressMap):
|
||||
mov dword [ebx + MP_ASSEMBLY_ADDRESS_MAP.RendezvousFunnelAddress], RendezvousFunnelProcStart
|
||||
mov dword [ebx + MP_ASSEMBLY_ADDRESS_MAP.ModeEntryOffset], Flat32Start - RendezvousFunnelProcStart
|
||||
mov dword [ebx + MP_ASSEMBLY_ADDRESS_MAP.RendezvousFunnelSize], RendezvousFunnelProcEnd - RendezvousFunnelProcStart
|
||||
mov dword [ebx + MP_ASSEMBLY_ADDRESS_MAP.RelocateApLoopFuncAddress], AsmRelocateApLoopStart
|
||||
mov dword [ebx + MP_ASSEMBLY_ADDRESS_MAP.RelocateApLoopFuncSize], AsmRelocateApLoopEnd - AsmRelocateApLoopStart
|
||||
mov dword [ebx + MP_ASSEMBLY_ADDRESS_MAP.RelocateApLoopFuncAddressGeneric], AsmRelocateApLoopGenericStart
|
||||
mov dword [ebx + MP_ASSEMBLY_ADDRESS_MAP.RelocateApLoopFuncSizeGeneric], AsmRelocateApLoopGenericEnd - AsmRelocateApLoopGenericStart
|
||||
mov dword [ebx + MP_ASSEMBLY_ADDRESS_MAP.ModeTransitionOffset], Flat32Start - RendezvousFunnelProcStart
|
||||
mov dword [ebx + MP_ASSEMBLY_ADDRESS_MAP.SwitchToRealNoNxOffset], SwitchToRealProcStart - Flat32Start
|
||||
mov dword [ebx + MP_ASSEMBLY_ADDRESS_MAP.SwitchToRealPM16ModeOffset], 0
|
||||
|
Reference in New Issue
Block a user