From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=17.151.62.27; helo=mail-in5.apple.com; envelope-from=afish@apple.com; receiver=edk2-devel@lists.01.org Received: from mail-in5.apple.com (mail-out5.apple.com [17.151.62.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 595F3211D22F3 for ; Wed, 20 Jun 2018 20:24:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1529551498; x=2393465098; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-transfer-encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=rsjPFTar+UUz7TQKu1Fg0R/+ZXCwAL8hVfjx/fTpPQM=; b=pfddihJbRlKF+pEdkA/R6ffuAzuJ08p0qYV58KPVZRLkZgLjyhpBS4xBUW8TOOE7 RufEON38xC6IbnwfPcgaVJfw58UAAiQXQ071u/zthw4ltPYZ+04d7fHX6cmNZ0Vu dsSNNXk63E1oS8fqutB8z2mCaVd3biCmO+VKpzRHfjJxhPo29zd9B7/NM8vVe+j7 ky1zPCKr+rB2LMxw/ij0WatVEfZyG5EVelCaMwimWRmG5ZdmR4ZgzGbmmnBJ/f0G 2+3YwcC6fXPuyvEYEHqLsP6G0bK0SLZTd3DRVDOW+4GzlosF47F1mHV1sEzzvFfL rD6BDQ+7C5SkEKKK8vmu/w==; X-AuditID: 11973e13-615ff7000000242c-10-5b2b1a8a8fd1 Received: from mr2-mtap-s01.rno.apple.com (mr2-mtap-s01.rno.apple.com [17.179.226.133]) (using TLS with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail-in5.apple.com (Apple Secure Mail Relay) with SMTP id 86.B3.09260.A8A1B2B5; Wed, 20 Jun 2018 20:24:58 -0700 (PDT) MIME-version: 1.0 Received: from nwk-mmpp-sz09.apple.com (nwk-mmpp-sz09.apple.com [17.128.115.80]) by mr2-mtap-s01.rno.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) with ESMTPS id <0PAN006EULHMT280@mr2-mtap-s01.rno.apple.com>; Wed, 20 Jun 2018 20:24:58 -0700 (PDT) Received: from process_viserion-daemon.nwk-mmpp-sz09.apple.com by nwk-mmpp-sz09.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) id <0PAN00800L1IMI00@nwk-mmpp-sz09.apple.com>; Wed, 20 Jun 2018 20:24:58 -0700 (PDT) X-Va-A: X-Va-T-CD: 81ca60fce39c2560b6c4a7e5841f9b8f X-Va-E-CD: 88424f74c62f8a227cceea89a971252d X-Va-R-CD: b57751ffccc5b87796cbc4be9a251208 X-Va-CD: 0 X-Va-ID: 513c29dd-c42f-4789-891e-b47e54137fa8 X-V-A: X-V-T-CD: c589860349450d19dc65d557cec07725 X-V-E-CD: 88424f74c62f8a227cceea89a971252d X-V-R-CD: b57751ffccc5b87796cbc4be9a251208 X-V-CD: 0 X-V-ID: 72b7c477-1f91-415a-9cae-daba7b4a2dbe Received: from process_milters-daemon.nwk-mmpp-sz09.apple.com by nwk-mmpp-sz09.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) id <0PAN00800L1FMH00@nwk-mmpp-sz09.apple.com>; Wed, 20 Jun 2018 20:24:58 -0700 (PDT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-21_01:,, signatures=0 X-Proofpoint-Scanner-Instance: nwk-grpmailp-qapp18.corp.apple.com-10000_instance1 Received: from [17.234.93.249] (unknown [17.234.93.249]) by nwk-mmpp-sz09.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) with ESMTPSA id <0PAN003KFLHLWAB0@nwk-mmpp-sz09.apple.com>; Wed, 20 Jun 2018 20:24:58 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: <734D49CCEBEEF84792F5B80ED585239D5BD3F73E@SHSMSX104.ccr.corp.intel.com> Date: Wed, 20 Jun 2018 20:24:56 -0700 Cc: edk2-devel Message-id: <1800C800-ED89-4C23-89CB-E8E5E1CCE672@apple.com> References: <31C6D3FB-91D3-491B-8059-4B6DEA11BDF9@apple.com> <734D49CCEBEEF84792F5B80ED585239D5BD3F73E@SHSMSX104.ccr.corp.intel.com> To: "Ni, Ruiyu" X-Mailer: Apple Mail (2.3445.6.18) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOIsWRmVeSWpSXmKPExsUiuPlRq26XlHa0wYR2HYs9h44yW7zsWc3u wOSxeM9LJo/u2f9YApiiuGxSUnMyy1KL9O0SuDIm909lKWhSqjg2/RlLA+NLyS5GTg4JAROJ 3Xc2sXQxcnEICRxgktj/4SwbSIJXQFDix+R7QAkODmYBeYmD52VBwswCWhLfH7WygNhCAuuY JBa8FIXo7WKS2PPoOiPEUHaJP792sEDY2hJLvy5ghrHv3lzCDmPv2nmQCcLmkliw9TQrhK0r ceDTEiibTWL9iSVQNVoSS46dYoezd15ng7HfbpoGNZ9T4vyXiVA1OhJHv/xlhziuE+jQo2eg irIl3szbAfaYhECwxP63yhA1E5kkXrVvARsqLCAu8e7MJmYIO1/i8N7DYDabgLLEivkfwBZw CoRJ3Hi4AMxmEVCV6LjwgBESQhoSX1dvZ4cEoo3E+n3bGCEWtDFKNPxrBvtMREBFYta6X8wT GBVnIQX2LERgz0IK7AWMzKsYhXITM3N0M/NM9RILCnJS9ZLzczcxglLCdDvhHYynV1kdYhTg YFTi4W0I0YoWYk0sK67MPcQozcGiJM57JEkjWkggPbEkNTs1tSC1KL6oNCe1+BAjEwenVAOj /v7Fgvtnib54/Va++P+c0/6fn68oydj35aHLPYvglu0aK3Yfdu6J3P/Rvpll7aO6N/G5zprx Sq/EPB+J6WX364n4STMxqz/6Z9IwP+LI8fB1ckdi/QpTn3Gs9hDK7ijweZP05Rdvdz6zUitb nP45v2qeE2unxF46xrn161bD12fymcU56zqVWIozEg21mIuKEwHJSbsP6gIAAA== Subject: Re: Is the PEI Core MP Safe? UefiCpuPkg seems to think so calling GetFirstGuidHob on the APs? X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2018 03:24:59 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII > On Jun 20, 2018, at 8:06 PM, Ni, Ruiyu wrote: > > Andrew, > Good catch! It does break the rule that AP shouldn't call PEI services. > But considering the specific case, it should be safe. > Because: > 1. HOB only stores a pointer to the buffer that contains all the MP information. > 2. BSP modifies the HOB by only appending data to the end. It may modifies some HOB content. But MpInitLib > implementation itself doesn't modify the pointer value stored in HOB. > Ray, I think the should be safe is also making assumptions about the debug and a few other library instances that got tested against. It is not really an architectural guaranty against the library classes that could be linked. We don't use the default It would be good to use an IDT entry, or optionally a global variable if memory is present, longer term. Thanks, Andrew Fish > In PEI environment where global variable is read-only, it's hard to not rely on HOB. > I guess that's the reason of today's tricky implementation. > > Thanks/Ray > >> -----Original Message----- >> From: edk2-devel On Behalf Of Andrew >> Fish >> Sent: Thursday, June 21, 2018 1:23 AM >> To: edk2-devel >> Subject: [edk2] Is the PEI Core MP Safe? UefiCpuPkg seems to think so calling >> GetFirstGuidHob on the APs? >> >> 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/MpIni >> tLib/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/MpIni >> tLib/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/MpIni >> tLib/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 >> _______________________________________________ >> edk2-devel mailing list >> edk2-devel@lists.01.org >> https://lists.01.org/mailman/listinfo/edk2-devel > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel