From: "Ni, Ray" <ray.ni@intel.com>
To: "devel@edk2.groups.io" <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
Date: Mon, 23 Dec 2019 07:38:28 +0000 [thread overview]
Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C3A8DBD@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20191223064806.682-2-eric.dong@intel.com>
>
> + 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.
>
> + // Decrease the count to mark this AP as finished.
2. BSP is also handled here. So this comment is mis-leading.
>
> + //
>
> + 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.
next prev parent reply other threads:[~2019-12-23 7:38 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 ` Ni, Ray [this message]
2019-12-23 7:48 ` [edk2-devel] " Dong, Eric
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=734D49CCEBEEF84792F5B80ED585239D5C3A8DBD@SHSMSX104.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