]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
UefiCpuPkg/CpuDxe: Enable protection for newly added page table
[mirror_edk2.git] / UefiCpuPkg / Library / MpInitLib / Ia32 / MpFuncs.nasm
index 9067f7807098201c539192147eacd1cb72fdda4b..2b6c27d4ec675f6389436ce3862b01b22284a5b1 100644 (file)
@@ -86,6 +86,12 @@ Flat32Start:                                   ; protected mode entry point
 \r
     mov        esi, ebx\r
 \r
+    ; Increment the number of APs executing here as early as possible\r
+    ; This is decremented in C code when AP is finished executing\r
+    mov        edi, esi\r
+    add        edi, NumApsExecutingLocation\r
+    lock inc   dword [edi]\r
+\r
     mov         edi, esi\r
     add         edi, EnableExecuteDisableLocation\r
     cmp         byte [edi], 0\r
@@ -130,7 +136,7 @@ TestLock:
     jz         TestLock\r
 \r
     mov        ecx, esi\r
-    add        ecx, NumApsExecutingLocation\r
+    add        ecx, ApIndexLocation\r
     inc        dword [ecx]\r
     mov        ebx, [ecx]\r
 \r
@@ -200,7 +206,7 @@ CProcedureInvoke:
     mov        eax, ASM_PFX(InitializeFloatingPointUnits)\r
     call       eax               ; Call assembly function to initialize FPU per UEFI spec\r
 \r
-    push       ebx               ; Push NumApsExecuting\r
+    push       ebx               ; Push ApIndex\r
     mov        eax, esi\r
     add        eax, LockLocation\r
     push       eax               ; push address of exchange info data buffer\r
@@ -215,19 +221,28 @@ CProcedureInvoke:
 RendezvousFunnelProcEnd:\r
 \r
 ;-------------------------------------------------------------------------------------\r
-;  AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment);\r
+;  AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack, CountTofinish);\r
 ;-------------------------------------------------------------------------------------\r
 global ASM_PFX(AsmRelocateApLoop)\r
 ASM_PFX(AsmRelocateApLoop):\r
 AsmRelocateApLoopStart:\r
-    cmp        byte [esp + 4], 1\r
+    mov        eax, esp\r
+    mov        esp, [eax + 16]     ; TopOfApStack\r
+    push       dword [eax]         ; push return address for stack trace\r
+    push       ebp\r
+    mov        ebp, esp\r
+    mov        ebx, [eax + 8]      ; ApTargetCState\r
+    mov        ecx, [eax + 4]      ; MwaitSupport\r
+    mov        eax, [eax + 20]     ; CountTofinish\r
+    lock dec   dword [eax]         ; (*CountTofinish)--\r
+    cmp        cl,  1              ; Check mwait-monitor support\r
     jnz        HltLoop\r
 MwaitLoop:\r
     mov        eax, esp\r
     xor        ecx, ecx\r
     xor        edx, edx\r
     monitor\r
-    mov        eax, [esp + 8]    ; Mwait Cx, Target C-State per eax[7:4]\r
+    mov        eax, ebx            ; Mwait Cx, Target C-State per eax[7:4]\r
     shl        eax, 4\r
     mwait\r
     jmp        MwaitLoop\r
@@ -235,7 +250,6 @@ HltLoop:
     cli\r
     hlt\r
     jmp        HltLoop\r
-    ret\r
 AsmRelocateApLoopEnd:\r
 \r
 ;-------------------------------------------------------------------------------------\r