From: "Wu, Jiaxin" <jiaxin.wu@intel.com>
To: "Ni, Ray" <ray.ni@intel.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Laszlo Ersek <lersek@redhat.com>,
"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 v4 4/8] UefiCpuPkg: Implements SmmCpuSyncLib library instance
Date: Tue, 19 Dec 2023 05:44:56 +0000 [thread overview]
Message-ID: <MN0PR11MB6158DA876768D376E8849D7FFE97A@MN0PR11MB6158.namprd11.prod.outlook.com> (raw)
In-Reply-To: <MN6PR11MB8244BD28EABF5E6EFFC825DA8C90A@MN6PR11MB8244.namprd11.prod.outlook.com>
Thanks Ray.
>
> 1. It's not "LockedCpuCount". It's "ArrivedCpuCountUponLock".
> Comments can be:
> Before the door is locked, CpuCount stores the arrived CPU count.
> After the door is locked, CpuCount is set to -1 indicating the door is locked.
> ArrivedCpuCpuntUponLock stores the arrived CPU count then.
>
>
Ok, I will update.
> > +/**
> > + Performs an atomic compare exchange operation to get semaphore.
> > + The compare exchange operation must be performed using MP safe
> > + mechanisms.
> > +
> > + @param[in,out] Sem IN: 32-bit unsigned integer
> > + OUT: original integer - 1 if Sem is not locked.
> > + OUT: original integer if Sem is locked
> > (MAX_UINT32).
> > +
> > + @retval Original integer - 1 if Sem is not locked.
> > + Original integer if Sem is locked (MAX_UINT32).
>
> 2. Can just say "MAX_UINT32 if Sem is locked".
>
>
Agree.
> > +
> > + //
> > + // Assign CPU Semaphore pointer
> > + //
> > + CpuSem = (*Context)->CpuSem;
> > + for (CpuIndex = 0; CpuIndex < NumberOfCpus; CpuIndex++) {
> > + CpuSem->Run = (SMM_CPU_SYNC_SEMAPHORE *)SemAddr;
> > + *CpuSem->Run = 0;
> > +
> > + CpuSem++;
> > + SemAddr += OneSemSize;
>
> 5. SafeIntLib was used earlier to make sure no integer overflow.
> But "SemAddr += OneSemSize" is simply ignoring the danger of integer
> overflow.
> I agree (NumberOfCpus + 1) * OneSemSize shouldn't cause integer overflow
> when code runs to here.
> But initial value of SemAddr is not zero. It's still possible the SemAddr +
> (NumberOfCpus+1)*OneSemSize causes integer overflow.
> I am ok if you don't fix it as I don't believe the integer overflow could happen
> in 5 years.
SemAddr is the address of allocated buffer (SemBuffer), "SemAddr += OneSemSize" will make SemAddr point to the part of allocated buffer. is it possible integer overflow? If so, the allocatepage should fail?
Thanks,
Jiaxin
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112690): https://edk2.groups.io/g/devel/message/112690
Mute This Topic: https://groups.io/mt/103187894/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2023-12-19 5:45 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 9:55 [edk2-devel] [PATCH v4 0/8] Refine SMM CPU Sync flow and abstract SmmCpuSyncLib Wu, Jiaxin
2023-12-15 9:55 ` [edk2-devel] [PATCH v4 1/8] UefiCpuPkg/PiSmmCpuDxeSmm: Optimize Semaphore Sync between BSP and AP Wu, Jiaxin
2023-12-19 3:55 ` Ni, Ray
2023-12-15 9:55 ` [edk2-devel] [PATCH v4 2/8] UefiCpuPkg: Adds SmmCpuSyncLib library class Wu, Jiaxin
2023-12-19 3:55 ` Ni, Ray
2023-12-15 9:55 ` [edk2-devel] [PATCH v4 3/8] MdePkg/MdeLibs.dsc.inc: Add SafeIntLib instance Wu, Jiaxin
2023-12-15 16:30 ` Michael D Kinney
2023-12-15 9:55 ` [edk2-devel] [PATCH v4 4/8] UefiCpuPkg: Implements SmmCpuSyncLib library instance Wu, Jiaxin
2023-12-18 9:23 ` Ni, Ray
2023-12-19 5:44 ` Wu, Jiaxin [this message]
2023-12-19 6:21 ` Ni, Ray
2023-12-15 9:55 ` [edk2-devel] [PATCH v4 5/8] OvmfPkg: Specifies SmmCpuSyncLib instance Wu, Jiaxin
2023-12-19 3:55 ` Ni, Ray
2023-12-15 9:55 ` [edk2-devel] [PATCH v4 6/8] UefiPayloadPkg: " Wu, Jiaxin
2023-12-19 3:55 ` Ni, Ray
2023-12-15 9:55 ` [edk2-devel] [PATCH v4 7/8] UefiCpuPkg/PiSmmCpuDxeSmm: Simplify RunningApCount decrement Wu, Jiaxin
2023-12-19 3:55 ` Ni, Ray
2023-12-15 9:55 ` [edk2-devel] [PATCH v4 8/8] UefiCpuPkg/PiSmmCpuDxeSmm: Consume SmmCpuSyncLib Wu, Jiaxin
2023-12-19 3:54 ` 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=MN0PR11MB6158DA876768D376E8849D7FFE97A@MN0PR11MB6158.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