1 ;------------------------------------------------------------------------------
5 ; Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved.<BR>
6 ; SPDX-License-Identifier: BSD-2-Clause-Patent
8 ;------------------------------------------------------------------------------
10 %include "TdxCommondefs.inc"
13 ; Note: BSP never gets here. APs will be unblocked by DXE
17 ; R9 [31:0] VCPU_INDEX
23 ; register itself in [rsp + CpuArrivalOffset]
26 lock xadd dword [rsp + CpuArrivalOffset], eax
32 mov eax, dword[rsp + CpuArrivalOffset]
33 jmp .check_arrival_cnt
36 mov eax, dword[rsp + CommandOffset]
37 cmp eax, MpProtectedModeWakeupCommandNoop
40 cmp eax, MpProtectedModeWakeupCommandWakeup
43 cmp eax, MpProtectedModeWakeupCommandAcceptPages
46 ; Don't support this command, so ignore
51 ; Read the top stack address from arguments
52 mov rsi, [rsp + AcceptPageArgsTopStackAddress]
55 ; Calculate the top stack address of the AP.
56 ; ApStackAddr = BaseStackAddr + (vCpuIndex) * ApStackSize
60 mov eax, [rsp + AcceptPageArgsApStackSize]
61 mov ebx, r9d ; vCpuIndex
63 add rsi, rax ; now rsi is ApStackAddr
67 ; Read the function address which will be called
68 mov rax, [rsp + WakeupVectorOffset]
71 ; vCPU index as the first argument
73 mov rdx, [rsp + AcceptPageArgsPhysicalStart]
74 mov r8, [rsp + AcceptPageArgsPhysicalEnd]
76 ; save the Mailbox address to rbx
84 ; save rax (the Mailbox address)
98 lock xadd dword [rsp + CpusExitingOffset], eax
104 mov eax, dword[rsp + CpusExitingOffset]
105 jmp .check_exiting_cnt
109 ; BSP sets these variables before unblocking APs
110 ; RAX: WakeupVectorOffset
111 ; RBX: Relocated mailbox address
115 mov eax, dword[rsp + WakeupVectorOffset]
116 mov rbx, [rsp + WakeupArgsRelocatedMailBox]