From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Fri, 24 May 2019 02:43:46 -0700 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 260A13179161; Fri, 24 May 2019 09:43:44 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-245.rdu2.redhat.com [10.10.120.245]) by smtp.corp.redhat.com (Postfix) with ESMTP id 552AB5C239; Fri, 24 May 2019 09:43:40 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 0/6] Fix race condition and add event protocol To: devel@edk2.groups.io, zhichao.gao@intel.com Cc: Jian J Wang , Hao A Wu , Ray Ni , Star Zeng , Liming gao , Sean Brogan , Michael Turner , Bret Barkelew , Michael D Kinney , Eric Dong References: <20190524050437.38616-1-zhichao.gao@intel.com> From: "Laszlo Ersek" Message-ID: Date: Fri, 24 May 2019 11:43:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190524050437.38616-1-zhichao.gao@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 24 May 2019 09:43:45 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 05/24/19 07:04, Gao, Zhichao wrote: > There is a race condition in CoreWaitForEvent function: > If an interrupt happens between CheckEvent and gIdleLoopEvent, > there would be a event pending during cpu sleep. > So it is required to check the gEventPending with the interrupt > disabled. > Implement a gEfiCpu2ProtocolGuid to fix that. The protocol include > one interface to enable interrupt and put the cpu to sleep. > > Add a event protocol gEdkiiCommonEventProtocolGuid to support > all TPL event. It is require for PI drivers that use HW interrput. > > Cc: Jian J Wang > Cc: Hao A Wu > cc: Ray Ni > Cc: Star Zeng > Cc: Liming gao > Cc: Sean Brogan > Cc: Michael Turner > Cc: Bret Barkelew > Cc: Michael D Kinney > Cc: Eric Dong > Cc: Laszlo Ersek Thanks for the CC; I'll let others review this series. Thanks Laszlo > Sean Brogan (5): > MdeModulePkg: Add gEdkiiCommonEventProtocolGuid for event > MdePkg/BaseLib.h: Add EnableInterruptsAndSleep function declare > MdePkg/BaseLib: Implement EnableInterruptsAndSleep > MdePkg: Add gEfiCpu2ProtocolGuid and header file > MdeModulePkg/DxeMain: Implement common event protocol > > Zhichao Gao (1): > UefiCpuPkg/CpuDxe: Implement Cpu2 protocol > > MdeModulePkg/Core/Dxe/DxeMain.h | 64 ++++++++++- > MdeModulePkg/Core/Dxe/DxeMain.inf | 1 + > MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 22 ++++ > .../Core/Dxe/DxeMain/DxeProtocolNotify.c | 1 + > MdeModulePkg/Core/Dxe/Event/Event.c | 102 ++++++++++++++++-- > MdeModulePkg/Core/Dxe/Event/Event.h | 2 +- > MdeModulePkg/Include/Protocol/CommonEvent.h | 18 ++++ > MdeModulePkg/MdeModulePkg.dec | 3 + > MdePkg/Include/Library/BaseLib.h | 11 ++ > MdePkg/Include/Protocol/Cpu2.h | 43 ++++++++ > .../Library/BaseLib/Ia32/EnableInterrupts.c | 18 +++- > .../BaseLib/Ia32/EnableInterrupts.nasm | 15 ++- > .../Library/BaseLib/X64/EnableInterrupts.nasm | 15 ++- > MdePkg/MdePkg.dec | 3 + > UefiCpuPkg/CpuDxe/CpuDxe.c | 40 ++++++- > UefiCpuPkg/CpuDxe/CpuDxe.h | 15 +++ > UefiCpuPkg/CpuDxe/CpuDxe.inf | 3 +- > 17 files changed, 358 insertions(+), 18 deletions(-) > create mode 100644 MdeModulePkg/Include/Protocol/CommonEvent.h > create mode 100644 MdePkg/Include/Protocol/Cpu2.h >