Fix the risk of AP stack conflict.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10714 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
xli24
2010-07-30 01:49:51 +00:00
parent 28d1916584
commit d6d858c4b7
8 changed files with 98 additions and 95 deletions

View File

@@ -85,31 +85,33 @@ ProtectedModeStart:: ; protected mode entry point
mov gs, ax
mov ss, ax ; Flat mode setup.
;
; ProgramStack
;
mov ecx, 1bh ; Read IA32_APIC_BASE MSR
rdmsr
and eax, 0fffff000h
add eax, 20h
mov ebx, dword ptr [eax]
shr ebx, 24
xor ecx, ecx
mov edi, esi
add edi, LockLocation
mov al, NotVacantFlag
TestLock::
xchg byte ptr [edi], al
cmp al, NotVacantFlag
jz TestLock
ProgramStack::
add edi, ProcessorNumber
mov ecx, dword ptr [edi + 4 * ebx] ; ECX = CpuNumber
mov edi, esi
add edi, StackSize
mov eax, dword ptr [edi]
inc ecx
mul ecx ; EAX = StackSize * (CpuNumber + 1)
mov edi, esi
add edi, StackStart
add eax, dword ptr [edi]
mov esp, eax
mov dword ptr [edi], eax
mov ebx, dword ptr [edi]
add eax, ebx ; EAX = StackStart + StackSize * (CpuNumber + 1)
Releaselock::
mov al, VacantFlag
mov edi, esi
add edi, LockLocation
xchg byte ptr [edi], al
mov esp, eax
;
; Call C Function