public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gerd Hoffmann" <kraxel@redhat.com>
To: devel@edk2.groups.io
Cc: Jordan Justen <jordan.l.justen@intel.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Jiewen Yao <jiewen.yao@intel.com>, Michael Brown <mcb30@ipxe.org>
Subject: [edk2-devel] [PATCH 1/1] OvmfPkg/IoMmuDxe: add locking to IoMmuAllocateCommonBuffer
Date: Thu, 20 Jul 2023 10:24:38 +0200	[thread overview]
Message-ID: <20230720082438.75669-1-kraxel@redhat.com> (raw)

IoMmuAllocateCommonBuffer has the very same allocation pattern
IoMmuAllocateBounceBuffer uses, so the fix added by commit a52044a9e602
("OvmfPkg/IoMmuDxe: add locking to IoMmuAllocateBounceBuffer") is needed
here too.

Reported-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 OvmfPkg/IoMmuDxe/IoMmuBuffer.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/OvmfPkg/IoMmuDxe/IoMmuBuffer.c b/OvmfPkg/IoMmuDxe/IoMmuBuffer.c
index 103003cae376..6fcf88b50ce1 100644
--- a/OvmfPkg/IoMmuDxe/IoMmuBuffer.c
+++ b/OvmfPkg/IoMmuDxe/IoMmuBuffer.c
@@ -442,7 +442,9 @@ IoMmuAllocateCommonBuffer (
   )
 {
   EFI_STATUS  Status;
+  EFI_TPL     OldTpl;
 
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
   Status = InternalAllocateBuffer (
              AllocateMaxAddress,
              MemoryType,
@@ -453,6 +455,7 @@ IoMmuAllocateCommonBuffer (
   ASSERT (Status == EFI_SUCCESS);
 
   mReservedMemBitmap |= *ReservedMemBitmap;
+  gBS->RestoreTPL (OldTpl);
 
   if (*ReservedMemBitmap != 0) {
     *PhysicalAddress -= SIZE_4KB;
@@ -476,6 +479,8 @@ IoMmuFreeCommonBuffer (
   IN UINTN                 CommonBufferPages
   )
 {
+  EFI_TPL  OldTpl;
+
   if (!mReservedSharedMemSupported) {
     goto LegacyFreeCommonBuffer;
   }
@@ -494,7 +499,10 @@ IoMmuFreeCommonBuffer (
     mReservedMemBitmap & ((UINT32)(~CommonBufferHeader->ReservedMemBitmap))
     ));
 
+  OldTpl              = gBS->RaiseTPL (TPL_NOTIFY);
   mReservedMemBitmap &= (UINT32)(~CommonBufferHeader->ReservedMemBitmap);
+  gBS->RestoreTPL (OldTpl);
+
   return EFI_SUCCESS;
 
 LegacyFreeCommonBuffer:
-- 
2.41.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107088): https://edk2.groups.io/g/devel/message/107088
Mute This Topic: https://groups.io/mt/100251949/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



             reply	other threads:[~2023-07-20  8:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-20  8:24 Gerd Hoffmann [this message]
2023-07-20  8:34 ` [edk2-devel] [PATCH 1/1] OvmfPkg/IoMmuDxe: add locking to IoMmuAllocateCommonBuffer Ard Biesheuvel
2023-07-20  9:00   ` Gerd Hoffmann
2023-07-20 10:22     ` Gerd Hoffmann

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=20230720082438.75669-1-kraxel@redhat.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