It is not legal to call anything EFI from the AP.

You might get lucky, but you are just winning the race, due to luck.

A AP safe DebugLib instance would be useful. Locks and reentrantcy 
Safe.

Sent from my iPhone

> On Jul 31, 2014, at 11:23 AM, Jordan Justen <jljus...@gmail.com> wrote:
> 
>> On Thu, Jul 31, 2014 at 2:58 AM, Chen Fan <chen.fan.f...@cn.fujitsu.com> 
>> wrote:
>> we allocate Stack for each AP via Memory Allocation Services. then
>> we can free the temporary stack at the end.
>> 
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Chen Fan <chen.fan.f...@cn.fujitsu.com>
>> ---
>> UefiCpuPkg/CpuDxe/CpuMp.c      | 14 +++++++++++++-
>> UefiCpuPkg/CpuDxe/Ia32/MpAsm.S |  2 ++
>> UefiCpuPkg/CpuDxe/X64/MpAsm.S  |  7 ++++++-
>> 3 files changed, 21 insertions(+), 2 deletions(-)
>> 
>> diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c
>> index 1d1ed3a..ca92d37 100644
>> --- a/UefiCpuPkg/CpuDxe/CpuMp.c
>> +++ b/UefiCpuPkg/CpuDxe/CpuMp.c
>> @@ -19,12 +19,24 @@ VOID *mCommonStack = 0;
>> VOID *mTopOfApCommonStack = 0;
>> 
>> 
>> -VOID
>> +VOID*
>> EFIAPI
>> ApEntryPointInC (
>>   VOID
>>   )
>> {
>> +  VOID *ThisCommonStack = 0;
>> +  VOID *ThisTopOfApCommonStack = 0;
>> +
>> +  // Allocate this processor stack space.
>> +  ThisCommonStack = AllocatePages (EFI_SIZE_TO_PAGES (SIZE_64KB));
> 
> Mike, Andrew, all,
> 
> Can AP's use BootServices?
> 
> Is it okay if they ensure the BSP is not using any services? Or, do we
> need to have the BSP do all the BootServices memory allocations?
> 
>> +  ASSERT(ThisCommonStack != NULL);
>> +
>> +  ThisTopOfApCommonStack = (VOID*) ((UINTN)ThisCommonStack + SIZE_64KB);
>> +
>> +  DEBUG((DEBUG_ERROR, "!!%d: %p\n", GetApicId(), ThisTopOfApCommonStack));
>> +
>> +  return ThisTopOfApCommonStack;
> 
> Can we instead use SwitchStack?
> 
> My thought is ApEntryPointInC will switch the AP to its own stack and
> then call AsmApDoneWithCommonStack. The AP will never return from
> ApEntryPointInC, and it would enter a spin loop of some sort where it
> could wait to be dispatched to run code later.
> 
> -Jordan
> 
>> }
>> 
>> 
>> diff --git a/UefiCpuPkg/CpuDxe/Ia32/MpAsm.S b/UefiCpuPkg/CpuDxe/Ia32/MpAsm.S
>> index 2b3d298..8252263 100644
>> --- a/UefiCpuPkg/CpuDxe/Ia32/MpAsm.S
>> +++ b/UefiCpuPkg/CpuDxe/Ia32/MpAsm.S
>> @@ -34,7 +34,9 @@ lock btsl   $0, ApStackLock
>>     jc      AsmApEntryPointAcquireLock
>> 
>>     movl    (ASM_PFX(mTopOfApCommonStack)), %esp
>> +    sub     $0x8, %esp
>>     call    ASM_PFX(ApEntryPointInC)
>> +    movl    %eax, %esp
>> 
>>     cli
>> 
>> diff --git a/UefiCpuPkg/CpuDxe/X64/MpAsm.S b/UefiCpuPkg/CpuDxe/X64/MpAsm.S
>> index cfad551..b03b043 100644
>> --- a/UefiCpuPkg/CpuDxe/X64/MpAsm.S
>> +++ b/UefiCpuPkg/CpuDxe/X64/MpAsm.S
>> @@ -34,7 +34,9 @@ lock btsl   $0, ApStackLock
>>     jc      AsmApEntryPointAcquireLock
>> 
>>     movq    (ASM_PFX(mTopOfApCommonStack)), %rsp
>> +    sub     $0x20, %rsp
>>     call    ASM_PFX(ApEntryPointInC)
>> +    movq    %rax, %rsp
>> 
>>     cli
>> 
>> @@ -46,7 +48,10 @@ AsmApEntryPointShareLock:
>>     decl    %eax
>>     jnz     AsmApEntryPointShareLock
>> 
>> -    jmp     ASM_PFX(AsmApEntryPoint)
>> +    sti
>> +loop:
>> +    hlt
>> +    jmp loop
>> 
>> #------------------------------------------------------------------------------
>> # VOID
>> --
>> 1.9.3
>> 

------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls. 
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to