From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (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 929792096FAB1 for ; Tue, 26 Jun 2018 05:52:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EAAF2DBDA; Tue, 26 Jun 2018 12:52:22 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-235.rdu2.redhat.com [10.10.120.235]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E7F22026D6A; Tue, 26 Jun 2018 12:52:22 +0000 (UTC) To: "Ni, Ruiyu" , 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: Laszlo Ersek Message-ID: <9a48b641-b71d-970c-25ed-f532ebb22afe@redhat.com> Date: Tue, 26 Jun 2018 14:52:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 26 Jun 2018 12:52:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 26 Jun 2018 12:52:22 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' 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 12:52:24 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Hi Ray, On 06/26/18 09:50, Ni, Ruiyu wrote: > 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. When you run QEMU on Windows, that means that QEMU uses "TCG" (Tiny Code Generator), which is a Just In Time compiler that runs the guest code with software emulation. That's not the production use of QEMU. For using QEMU with hardware virtualization (Intel vmx / AMD svm), please run QEMU on Linux, with KVM. This is documented in the Wiki article I referenced earlier -- the article specifically targets developers with a Windows background. You only need one Linux server (not desktop) for testing; for the interactive parts, you can use your usual Windows workstation. Thanks Laszlo