From: "Dong, Eric" <eric.dong@intel.com>
To: "Ni, Ray" <ray.ni@intel.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Laszlo Ersek <lersek@redhat.com>
Subject: Re: [edk2-devel] [PATCH v2 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove dependence between APs
Date: Mon, 23 Dec 2019 07:48:33 +0000 [thread overview]
Message-ID: <ED077930C258884BBCB450DB737E662259F6BC0E@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5C3A8DBD@SHSMSX104.ccr.corp.intel.com>
Hi Ray,
> -----Original Message-----
> From: Ni, Ray
> Sent: Monday, December 23, 2019 3:38 PM
> To: devel@edk2.groups.io; Dong, Eric <eric.dong@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Subject: RE: [edk2-devel] [PATCH v2 1/2] UefiCpuPkg/PiSmmCpuDxeSmm:
> Remove dependence between APs
>
> >
> > + WaitForSemaphore (&Token->RunningApCount);
> > +
> > + if (Token->RunningApCount == 0) {
> > + ReleaseSpinLock (Token->SpinLock);
> > }
>
> 1. if (InterlockedDecrement (&Token->RunningApCount) == 0) {
> ReleaseSpinLock (Token->SpinLock);
> }
>
> We should avoid checking RunningApCount directly because it's possible
> that AP#1 decrease the Count to 1 and before AP#1 checks the value against
> 0
> the Count is decreased by AP#2 to 0. So that causes AP#1 and AP#2 call
> ReleaseSpinLock() on the same SpinLock.
>
[[Eric]] good comments, will update it in next version.
> >
> > + // Decrease the count to mark this AP as finished.
>
> 2. BSP is also handled here. So this comment is mis-leading.
[[Eric]] will enhance the comments in next version.
>
> >
> > + //
> >
> > + if (Token != NULL) {
> > + WaitForSemaphore (&ProcToken->RunningApCount);
>
> 3. The code is written correctly but improperly IMO.
> Token is checked but ProcToken is deferenced.
> I suggest you check ProcToken directly.
[[Eric]] The other place in this function all check the Token status then update code.
So this code consistent with other place. I will keep this code to keep consistent.
Thanks,
Eric
next prev parent reply other threads:[~2019-12-23 7:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-23 6:48 [PATCH v2 0/2] Fix potential race condition issue Dong, Eric
2019-12-23 6:48 ` [PATCH v2 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Remove dependence between APs Dong, Eric
2019-12-23 7:38 ` [edk2-devel] " Ni, Ray
2019-12-23 7:48 ` Dong, Eric [this message]
2019-12-23 6:48 ` [PATCH v2 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Fix buffer overflow issue Dong, Eric
2019-12-23 7:39 ` Ni, Ray
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=ED077930C258884BBCB450DB737E662259F6BC0E@shsmsx102.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