From: "Ni, Ray" <ray.ni@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
"lersek@redhat.com" <lersek@redhat.com>,
"Wu, Jiaxin" <jiaxin.wu@intel.com>
Cc: "Dong, Eric" <eric.dong@intel.com>,
"Zeng, Star" <star.zeng@intel.com>,
Gerd Hoffmann <kraxel@redhat.com>,
"Kumar, Rahul R" <rahul.r.kumar@intel.com>
Subject: Re: [edk2-devel] [PATCH v1 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Check BspIndex first before lock cmpxchg
Date: Mon, 19 Feb 2024 07:12:30 +0000 [thread overview]
Message-ID: <MN6PR11MB82446956838227F92E9F0F638C512@MN6PR11MB8244.namprd11.prod.outlook.com> (raw)
In-Reply-To: <cf6ecb35-51b4-d35c-37ed-40ff3c224837@redhat.com>
> This patch makes me uncomfortable. I understand what it intends to do,
> and the intent is not wrong, but we're again treating "volatile UINT32"
> as atomic, and non-reorderable against the
> InterlockedCompareExchange32(). This kind of "optimization" is what
> people write cautionary tales about, later. It would be nice to see a
> semi-formal *proof* that this cannot backfire.
Laszlo,
Thanks for the questions. I was OOO in the past 10 days for Chinese New Year.
From Chapter 9 "Multiple-Processor Management",
section 9.2.2 "Memory Ordering in P6 and More Recent Processor Families",
I read the following:
In a single-processor system for memory regions defined as write-back cacheable,
the memory ordering model respects the following principles...:
* ...
* Reads or writes cannot be reordered with I/O instructions, locked instructions, or serializing instructions.
So, it guarantees/proves "read of BspIndex" performs before "InterlockedCompareExchange32()/lock comxchg".
I think that can resolve one of your concern regarding the "ordering".
I don't quite understand your concern regarding the "atomic".
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115585): https://edk2.groups.io/g/devel/message/115585
Mute This Topic: https://groups.io/mt/104094808/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
prev parent reply other threads:[~2024-02-19 7:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 11:19 [edk2-devel] [PATCH v1 0/2] SMM CPU Optimization for SMM Init & SMI Process Wu, Jiaxin
2024-02-01 11:20 ` [edk2-devel] [PATCH v1 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Execute CET and XD check only on BSP Wu, Jiaxin
2024-02-02 6:03 ` Ni, Ray
2024-02-02 6:35 ` Wu, Jiaxin
2024-02-02 14:05 ` Laszlo Ersek
2024-02-04 0:50 ` Wu, Jiaxin
2024-02-02 10:47 ` Laszlo Ersek
2024-02-01 11:20 ` [edk2-devel] [PATCH v1 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Check BspIndex first before lock cmpxchg Wu, Jiaxin
2024-02-01 18:20 ` Michael D Kinney
2024-02-02 6:33 ` Wu, Jiaxin
2024-02-02 10:37 ` Laszlo Ersek
2024-02-06 1:40 ` Ni, Ray
2024-02-06 12:46 ` Laszlo Ersek
2024-02-20 3:41 ` Wu, Jiaxin
2024-02-20 16:21 ` Laszlo Ersek
2024-02-19 7:12 ` Ni, Ray [this message]
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=MN6PR11MB82446956838227F92E9F0F638C512@MN6PR11MB8244.namprd11.prod.outlook.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