X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=UefiCpuPkg%2FLibrary%2FMpInitLib%2FIa32%2FMpFuncs.nasm;h=2b6c27d4ec675f6389436ce3862b01b22284a5b1;hb=147fd35c3e389ecd025dbfd243312bf5b22da7c9;hp=4bfa084c85a91457a1e60bc5cb5be217ca6fb3a7;hpb=845c5be1fd9bf7edfac4a103dfab70829686978f;p=mirror_edk2.git diff --git a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm index 4bfa084c85..2b6c27d4ec 100644 --- a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm +++ b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm @@ -86,6 +86,12 @@ Flat32Start: ; protected mode entry point mov esi, ebx + ; Increment the number of APs executing here as early as possible + ; This is decremented in C code when AP is finished executing + mov edi, esi + add edi, NumApsExecutingLocation + lock inc dword [edi] + mov edi, esi add edi, EnableExecuteDisableLocation cmp byte [edi], 0 @@ -130,7 +136,7 @@ TestLock: jz TestLock mov ecx, esi - add ecx, NumApsExecutingLocation + add ecx, ApIndexLocation inc dword [ecx] mov ebx, [ecx] @@ -154,21 +160,24 @@ GetApicId: mov eax, 0 cpuid cmp eax, 0bh - jnb X2Apic + jb NoX2Apic ; CPUID level below CPUID_EXTENDED_TOPOLOGY + + mov eax, 0bh + xor ecx, ecx + cpuid + test ebx, 0ffffh + jz NoX2Apic ; CPUID.0BH:EBX[15:0] is zero + + ; Processor is x2APIC capable; 32-bit x2APIC ID is already in EDX + jmp GetProcessorNumber + +NoX2Apic: ; Processor is not x2APIC capable, so get 8-bit APIC ID mov eax, 1 cpuid shr ebx, 24 mov edx, ebx - jmp GetProcessorNumber -X2Apic: - ; Processor is x2APIC capable, so get 32-bit x2APIC ID - mov eax, 0bh - xor ecx, ecx - cpuid - ; edx save x2APIC ID - GetProcessorNumber: ; ; Get processor number for this AP @@ -181,7 +190,7 @@ GetProcessorNumber: GetNextProcNumber: cmp [edi], edx ; APIC ID match? jz ProgramStack - add edi, 16 + add edi, 20 inc ebx jmp GetNextProcNumber @@ -197,7 +206,7 @@ CProcedureInvoke: mov eax, ASM_PFX(InitializeFloatingPointUnits) call eax ; Call assembly function to initialize FPU per UEFI spec - push ebx ; Push NumApsExecuting + push ebx ; Push ApIndex mov eax, esi add eax, LockLocation push eax ; push address of exchange info data buffer @@ -212,19 +221,28 @@ CProcedureInvoke: RendezvousFunnelProcEnd: ;------------------------------------------------------------------------------------- -; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment); +; AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, TopOfApStack, CountTofinish); ;------------------------------------------------------------------------------------- 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 + mov eax, [eax + 20] ; CountTofinish + lock dec dword [eax] ; (*CountTofinish)-- + 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 @@ -232,7 +250,6 @@ HltLoop: cli hlt jmp HltLoop - ret AsmRelocateApLoopEnd: ;-------------------------------------------------------------------------------------