From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: zhichao.gao@intel.com) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by groups.io with SMTP; Thu, 23 May 2019 22:04:44 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 May 2019 22:04:43 -0700 X-ExtLoop1: 1 Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga001.fm.intel.com with ESMTP; 23 May 2019 22:04:39 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Ray Ni , Star Zeng , Liming gao , Sean Brogan , Michael Turner , Bret Barkelew , Michael D Kinney , Eric Dong , Laszlo Ersek Subject: [PATCH 0/6] Fix race condition and add event protocol Date: Fri, 24 May 2019 13:04:31 +0800 Message-Id: <20190524050437.38616-1-zhichao.gao@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 -- 2.21.0.windows.1