public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Is the PEI Core MP Safe? UefiCpuPkg seems to think so calling GetFirstGuidHob on the APs?
@ 2018-06-20 17:23 Andrew Fish
  2018-06-21  3:06 ` Ni, Ruiyu
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Fish @ 2018-06-20 17:23 UTC (permalink / raw)
  To: edk2-devel

Is there some MP safe contract with the PEI Core implementation I don't know about? 

Looks like the APs are calling PeiServicesGetHobList() to figure out "who they are"? How does this work? Or am I missing something?


https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/MpInitLib/MpLib.c#L1945

/**
  This return the handle number for the calling processor.  This service may be
  called from the BSP and APs.
  @param[out] ProcessorNumber  Pointer to the handle number of AP.
                               The range is from 0 to the total number of
                               logical processors minus 1. The total number of
                               logical processors can be retrieved by
                               MpInitLibGetNumberOfProcessors().
  @retval EFI_SUCCESS             The current processor handle number was returned
                                  in ProcessorNumber.
  @retval EFI_INVALID_PARAMETER   ProcessorNumber is NULL.
  @retval EFI_NOT_READY           MP Initialize Library is not initialized.
**/
EFI_STATUS
EFIAPI
MpInitLibWhoAmI (
  OUT UINTN                    *ProcessorNumber
  )
{
  CPU_MP_DATA           *CpuMpData;

  if (ProcessorNumber == NULL) {
    return EFI_INVALID_PARAMETER;
  }

  CpuMpData = GetCpuMpData ();

  return GetProcessorNumber (CpuMpData, ProcessorNumber);
}


https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c#L34

/**
  Get pointer to CPU MP Data structure.
  @return  The pointer to CPU MP Data structure.
**/
CPU_MP_DATA *
GetCpuMpData (
  VOID
  )
{
  CPU_MP_DATA      *CpuMpData;

  CpuMpData = GetCpuMpDataFromGuidedHob ();
  ASSERT (CpuMpData != NULL);
  return CpuMpData;
}

https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/MpInitLib/MpLib.c#L2302


/**
  Get pointer to CPU MP Data structure from GUIDed HOB.
  @return  The pointer to CPU MP Data structure.
**/
CPU_MP_DATA *
GetCpuMpDataFromGuidedHob (
  VOID
  )
{
  EFI_HOB_GUID_TYPE       *GuidHob;
  VOID                    *DataInHob;
  CPU_MP_DATA             *CpuMpData;

  CpuMpData = NULL;
  GuidHob = GetFirstGuidHob (&mCpuInitMpLibHobGuid);
  if (GuidHob != NULL) {
    DataInHob = GET_GUID_HOB_DATA (GuidHob);
    CpuMpData = (CPU_MP_DATA *) (*(UINTN *) DataInHob);
  }
  return CpuMpData;
}

Thanks,

Andrew Fish


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-06-22 17:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-20 17:23 Is the PEI Core MP Safe? UefiCpuPkg seems to think so calling GetFirstGuidHob on the APs? Andrew Fish
2018-06-21  3:06 ` Ni, Ruiyu
2018-06-21  3:24   ` Andrew Fish
2018-06-21  3:34     ` Ni, Ruiyu
2018-06-21  5:57       ` Dong, Eric
2018-06-22  6:52     ` 答复: " Fan Jeff
2018-06-22 17:32       ` Andrew Fish

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox