From: "Ni, Ruiyu" <ruiyu.ni@Intel.com>
To: edk2-devel@lists.01.org
Subject: Re: [PATCH] UefiCpuPkg/MpInitLib: AP uses memory preceding IDT to store CpuMpData
Date: Wed, 27 Jun 2018 14:00:57 +0800 [thread overview]
Message-ID: <aa0a2d5f-d3e9-f001-4d20-380d7b623a5e@Intel.com> (raw)
In-Reply-To: <b6e59369-af6d-b9b9-ad55-7382a44eebad@redhat.com>
On 6/27/2018 2:57 AM, Laszlo Ersek wrote:
> Second, even assuming that PushCpuMpData() and PopCpuMpData() are
> atomic, the order in which APs complete the AP procedure is not
> deterministic, and it need not be the exact reverse of the entry order.
> We may have the following order, for example:
>
> - AP 1 writes CpuMpData, and saves the original PEI services pointer on
> its stack,
> - AP 2 writes CpuMpData, and saves the same CpuMpData value (originally
> written by AP 1) on its stack,
> - AP 1 completes the AP procedure and restores the original PEI services
> pointer from its stack,
> - AP 2 completes the AP procedure, and overwrites the PEI services
> pointer, with the CpuMpData value from its stack, that was originally
> written by AP 1.
>
Thanks for the analysis. It's a stupid bug that I should be aware of.
That can also explain why I cannot reproduce it. It's random.
> Assuming I (remotely) understand what's going on, I'd (vaguely) suggest
> three alternatives:
>
> - instead of the idea captured in this patch, we should use an APIC ID
> search similar to the one done initially in "MpFuncs.nasm",
Don't understand. Can you kindly explain more?
>
> - or else, we should stick with the current idea, but use atomic
> compare-and-swap operations, so that the original PEI services pointer
> value be restored ultimately, at the least,
I like this idea. Will generate the V2 patch.
>
> - or else (possibly the simplest fix), allocate a separate IDT for each
> AP, including the UINTN that precedes the (now AP-specific) IDT. This
> means that the PEI services pointer*location* would be separate for
> each AP, and no contention would occur.
I think it's the most complicated fix:)
--
Thanks,
Ray
next prev parent reply other threads:[~2018-06-27 6:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-25 2:54 [PATCH] UefiCpuPkg/MpInitLib: AP uses memory preceding IDT to store CpuMpData Ruiyu Ni
2018-06-25 16:01 ` Laszlo Ersek
2018-06-25 17:01 ` Laszlo Ersek
2018-06-26 7:50 ` Ni, Ruiyu
2018-06-26 12:52 ` Laszlo Ersek
2018-06-26 17:06 ` Laszlo Ersek
2018-06-26 17:20 ` Andrew Fish
2018-06-26 18:57 ` Laszlo Ersek
2018-06-27 6:00 ` Ni, Ruiyu [this message]
2018-06-27 12:00 ` Laszlo Ersek
2018-06-29 9:36 ` Ni, Ruiyu
2018-06-27 5:06 ` Ni, Ruiyu
2018-06-27 4:50 ` Ni, Ruiyu
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=aa0a2d5f-d3e9-f001-4d20-380d7b623a5e@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