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 6A4B87803CD for ; Fri, 21 Jul 2023 22:55:55 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=S2HpleT+QkajluVAAx4de4s5zTuLN3i9u4b8+QT0C4g=; 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=1689980154; v=1; b=QsGkBV8CdBaSOiYtFIzf+WFKgMd+1YoOFdvS/ABYbZeUtP0cOLV0bgLPPLgrA1TFJHDrmkOE s3FIqzszK4nVzNV+MiUkMdQ4ornkormcix0AR2EdMdhWPiXbxSg9V8VGGA9+vtzjwpZMYMWU7mp /Fium9bXXNL89DFVilhpOe6w= X-Received: by 127.0.0.2 with SMTP id 7xQzYY7687511xGh1VuLujQD; Fri, 21 Jul 2023 15:55:54 -0700 X-Received: from mail-vk1-f169.google.com (mail-vk1-f169.google.com [209.85.221.169]) by mx.groups.io with SMTP id smtpd.web10.19766.1689980153236866591 for ; Fri, 21 Jul 2023 15:55:53 -0700 X-Received: by mail-vk1-f169.google.com with SMTP id 71dfb90a1353d-48165cd918dso994095e0c.0 for ; Fri, 21 Jul 2023 15:55:53 -0700 (PDT) X-Gm-Message-State: OCFMAdkUHK16LAJwWMowTKNSx7686176AA= X-Google-Smtp-Source: APBJJlFyyyrC965D4mgLxlRMW1AvDtUNzZhI02S5G6ORO9Bj0qmRVwbB/QQEWNhRO/4iecEoVXt/RqXdAG8rF0CImBo= X-Received: by 2002:a1f:dac6:0:b0:481:42ec:10ed with SMTP id r189-20020a1fdac6000000b0048142ec10edmr2299587vkg.7.1689980151999; Fri, 21 Jul 2023 15:55:51 -0700 (PDT) MIME-Version: 1.0 References: <20230720134557.3903923-1-ardb@kernel.org> In-Reply-To: <20230720134557.3903923-1-ardb@kernel.org> From: "Pedro Falcato" Date: Fri, 21 Jul 2023 23:55:40 +0100 Message-ID: Subject: Re: [edk2-devel] [RFC/RFT PATCH] OvmfPkg/IoMmuDxe: don't rely on TPLs for re-entrancy To: devel@edk2.groups.io, ardb@kernel.org Cc: 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=QsGkBV8C; 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 Thu, Jul 20, 2023 at 2:46=E2=80=AFPM Ard Biesheuvel wr= ote: > > Instead of relying on raising the TPL to protect the critical sections > 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? 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... --=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 (#107134): https://edk2.groups.io/g/devel/message/107134 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-