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:
@@ -23,5 +23,6 @@ GdtrLocation equ LockLocation + 20h
|
||||
IdtrLocation equ LockLocation + 2Ah
|
||||
BufferStartLocation equ LockLocation + 34h
|
||||
Cr3OffsetLocation equ LockLocation + 38h
|
||||
ProcessorNumberLocation equ LockLocation + 3Ch
|
||||
|
||||
;-------------------------------------------------------------------------------
|
||||
|
@@ -24,6 +24,7 @@
|
||||
.equ IdtrLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x2A
|
||||
.equ BufferStartLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x34
|
||||
.equ Cr3OffsetLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x38
|
||||
.equ ProcessorNumberLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x38
|
||||
|
||||
#-------------------------------------------------------------------------------------
|
||||
|
||||
@@ -128,31 +129,33 @@ LongModeStart:
|
||||
.byte 0x66
|
||||
movw %ax,%ss
|
||||
|
||||
movl %esi, %edi
|
||||
addl $LockLocation, %edi
|
||||
movb $NotVacantFlag, %al
|
||||
TestLock:
|
||||
xchgb (%edi), %al
|
||||
cmpb $NotVacantFlag, %al
|
||||
jz TestLock
|
||||
#
|
||||
# ProgramStack
|
||||
#
|
||||
movl $0x1b, %ecx
|
||||
rdmsr
|
||||
andl $0xfffff000, %eax
|
||||
addl $0x20, %eax
|
||||
movl (%eax), %ebx
|
||||
shrl $24, %ebx
|
||||
|
||||
xorq %rcx, %rcx
|
||||
movl %esi,%edi
|
||||
addl $ProcessorNumberLocation, %edi
|
||||
movl (%edi, %ebx, 4), %ecx
|
||||
|
||||
ProgramStack:
|
||||
|
||||
movl %esi, %edi
|
||||
addl $StackSizeLocation, %edi
|
||||
movl %esi,%edi
|
||||
addl $StackSizeLocation, %edi
|
||||
movq (%edi), %rax
|
||||
movl %esi, %edi
|
||||
incq %rcx
|
||||
mulq %rcx
|
||||
|
||||
movl %esi,%edi
|
||||
addl $StackStartAddressLocation, %edi
|
||||
addq (%edi), %rax
|
||||
movq (%edi), %rbx
|
||||
addq %rbx, %rax
|
||||
|
||||
movq %rax, %rsp
|
||||
movq %rax, (%edi)
|
||||
|
||||
Releaselock:
|
||||
|
||||
movb $VacantFlag, %al
|
||||
movl %esi, %edi
|
||||
addl $LockLocation, %edi
|
||||
xchgb (%edi), %al
|
||||
|
||||
#
|
||||
# Call C Function
|
||||
|
@@ -112,31 +112,33 @@ LongModeStart::
|
||||
mov es, ax
|
||||
mov ss, ax
|
||||
|
||||
;
|
||||
; 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 rcx, rcx
|
||||
mov edi, esi
|
||||
add edi, LockLocation
|
||||
mov al, NotVacantFlag
|
||||
TestLock::
|
||||
xchg byte ptr [edi], al
|
||||
cmp al, NotVacantFlag
|
||||
jz TestLock
|
||||
|
||||
ProgramStack::
|
||||
add edi, ProcessorNumberLocation
|
||||
mov ecx, dword ptr [edi + 4 * ebx] ; RCX = CpuNumber
|
||||
|
||||
mov edi, esi
|
||||
add edi, StackSizeLocation
|
||||
mov rax, qword ptr [edi]
|
||||
inc rcx
|
||||
mul rcx ; RAX = StackSize * (CpuNumber + 1)
|
||||
|
||||
mov edi, esi
|
||||
add edi, StackStartAddressLocation
|
||||
add rax, qword ptr [edi]
|
||||
mov rbx, qword ptr [edi]
|
||||
add rax, rbx ; RAX = StackStart + StackSize * (CpuNumber + 1)
|
||||
|
||||
mov rsp, rax
|
||||
mov qword ptr [edi], rax
|
||||
|
||||
Releaselock::
|
||||
|
||||
mov al, VacantFlag
|
||||
mov edi, esi
|
||||
add edi, LockLocation
|
||||
xchg byte ptr [edi], al
|
||||
|
||||
;
|
||||
; Call C Function
|
||||
|
Reference in New Issue
Block a user