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 89B0A74003A for ; Mon, 24 Jul 2023 17:08:41 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=DNYO2zS+OcwFXwoQt3LPKXRfpIKcY463H3+jb3Z0RRY=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:X-Received:X-Gm-Message-State:X-Google-Smtp-Source:X-Received:MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1690218520; v=1; b=PXLaY4juJmvj2o/xxdP7wW8iU0CcyIFxiMd+c0UjqEA54AItXe6ZT99ZoMcZ0t9s/GwUYRv4 SBVuk7kR3D2d16yHIPOVZtsYk380HYnk85dSeLdhii4zW1yrovAO9M3JOra8ceeGhVBdCY+S2n0 ZSdpio2ah13ictyK4UlROOVM= X-Received: by 127.0.0.2 with SMTP id dqOjYY7687511xuZ636reBhM; Mon, 24 Jul 2023 10:08:40 -0700 X-Received: from mail-ua1-f52.google.com (mail-ua1-f52.google.com [209.85.222.52]) by mx.groups.io with SMTP id smtpd.web10.53502.1690218519436502138 for ; Mon, 24 Jul 2023 10:08:39 -0700 X-Received: by mail-ua1-f52.google.com with SMTP id a1e0cc1a2514c-78caeb69125so1700294241.3 for ; Mon, 24 Jul 2023 10:08:39 -0700 (PDT) X-Gm-Message-State: mhoOk8LJZhSlEBDVJPWzPP7ix7686176AA= X-Google-Smtp-Source: APBJJlE4UrtGa/lfzfhCymXvO+hcuC5CPASuNyib3jQYRPE5zcpUx2XH/0j5verjnf/rCGcQTks+IQDz93yKn47z4OI= X-Received: by 2002:a67:fdd2:0:b0:443:5792:1891 with SMTP id l18-20020a67fdd2000000b0044357921891mr3461361vsq.19.1690218518330; Mon, 24 Jul 2023 10:08:38 -0700 (PDT) MIME-Version: 1.0 References: <20230720134557.3903923-1-ardb@kernel.org> In-Reply-To: From: "Pedro Falcato" Date: Mon, 24 Jul 2023 18:08:27 +0100 Message-ID: Subject: Re: [edk2-devel] [RFC/RFT PATCH] OvmfPkg/IoMmuDxe: don't rely on TPLs for re-entrancy To: Ard Biesheuvel Cc: devel@edk2.groups.io, Gerd Hoffmann , Jiewen Yao , Michael Brown Precedence: Bulk 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,pedro.falcato@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=PXLaY4ju; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On Mon, Jul 24, 2023 at 3:21=E2=80=AFPM Ard Biesheuvel wr= ote: > > On Sat, 22 Jul 2023 at 00:55, Pedro Falcato wro= te: > > > > On Thu, Jul 20, 2023 at 2:46=E2=80=AFPM Ard Biesheuvel wrote: > > > > > > Instead of relying on raising the TPL to protect the critical section= s > > > that manipulate the global bitmask that keeps track of bounce buffer > > > allocations, use compare-and-exchange to manage the global variable, = and > > > tweak the logic to line up with that. > > > > > > Given that IoMmuDxe implements a singleton protocol that is shared > > > between multiple drivers, and considering the elaborate and confusing > > > requirements in the UEFP spec regarding TPL levels at which protocol > > > methods may be invoked, not relying on TPL levels at all is a more > > > > Really good change (I had thought of this when reading through the > > other IoMmuDxe thread), but I'm wondering if this warrants the > > addition of bit ops (AND, OR at least) to SynchronizationLib? > > > > Thanks. > > Atomic AND/OR would only help on the free path in this case. > > > Sidenote: the compiler can detect if atomic intrinsics use the "fetch" > > value in (fetch_or, or_fetch, etc) and thus use smaller, more > > efficient instruction sequences (https://godbolt.org/z/zWTTWacEd). if > > only we could use those... > > > > In principle, I'd agree but these are rarely used so I'm not sure it's > worth the effort refactoring this. Good point, let's skip any extensive refactoring for now. Acked-by: Pedro Falcato --=20 Pedro -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107184): https://edk2.groups.io/g/devel/message/107184 Mute This Topic: https://groups.io/mt/100256049/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-