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.29; helo=mail-in7.apple.com; envelope-from=afish@apple.com; receiver=edk2-devel@lists.01.org Received: from mail-in7.apple.com (mail-out7.apple.com [17.151.62.29]) (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 4C179210D512B for ; Fri, 22 Jun 2018 10:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1529688736; x=2393602336; 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=7thYerXagyPuCGJm6XTvIUSXmIUG+JVWUDsfV5rvoiE=; b=3N4rO9iNJ8nyf5hKtZGGlIEK4IVUuSZ507mAsYsRel8SDq2YG3LP/eNtDXRsyyvk Wk9bJHKAbCmn7+P5JuXf3mUR2toa8Plkq2jlf3uhnFO+pRqvyzJDIODEjJWibQXg QmnJBDfAJk53OHfno4AEhRgPhimc8kUxMfgZzUYpykRt2FqwfaYT9TF4Xzd1JaKr S4RARzjhecuXUohOY2olk/dd75Pzo4ngXKJkQ/yYPdhlYNLQ5auL/RETxf32+mYc pSu9tPWdoXYwS6kbWHsI5kdlV6qnFQ1p0LpEt3jsltVCDr2ENigoOeIjjdh5CT9R kC2b8KjzlqTRHpILcELHnA==; X-AuditID: 11973e16-6f1ff7000000740c-e7-5b2d32a0d849 Received: from mr2-mtap-s02.rno.apple.com (mr2-mtap-s02.rno.apple.com [17.179.226.134]) (using TLS with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail-in7.apple.com (Apple Secure Mail Relay) with SMTP id D5.88.29708.0A23D2B5; Fri, 22 Jun 2018 10:32:16 -0700 (PDT) MIME-version: 1.0 Received: from nwk-mmpp-sz10.apple.com (nwk-mmpp-sz10.apple.com [17.128.115.122]) by mr2-mtap-s02.rno.apple.com (Oracle Communications Messaging Server 8.0.2.2.20180329 64bit (built Mar 29 2018)) with ESMTPS id <0PAQ002V1JDSRZA0@mr2-mtap-s02.rno.apple.com>; Fri, 22 Jun 2018 10:32:16 -0700 (PDT) Received: from process_viserion-daemon.nwk-mmpp-sz10.apple.com by nwk-mmpp-sz10.apple.com (Oracle Communications Messaging Server 8.0.2.2.20180403 64bit (built Apr 3 2018)) id <0PAQ00800J9ZPI00@nwk-mmpp-sz10.apple.com>; Fri, 22 Jun 2018 10:32:16 -0700 (PDT) X-Va-A: X-Va-T-CD: 80f7f64350c3d190af1fc1690cc45ec5 X-Va-E-CD: 0f82c4678ce802350f2a587b62689ca8 X-Va-R-CD: 9947056c3c3f1e59b63ef382061924c2 X-Va-CD: 0 X-Va-ID: 62a71a3e-279a-4fa9-abca-d7de124c2d21 X-V-A: X-V-T-CD: 002984488131224790a9d425531708b1 X-V-E-CD: 0f82c4678ce802350f2a587b62689ca8 X-V-R-CD: 9947056c3c3f1e59b63ef382061924c2 X-V-CD: 0 X-V-ID: f393ecc0-646b-4eb3-b878-ab1e074df5c6 Received: from process_milters-daemon.nwk-mmpp-sz10.apple.com by nwk-mmpp-sz10.apple.com (Oracle Communications Messaging Server 8.0.2.2.20180403 64bit (built Apr 3 2018)) id <0PAQ00800J9OOY00@nwk-mmpp-sz10.apple.com>; Fri, 22 Jun 2018 10:32:16 -0700 (PDT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-22_03:,, signatures=0 X-Proofpoint-Scanner-Instance: nwk-grpmailp-qapp14.corp.apple.com-10000_instance1 Received: from [17.235.0.203] (unknown [17.235.0.203]) by nwk-mmpp-sz10.apple.com (Oracle Communications Messaging Server 8.0.2.2.20180403 64bit (built Apr 3 2018)) with ESMTPSA id <0PAQ004JNJDRGVB0@nwk-mmpp-sz10.apple.com>; Fri, 22 Jun 2018 10:32:16 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: Date: Fri, 22 Jun 2018 10:32:14 -0700 Cc: "Ni, Ruiyu" , edk2-devel Message-id: References: <31C6D3FB-91D3-491B-8059-4B6DEA11BDF9@apple.com> <734D49CCEBEEF84792F5B80ED585239D5BD3F73E@SHSMSX104.ccr.corp.intel.com> <1800C800-ED89-4C23-89CB-E8E5E1CCE672@apple.com> To: Fan Jeff X-Mailer: Apple Mail (2.3445.6.18) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPIsWRmVeSWpSXmKPExsUiuPlRm+4CI91og+XN+hZ7Dh1ltnjZs5rd 4sTneWwOzB6Pe86weSze85LJo3v2P5YA5igum5TUnMyy1CJ9uwSujO/HRAveGVZ8ulDUwLhN vYuRk0NCwETi1sF2li5GLg4hgQNMEkvv7mACSfAKCEr8mHwPKMHBwSygLjFlSi5EzXomiZfH /kE1dDFJNP1azQYxiV3iz68dLBC2tsTlrjZGGLv1wHG4+JXHm5kgbC6JBVtPs4IskBDQlWh/ EwIRZpNYf2IJE0RYS2L6e26IsJZEz5pDzDD2gxMPoKZzSpz/MpEdolxH4tWjGIjLOpkkNh2f C1WfLdEw4TfUBcESJ9c1skMU9TNJnNw8jR0kISwgLvHuzCZmkISwwA5GifvPIe5nE1CWWDH/ A1gRp0C8xP/pG8AmsQioShx/9wJsA7OAl8ShozuZIGxtiSfvLrBCAtFG4u6Bd0wQ23qYJPYc PwnWICKgJnFpzkO2CYyKs5ACexYisGchGbWAkXkVo1BuYmaObmaeuV5iQUFOql5yfu4mRlCK mG4ntoPx4SqrQ4wCHIxKPLwaX3WihVgTy4orcw8xSnOwKInz+pkDhQTSE0tSs1NTC1KL4otK c1KLDzEycXBKNTDmnbqsb/s64bWwTkzEz0drLmhMOfDQw/XxXSafFxXzNE+cbX4t0P5d9OE7 zb2Pyny75rxRSJzz/mkrT2Wx23OXo4aF8yZOkrkRHXkmYJ53HdeBCTUvhDVn+pw8s2FHxJLe Gft2s2xbtyPCwVty4/mPV0x2qrvUzrl6t9Wyz+7sp79PLt16s0/siBJLcUaioRZzUXEiAJBq jxfyAgAA Subject: =?UTF-8?B?UmU6IOetlOWkjTogSXMgdGhlIFBFSSBDb3JlIE1QIFNhZmU/IFVlZmlDcHVQa2cgc2VlbXMgdG8gdGhpbmsgc28gY2FsbGluZyBHZXRGaXJzdEd1aWRIb2Igb24gdGhlIEFQcz8=?= 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: Fri, 22 Jun 2018 17:32:17 -0000 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: quoted-printable Jeff, I forgot to mention I found this issue by inspection, but I I'm chasing = 2 MP issues in our internal code base. I'm not sure if it is the = UefiCpuPkg code, the consumers code, or something else that is causing = the issues.=20 1) I'm seeing an intermittent issue in PEI and it looks like one of the = APs is getting disabled, and a required configuration step is being = skipped.=20 2) I turned on the mwait AP Idle (I also add BSP mwait idle) and one of = our very complicated DXE MP functions started failing.=20 I'm hoping to get an ITP (JTAG debugger) setup next week and get more = info on what is happening.=20 Thanks, Andrew Fish > On Jun 21, 2018, at 11:52 PM, Fan Jeff = wrote: >=20 > Andrew, >=20 > Not all services are permitted for AP routines. For example, = MP->WhoAmI() could be invoked by AP by specified >=20 > Current implementation should be safe. I also agree with IDT entry = solution, as we did in DebugAgentLib. >=20 > Thanks! > Jeff >=20 > =E5=8F=91=E4=BB=B6=E4=BA=BA: Andrew Fish > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2018=E5=B9=B46=E6=9C=8821=E6=97=A5= 11:25 > =E6=94=B6=E4=BB=B6=E4=BA=BA: Ni, Ruiyu > =E6=8A=84=E9=80=81: edk2-devel > =E4=B8=BB=E9=A2=98: Re: [edk2] Is the PEI Core MP Safe? UefiCpuPkg = seems to think so calling GetFirstGuidHob on the APs? >=20 >=20 >=20 >> On Jun 20, 2018, at 8:06 PM, Ni, Ruiyu wrote: >>=20 >> 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. >>=20 >=20 > Ray, >=20 > 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 >=20 > It would be good to use an IDT entry, or optionally a global variable = if memory is present, longer term. >=20 > Thanks, >=20 > Andrew Fish >=20 >> 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. >>=20 >> Thanks/Ray >>=20 >>> -----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? >>>=20 >>> Is there some MP safe contract with the PEI Core implementation I = don't >>> know about? >>>=20 >>> Looks like the APs are calling PeiServicesGetHobList() to figure out = "who they >>> are"? How does this work? Or am I missing something? >>>=20 >>>=20 >>> = https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/MpIni >>> tLib/MpLib.c#L1945 >>>=20 >>> /** >>> 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; >>>=20 >>> if (ProcessorNumber =3D=3D NULL) { >>> return EFI_INVALID_PARAMETER; >>> } >>>=20 >>> CpuMpData =3D GetCpuMpData (); >>>=20 >>> return GetProcessorNumber (CpuMpData, ProcessorNumber); } >>>=20 >>>=20 >>> = https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/MpIni >>> tLib/PeiMpLib.c#L34 >>>=20 >>> /** >>> Get pointer to CPU MP Data structure. >>> @return The pointer to CPU MP Data structure. >>> **/ >>> CPU_MP_DATA * >>> GetCpuMpData ( >>> VOID >>> ) >>> { >>> CPU_MP_DATA *CpuMpData; >>>=20 >>> CpuMpData =3D GetCpuMpDataFromGuidedHob (); >>> ASSERT (CpuMpData !=3D NULL); >>> return CpuMpData; >>> } >>>=20 >>> = https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/MpIni >>> tLib/MpLib.c#L2302 >>>=20 >>>=20 >>> /** >>> 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; >>>=20 >>> CpuMpData =3D NULL; >>> GuidHob =3D GetFirstGuidHob (&mCpuInitMpLibHobGuid); >>> if (GuidHob !=3D NULL) { >>> DataInHob =3D GET_GUID_HOB_DATA (GuidHob); >>> CpuMpData =3D (CPU_MP_DATA *) (*(UINTN *) DataInHob); >>> } >>> return CpuMpData; >>> } >>>=20 >>> Thanks, >>>=20 >>> 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 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel