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 4DA54203369CE for ; Mon, 25 Jun 2018 09:01:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C7A340122DE; Mon, 25 Jun 2018 16:01:23 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-200.rdu2.redhat.com [10.10.120.200]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F6777C30; Mon, 25 Jun 2018 16:01:22 +0000 (UTC) To: Ruiyu Ni Cc: edk2-devel@lists.01.org, Jiewen Yao , Eric Dong , Fish Andrew References: <20180625025402.201636-1-ruiyu.ni@intel.com> From: Laszlo Ersek Message-ID: <5d25617f-8710-9d7f-8795-30b004326515@redhat.com> Date: Mon, 25 Jun 2018 18:01: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: <20180625025402.201636-1-ruiyu.ni@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 25 Jun 2018 16:01:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 25 Jun 2018 16:01:23 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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: Mon, 25 Jun 2018 16:01:24 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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 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