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.20, mailfrom: zhichao.gao@intel.com) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by groups.io with SMTP; Tue, 09 Jul 2019 01:40:45 -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 orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jul 2019 01:40:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,470,1557212400"; d="scan'208";a="185865575" Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga001.fm.intel.com with ESMTP; 09 Jul 2019 01:40:00 -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 Subject: [PATCH V2 0/4] Fix race condition and add event protocol Date: Tue, 9 Jul 2019 16:39:52 +0800 Message-Id: <20190709083956.13024-1-zhichao.gao@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit V1: 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. V2: Move EnableInterruptsAndSleep to UefiCpuPkg/CpuDxe. It is inappropiate to add it to MdePkg which should only contain code base on the UEFI spec. Change the name gEfiCpu2ProtocolGuid to gEdkiiCpu2ProtocolGuid. 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 Sean Brogan (3): MdeModulePkg: Add gEdkiiCpu2ProtocolGuid and header file UefiCpuPkg/CpuDxe: Implement Cpu2 protocol MdeModulePkg/DxeMain: Implement common event protocol Zhichao Gao (1): MdeModulePkg: Add gEdkiiCommonEventProtocolGuid for creating event MdeModulePkg/Core/Dxe/DxeMain.h | 64 ++++++++++- MdeModulePkg/Core/Dxe/DxeMain.inf | 2 + 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/Include/Protocol/Cpu2.h | 43 ++++++++ MdeModulePkg/MdeModulePkg.dec | 6 ++ UefiCpuPkg/CpuDxe/CpuDxe.c | 38 +++++++ UefiCpuPkg/CpuDxe/CpuDxe.h | 25 +++++ UefiCpuPkg/CpuDxe/CpuDxe.inf | 3 + .../CpuDxe/Ia32/EnableInterruptsAndSleep.c | 24 +++++ .../CpuDxe/X64/EnableInterruptsAndSleep.nasm | 31 ++++++ 14 files changed, 368 insertions(+), 13 deletions(-) create mode 100644 MdeModulePkg/Include/Protocol/CommonEvent.h create mode 100644 MdeModulePkg/Include/Protocol/Cpu2.h create mode 100644 UefiCpuPkg/CpuDxe/Ia32/EnableInterruptsAndSleep.c create mode 100644 UefiCpuPkg/CpuDxe/X64/EnableInterruptsAndSleep.nasm -- 2.21.0.windows.1