From: "Ard Biesheuvel" <ardb@kernel.org>
To: Michael Brown <mcb30@ipxe.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>,
devel@edk2.groups.io, Jiewen Yao <jiewen.yao@intel.com>,
Jordan Justen <jordan.l.justen@intel.com>
Subject: Re: [edk2-devel] [PATCH 1/1] OvmfPkg/IoMmuDxe: add locking to IoMmuAllocateBounceBuffer
Date: Thu, 20 Jul 2023 00:06:47 +0200 [thread overview]
Message-ID: <CAMj1kXGTGTFbXVCp_rgJ_pXV9reiozM=W1XR1VQs1kzKUOtG7g@mail.gmail.com> (raw)
In-Reply-To: <010201896f3cee08-297652da-0698-47a8-8832-246bc0d63518-000000@eu-west-1.amazonses.com>
On Wed, 19 Jul 2023 at 19:40, Michael Brown <mcb30@ipxe.org> wrote:
>
> On 19/07/2023 17:52, Ard Biesheuvel wrote:
> > On Wed, 19 Jul 2023 at 18:32, Gerd Hoffmann <kraxel@redhat.com> wrote:
> >> On Wed, Jul 19, 2023 at 04:04:28PM +0000, Michael Brown wrote:
> >>> It looks as though IoMmuFreeBounceBuffer() should also raise to TPL_NOTIFY
> >>> while modifying mReservedMemBitmap, since the modification made in
> >>> IoMmuFreeBounceBuffer() is not an atomic operation:
> >>>
> >>> mReservedMemBitmap &= (UINT32)(~MapInfo->ReservedMemBitmap);
> >>
> >> I'd expect modern compilers optimize that to a single instruction,
> >
> > You mean something along the lines of
> >
> > andl %reg, mReservedMemBitmap(%rip)
> >
> > right?
>
> Even with a single orl/andl instruction, the operation is unlocked.
> It's guaranteed atomic against interrupts (since interrupts always occur
> at instruction boundaries) but it's not guaranteed atomic against
> concurrent accesses to the same global variable from other processors.
>
> (I have no idea if the UEFI model allows APs to call into the IOMMU
> protocol or not, so I don't know if this is a real problem.)
>
No, it's not really a problem. While there is a notion of 'run
function F() on AP #n' in the MpServices protocol, there is no real
SMP support where the same code and data are being used concurrently
on multiple cores in parallel.
> On a quick review of the code, there appear to be other points that also
> modify mReservedMemBitmap (IoMmuAllocateCommonBuffer() and
> IoMmuFreeCommonBuffer()). I'd guess that these also need to raise to
> TPL_NOTIFY, but I'm not familiar with the code so I don't know if
> there's anything that makes this unnecessary.
>
Thanks for mentioning that - perhaps Gerd could have another look? (I
merged the v2 already)
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107064): https://edk2.groups.io/g/devel/message/107064
Mute This Topic: https://groups.io/mt/100233359/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-07-19 22:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-19 11:33 [edk2-devel] [PATCH 1/1] OvmfPkg/IoMmuDxe: add locking to IoMmuAllocateBounceBuffer Gerd Hoffmann
2023-07-19 16:04 ` Michael Brown
2023-07-19 16:31 ` Gerd Hoffmann
2023-07-19 16:52 ` Ard Biesheuvel
2023-07-19 17:40 ` Michael Brown
2023-07-19 22:06 ` Ard Biesheuvel [this message]
2023-07-20 8:30 ` Gerd Hoffmann
2023-07-20 8:28 ` Gerd Hoffmann
2023-07-20 12:45 ` Ard Biesheuvel
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='CAMj1kXGTGTFbXVCp_rgJ_pXV9reiozM=W1XR1VQs1kzKUOtG7g@mail.gmail.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