From: "Gao, Zhichao" <zhichao.gao@intel.com>
To: "Ni, Ray" <ray.ni@intel.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Wang, Jian J" <jian.j.wang@intel.com>,
"Wu, Hao A" <hao.a.wu@intel.com>,
"Zeng, Star" <star.zeng@intel.com>,
"Gao, Liming" <liming.gao@intel.com>,
Sean Brogan <sean.brogan@microsoft.com>,
Michael Turner <Michael.Turner@microsoft.com>,
Bret Barkelew <Bret.Barkelew@microsoft.com>,
"Kinney, Michael D" <michael.d.kinney@intel.com>,
"Dong, Eric" <eric.dong@intel.com>,
Laszlo Ersek <lersek@redhat.com>
Subject: Re: [PATCH 0/6] Fix race condition and add event protocol
Date: Fri, 24 May 2019 07:47:50 +0000 [thread overview]
Message-ID: <3CE959C139B4C44DBEA1810E3AA6F9000B7D4F48@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5C15E506@SHSMSX104.ccr.corp.intel.com>
Sorry I didn't add the BZ link.
https://bugzilla.tianocore.org/show_bug.cgi?id=1400
"If an interrupt happens between CheckEvent and gIdleLoopEvent, there would be a event pending during cpu sleep."
Here is the wait for event flow:
Result = CheckEvent
(interrupt happens here, and set the gEventPending)
Result == FALSE
Ilde event (put cpu to sleep)(there are events in pending list and they should be handle, but the cpu is hlt and cannot handle it)
Solution is here:
Result = CheckEvent
(interrupt happens)
Disable interrupt
PendingResult = Check gEventPending
If gEventPending == TRUE {
Enable interrupt and goto CheckEvent to handle
} else {
Enable interrupt and hlt (this should be 'atomic' so that no race condition would happen)
}
Thanks,
Zhichao
> -----Original Message-----
> From: Ni, Ray
> Sent: Friday, May 24, 2019 1:18 PM
> To: Gao, Zhichao <zhichao.gao@intel.com>; devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Zeng, Star <star.zeng@intel.com>; Gao, Liming <liming.gao@intel.com>;
> Sean Brogan <sean.brogan@microsoft.com>; Michael Turner
> <Michael.Turner@microsoft.com>; Bret Barkelew
> <Bret.Barkelew@microsoft.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>; Dong, Eric <eric.dong@intel.com>; Laszlo
> Ersek <lersek@redhat.com>
> Subject: RE: [PATCH 0/6] Fix race condition and add event protocol
>
> Zhichao,
> Did your detailed patch commit message describe the consequence of the
> race condition? (I haven't checked.) If no, could you please describe in detail
> about the consequence?
>
> Thanks,
> Ray
>
> > -----Original Message-----
> > From: Gao, Zhichao
> > Sent: Friday, May 24, 2019 1:05 PM
> > To: devel@edk2.groups.io
> > Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A
> > <hao.a.wu@intel.com>; Ni, Ray <ray.ni@intel.com>; Zeng, Star
> > <star.zeng@intel.com>; Gao, Liming <liming.gao@intel.com>; Sean Brogan
> > <sean.brogan@microsoft.com>; Michael Turner
> > <Michael.Turner@microsoft.com>; Bret Barkelew
> > <Bret.Barkelew@microsoft.com>; Kinney, Michael D
> > <michael.d.kinney@intel.com>; Dong, Eric <eric.dong@intel.com>; Laszlo
> > Ersek <lersek@redhat.com>
> > Subject: [PATCH 0/6] Fix race condition and add event protocol
> >
> > 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 <jian.j.wang@intel.com>
> > Cc: Hao A Wu <hao.a.wu@intel.com>
> > cc: Ray Ni <ray.ni@intel.com>
> > Cc: Star Zeng <star.zeng@intel.com>
> > Cc: Liming gao <liming.gao@intel.com>
> > Cc: Sean Brogan <sean.brogan@microsoft.com>
> > Cc: Michael Turner <Michael.Turner@microsoft.com>
> > Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > Cc: Eric Dong <eric.dong@intel.com>
> > Cc: Laszlo Ersek <lersek@redhat.com>
> >
> > 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
next prev parent reply other threads:[~2019-05-24 7:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-24 5:04 [PATCH 0/6] Fix race condition and add event protocol Gao, Zhichao
2019-05-24 5:04 ` [PATCH 1/6] MdeModulePkg: Add gEdkiiCommonEventProtocolGuid for event Gao, Zhichao
2019-05-24 5:04 ` [PATCH 2/6] MdePkg/BaseLib.h: Add EnableInterruptsAndSleep function declare Gao, Zhichao
2019-05-24 5:04 ` [PATCH 3/6] MdePkg/BaseLib: Implement EnableInterruptsAndSleep Gao, Zhichao
2019-05-24 5:04 ` [PATCH 4/6] MdePkg: Add gEfiCpu2ProtocolGuid and header file Gao, Zhichao
2019-05-24 5:20 ` Liming Gao
2019-05-24 5:27 ` Gao, Zhichao
2019-05-24 5:34 ` [edk2-devel] " Yao, Jiewen
2019-05-24 5:38 ` Yao, Jiewen
2019-05-24 6:02 ` Liming Gao
2019-05-24 7:48 ` Gao, Zhichao
2019-05-24 5:04 ` [PATCH 5/6] UefiCpuPkg/CpuDxe: Implement Cpu2 protocol Gao, Zhichao
2019-05-24 5:04 ` [PATCH 6/6] MdeModulePkg/DxeMain: Implement common event protocol Gao, Zhichao
2019-05-24 5:17 ` [PATCH 0/6] Fix race condition and add " Ni, Ray
2019-05-24 7:47 ` Gao, Zhichao [this message]
2019-05-24 9:43 ` [edk2-devel] " Laszlo Ersek
2019-05-24 12:52 ` Felix Polyudov
2019-06-13 16:22 ` Liming Gao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3CE959C139B4C44DBEA1810E3AA6F9000B7D4F48@SHSMSX101.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox