From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 9ECB2211F886B for ; Tue, 26 Jun 2018 00:49:59 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2018 00:49:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,274,1526367600"; d="scan'208";a="235636600" Received: from ray-dev.ccr.corp.intel.com (HELO [10.239.9.4]) ([10.239.9.4]) by orsmga005.jf.intel.com with ESMTP; 26 Jun 2018 00:49:58 -0700 To: edk2-devel@lists.01.org References: <20180625025402.201636-1-ruiyu.ni@intel.com> <5d25617f-8710-9d7f-8795-30b004326515@redhat.com> <7c6ac3f2-0bbf-fa7d-0107-34656a9faf9c@redhat.com> From: "Ni, Ruiyu" Message-ID: Date: Tue, 26 Jun 2018 15:50:19 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <7c6ac3f2-0bbf-fa7d-0107-34656a9faf9c@redhat.com> Subject: Re: [PATCH] UefiCpuPkg/MpInitLib: AP uses memory preceding IDT to store CpuMpData 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: Tue, 26 Jun 2018 07:49:59 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 6/26/2018 1:01 AM, Laszlo Ersek wrote: > On 06/25/18 18:01, Laszlo Ersek wrote: >> Hello Ray, >> >> On 06/25/18 04:54, Ruiyu Ni wrote: >>> Today's MpInitLib PEI implementation directly calls >>> PeiServices->GetHobList() from AP which may cause racing issue. >>> >>> This patch fixes this issue by storing the CpuMpData to memory >>> preceding IDT. Pointer to PeiServices pointer is stored there, >>> so after AP procedure returns, the PeiServices pointer should be >>> restored. >>> >>> Contributed-under: TianoCore Contribution Agreement 1.1 >>> Signed-off-by: Ruiyu Ni >>> Cc: Jeff Fan >>> Cc: Eric Dong >>> Cc: Jiewen Yao >>> Cc: Fish Andrew >>> --- >>> UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 33 ++++++++++++++++++- >>> UefiCpuPkg/Library/MpInitLib/MpLib.c | 8 +++++ >>> UefiCpuPkg/Library/MpInitLib/MpLib.h | 27 +++++++++++++++- >>> UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 56 +++++++++++++++++++++++++++++++-- >>> 4 files changed, 119 insertions(+), 5 deletions(-) >>> >>> diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c >>> index e7ed21c6cd..26fead2c66 100644 >>> --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c >>> +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c >> >> [snip] >> >>> +/** >>> + Pop the CpuMpData. >>> + >>> + @param[in] Pointer The pointer value which was stored in where the CPU MP Data is pushed. >>> + @param[in] Context The context of push/pop operation. >>> +**/ >>> +VOID >>> +PopCpuMpData ( >>> + IN VOID *Pointer, >>> + IN VOID *Context >>> + ) >>> +{ >> >> (1) When I applied this patch for regression-testing, "git am" >> complained that the above line added two trailing space characters. Can >> you please remove them? >> >> (2) Other than that, I tested this patch with OVMF -- the patch breaks >> OVMF. The last part of the log is: >> >>> Loading PEIM [CpuMpPei] >>> Loading PEIM at 0x000BFE81000 EntryPoint=0x000BFE86DC6 CpuMpPei.efi >>> AP Loop Mode is 1 >>> WakeupBufferStart = 9F000, WakeupBufferSize = 1000 >>> TimedWaitForApFinish: reached FinishedApLimit=7 in 121 microseconds >>> APIC MODE is 1 >>> MpInitLib: Find 8 processors in system. >>> Does not find any stored CPU BIST information from PPI! >>> APICID - 0x00000000, BIST - 0x00000000 >>> APICID - 0x00000001, BIST - 0x00000000 >>> APICID - 0x00000002, BIST - 0x00000000 >>> APICID - 0x00000003, BIST - 0x00000000 >>> APICID - 0x00000004, BIST - 0x00000000 >>> APICID - 0x00000005, BIST - 0x00000000 >>> APICID - 0x00000006, BIST - 0x00000000 >>> APICID - 0x00000007, BIST - 0x00000000 >>> Install PPI: [EfiSecPlatformInformation2Ppi] >>> Install PPI: [EfiPeiMpServicesPpi] >>> Notify: PPI Guid: [EfiPeiMpServicesPpi], Peim notify entry point: 8524F8 >>> PlatformPei: OnMpServicesAvailable > > Sorry, I failed to mention: after the last line is printed, the boot > process is stuck, and all CPUs appear spinning. I tried to directly boot OVMF in my Win10. The OnMpServicesAvailable() is not called because the PPI notification is not installed. So I tried to modify InstallFeatureControlCallback() in PlatformPei/FeatureControl.c to unconditionally call "PeiServicesNotifyPpi (&mMpServicesNotify);". The new image can boot to Shell and I can find "OnMpServicesAvailable" debug message in the log. > > Thanks > Laszlo > >> The last line is printed by OvmfPkg/PlatformPei, in >> "OvmfPkg/PlatformPei/FeatureControl.c". OVMF uses >> EFI_PEI_MP_SERVICES_PPI to write the Feature Control MSR on all CPUs. >> >> https://github.com/tianocore/tianocore.github.io/wiki/Testing-SMM-with-QEMU,-KVM-and-libvirt#enable-nested-virtualization >> https://github.com/tianocore/tianocore.github.io/wiki/Testing-SMM-with-QEMU,-KVM-and-libvirt#confirm-simple-multiprocessing-during-boot >> >> Thanks, >> Laszlo >> _______________________________________________ >> 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 > -- Thanks, Ray