From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id CAF8BD8027F for ; Thu, 20 Jul 2023 08:24:49 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=p4MqOgsrZQprBRO6G6MTOqGSHs64snZG97LylGQob+U=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:X-Received:X-MC-Unique:X-Received:X-Received:X-Received:From:To:Cc:Subject:Date:Message-ID:MIME-Version:X-Scanned-By:X-Mimecast-Spam-Score:X-Mimecast-Originator:Precedence:List-Unsubscribe:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:X-Gm-Message-State:Content-Transfer-Encoding:Content-Type; s=20140610; t=1689841488; v=1; b=tKZXmFduu2hK5+qUtllEUb4eaOBD2FOQXhPamTfmfqywOfaUBWjgpOYtAYZiuna0wsfuA78I //7kiJbw5Iq+moVWY519cXwWgmTt/WypoGjY7by3Rn8tx+bFkEMem79x0rBgIVgrPabdac7tBqE Lhe6+RR296r3WgOnYH0E0+x4= X-Received: by 127.0.0.2 with SMTP id yZp4YY7687511xyBLThCVoGD; Thu, 20 Jul 2023 01:24:48 -0700 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.8366.1689841487762765322 for ; Thu, 20 Jul 2023 01:24:47 -0700 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-150-QInlD8T9Ppu_34bQ1QwKEQ-1; Thu, 20 Jul 2023 04:24:42 -0400 X-MC-Unique: QInlD8T9Ppu_34bQ1QwKEQ-1 X-Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0D4E38F1840; Thu, 20 Jul 2023 08:24:42 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.89]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C280492B03; Thu, 20 Jul 2023 08:24:40 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DCE5518009DC; Thu, 20 Jul 2023 10:24:38 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jordan Justen , Gerd Hoffmann , Ard Biesheuvel , Jiewen Yao , Michael Brown Subject: [edk2-devel] [PATCH 1/1] OvmfPkg/IoMmuDxe: add locking to IoMmuAllocateCommonBuffer Date: Thu, 20 Jul 2023 10:24:38 +0200 Message-ID: <20230720082438.75669-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com X-Gm-Message-State: P7eYNj8fe7GEUlDkzt2GVZ8hx7686176AA= Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=tKZXmFdu; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none) 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 Signed-off-by: Gerd Hoffmann --- 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] -=-=-=-=-=-=-=-=-=-=-=-