From nobody Sat May 11 12:35:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=bu.edu ARC-Seal: i=1; a=rsa-sha256; t=1682629918; cv=none; d=zohomail.com; s=zohoarc; b=MiLKm0joza53x3taFJJAM/IabcPASYXpvPhY0ur085XDuOq6IchyGUXPvy3NOM8jNn8bgMvY9f94jlLUZ4L00S7mNgAt9lerBwXKDcBsCgWIetBqC9dpCDkPj9B93WK9kNqdbK9tPuYwoiTDDwJlxGYQ7VvH59jKxyaP64GhzW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682629918; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=S5GA8Y1UMhuzqKrQy3ytJIXFWBXaejHanlC6dTX2Ipg=; b=NPmDVfqDA4Zt+vf+FNr6PHK0g4G0pzxOJHSrMp0lR4/qFCm6fbsB3bGeIiNCy99CtKhOA2QvZ7Ru5TExqN+Npq/Kcls2gP6z2RdRweJGOk6jb/c5MLSoRUJQiibgMpU9edr6hfxBp4eozkALaOJ8qplDrHGEcayzVLZiFWWcAzs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682629918796586.1823006625293; Thu, 27 Apr 2023 14:11:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ps8tC-0005uD-IX; Thu, 27 Apr 2023 17:10:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps8tA-0005su-NK for qemu-devel@nongnu.org; Thu, 27 Apr 2023 17:10:52 -0400 Received: from esa16.hc2706-39.iphmx.com ([216.71.140.205]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps8t8-0005N6-KC for qemu-devel@nongnu.org; Thu, 27 Apr 2023 17:10:52 -0400 Received: from mail-qv1-f71.google.com ([209.85.219.71]) by ob1.hc2706-39.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 27 Apr 2023 17:10:29 -0400 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-5ef5fe13973so60531196d6.0 for ; Thu, 27 Apr 2023 14:10:29 -0700 (PDT) Received: from mozz.bu.edu (mozz.bu.edu. [128.197.127.33]) by smtp.gmail.com with ESMTPSA id dz16-20020a05620a2b9000b0074df16f36f1sm6204726qkb.108.2023.04.27.14.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 14:10:27 -0700 (PDT) X-IronPort-RemoteIP: 209.85.219.71 X-IronPort-MID: 273505165 X-IronPort-Reputation: None X-IronPort-Listener: OutgoingMail X-IronPort-SenderGroup: RELAY_GSUITE X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:4tiX7KjNxohiUjvd89uIo3zKX1613BIKZh0ujC45NGQN5FlHY01je htvCzjSMvaJZ2SgKo0kao6y8x4G68PUm4NrSAA6rS82EC8W8JqUDtmndXv9bniYRiHhoOOLz Cm8hv3odp1coqr0/0/1WlTZhSAgk/rOHvykU7Ss1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPSwP9TlK6q4mhA4gZhPasjUGL2zBH5MrpOfcldEFOlGuG4LsbiL 87fwbew+H/u/htFIrtJRZ6iLyXm6paLVeS/oiM+t5qK23CulQRrukoPD8fwXG8M49m/c3Gd/ /0W3XC4YV9B0qQhA43xWTEBe811FfQuFLMqvRFTGCFcpqHLWyKE/hlgMK05FZUc8MllAnxoz PEjLjAuS0qSlvy8kJvuH4GAhux7RCXqFIYWu3Ul1C+ASPh5GNbMRKLF4dIe1zA17ixMNayGN oxJNHw1NUWGPEQn1lQ/UfrSmM+hgmn5fydwok/TqKYqi4TW5FYui+W1bYOLJ7RmQ+17w3mZh zP59l3CJUg8DI22xB2Uqi+V07qncSTTHdh6+KeD3udnhUDWymENBRk+U1y9rv+kzEmkVLpix 1c8/yMvqe0r6hXuQIakGRK/p3GAs1gXXN84//AG1TxhA5H8u26xblXohBYdNLTKaOdeqeQW6 2K0 IronPort-HdrOrdr: A9a23:l/LavKsXNq7SikfMrEYWrP9O7skDoNV00zEX/kB9WHVpmwKj5q STdZMgpGPJYVMqMk3I9urwXpVoLUmsl6KdpLNhRotKPzOWxVdAUrsSlLcKqgeIc0aOldK1l5 0QCZSWYOeRMbEQt7ec3ODXKadE/PC3tIqFv6Px9UtMcC1dQ51czm5Ce3mm+45NKDWux6BVKH NR3KR6TkKbCAwqhw2AaRg4Y9Q= X-Talos-CUID: 9a23:YdciMWN5chC8N+5DQC1t21wXB+Ycf0bbzFT1eV6pF2w5YejA X-Talos-MUID: 9a23:YHIW4Qpn89fWhdCoI3Aezx8/C8ZJspunMXsqyLM+6uCJEj0oZg7I2Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bu.edu; s=s1gsbu; t=1682629828; x=1685221828; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S5GA8Y1UMhuzqKrQy3ytJIXFWBXaejHanlC6dTX2Ipg=; b=Q4BOLKNFXYM9xz7kImvgEA3RG8m018gsEEiw60e8NFmlQ0yDXHTPIm8bo9j3LKftUh pWnlFeG7macRXXc8QY5bxKVzwUOLGxEC0TxjBUaUZ2E1y8GDRjwhbmWbHRNQJK4RDV0L AGR3/60+Sq3rwD+uhPZYPTLfR7qWsYZC0beoTjslIjJwj8rvzPZQabxr7h7OG1fPXMYm TbKM3xzwXXYja9We7LPBVY3+Fc9XgJNh1SLmZEXHXeF0ZAjnGxoW4nau+Awwy3rI1Owx 3K+w2TumTHeh1mDlaRI80iOxbwysrMgqyW1qC8hW1j2l6GdSqXqKuGdNFLP9HVyQm5jd pM9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682629828; x=1685221828; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S5GA8Y1UMhuzqKrQy3ytJIXFWBXaejHanlC6dTX2Ipg=; b=J20GPBE2X6if08lMvPU6ayd9eCaBWNO/amLVYsbTTR4Xe0q4e3Ie+cHK3GGAfwfKhR B6MkyVH8KDqnWGosZgVcao8gx/cqVBQHJWSgyWy1+zeWaZCXmJ4Q9y+Kgtk4NzhJAcz2 ZXpB2wdol1H/CwE21ZrKAWTRMOA+gjjr1szOE5hg6I9b9stwVkK/DdMum/F2G29gdmll dROroy6Dm+7shIp34fJXGHQ3xnvQe0WBAxzzBoTzWTwpI2ExOsR0idQtpERwC1NKQmBJ AhGFVRhTpnG2UT1u/nuPZsjX1dVaKcwX4JFwAEfwyw1TF8kMSY0Gk7NyGvzkOcMSC3/X fQsA== X-Gm-Message-State: AC+VfDy/1JYYswP6FyuW5NEnzgFaEnED6hdS0QFYafeJSLrP/Viar9kI twYI8oODPteEWIrPf4dRBm1pOU08IcLhnc4WTdb11ku/DscG391qbLVcUWoYzNvnyrSIRZIWDA9 UsIuexbau998TgqlQVyo5Un4FUugYQb++g+pqb6ybyXE= X-Received: by 2002:a05:6214:212d:b0:5e7:f7eb:d87 with SMTP id r13-20020a056214212d00b005e7f7eb0d87mr4589029qvc.47.1682629828215; Thu, 27 Apr 2023 14:10:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Ik6U0VsaJkRAhW1VCGgiYCavtRYM7GbThgwIQ0FXZz4wj7/3BMvznECDE4EIq7G5Cpcw3+Q== X-Received: by 2002:a05:6214:212d:b0:5e7:f7eb:d87 with SMTP id r13-20020a056214212d00b005e7f7eb0d87mr4588993qvc.47.1682629827942; Thu, 27 Apr 2023 14:10:27 -0700 (PDT) From: Alexander Bulekov To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Stefan Hajnoczi , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mauro Matteo Cascella , Peter Xu , Jason Wang , David Hildenbrand , Gerd Hoffmann , Thomas Huth , Laurent Vivier , Bandan Das , "Edgar E . Iglesias" , Darren Kenny , Bin Meng , Paolo Bonzini , "Michael S . Tsirkin" , Marcel Apfelbaum , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Eduardo Habkost , Jon Maloy , Siqi Chen , Michael Tokarev Subject: [PATCH v10 1/8] memory: prevent dma-reentracy issues Date: Thu, 27 Apr 2023 17:10:06 -0400 Message-Id: <20230427211013.2994127-2-alxndr@bu.edu> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230427211013.2994127-1-alxndr@bu.edu> References: <20230427211013.2994127-1-alxndr@bu.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CES-GSUITE_AUTH: bf3aNvsZpxl8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.140.205; envelope-from=alxndr@bu.edu; helo=esa16.hc2706-39.iphmx.com X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.266, HK_RANDOM_FROM=0.999, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bu.edu) X-ZM-MESSAGEID: 1682629920598100005 Content-Type: text/plain; charset="utf-8" Add a flag to the DeviceState, when a device is engaged in PIO/MMIO/DMA. This flag is set/checked prior to calling a device's MemoryRegion handlers, and set when device code initiates DMA. The purpose of this flag is to prevent two types of DMA-based reentrancy issues: 1.) mmio -> dma -> mmio case 2.) bh -> dma write -> mmio case These issues have led to problems such as stack-exhaustion and use-after-frees. Summary of the problem from Peter Maydell: https://lore.kernel.org/qemu-devel/CAFEAcA_23vc7hE3iaM-JVA6W38LK4hJoWae5Kck= nhPRD5fPBZA@mail.gmail.com Resolves: https://gitlab.com/qemu-project/qemu/-/issues/62 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/540 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/541 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/556 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/557 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/827 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1282 Resolves: CVE-2023-0330 Signed-off-by: Alexander Bulekov Reviewed-by: Thomas Huth --- include/exec/memory.h | 5 +++++ include/hw/qdev-core.h | 7 +++++++ softmmu/memory.c | 16 ++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 15ade918ba..e45ce6061f 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -767,6 +767,8 @@ struct MemoryRegion { bool is_iommu; RAMBlock *ram_block; Object *owner; + /* owner as TYPE_DEVICE. Used for re-entrancy checks in MR access hotp= ath */ + DeviceState *dev; =20 const MemoryRegionOps *ops; void *opaque; @@ -791,6 +793,9 @@ struct MemoryRegion { unsigned ioeventfd_nb; MemoryRegionIoeventfd *ioeventfds; RamDiscardManager *rdm; /* Only for RAM */ + + /* For devices designed to perform re-entrant IO into their own IO MRs= */ + bool disable_reentrancy_guard; }; =20 struct IOMMUMemoryRegion { diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index bd50ad5ee1..7623703943 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -162,6 +162,10 @@ struct NamedClockList { QLIST_ENTRY(NamedClockList) node; }; =20 +typedef struct { + bool engaged_in_io; +} MemReentrancyGuard; + /** * DeviceState: * @realized: Indicates whether the device has been fully constructed. @@ -194,6 +198,9 @@ struct DeviceState { int alias_required_for_version; ResettableState reset; GSList *unplug_blockers; + + /* Is the device currently in mmio/pio/dma? Used to prevent re-entranc= y */ + MemReentrancyGuard mem_reentrancy_guard; }; =20 struct DeviceListener { diff --git a/softmmu/memory.c b/softmmu/memory.c index b1a6cae6f5..fe23f0e5ce 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -542,6 +542,18 @@ static MemTxResult access_with_adjusted_size(hwaddr ad= dr, access_size_max =3D 4; } =20 + /* Do not allow more than one simultaneous access to a device's IO Reg= ions */ + if (mr->dev && !mr->disable_reentrancy_guard && + !mr->ram_device && !mr->ram && !mr->rom_device && !mr->readonly) { + if (mr->dev->mem_reentrancy_guard.engaged_in_io) { + warn_report("Blocked re-entrant IO on " + "MemoryRegion: %s at addr: 0x%" HWADDR_PRIX, + memory_region_name(mr), addr); + return MEMTX_ACCESS_ERROR; + } + mr->dev->mem_reentrancy_guard.engaged_in_io =3D true; + } + /* FIXME: support unaligned access? */ access_size =3D MAX(MIN(size, access_size_max), access_size_min); access_mask =3D MAKE_64BIT_MASK(0, access_size * 8); @@ -556,6 +568,9 @@ static MemTxResult access_with_adjusted_size(hwaddr add= r, access_mask, attrs); } } + if (mr->dev) { + mr->dev->mem_reentrancy_guard.engaged_in_io =3D false; + } return r; } =20 @@ -1170,6 +1185,7 @@ static void memory_region_do_init(MemoryRegion *mr, } mr->name =3D g_strdup(name); mr->owner =3D owner; + mr->dev =3D (DeviceState *) object_dynamic_cast(mr->owner, TYPE_DEVICE= ); mr->ram_block =3D NULL; =20 if (name) { --=20 2.39.0 From nobody Sat May 11 12:35:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=bu.edu ARC-Seal: i=1; a=rsa-sha256; t=1682629914; cv=none; d=zohomail.com; s=zohoarc; b=LLPNQFrq5fmJVDh57JcIVH5wegkm5UkUNkLsmXJ35hnK07/A/yl47hQ5h0AtQemRot0a2HcHDfcAzuB0Dubl4ZpvEw/7zfn/fNbHBqyHj0LibG1ucRrr07PkSrLTMuARken2Lf6i/1Bu27iEF18Mmy5aA0ZDdXmZ0VJoSCVwsBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682629914; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lp25phZ45HRqtDee0Q+1ws/xkoM4Gpnqec2ldOouCHM=; b=XNbKWZFcyEXrAddVpQHWUFeu85I6uMWUji5CiXTvSwZnQk3jrgXgX4KU1CifgWqtrIT31Y7ylv8a/WcvKEGZenxk1RsoVyxcg4aqPPPl/r2XFl8KqIbsy+sZp32wxcib1DhSNroM1MeG1pqPecG7dLYeoKoiUUfb39AsKxVHXao= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682629914904933.3876715328383; Thu, 27 Apr 2023 14:11:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ps8tH-0005vU-3S; Thu, 27 Apr 2023 17:10:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps8tE-0005v1-Pm for qemu-devel@nongnu.org; Thu, 27 Apr 2023 17:10:56 -0400 Received: from esa13.hc2706-39.iphmx.com ([216.71.137.83]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps8tC-0005O0-Oo for qemu-devel@nongnu.org; Thu, 27 Apr 2023 17:10:56 -0400 Received: from mail-oi1-f200.google.com ([209.85.167.200]) by ob1.hc2706-39.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 27 Apr 2023 17:10:53 -0400 Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-38c5845e8e5so6153812b6e.0 for ; Thu, 27 Apr 2023 14:10:52 -0700 (PDT) Received: from mozz.bu.edu (mozz.bu.edu. [128.197.127.33]) by smtp.gmail.com with ESMTPSA id j14-20020ac84c8e000000b003ef3df76ec7sm6483969qtv.93.2023.04.27.14.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 14:10:31 -0700 (PDT) X-IronPort-RemoteIP: 209.85.167.200 X-IronPort-MID: 275213208 X-IronPort-Reputation: None X-IronPort-Listener: OutgoingMail X-IronPort-SenderGroup: RELAY_GSUITE X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:QZJlTKkfDfSSZXf88vFrUAjo5gw/JERdPkR7XQ2eYbSJt1+Wr1Gzt xJLXT+EO/3eZDamedglOYXioR8HsZbcmNE2TQVorClhRS4T+ZvOCOrCEkqhZCn6wu8v7a5EA 2fyTvGacajYm1eF/k/F3oDJ9CU6jufQAOKnUoYoAwgpLSd8UiAtlBl/rOAwh49skLCRDhiE/ Nj/uKUzAnf8s9JPGj9SuvPrRC9H5qyo42tE5ANmPpingXeF/5UrJMNHTU2OByagKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0xK6aYD76vRxjnVaPpIACRYpQRw/ZwNlPjxG4 I4lWZSYEW/FN0BX8QgXe0Aw/ypWZMWq9FJbSJQWXAP6I0DuKhPRL/tS4E4eYpIcxsBHE1p3s v1ECRpRaCHZ2uWZ3+fuIgVsrpxLwMjDOYoevjRnzGicA6x+GdbMRKLF4dIe1zA17ixMNayGN oxJNHw2MkuGOUUXUrsUIMtWcOOAj33vdTFCgFiI46c7/gA/ySQrj+W3aYGPIoziqcN9t2+0+ lnX0DvDGwAVMtO/6D66wi60ibqa9c/8cMdIfFGizdZzjViOg2AeFhASfV28p/a/lwi5Qd03F qAP0i8nrKx3803yC9enB0X+r3mDsRoRHdFXFoXW9T2w90Yd2C7BbkBsc9KLQIdOWBMeLdDy6 mK0og== IronPort-HdrOrdr: A9a23:2fzk6q6BEtdGHyIilwPXwBXXdLJyesId70hD6qkRc20yTiX8ra qTdZsgpHvJYVoqKRMdcLO7Scq9qBHnm6KdiLN5VduftWHd01eAFoFt6ovkzXnMHSn39uk178 ZdWpJ/BtrxClY/t8r+7AOkFc1I+rm6GcuT9IDjJhlWPGRXQpAlxAd/BwadHAlXaWB9aqbRRK Dw2vZ6 X-Talos-CUID: =?us-ascii?q?9a23=3A92UwyGjYnLG96EGblPy/5MjewTJuLWLZ8FHgMXS?= =?us-ascii?q?BTmc1aZfJT27KpaRLjJ87?= X-Talos-MUID: 9a23:5JPmtAmbCS9h6yXSo00vdnpLHes02LWBV3oUgJoAtOmlMRNAZy+S2WE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bu.edu; s=s1gsbu; t=1682629852; x=1685221852; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lp25phZ45HRqtDee0Q+1ws/xkoM4Gpnqec2ldOouCHM=; b=D1BAdHcOKXPCxaoq2nLAWDtGiXB9XlEGYzXFrNK3lBgS4yDo9cRkgXmV6/yjKyVdMj e0diDehi2nMCc6m3JQ+3HF/KgnsIhyX8tCSY8AyVRKcS7vHCXzaPP5xdeYT8ISWZLuay iMjYM+CBEo/l5YwiXTqEu+Lg9Pb8GCbuePE9BiBIC/jQO9/w+cl8TDPtQC87UbIMTyTW JOBAJCFBjVx++tHzrq287RrZk0S0zTRoQQM45YU4znx4P9C6D8WXNnkgmE3y/Hky3XLf S8P6gCJbp+El7HyCEEM0rKVibggHaq4jMBQ4rz62lGaT9d7SJfVj6Xhj9/pM981kBQR+ XDdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682629852; x=1685221852; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lp25phZ45HRqtDee0Q+1ws/xkoM4Gpnqec2ldOouCHM=; b=Zy+EjaB32HmMNaLLV5cvoZNwc+JLSfPt6UyQR+6h2PgLMzkF08qlbqV05ji/iu7Nx6 f9p2mrbtI8H7LIR88vJ/L3dplkx5qAfIuwHozC/G/7BBGAhjgOKRLEAfze0M0tvcL/8W w4EkfQK6Xgenu0wQQmNhIGcQmihsCUtGmMqkrublxVxezvoU0Jy7P3jtTtn8EpsyBgSi 1dQmEVtzvzGtBinc2ulYEuHf/zP7OPVqysYyGKazTVeOQJwU9hozf+w4DT3Dtn1QWjO6 Y5tvbtTK8R0/irgN813K1hvWF8FDcoRsqSUEhz7cy9ruDpVmeuSGdf9MYvvC/DXVYctW VSWw== X-Gm-Message-State: AC+VfDyNakKsjwqI8JYtHPzvolEpWxCe14y/PfnEfdZaEsYot5z44aMA wbTUkYIToVDGNYWJOHE261aLbQfu1lRnOs8NQi0vqFgmVut5+tDZ9fRr7KphoUz/SpYajg9+FDz w570faZ2yOe2NDVDf9v94Dnvh0wzden2w3lJsobX+IO8= X-Received: by 2002:a05:6214:c88:b0:5f4:4e3d:2bde with SMTP id r8-20020a0562140c8800b005f44e3d2bdemr3329536qvr.48.1682629831789; Thu, 27 Apr 2023 14:10:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4jb2+k0W+QOxztuMbRyAZjbakFzGUw4xXgSPdtKhPEIPchovU1lxd5ffeCdz8rSaOEXnDiHg== X-Received: by 2002:a05:6214:c88:b0:5f4:4e3d:2bde with SMTP id r8-20020a0562140c8800b005f44e3d2bdemr3329482qvr.48.1682629831455; Thu, 27 Apr 2023 14:10:31 -0700 (PDT) From: Alexander Bulekov To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Stefan Hajnoczi , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mauro Matteo Cascella , Peter Xu , Jason Wang , David Hildenbrand , Gerd Hoffmann , Thomas Huth , Laurent Vivier , Bandan Das , "Edgar E . Iglesias" , Darren Kenny , Bin Meng , Paolo Bonzini , "Michael S . Tsirkin" , Marcel Apfelbaum , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Eduardo Habkost , Jon Maloy , Siqi Chen , Michael Tokarev , Fam Zheng , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org (open list:Block I/O path) Subject: [PATCH v10 2/8] async: Add an optional reentrancy guard to the BH API Date: Thu, 27 Apr 2023 17:10:07 -0400 Message-Id: <20230427211013.2994127-3-alxndr@bu.edu> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230427211013.2994127-1-alxndr@bu.edu> References: <20230427211013.2994127-1-alxndr@bu.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CES-GSUITE_AUTH: bf3aNvsZpxl8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.137.83; envelope-from=alxndr@bu.edu; helo=esa13.hc2706-39.iphmx.com X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.266, HK_RANDOM_FROM=0.999, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bu.edu) X-ZM-MESSAGEID: 1682629916174100005 Content-Type: text/plain; charset="utf-8" Devices can pass their MemoryReentrancyGuard (from their DeviceState), when creating new BHes. Then, the async API will toggle the guard before/after calling the BH call-back. This prevents bh->mmio reentrancy issues. Reviewed-by: Darren Kenny Signed-off-by: Alexander Bulekov --- docs/devel/multiple-iothreads.txt | 7 +++++++ include/block/aio.h | 18 ++++++++++++++++-- include/qemu/main-loop.h | 7 +++++-- tests/unit/ptimer-test-stubs.c | 3 ++- util/async.c | 18 +++++++++++++++++- util/main-loop.c | 5 +++-- util/trace-events | 1 + 7 files changed, 51 insertions(+), 8 deletions(-) diff --git a/docs/devel/multiple-iothreads.txt b/docs/devel/multiple-iothre= ads.txt index 343120f2ef..a3e949f6b3 100644 --- a/docs/devel/multiple-iothreads.txt +++ b/docs/devel/multiple-iothreads.txt @@ -61,6 +61,7 @@ There are several old APIs that use the main loop AioCont= ext: * LEGACY qemu_aio_set_event_notifier() - monitor an event notifier * LEGACY timer_new_ms() - create a timer * LEGACY qemu_bh_new() - create a BH + * LEGACY qemu_bh_new_guarded() - create a BH with a device re-entrancy gu= ard * LEGACY qemu_aio_wait() - run an event loop iteration =20 Since they implicitly work on the main loop they cannot be used in code th= at @@ -72,8 +73,14 @@ Instead, use the AioContext functions directly (see incl= ude/block/aio.h): * aio_set_event_notifier() - monitor an event notifier * aio_timer_new() - create a timer * aio_bh_new() - create a BH + * aio_bh_new_guarded() - create a BH with a device re-entrancy guard * aio_poll() - run an event loop iteration =20 +The qemu_bh_new_guarded/aio_bh_new_guarded APIs accept a "MemReentrancyGua= rd" +argument, which is used to check for and prevent re-entrancy problems. For +BHs associated with devices, the reentrancy-guard is contained in the +corresponding DeviceState and named "mem_reentrancy_guard". + The AioContext can be obtained from the IOThread using iothread_get_aio_context() or for the main loop using qemu_get_aio_context= (). Code that takes an AioContext argument works both in IOThreads or the main diff --git a/include/block/aio.h b/include/block/aio.h index e267d918fd..89bbc536f9 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -23,6 +23,8 @@ #include "qemu/thread.h" #include "qemu/timer.h" #include "block/graph-lock.h" +#include "hw/qdev-core.h" + =20 typedef struct BlockAIOCB BlockAIOCB; typedef void BlockCompletionFunc(void *opaque, int ret); @@ -323,9 +325,11 @@ void aio_bh_schedule_oneshot_full(AioContext *ctx, QEM= UBHFunc *cb, void *opaque, * is opaque and must be allocated prior to its use. * * @name: A human-readable identifier for debugging purposes. + * @reentrancy_guard: A guard set when entering a cb to prevent + * device-reentrancy issues */ QEMUBH *aio_bh_new_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque, - const char *name); + const char *name, MemReentrancyGuard *reentrancy_g= uard); =20 /** * aio_bh_new: Allocate a new bottom half structure @@ -334,7 +338,17 @@ QEMUBH *aio_bh_new_full(AioContext *ctx, QEMUBHFunc *c= b, void *opaque, * string. */ #define aio_bh_new(ctx, cb, opaque) \ - aio_bh_new_full((ctx), (cb), (opaque), (stringify(cb))) + aio_bh_new_full((ctx), (cb), (opaque), (stringify(cb)), NULL) + +/** + * aio_bh_new_guarded: Allocate a new bottom half structure with a + * reentrancy_guard + * + * A convenience wrapper for aio_bh_new_full() that uses the cb as the name + * string. + */ +#define aio_bh_new_guarded(ctx, cb, opaque, guard) \ + aio_bh_new_full((ctx), (cb), (opaque), (stringify(cb)), guard) =20 /** * aio_notify: Force processing of pending events. diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index b3e54e00bc..68e70e61aa 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -387,9 +387,12 @@ void qemu_cond_timedwait_iothread(QemuCond *cond, int = ms); =20 /* internal interfaces */ =20 +#define qemu_bh_new_guarded(cb, opaque, guard) \ + qemu_bh_new_full((cb), (opaque), (stringify(cb)), guard) #define qemu_bh_new(cb, opaque) \ - qemu_bh_new_full((cb), (opaque), (stringify(cb))) -QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name); + qemu_bh_new_full((cb), (opaque), (stringify(cb)), NULL) +QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name, + MemReentrancyGuard *reentrancy_guard); void qemu_bh_schedule_idle(QEMUBH *bh); =20 enum { diff --git a/tests/unit/ptimer-test-stubs.c b/tests/unit/ptimer-test-stubs.c index f2bfcede93..8c9407c560 100644 --- a/tests/unit/ptimer-test-stubs.c +++ b/tests/unit/ptimer-test-stubs.c @@ -107,7 +107,8 @@ int64_t qemu_clock_deadline_ns_all(QEMUClockType type, = int attr_mask) return deadline; } =20 -QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name) +QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name, + MemReentrancyGuard *reentrancy_guard) { QEMUBH *bh =3D g_new(QEMUBH, 1); =20 diff --git a/util/async.c b/util/async.c index 21016a1ac7..a9b528c370 100644 --- a/util/async.c +++ b/util/async.c @@ -65,6 +65,7 @@ struct QEMUBH { void *opaque; QSLIST_ENTRY(QEMUBH) next; unsigned flags; + MemReentrancyGuard *reentrancy_guard; }; =20 /* Called concurrently from any thread */ @@ -137,7 +138,7 @@ void aio_bh_schedule_oneshot_full(AioContext *ctx, QEMU= BHFunc *cb, } =20 QEMUBH *aio_bh_new_full(AioContext *ctx, QEMUBHFunc *cb, void *opaque, - const char *name) + const char *name, MemReentrancyGuard *reentrancy_g= uard) { QEMUBH *bh; bh =3D g_new(QEMUBH, 1); @@ -146,13 +147,28 @@ QEMUBH *aio_bh_new_full(AioContext *ctx, QEMUBHFunc *= cb, void *opaque, .cb =3D cb, .opaque =3D opaque, .name =3D name, + .reentrancy_guard =3D reentrancy_guard, }; return bh; } =20 void aio_bh_call(QEMUBH *bh) { + bool last_engaged_in_io =3D false; + + if (bh->reentrancy_guard) { + last_engaged_in_io =3D bh->reentrancy_guard->engaged_in_io; + if (bh->reentrancy_guard->engaged_in_io) { + trace_reentrant_aio(bh->ctx, bh->name); + } + bh->reentrancy_guard->engaged_in_io =3D true; + } + bh->cb(bh->opaque); + + if (bh->reentrancy_guard) { + bh->reentrancy_guard->engaged_in_io =3D last_engaged_in_io; + } } =20 /* Multiple occurrences of aio_bh_poll cannot be called concurrently. */ diff --git a/util/main-loop.c b/util/main-loop.c index e180c85145..4d76261010 100644 --- a/util/main-loop.c +++ b/util/main-loop.c @@ -605,9 +605,10 @@ void main_loop_wait(int nonblocking) =20 /* Functions to operate on the main QEMU AioContext. */ =20 -QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name) +QEMUBH *qemu_bh_new_full(QEMUBHFunc *cb, void *opaque, const char *name, M= emReentrancyGuard *reentrancy_guard) { - return aio_bh_new_full(qemu_aio_context, cb, opaque, name); + return aio_bh_new_full(qemu_aio_context, cb, opaque, name, + reentrancy_guard); } =20 /* diff --git a/util/trace-events b/util/trace-events index 16f78d8fe5..3f7e766683 100644 --- a/util/trace-events +++ b/util/trace-events @@ -11,6 +11,7 @@ poll_remove(void *ctx, void *node, int fd) "ctx %p node %= p fd %d" # async.c aio_co_schedule(void *ctx, void *co) "ctx %p co %p" aio_co_schedule_bh_cb(void *ctx, void *co) "ctx %p co %p" +reentrant_aio(void *ctx, const char *name) "ctx %p name %s" =20 # thread-pool.c thread_pool_submit(void *pool, void *req, void *opaque) "pool %p req %p op= aque %p" --=20 2.39.0 From nobody Sat May 11 12:35:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=bu.edu ARC-Seal: i=1; a=rsa-sha256; t=1682629947; cv=none; d=zohomail.com; s=zohoarc; b=B8bdHTgjgUl1tEskfCGtrZaVDdac3gT5tKB9UV+wkoA18TLo5STWbm9/IEjHAd2bvmPF77Fw0h/0nvR3jDnhpTLC9EhN0t78Z0df/r7lsBf0+jdfJfDoEcuGSLDkt9FuRFhzUIl0RxtE5H6wXR9IXjsygGeJyKjXVS0074AZnl4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682629947; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=y81jYrFdHFI0h2IHDmqZGbfVAz90Pdxvxksgm9ZaytQ=; b=a+HvlF1bZ/Lg5thr6pjx8BBWnDIRpdTlE/C1m1/nodTqGEceXTfNV1KmOij1OaHga/yN0yptobOTd5R+NmaFtb8PhgIjytnLEmffP737bbEmWXZTO9VZTi266XmOxvfRAHfnPkiO7kaVt5kQYpQi6+zKp7h5QL041lAwCcsm4MA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682629947064593.2798919640406; Thu, 27 Apr 2023 14:12:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ps8t7-0005rz-Qf; Thu, 27 Apr 2023 17:10:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps8t2-0005rD-CE for qemu-devel@nongnu.org; Thu, 27 Apr 2023 17:10:45 -0400 Received: from esa1.hc2706-39.iphmx.com ([68.232.153.39]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps8sz-0005K9-U4 for qemu-devel@nongnu.org; Thu, 27 Apr 2023 17:10:44 -0400 Received: from mail-qt1-f197.google.com ([209.85.160.197]) by ob1.hc2706-39.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 27 Apr 2023 17:10:36 -0400 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-3ef30a89abbso59844571cf.2 for ; Thu, 27 Apr 2023 14:10:36 -0700 (PDT) Received: from mozz.bu.edu (mozz.bu.edu. [128.197.127.33]) by smtp.gmail.com with ESMTPSA id d9-20020a05620a240900b0074e24692929sm6228207qkn.106.2023.04.27.14.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 14:10:34 -0700 (PDT) X-IronPort-RemoteIP: 209.85.160.197 X-IronPort-MID: 277415118 X-IronPort-Reputation: None X-IronPort-Listener: OutgoingMail X-IronPort-SenderGroup: RELAY_GSUITE X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:35Ve8ayA21Jr2pJmi/p6t+eJxCrEfRIJ4+MujC+fZmUNrF6WrkUGm DAcDW+Ea/eLNGOhfdtzYYi3p0gA656BmNAySwBuqi00HyNBpPSeOdnIdU2Y0wF+jyHgoOCLy +1EN7Es+ehtFie0Si+Fa+Sn9j8kk/nTHNIQMcacUghpXwhoVSw9vhxqnu89k+ZAjMOwRgiAo rsemeWGULOe82MyYzN8B56r8ks156yu4mxA5TTSWNgQ1LPgvyhNZH4gDfzpR5fIatE8NvK3Q e/F0Ia48gvxl/v6Ior4+lpTWhRiro/6ZGBiuFIPM0SRqkEqShgJ70oOHKF0hXG7Ktm+t4sZJ N1l7fRcQOqyV0HGsL11vxJwSkmSMUDakVNuzLfWXcG7liX7n3XQL/pGXWdqfq859r1OImxF7 cMIdA8SfEyyvrfjqF67YrEEasULKcDqOMYGpiglw2iIUrApRpfMR6iM7thdtNsyrpoWTLCOO oxAN2IpNUWfC/FMEg5/5JYWleO4gHXlWzdF7l+ZuMLb5kCJk1MtieW0aYq9ltqidZpthQWmg Tj69F/gJzcrGPyElgWb/Sf57gPItWahMG4IL5Wh+/t3xVGe2GEXIBsRU1S9vL++kEHWZj5EA 0kd+y5rtLRrsULyH4a7UBq/r3qJ+BUbXrK8DtEH1e1E8YKMiy7xO4TOZmIphAAO3CPueQEX6 w== IronPort-HdrOrdr: A9a23:ALQeOK925eQl/Y3Xz0Ruk+DhI+orL9Y04lQ7vn2ZKCYlC/Bw8v rFoB1173/JYVoqKRYdcPq7Scq9qArnhPxICOoqU4tKPjOW3VdARbsKheDfKlbbaknDH4BmpM FdmmtFZOEYz2IWsS832maF+h8boeW6zA== X-Talos-CUID: 9a23:hvnOzGMHCGvNgO5DCQ87t2w1FpscUXDW1EjAf3CnGzpYcejA X-Talos-MUID: 9a23:+DPFWQb6a0dIl+BTh2DUn3JcE51U6J+3LWY8vbUd5PaaOnkl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bu.edu; s=s1gsbu; t=1682629835; x=1685221835; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=y81jYrFdHFI0h2IHDmqZGbfVAz90Pdxvxksgm9ZaytQ=; b=k+E5MGszO4U/Q+93DhK0WRb5KBoOox2CxKEZ3J6PtwAWqEa32MGSUkLfoW7iNU3xlY 45jnKJYg12pD7LSh1I0gRW+sfyYJ/M9TaUAWQET98X7645AZ03jy5lu2Smk13sg4w7kn S7rjM8xeB+Et56mdc7777OpVyx+kJkNiQnz+orJdaq86++HDD6bL3cbfV515lFX9+KBM j28OoHZk2nhLkEr4yQOCpSdAQCSG0jacSZwST4FmQ/ZlDxJSqpqa9VNdc3ysQwKQ5uCY AS3u+Ezpa3gP8ZF8o6A0Ah0fAE91uGbv2OpKAZxImPRoMzBxHk3hepRt6uVGqmDRkG4v 2VgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682629835; x=1685221835; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y81jYrFdHFI0h2IHDmqZGbfVAz90Pdxvxksgm9ZaytQ=; b=TAB/dJGKvwaAwB33jTzVynrHPQ9jB4FrGCR7D4yfrasamIuWKDa7N8fGEytDnZG9PH yoV4vvkv/EB4fv/sDfqMBxGgQiXX1usoI696wusXxl946OQCzSM4fqTlZch33egtBtDI z+2s3Tnn/x97A0xKS1i3McoVoPxrOm2GL/hqu7eGdi2D45HBO+xDFRnq0wR68khDkI5v +GIn3cXo8+tn6Cm3mGTlZPWVp2V+pXBVxxGbIUu69JqzuwPwyIEyzT0wbxW7gad+jaKo DjG6esIl6jd08TnGLjQlELzq44bDh6oBj8thdyQult3gw5ePtQWC/WKe2v+zZqjtyZ2i /l4w== X-Gm-Message-State: AC+VfDwSRyUxBcEZBYBpl+pgZPert734/taFyuNGyJwZcBf4+/UR0miB baU4tIg0IXormU8uoonKUyi67ond1deQTalRq/HOD9FIAkgkplq1ejLM3Xk0xPG3wejznq0kRAm MbQ98VA4FHcondJgmGewNCR1qtavvu0IW4qCRcaV/DXg= X-Received: by 2002:a05:622a:5ca:b0:3ef:64d9:f0b3 with SMTP id d10-20020a05622a05ca00b003ef64d9f0b3mr4001819qtb.14.1682629835153; Thu, 27 Apr 2023 14:10:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7mZNJ6S1IzpkXugvfanukXvQFph5x3I2LaxWduCjgTu22B/iObV7QHaOcQc7iKsAQz+1cuHw== X-Received: by 2002:a05:622a:5ca:b0:3ef:64d9:f0b3 with SMTP id d10-20020a05622a05ca00b003ef64d9f0b3mr4001773qtb.14.1682629834780; Thu, 27 Apr 2023 14:10:34 -0700 (PDT) From: Alexander Bulekov To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Stefan Hajnoczi , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mauro Matteo Cascella , Peter Xu , Jason Wang , David Hildenbrand , Gerd Hoffmann , Thomas Huth , Laurent Vivier , Bandan Das , "Edgar E . Iglesias" , Darren Kenny , Bin Meng , Paolo Bonzini , "Michael S . Tsirkin" , Marcel Apfelbaum , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Eduardo Habkost , Jon Maloy , Siqi Chen , Michael Tokarev Subject: [PATCH v10 3/8] checkpatch: add qemu_bh_new/aio_bh_new checks Date: Thu, 27 Apr 2023 17:10:08 -0400 Message-Id: <20230427211013.2994127-4-alxndr@bu.edu> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230427211013.2994127-1-alxndr@bu.edu> References: <20230427211013.2994127-1-alxndr@bu.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CES-GSUITE_AUTH: bf3aNvsZpxl8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.153.39; envelope-from=alxndr@bu.edu; helo=esa1.hc2706-39.iphmx.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.266, HK_RANDOM_FROM=0.999, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bu.edu) X-ZM-MESSAGEID: 1682629948652100001 Content-Type: text/plain; charset="utf-8" Advise authors to use the _guarded versions of the APIs, instead. Reviewed-by: Darren Kenny Signed-off-by: Alexander Bulekov --- scripts/checkpatch.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d768171dcf..eeaec436eb 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2865,6 +2865,14 @@ sub process { if ($line =3D~ /\bsignal\s*\(/ && !($line =3D~ /SIG_(?:IGN|DFL)/)) { ERROR("use sigaction to establish signal handlers; signal is not portab= le\n" . $herecurr); } +# recommend qemu_bh_new_guarded instead of qemu_bh_new + if ($realfile =3D~ /.*\/hw\/.*/ && $line =3D~ /\bqemu_bh_new\s*\(/= ) { + ERROR("use qemu_bh_new_guarded() instead of qemu_bh_new() to avoid reen= trancy problems\n" . $herecurr); + } +# recommend aio_bh_new_guarded instead of aio_bh_new + if ($realfile =3D~ /.*\/hw\/.*/ && $line =3D~ /\baio_bh_new\s*\(/)= { + ERROR("use aio_bh_new_guarded() instead of aio_bh_new() to avoid reentr= ancy problems\n" . $herecurr); + } # check for module_init(), use category-specific init macros explicitly pl= ease if ($line =3D~ /^module_init\s*\(/) { ERROR("please use block_init(), type_init() etc. instead of module_init= ()\n" . $herecurr); --=20 2.39.0 From nobody Sat May 11 12:35:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=bu.edu ARC-Seal: i=1; a=rsa-sha256; t=1682629897; cv=none; d=zohomail.com; s=zohoarc; b=M5AmJ6G9Llj/9VptbLoSceOCiOU8gKwY+0AZkqkh4j0BQVJqukuhQ2l9UlZYNdODIigFdIcZXbsqz41RSxu+BWkISFhjyAq6ptozAPwsgGxIHJbiQ3fZSzqPbwR3cX5yELjJUIld3592ns4Uvdkms1d+yccpHL1q3qeZgAmQKiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682629897; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VcAcKX7/rrkQbLPugxX5FYzGcIPCu/jEZtAHpxtM8bY=; b=fUv1HIAS76JZWF8h/S1FVT92w/I+gaQ8Wb25P7eLFWzPslGOWcMtpDTEKjrohhPIH8ybRrYOciEDp7aaieDy6XCbya6ZE6sIcjFKMirGDuiBrh2HhDcWEeBNhv624iVKujZZRLngQ+f8lEDa3uvMh7fe1IpQwKSCXhbaIZYjd3I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1682629897396248.45041100423646; Thu, 27 Apr 2023 14:11:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.527085.819309 (Exim 4.92) (envelope-from ) id 1ps8tC-0007Mj-Q7; Thu, 27 Apr 2023 21:10:54 +0000 Received: by outflank-mailman (output) from mailman id 527085.819309; Thu, 27 Apr 2023 21:10:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ps8tC-0007Mc-NW; Thu, 27 Apr 2023 21:10:54 +0000 Received: by outflank-mailman (input) for mailman id 527085; Thu, 27 Apr 2023 21:10:53 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ps8tB-0007MU-An for xen-devel@lists.xenproject.org; Thu, 27 Apr 2023 21:10:53 +0000 Received: from esa3.hc2706-39.iphmx.com (esa3.hc2706-39.iphmx.com [68.232.154.118]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f9d7d0c6-e53f-11ed-8611-37d641c3527e; Thu, 27 Apr 2023 23:10:47 +0200 (CEST) Received: from mail-qv1-f69.google.com ([209.85.219.69]) by ob1.hc2706-39.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 27 Apr 2023 17:10:39 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6164549243eso33233136d6.2 for ; Thu, 27 Apr 2023 14:10:39 -0700 (PDT) Received: from mozz.bu.edu (mozz.bu.edu. [128.197.127.33]) by smtp.gmail.com with ESMTPSA id h11-20020a0cf44b000000b005fd79831ac7sm5655053qvm.84.2023.04.27.14.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 14:10:38 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f9d7d0c6-e53f-11ed-8611-37d641c3527e X-IronPort-RemoteIP: 209.85.219.69 X-IronPort-MID: 275044140 X-IronPort-Reputation: None X-IronPort-Listener: OutgoingMail X-IronPort-SenderGroup: RELAY_GSUITE X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:jWy096DFhsNoChVW/23iw5YqxClBgxIJ4kV8jS/XYbTApDxwhTNRy 2UdUW7XafbcNGv0LYx3O4nk8k0PvsLUytUwTANkpHpgcSl2pJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdleF+lH2dOCn9SImvU2xbuKUIPbePSxsThNTRi4kiBZy88Y0mYctitWia++3k YqaT/b3ZRn0ilaYDkpOs/jY8E8146yp0N8llgdWic5j7Qe2e0Y9Ucp3yZGZdxPQXoRSF+imc OfPpJnRErTxpkpF5nuNy94XQ2VTKlLgFVHmZkl+AsBOtiN/Shkaic7XAha9hXB/0F1ll/gpo DlEWAfZpQ0BZ8Ugk8xEO/VU/r0X0QSrN9YrLFDm2fF/wXEqfFPW0qR8HW5xNrcR67h4Hl5is uIRdjwSO0Xra+KemNpXS8Fpj8UnadD1ZcYR5CAmwjbeAvIrB5vERs0m5/cChGZ21p0IR6+PI ZRIAdZsRE2ojxlnM1MHDp4ktO21wHTzblW0rXrP+vdvvzSKkFQZPL7FCITMOcaOeuNptRjFm lPBp2fyOipGHYnKodaC2jf27gPVpgvrVYRXGLCm+/pChFyI2ndVGBAQTUG8o/Sylgi5Qd03F qAP0i8nrKx37VLyC9ejDlu3p3mLuhNaUN1VewEn1DywJmPvy17xLgA5ovRpMrTKaOdeqeQW6 2K0 IronPort-HdrOrdr: A9a23:6p2AFKAwZiuAEo7lHelx55DYdb4zR+YMi2TDtnoBLyC9F/bzqy nApoV+6faZskdyZJhCo6HiBEDjex3hHPdOiOF8AV7LZmLbkVGpIoZj6oWn7jvlEy34n9Q96Y 5bc6Z4CNr/SWJ3iMrx/Q+ieuxB/DDtytHOuQ6x9QYJcShaL4ph6Ap4DQjeMmAefmZ77MoCea ah2g== X-Talos-CUID: 9a23:CRTgwG31rQ3WuydR7XUMvrxfINF0YGzyi3zqKl7mBnlWZPqLQAGc5/Yx X-Talos-MUID: =?us-ascii?q?9a23=3AP9t/OQ/sAOnpvnteL836IoCQf/82+ue0DH8rrb5?= =?us-ascii?q?Y5vW1MnRzMA+m0B3iFw=3D=3D?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bu.edu; s=s1gsbu; t=1682629839; x=1685221839; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VcAcKX7/rrkQbLPugxX5FYzGcIPCu/jEZtAHpxtM8bY=; b=N40DSYhOta7JFmG2GB79FxQAiuTAlNVGB9URV2Swz+8b3fBhvOazTB62Y1t4RueU1l QwO7Lpz5bSqDLIXvWeZsSmOw8bLAuizNjQvBsLrvFXvpVp5Z7zAmo9xK20K5Y+WU/cbT K0mx99O39IvOP5gNli+xSBIcCe/EinKgZOvP9S0OMFa9rEH5e+qU77WYpwnVRpi1qDe/ w1phQtKZsywbP3+aj2gWR0D9Bcno0pS37W33dlK9meGQrf94n9gkwJouAXpKVfmPldMW Rc6SZ77f5OXS+hsOo35EABfV+q+wGhd2LFsUEbG+Qbdu6Gwa/CSf77HM3ivs+B4GfCTi tnYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682629839; x=1685221839; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VcAcKX7/rrkQbLPugxX5FYzGcIPCu/jEZtAHpxtM8bY=; b=K24WjEvwWSxLgxhJg7cWO0KqC56s6PF8ukmG3VUBL5/ZEH60rYNG4+uvMVNMFAKVTu wJESsVWwnqInOkTaCnZg4WMeUXnY28wDXStXe0gfzvG6oWPHx+0ayNvi0dru5Lh3jtpj XPYk0ikadcRn2CZTPhI4ytby+3fJEyEdzfeusmx/kj8X+oHB8PlXfpRivQ0/FT3S1eAG 1gpUzOHdKr1FFyLQ/P6J0fTlzWENpmur8I6ZknRWyBK919cLsBseocscgehjk6SKwpiJ 3ihxFjYrM7D/bCq/HS3MuqzZ47ggB5m7fhwUhaaTlZC5dg8iU8NiZ6S4anVkUb8DqYoJ 9DZw== X-Gm-Message-State: AC+VfDzjRimz4zTOndVlXVJHDWERZGiKzsN+gVBoSmcVyICkx9bWneMr ngMY6aytWx7SwCyAiCRHMrRlwozbgt2RnKoZLkduJwupy56fGKo1OmDQr4w8nbRN0wApDAz6vOM Mw9zTRA+RbVUeyQFAiS5RjbeU17r7M4Fr0oPYsw6rAQ== X-Received: by 2002:a05:6214:2347:b0:615:29ab:e4a8 with SMTP id hu7-20020a056214234700b0061529abe4a8mr4422556qvb.31.1682629839187; Thu, 27 Apr 2023 14:10:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4laAbHzi59OplL5JKmO3ZiPSgnb9qxKrUcBhNChCQYWle0Ak0C/LKDEq5d8xbA/FOOHc7blw== X-Received: by 2002:a05:6214:2347:b0:615:29ab:e4a8 with SMTP id hu7-20020a056214234700b0061529abe4a8mr4422500qvb.31.1682629838820; Thu, 27 Apr 2023 14:10:38 -0700 (PDT) From: Alexander Bulekov To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Stefan Hajnoczi , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mauro Matteo Cascella , Peter Xu , Jason Wang , David Hildenbrand , Gerd Hoffmann , Thomas Huth , Laurent Vivier , Bandan Das , "Edgar E . Iglesias" , Darren Kenny , Bin Meng , Paolo Bonzini , "Michael S . Tsirkin" , Marcel Apfelbaum , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Eduardo Habkost , Jon Maloy , Siqi Chen , Michael Tokarev , Paul Durrant , Stefano Stabellini , Anthony Perard , Kevin Wolf , Hanna Reitz , Amit Shah , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow , Peter Maydell , Mark Cave-Ayland , Keith Busch , Klaus Jensen , Fam Zheng , Dmitry Fleytman , "Gonglei (Arei)" , xen-devel@lists.xenproject.org (open list:X86 Xen CPUs), qemu-block@nongnu.org (open list:virtio-blk), qemu-arm@nongnu.org (open list:i.MX31 (kzm)), qemu-ppc@nongnu.org (open list:New World (mac99)) Subject: [PATCH v10 4/8] hw: replace most qemu_bh_new calls with qemu_bh_new_guarded Date: Thu, 27 Apr 2023 17:10:09 -0400 Message-Id: <20230427211013.2994127-5-alxndr@bu.edu> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230427211013.2994127-1-alxndr@bu.edu> References: <20230427211013.2994127-1-alxndr@bu.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CES-GSUITE_AUTH: bf3aNvsZpxl8 X-ZohoMail-DKIM: pass (identity @bu.edu) X-ZM-MESSAGEID: 1682629899079100001 Content-Type: text/plain; charset="utf-8" This protects devices from bh->mmio reentrancy issues. Thanks: Thomas Huth for diagnosing OS X test failure. Reviewed-by: Darren Kenny Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Reviewed-by: Paul Durrant Signed-off-by: Alexander Bulekov Reviewed-by: Thomas Huth --- hw/9pfs/xen-9p-backend.c | 5 ++++- hw/block/dataplane/virtio-blk.c | 3 ++- hw/block/dataplane/xen-block.c | 5 +++-- hw/char/virtio-serial-bus.c | 3 ++- hw/display/qxl.c | 9 ++++++--- hw/display/virtio-gpu.c | 6 ++++-- hw/ide/ahci.c | 3 ++- hw/ide/ahci_internal.h | 1 + hw/ide/core.c | 4 +++- hw/misc/imx_rngc.c | 6 ++++-- hw/misc/macio/mac_dbdma.c | 2 +- hw/net/virtio-net.c | 3 ++- hw/nvme/ctrl.c | 6 ++++-- hw/scsi/mptsas.c | 3 ++- hw/scsi/scsi-bus.c | 3 ++- hw/scsi/vmw_pvscsi.c | 3 ++- hw/usb/dev-uas.c | 3 ++- hw/usb/hcd-dwc2.c | 3 ++- hw/usb/hcd-ehci.c | 3 ++- hw/usb/hcd-uhci.c | 2 +- hw/usb/host-libusb.c | 6 ++++-- hw/usb/redirect.c | 6 ++++-- hw/usb/xen-usb.c | 3 ++- hw/virtio/virtio-balloon.c | 5 +++-- hw/virtio/virtio-crypto.c | 3 ++- 25 files changed, 66 insertions(+), 33 deletions(-) diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c index 74f3a05f88..0e266c552b 100644 --- a/hw/9pfs/xen-9p-backend.c +++ b/hw/9pfs/xen-9p-backend.c @@ -61,6 +61,7 @@ typedef struct Xen9pfsDev { =20 int num_rings; Xen9pfsRing *rings; + MemReentrancyGuard mem_reentrancy_guard; } Xen9pfsDev; =20 static void xen_9pfs_disconnect(struct XenLegacyDevice *xendev); @@ -443,7 +444,9 @@ static int xen_9pfs_connect(struct XenLegacyDevice *xen= dev) xen_9pdev->rings[i].ring.out =3D xen_9pdev->rings[i].data + XEN_FLEX_RING_SIZE(ring_order); =20 - xen_9pdev->rings[i].bh =3D qemu_bh_new(xen_9pfs_bh, &xen_9pdev->ri= ngs[i]); + xen_9pdev->rings[i].bh =3D qemu_bh_new_guarded(xen_9pfs_bh, + &xen_9pdev->rings[i], + &xen_9pdev->mem_reent= rancy_guard); xen_9pdev->rings[i].out_cons =3D 0; xen_9pdev->rings[i].out_size =3D 0; xen_9pdev->rings[i].inprogress =3D false; diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-bl= k.c index b28d81737e..a6202997ee 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -127,7 +127,8 @@ bool virtio_blk_data_plane_create(VirtIODevice *vdev, V= irtIOBlkConf *conf, } else { s->ctx =3D qemu_get_aio_context(); } - s->bh =3D aio_bh_new(s->ctx, notify_guest_bh, s); + s->bh =3D aio_bh_new_guarded(s->ctx, notify_guest_bh, s, + &DEVICE(vdev)->mem_reentrancy_guard); s->batch_notify_vqs =3D bitmap_new(conf->num_queues); =20 *dataplane =3D s; diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c index 734da42ea7..d8bc39d359 100644 --- a/hw/block/dataplane/xen-block.c +++ b/hw/block/dataplane/xen-block.c @@ -633,8 +633,9 @@ XenBlockDataPlane *xen_block_dataplane_create(XenDevice= *xendev, } else { dataplane->ctx =3D qemu_get_aio_context(); } - dataplane->bh =3D aio_bh_new(dataplane->ctx, xen_block_dataplane_bh, - dataplane); + dataplane->bh =3D aio_bh_new_guarded(dataplane->ctx, xen_block_datapla= ne_bh, + dataplane, + &DEVICE(xendev)->mem_reentrancy_gua= rd); =20 return dataplane; } diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 7d4601cb5d..dd619f0731 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -985,7 +985,8 @@ static void virtser_port_device_realize(DeviceState *de= v, Error **errp) return; } =20 - port->bh =3D qemu_bh_new(flush_queued_data_bh, port); + port->bh =3D qemu_bh_new_guarded(flush_queued_data_bh, port, + &dev->mem_reentrancy_guard); port->elem =3D NULL; } =20 diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 80ce1e9a93..f1c0eb7dfc 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -2201,11 +2201,14 @@ static void qxl_realize_common(PCIQXLDevice *qxl, E= rror **errp) =20 qemu_add_vm_change_state_handler(qxl_vm_change_state_handler, qxl); =20 - qxl->update_irq =3D qemu_bh_new(qxl_update_irq_bh, qxl); + qxl->update_irq =3D qemu_bh_new_guarded(qxl_update_irq_bh, qxl, + &DEVICE(qxl)->mem_reentrancy_gua= rd); qxl_reset_state(qxl); =20 - qxl->update_area_bh =3D qemu_bh_new(qxl_render_update_area_bh, qxl); - qxl->ssd.cursor_bh =3D qemu_bh_new(qemu_spice_cursor_refresh_bh, &qxl-= >ssd); + qxl->update_area_bh =3D qemu_bh_new_guarded(qxl_render_update_area_bh,= qxl, + &DEVICE(qxl)->mem_reentrancy= _guard); + qxl->ssd.cursor_bh =3D qemu_bh_new_guarded(qemu_spice_cursor_refresh_b= h, &qxl->ssd, + &DEVICE(qxl)->mem_reentrancy_= guard); } =20 static void qxl_realize_primary(PCIDevice *dev, Error **errp) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 5e15c79b94..66ac9b6cc5 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1339,8 +1339,10 @@ void virtio_gpu_device_realize(DeviceState *qdev, Er= ror **errp) =20 g->ctrl_vq =3D virtio_get_queue(vdev, 0); g->cursor_vq =3D virtio_get_queue(vdev, 1); - g->ctrl_bh =3D qemu_bh_new(virtio_gpu_ctrl_bh, g); - g->cursor_bh =3D qemu_bh_new(virtio_gpu_cursor_bh, g); + g->ctrl_bh =3D qemu_bh_new_guarded(virtio_gpu_ctrl_bh, g, + &qdev->mem_reentrancy_guard); + g->cursor_bh =3D qemu_bh_new_guarded(virtio_gpu_cursor_bh, g, + &qdev->mem_reentrancy_guard); QTAILQ_INIT(&g->reslist); QTAILQ_INIT(&g->cmdq); QTAILQ_INIT(&g->fenceq); diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 55902e1df7..4e76d6b191 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1509,7 +1509,8 @@ static void ahci_cmd_done(const IDEDMA *dma) ahci_write_fis_d2h(ad); =20 if (ad->port_regs.cmd_issue && !ad->check_bh) { - ad->check_bh =3D qemu_bh_new(ahci_check_cmd_bh, ad); + ad->check_bh =3D qemu_bh_new_guarded(ahci_check_cmd_bh, ad, + &ad->mem_reentrancy_guard); qemu_bh_schedule(ad->check_bh); } } diff --git a/hw/ide/ahci_internal.h b/hw/ide/ahci_internal.h index 303fcd7235..2480455372 100644 --- a/hw/ide/ahci_internal.h +++ b/hw/ide/ahci_internal.h @@ -321,6 +321,7 @@ struct AHCIDevice { bool init_d2h_sent; AHCICmdHdr *cur_cmd; NCQTransferState ncq_tfs[AHCI_MAX_CMDS]; + MemReentrancyGuard mem_reentrancy_guard; }; =20 struct AHCIPCIState { diff --git a/hw/ide/core.c b/hw/ide/core.c index 45d14a25e9..de48ff9f86 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -513,6 +513,7 @@ BlockAIOCB *ide_issue_trim( BlockCompletionFunc *cb, void *cb_opaque, void *opaque) { IDEState *s =3D opaque; + IDEDevice *dev =3D s->unit ? s->bus->slave : s->bus->master; TrimAIOCB *iocb; =20 /* Paired with a decrement in ide_trim_bh_cb() */ @@ -520,7 +521,8 @@ BlockAIOCB *ide_issue_trim( =20 iocb =3D blk_aio_get(&trim_aiocb_info, s->blk, cb, cb_opaque); iocb->s =3D s; - iocb->bh =3D qemu_bh_new(ide_trim_bh_cb, iocb); + iocb->bh =3D qemu_bh_new_guarded(ide_trim_bh_cb, iocb, + &DEVICE(dev)->mem_reentrancy_guard); iocb->ret =3D 0; iocb->qiov =3D qiov; iocb->i =3D -1; diff --git a/hw/misc/imx_rngc.c b/hw/misc/imx_rngc.c index 632c03779c..082c6980ad 100644 --- a/hw/misc/imx_rngc.c +++ b/hw/misc/imx_rngc.c @@ -228,8 +228,10 @@ static void imx_rngc_realize(DeviceState *dev, Error *= *errp) sysbus_init_mmio(sbd, &s->iomem); =20 sysbus_init_irq(sbd, &s->irq); - s->self_test_bh =3D qemu_bh_new(imx_rngc_self_test, s); - s->seed_bh =3D qemu_bh_new(imx_rngc_seed, s); + s->self_test_bh =3D qemu_bh_new_guarded(imx_rngc_self_test, s, + &dev->mem_reentrancy_guard); + s->seed_bh =3D qemu_bh_new_guarded(imx_rngc_seed, s, + &dev->mem_reentrancy_guard); } =20 static void imx_rngc_reset(DeviceState *dev) diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c index 43bb1f56ba..80a789f32b 100644 --- a/hw/misc/macio/mac_dbdma.c +++ b/hw/misc/macio/mac_dbdma.c @@ -914,7 +914,7 @@ static void mac_dbdma_realize(DeviceState *dev, Error *= *errp) { DBDMAState *s =3D MAC_DBDMA(dev); =20 - s->bh =3D qemu_bh_new(DBDMA_run_bh, s); + s->bh =3D qemu_bh_new_guarded(DBDMA_run_bh, s, &dev->mem_reentrancy_gu= ard); } =20 static void mac_dbdma_class_init(ObjectClass *oc, void *data) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 53e1c32643..447f669921 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2917,7 +2917,8 @@ static void virtio_net_add_queue(VirtIONet *n, int in= dex) n->vqs[index].tx_vq =3D virtio_add_queue(vdev, n->net_conf.tx_queue_size, virtio_net_handle_tx_bh); - n->vqs[index].tx_bh =3D qemu_bh_new(virtio_net_tx_bh, &n->vqs[inde= x]); + n->vqs[index].tx_bh =3D qemu_bh_new_guarded(virtio_net_tx_bh, &n->= vqs[index], + &DEVICE(vdev)->mem_reent= rancy_guard); } =20 n->vqs[index].tx_waiting =3D 0; diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index f59dfe1cbe..fd917fcda1 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -4607,7 +4607,8 @@ static void nvme_init_sq(NvmeSQueue *sq, NvmeCtrl *n,= uint64_t dma_addr, QTAILQ_INSERT_TAIL(&(sq->req_list), &sq->io_req[i], entry); } =20 - sq->bh =3D qemu_bh_new(nvme_process_sq, sq); + sq->bh =3D qemu_bh_new_guarded(nvme_process_sq, sq, + &DEVICE(sq->ctrl)->mem_reentrancy_guard); =20 if (n->dbbuf_enabled) { sq->db_addr =3D n->dbbuf_dbs + (sqid << 3); @@ -5253,7 +5254,8 @@ static void nvme_init_cq(NvmeCQueue *cq, NvmeCtrl *n,= uint64_t dma_addr, } } n->cq[cqid] =3D cq; - cq->bh =3D qemu_bh_new(nvme_post_cqes, cq); + cq->bh =3D qemu_bh_new_guarded(nvme_post_cqes, cq, + &DEVICE(cq->ctrl)->mem_reentrancy_guard); } =20 static uint16_t nvme_create_cq(NvmeCtrl *n, NvmeRequest *req) diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c index c485da792c..3de288b454 100644 --- a/hw/scsi/mptsas.c +++ b/hw/scsi/mptsas.c @@ -1322,7 +1322,8 @@ static void mptsas_scsi_realize(PCIDevice *dev, Error= **errp) } s->max_devices =3D MPTSAS_NUM_PORTS; =20 - s->request_bh =3D qemu_bh_new(mptsas_fetch_requests, s); + s->request_bh =3D qemu_bh_new_guarded(mptsas_fetch_requests, s, + &DEVICE(dev)->mem_reentrancy_guard= ); =20 scsi_bus_init(&s->bus, sizeof(s->bus), &dev->qdev, &mptsas_scsi_info); } diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index c97176110c..3c20b47ad0 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -193,7 +193,8 @@ static void scsi_dma_restart_cb(void *opaque, bool runn= ing, RunState state) AioContext *ctx =3D blk_get_aio_context(s->conf.blk); /* The reference is dropped in scsi_dma_restart_bh.*/ object_ref(OBJECT(s)); - s->bh =3D aio_bh_new(ctx, scsi_dma_restart_bh, s); + s->bh =3D aio_bh_new_guarded(ctx, scsi_dma_restart_bh, s, + &DEVICE(s)->mem_reentrancy_guard); qemu_bh_schedule(s->bh); } } diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c index fa76696855..4de34536e9 100644 --- a/hw/scsi/vmw_pvscsi.c +++ b/hw/scsi/vmw_pvscsi.c @@ -1184,7 +1184,8 @@ pvscsi_realizefn(PCIDevice *pci_dev, Error **errp) pcie_endpoint_cap_init(pci_dev, PVSCSI_EXP_EP_OFFSET); } =20 - s->completion_worker =3D qemu_bh_new(pvscsi_process_completion_queue, = s); + s->completion_worker =3D qemu_bh_new_guarded(pvscsi_process_completion= _queue, s, + &DEVICE(pci_dev)->mem_reent= rancy_guard); =20 scsi_bus_init(&s->bus, sizeof(s->bus), DEVICE(pci_dev), &pvscsi_scsi_i= nfo); /* override default SCSI bus hotplug-handler, with pvscsi's one */ diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c index 88f99c05d5..f013ded91e 100644 --- a/hw/usb/dev-uas.c +++ b/hw/usb/dev-uas.c @@ -937,7 +937,8 @@ static void usb_uas_realize(USBDevice *dev, Error **err= p) =20 QTAILQ_INIT(&uas->results); QTAILQ_INIT(&uas->requests); - uas->status_bh =3D qemu_bh_new(usb_uas_send_status_bh, uas); + uas->status_bh =3D qemu_bh_new_guarded(usb_uas_send_status_bh, uas, + &d->mem_reentrancy_guard); =20 dev->flags |=3D (1 << USB_DEV_FLAG_IS_SCSI_STORAGE); scsi_bus_init(&uas->bus, sizeof(uas->bus), DEVICE(dev), &usb_uas_scsi_= info); diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c index 8755e9cbb0..a0c4e782b2 100644 --- a/hw/usb/hcd-dwc2.c +++ b/hw/usb/hcd-dwc2.c @@ -1364,7 +1364,8 @@ static void dwc2_realize(DeviceState *dev, Error **er= rp) s->fi =3D USB_FRMINTVL - 1; s->eof_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, dwc2_frame_boundary,= s); s->frame_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, dwc2_work_timer, s= ); - s->async_bh =3D qemu_bh_new(dwc2_work_bh, s); + s->async_bh =3D qemu_bh_new_guarded(dwc2_work_bh, s, + &dev->mem_reentrancy_guard); =20 sysbus_init_irq(sbd, &s->irq); } diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index d4da8dcb8d..c930c60921 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -2533,7 +2533,8 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev,= Error **errp) } =20 s->frame_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, ehci_work_timer, s= ); - s->async_bh =3D qemu_bh_new(ehci_work_bh, s); + s->async_bh =3D qemu_bh_new_guarded(ehci_work_bh, s, + &dev->mem_reentrancy_guard); s->device =3D dev; =20 s->vmstate =3D qemu_add_vm_change_state_handler(usb_ehci_vm_state_chan= ge, s); diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 8ac1175ad2..77baaa7a6b 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -1190,7 +1190,7 @@ void usb_uhci_common_realize(PCIDevice *dev, Error **= errp) USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL); } } - s->bh =3D qemu_bh_new(uhci_bh, s); + s->bh =3D qemu_bh_new_guarded(uhci_bh, s, &DEVICE(dev)->mem_reentrancy= _guard); s->frame_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, uhci_frame_timer, = s); s->num_ports_vmstate =3D NB_PORTS; QTAILQ_INIT(&s->queues); diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index 176868d345..f500db85ab 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -1141,7 +1141,8 @@ static void usb_host_nodev_bh(void *opaque) static void usb_host_nodev(USBHostDevice *s) { if (!s->bh_nodev) { - s->bh_nodev =3D qemu_bh_new(usb_host_nodev_bh, s); + s->bh_nodev =3D qemu_bh_new_guarded(usb_host_nodev_bh, s, + &DEVICE(s)->mem_reentrancy_guard= ); } qemu_bh_schedule(s->bh_nodev); } @@ -1739,7 +1740,8 @@ static int usb_host_post_load(void *opaque, int versi= on_id) USBHostDevice *dev =3D opaque; =20 if (!dev->bh_postld) { - dev->bh_postld =3D qemu_bh_new(usb_host_post_load_bh, dev); + dev->bh_postld =3D qemu_bh_new_guarded(usb_host_post_load_bh, dev, + &DEVICE(dev)->mem_reentrancy_= guard); } qemu_bh_schedule(dev->bh_postld); dev->bh_postld_pending =3D true; diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index fd7df599bc..39fbaaab16 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -1441,8 +1441,10 @@ static void usbredir_realize(USBDevice *udev, Error = **errp) } } =20 - dev->chardev_close_bh =3D qemu_bh_new(usbredir_chardev_close_bh, dev); - dev->device_reject_bh =3D qemu_bh_new(usbredir_device_reject_bh, dev); + dev->chardev_close_bh =3D qemu_bh_new_guarded(usbredir_chardev_close_b= h, dev, + &DEVICE(dev)->mem_reentran= cy_guard); + dev->device_reject_bh =3D qemu_bh_new_guarded(usbredir_device_reject_b= h, dev, + &DEVICE(dev)->mem_reentran= cy_guard); dev->attach_timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, usbredir_do_att= ach, dev); =20 packet_id_queue_init(&dev->cancelled, dev, "cancelled"); diff --git a/hw/usb/xen-usb.c b/hw/usb/xen-usb.c index 66cb3f7c24..38ee660a30 100644 --- a/hw/usb/xen-usb.c +++ b/hw/usb/xen-usb.c @@ -1032,7 +1032,8 @@ static void usbback_alloc(struct XenLegacyDevice *xen= dev) =20 QTAILQ_INIT(&usbif->req_free_q); QSIMPLEQ_INIT(&usbif->hotplug_q); - usbif->bh =3D qemu_bh_new(usbback_bh, usbif); + usbif->bh =3D qemu_bh_new_guarded(usbback_bh, usbif, + &DEVICE(xendev)->mem_reentrancy_guard); } =20 static int usbback_free(struct XenLegacyDevice *xendev) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index fd06fcfb3f..d004cf29d2 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -886,8 +886,9 @@ static void virtio_balloon_device_realize(DeviceState *= dev, Error **errp) precopy_add_notifier(&s->free_page_hint_notify); =20 object_ref(OBJECT(s->iothread)); - s->free_page_bh =3D aio_bh_new(iothread_get_aio_context(s->iothrea= d), - virtio_ballloon_get_free_page_hints, = s); + s->free_page_bh =3D aio_bh_new_guarded(iothread_get_aio_context(s-= >iothread), + virtio_ballloon_get_free_page= _hints, s, + &dev->mem_reentrancy_guard); } =20 if (virtio_has_feature(s->host_features, VIRTIO_BALLOON_F_REPORTING)) { diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 802e1b9659..2fe804510f 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -1074,7 +1074,8 @@ static void virtio_crypto_device_realize(DeviceState = *dev, Error **errp) vcrypto->vqs[i].dataq =3D virtio_add_queue(vdev, 1024, virtio_crypto_handle_dataq_b= h); vcrypto->vqs[i].dataq_bh =3D - qemu_bh_new(virtio_crypto_dataq_bh, &vcrypto->vqs[i]); + qemu_bh_new_guarded(virtio_crypto_dataq_bh, &vcrypto->vqs= [i], + &dev->mem_reentrancy_guard); vcrypto->vqs[i].vcrypto =3D vcrypto; } =20 --=20 2.39.0 From nobody Sat May 11 12:35:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=bu.edu ARC-Seal: i=1; a=rsa-sha256; t=1682629918; cv=none; d=zohomail.com; s=zohoarc; b=UWkWV3ljAC8HMcrGVFjWGgJ4yqVRxh1nn4Ot8IiA3TziZjRqhDZGP4/o6eWyE93w5VvbEQkz7CdADFe+dGicrQD7XDvl32BTLVyfbeZP/2pa2q0EK7ozivDZAsK/DmnxvOa8Mo+Pr0JlnQnrsYCBSLOAcATc+HFh18aHFRHluzQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682629918; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3SdAMrXHXFKpIl5axn2Wa+vv4dRDlBMdBU9qEifc6x0=; b=NrESSLyrOlKwFoaXXhgixcF6FI7JcO48H2ohlSnM+8EXGzupDeXAkE0GN8PqDeNv5RvYdjGSI0BT5N1//fYLCD+WwUHpbEG4b2qk5pCLW7QPCzSSOkQHV+Hc39zgQKM0lueeZxRYSkfFVifP6D1muhbdJqNMly7pNQkUWAIbeMc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682629918582211.47981154405727; Thu, 27 Apr 2023 14:11:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ps8tA-0005sq-DV; Thu, 27 Apr 2023 17:10:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps8t6-0005rx-0t for qemu-devel@nongnu.org; Thu, 27 Apr 2023 17:10:49 -0400 Received: from esa8.hc2706-39.iphmx.com ([216.71.140.196]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps8t3-0005MH-82 for qemu-devel@nongnu.org; Thu, 27 Apr 2023 17:10:47 -0400 Received: from mail-qk1-f199.google.com ([209.85.222.199]) by ob1.hc2706-39.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 27 Apr 2023 17:10:43 -0400 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-74e0cfab3f0so1383337785a.1 for ; Thu, 27 Apr 2023 14:10:43 -0700 (PDT) Received: from mozz.bu.edu (mozz.bu.edu. [128.197.127.33]) by smtp.gmail.com with ESMTPSA id z30-20020a0ca95e000000b005ef61084fddsm5909401qva.131.2023.04.27.14.10.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 14:10:41 -0700 (PDT) X-IronPort-RemoteIP: 209.85.222.199 X-IronPort-MID: 273267400 X-IronPort-Reputation: None X-IronPort-Listener: OutgoingMail X-IronPort-SenderGroup: RELAY_GSUITE X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:+IGXKaA07k9pqxVW/5fhw5YqxClBgxIJ4kV8jS/XYbTApGwrgTIDz WEeXT+DPfmIZ2X2fdAlPoWx/U8G78DSy9Y3TANkpHpgcSl2pJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdleF+lH2dOCn9SImvU2xbuKUIPbePSxsThNTRi4kiBZy88Y0mYctitWia++3k YqaT/b3ZRn0ilaYDkpOs/jY8E8146yp0N8llgdWic5j7Qe2e0Y9Ucp3yZGZdxPQXoRSF+imc OfPpJnRErTxpkpF5nuNy94XQ2VTKlLgFVHmZkl+AsBOtiN/Shkaic7XAha9hXB/0F1ll/gpo DlEWAfZpQ0BZ8Ugk8xEO/VU/r0X0QSrN9YrLFDm2fF/wXEqfFPGyqpEF1smALEkubl7XmJWr sJHGTskO0Xra+KemNpXS8Fpj8UnadDoZcYR4yAxiz7eCvkiTNbIRKCiCd1whm9hwJATW6yEP YxAOGsHgBfoOnWjPn8eDII4kP2AjGS5fjFFwL6QjfBouDKNk1ApiNABNvLqIPGTdOkSwX+U+ ELFxELhHA0cOe6AnG/tHnWEw7WncTnAcJsfEaD9+vN0jVm7wGsVBxsLE1yhrpGEZlWWXtteL wkN+XNro/FjpQqkSd7yWxD+q3mB1vIBZ+dt/yQBwFnl4sLpD8yxXQDokhYphAQaifIL IronPort-HdrOrdr: A9a23:tpe5R66AU/ywPhytLAPXwPHXdLJyesId70hD6qkRc20tTiX8ra qTdZsgtSMc5AxhP03Is+rwW5VoOEmsl6KdgrN+AV7BZniChILAFugLhrcKqAeQfxEWmNQts5 uIsJITNDQzNzVHZArBjzVQ2uxA/OW6 X-Talos-CUID: =?us-ascii?q?9a23=3AJ+VyKWnx4lwOShyXdceA2zgtfnrXOVfUk13LOV+?= =?us-ascii?q?FNVoqF7HKSkfLxvxVmOM7zg=3D=3D?= X-Talos-MUID: 9a23:q2HQIgrTUrfcNGGofpoezw44Gd5Zz+PxMUxTsZY9ndGaKSp9CSjI2Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bu.edu; s=s1gsbu; t=1682629842; x=1685221842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3SdAMrXHXFKpIl5axn2Wa+vv4dRDlBMdBU9qEifc6x0=; b=KW7CV0J6EY0fDwThGtGw2mV/XIr2QVr9ZzmmCxQL3KD5G23HIbJP/Ts25JkCfWJ+RC IxqH5DOE5TQpIU5qq1u4hOuL3nbZrAkljXBE8lakBfKn7bTXfWNyNOCZz14xAvGyp0+S 2hGWcspqZ4+8E2sXL+sv2K0mdNtZj2GbZF9R1aa0i6SV9V89V7VGCreAM1BlXZ8ybVrV rqHkU/HW4W5kRTo+9zfKTibYMRJ9flsws+Snd0flNLR/81a6s0K1F6xk6k+oQ4LOPkO9 LYW0Q/4CCusiAk91x76HiHDTm7kXIVoCebsvov/G4taQnZfTgFuXGz/FGKq8VHbM4P9n agQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682629842; x=1685221842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3SdAMrXHXFKpIl5axn2Wa+vv4dRDlBMdBU9qEifc6x0=; b=cxMteY2wlHYSqj5WPa+TnQcxF9K44l6TrhekrJHif6A6d0hL11FeXK2frH6bcPi0Uk 1IWQE+xitGhHt+UrCXlzO0fxn/raDFJ4RZGghYS1cNGuxb1jHesWwFpCncFb42Y7hu6L Qcd7ynkWDwo7Wq1yY3LhmcAtFfC632qr/H9QMyww5Z2uli4xjJBIJxiF26aItcK5+udW riuyKvZ39Sl6/d9o0hPrkYlIsKMnxjDNCra+STHunq3DE/5E75brKZExlCQMtktTJnI+ l/0ihN7dLfWbQcP24UhNIUclfjqhBdOZ1h4YsjaCl0PdgpyyuB/OgQkICWnJcLHu9Rie FJtQ== X-Gm-Message-State: AC+VfDz2r+E1oowp2QLPUVlejiEKprhnO2wDbv0zwSiPwX6+DgnU4gRZ EPU2D4lAo4j4Q7busM7lY2x/BfuZ+Fabr+pdJ50bxwD9tAqSilSoeNWfIYXB2ZUQPan9PjhBKn1 osevOOpvycpDPjjSNSVH+dT/13UoSsZ8vI4aoK2LYPbg= X-Received: by 2002:a05:6214:20ee:b0:614:da60:f45d with SMTP id 14-20020a05621420ee00b00614da60f45dmr4902469qvk.30.1682629842287; Thu, 27 Apr 2023 14:10:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6B2366U41LLQszN6ihcZBrJk8YDRrKzcE3mBVfX6MFBk6kfHQJtYnCxk0tCNi7X4uqKewdLA== X-Received: by 2002:a05:6214:20ee:b0:614:da60:f45d with SMTP id 14-20020a05621420ee00b00614da60f45dmr4902422qvk.30.1682629842058; Thu, 27 Apr 2023 14:10:42 -0700 (PDT) From: Alexander Bulekov To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Stefan Hajnoczi , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mauro Matteo Cascella , Peter Xu , Jason Wang , David Hildenbrand , Gerd Hoffmann , Thomas Huth , Laurent Vivier , Bandan Das , "Edgar E . Iglesias" , Darren Kenny , Bin Meng , Paolo Bonzini , "Michael S . Tsirkin" , Marcel Apfelbaum , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Eduardo Habkost , Jon Maloy , Siqi Chen , Michael Tokarev , Fiona Ebner , Fam Zheng Subject: [PATCH v10 5/8] lsi53c895a: disable reentrancy detection for script RAM Date: Thu, 27 Apr 2023 17:10:10 -0400 Message-Id: <20230427211013.2994127-6-alxndr@bu.edu> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230427211013.2994127-1-alxndr@bu.edu> References: <20230427211013.2994127-1-alxndr@bu.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CES-GSUITE_AUTH: bf3aNvsZpxl8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.140.196; envelope-from=alxndr@bu.edu; helo=esa8.hc2706-39.iphmx.com X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.266, HK_RANDOM_FROM=0.999, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bu.edu) X-ZM-MESSAGEID: 1682629920800100007 Content-Type: text/plain; charset="utf-8" As the code is designed to use the memory APIs to access the script ram, disable reentrancy checks for the pseudo-RAM ram_io MemoryRegion. In the future, ram_io may be converted from an IO to a proper RAM MemoryReg= ion. Reported-by: Fiona Ebner Signed-off-by: Alexander Bulekov Reviewed-by: Thomas Huth Reviewed-by: Darren Kenny --- hw/scsi/lsi53c895a.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index af93557a9a..db27872963 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -2302,6 +2302,12 @@ static void lsi_scsi_realize(PCIDevice *dev, Error *= *errp) memory_region_init_io(&s->io_io, OBJECT(s), &lsi_io_ops, s, "lsi-io", 256); =20 + /* + * Since we use the address-space API to interact with ram_io, disable= the + * re-entrancy guard. + */ + s->ram_io.disable_reentrancy_guard =3D true; + address_space_init(&s->pci_io_as, pci_address_space_io(dev), "lsi-pci-= io"); qdev_init_gpio_out(d, &s->ext_irq, 1); =20 --=20 2.39.0 From nobody Sat May 11 12:35:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=bu.edu ARC-Seal: i=1; a=rsa-sha256; t=1682629972; cv=none; d=zohomail.com; s=zohoarc; b=KOvXqN73GII8kHvw43xdVU/AEsJp3Q7MJttgvnhUPQQ/p1O2JrPGkC94uH5/mqf9TgBCUz2b7BELGYManP/PUsp2xO/8t+w6pupylnZ3WQx/mW605xrHZ45/WjNfMMEB0W0w/wMj5U0X4bnRQFZd0UXu34otlIR6lFmL9doRK98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682629972; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=baPw7HeUNSOgBdUdX5+Wv116KVOdtz82o0yKX11s6GY=; b=MeVh10ek81MROQDhk9VH0YhduvF5D0URx1fjwJ/dSPKtkUBa9WMslacFrvAp2BWZ2/gqWklQH85NQD/8amjzRhSeQSWTIpnLLIv+HUVTxFK3wOliVYcyc15r4o2+gQcnxzuDVdStYtYQhMH+R84yu77UJM8XFu/5nD2BImTs1Yo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682629972452373.2331803529245; Thu, 27 Apr 2023 14:12:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ps8tD-0005up-H1; Thu, 27 Apr 2023 17:10:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps8tC-0005uQ-Ks for qemu-devel@nongnu.org; Thu, 27 Apr 2023 17:10:54 -0400 Received: from esa16.hc2706-39.iphmx.com ([216.71.140.205]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps8tB-0005N6-1u for qemu-devel@nongnu.org; Thu, 27 Apr 2023 17:10:54 -0400 Received: from mail-qt1-f198.google.com ([209.85.160.198]) by ob1.hc2706-39.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 27 Apr 2023 17:10:46 -0400 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-3ef691d1eebso41123141cf.3 for ; Thu, 27 Apr 2023 14:10:46 -0700 (PDT) Received: from mozz.bu.edu (mozz.bu.edu. [128.197.127.33]) by smtp.gmail.com with ESMTPSA id y11-20020ac8128b000000b003ef6582d971sm4947634qti.47.2023.04.27.14.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 14:10:44 -0700 (PDT) X-IronPort-RemoteIP: 209.85.160.198 X-IronPort-MID: 273505222 X-IronPort-Reputation: None X-IronPort-Listener: OutgoingMail X-IronPort-SenderGroup: RELAY_GSUITE X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:L1ko/qMmjNAJjcXvrR0clcFynXyQoLVcMsEvi/4bfWQNrUpzhWZSy WUfUW2DPf7cMWrxf9gkbI+//BsPvsDUzN82SAZtpSBmQkwRlceUXt7xwmUcns+xwm8vaGo9s q3yv/GZdJhcokf0/0vraf656yEnj8lkf5KkYMbcICd9WAR4fykojBNnioYRj5VhxNO0GGthg /uryyHkEALjim8c3l48sfrZ80sz5quq41v0g3RlDRx1lA6G/5UqJM9HTU2BByOQapVZGOe8W 9HCwNmRlo8O105wYj8Nuu+TnnwiG9Y+DyDX4pZlc/HKbix5m8AH+v1T2MzwyKtgo27hc9hZk L2hvHErIOsjFvSkdO81CnG0H8ziVEHvFXCuzXWX6KSuI0P6n3TE76RwFmMaDKgj2LhRJ1AUz voGFA0OV0XW7w626OrTpuhEg80iKIzyINpatCgxnXfWCvEpRZ2FSKLPjTNa9G1o14YeQLCHO ZJfMGs/BPjDS0Qn1lM/AZYumuuyrnPiNTBUtTp5oIJtvDOOlFEriuKF3Nz9Q+WPHJlzgB6hv DyF8U6lHj9CD/HF4G/Qmp6rrqqV9c/hY6oLGbils/JnnlCX7moUDhIQSB28u/bRt6Klc9dWK khR4zZ36KZrpRztQd76UBm15nWDu3bwRuZtLgHz0ynVooK83upTLjJYJtKdQLTKbPMLeAE= IronPort-HdrOrdr: A9a23:OekdeK5sCWHurHwhSgPXwPLXdLJyesId70hD6qkXc3Bom62j+P xG+c5x6faaslgssR0b+OxoWpPwIk80hKQU3WB5B97LNmTbUQ2TXeRfBODZsl/d8kPFh4lg/J YlX69iCMDhSXhW5PyKhjVQyuxQpOW6zA== X-Talos-CUID: =?us-ascii?q?9a23=3AJmGVPmjDK6bOEhuqmqhpZxuLFjJuXizD1lX8Emq?= =?us-ascii?q?DKzhPbozPclmOxJ5nqp87?= X-Talos-MUID: 9a23:KtIfMwX5UMfVn2jq/AbVgWg+Etkw2r7wS04nzYko4/KpbwUlbg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bu.edu; s=s1gsbu; t=1682629845; x=1685221845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=baPw7HeUNSOgBdUdX5+Wv116KVOdtz82o0yKX11s6GY=; b=bLc+Sf5D1COH9x0JkJGO6Ctb9788JBLqleFbg1rk9fKeYwT1xuEpXgsPlBhLdBxhc8 +dHqKSk7ueRWZawLcd9+Lqpt+n57ngOvEilE/H/vrR4RembzJXWHy2UfrV5dI/YqXTOS lQtmWH3P2jAFFIoFwK1y0p/lKJerr8CicukEyGsfIZNl01WAhafJnv2jlDL24EjkEPru xXHtzIt1wpHEYtZdX6uiiXwxTqORr17CyOzXdCa1CrS9kWtARYnIOQ5v6cYDXWrD+aWm XbWeTViYxuACcF2UU7KxIm5JIn5LQ+xm2cOGEDpX1wfDJ3ArwMCvHTyw22PhEYrk17uc GNJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682629845; x=1685221845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=baPw7HeUNSOgBdUdX5+Wv116KVOdtz82o0yKX11s6GY=; b=M2C9Ajbb6IVCXJcoMpZyL0E+nhXF5IR+or/D5s1U2SkoK96tjT0iZDRB2mB5SKeYIN p11KWbB4T3Dq8aOQmpR6bMLMQWibOcgUkybxuDfesHFpDhX7/jFelfFZqU3tH5km3NlH mwgo7mISidkzovYQg15kdKfa4SiNmIVFNyq74BJI9Rx4YebJXHQ+YTev9RqOsgTo3Cau vvzi39aHPhnZP/MIS3fjRWCTlgZCequluGj4qDa2aMUjZtRGceGYc1qVd/rMnR8Ovydp M/r32aM5ZLgLzRYHYAWdBeSTsyUss83ONPw0LeYGfTBGfjP1Hj8RTW2kATzS/SZv6zat pabQ== X-Gm-Message-State: AC+VfDxGPa99daqbrbwuUqTjcvkK1jJ+iSxtd9VtxnPGn5On1lGfk77y LsFFGcakv34p/DOnNP1ykQOxC9wrBPMksRHi53xNCxmgTQALyJJ6V9f1OGvEzS0grRTHYLKiy6w hkngDU08HtVoGsGvdV6yHZsMwe+lWQcpMYb6uoXP7J7M= X-Received: by 2002:ac8:57c4:0:b0:3ea:bac1:a5be with SMTP id w4-20020ac857c4000000b003eabac1a5bemr4760082qta.42.1682629845233; Thu, 27 Apr 2023 14:10:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5qbri2Q+LH4NR35KATOGWb7DKHwgO2Xe2TuucXECJ/VltVtTl8c7BvSI8Jk5PVIxv7tHJtJg== X-Received: by 2002:ac8:57c4:0:b0:3ea:bac1:a5be with SMTP id w4-20020ac857c4000000b003eabac1a5bemr4760042qta.42.1682629844982; Thu, 27 Apr 2023 14:10:44 -0700 (PDT) From: Alexander Bulekov To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Stefan Hajnoczi , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mauro Matteo Cascella , Peter Xu , Jason Wang , David Hildenbrand , Gerd Hoffmann , Thomas Huth , Laurent Vivier , Bandan Das , "Edgar E . Iglesias" , Darren Kenny , Bin Meng , Paolo Bonzini , "Michael S . Tsirkin" , Marcel Apfelbaum , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Eduardo Habkost , Jon Maloy , Siqi Chen , Michael Tokarev , Peter Maydell , qemu-arm@nongnu.org (open list:Raspberry Pi) Subject: [PATCH v10 6/8] bcm2835_property: disable reentrancy detection for iomem Date: Thu, 27 Apr 2023 17:10:11 -0400 Message-Id: <20230427211013.2994127-7-alxndr@bu.edu> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230427211013.2994127-1-alxndr@bu.edu> References: <20230427211013.2994127-1-alxndr@bu.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CES-GSUITE_AUTH: bf3aNvsZpxl8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.140.205; envelope-from=alxndr@bu.edu; helo=esa16.hc2706-39.iphmx.com X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.266, HK_RANDOM_FROM=0.999, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bu.edu) X-ZM-MESSAGEID: 1682629973260100001 Content-Type: text/plain; charset="utf-8" As the code is designed for re-entrant calls from bcm2835_property to bcm2835_mbox and back into bcm2835_property, mark iomem as reentrancy-safe. Signed-off-by: Alexander Bulekov Reviewed-by: Thomas Huth --- hw/misc/bcm2835_property.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c index 890ae7bae5..de056ea2df 100644 --- a/hw/misc/bcm2835_property.c +++ b/hw/misc/bcm2835_property.c @@ -382,6 +382,13 @@ static void bcm2835_property_init(Object *obj) =20 memory_region_init_io(&s->iomem, OBJECT(s), &bcm2835_property_ops, s, TYPE_BCM2835_PROPERTY, 0x10); + + /* + * bcm2835_property_ops call into bcm2835_mbox, which in-turn reads fr= om + * iomem. As such, mark iomem as re-entracy safe. + */ + s->iomem.disable_reentrancy_guard =3D true; + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); sysbus_init_irq(SYS_BUS_DEVICE(s), &s->mbox_irq); } --=20 2.39.0 From nobody Sat May 11 12:35:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=bu.edu ARC-Seal: i=1; a=rsa-sha256; t=1682629967; cv=none; d=zohomail.com; s=zohoarc; b=J0GkcCTU+DcoM8GD2O1QTk5dDr7HBTT+btnLhzeMsglvCnk9mFkhCIw/oxmiVqzLSZ4crntz57Mpo3ihfcXwUiXTaB94Gp+I4qxRZaR34A696+B600+Eav9siuRZCdVpEicX8uGb0icnXt8eRxTCoDxMgbz1Ls3MH1LlSPLSS+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682629967; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=68oaiYGL7UhG3W5jva6oSZ0GIeZDrcn2k6P7uHwGxlY=; b=h6bseWcPJO5ZMrL4fcGArb8QKhR+HhUBPsNg2lTS8GsgqTnY4jBrbinRHDcFJA0Zr48r+v/u3bY/713JdNnMVnJfitqqJuDGBDMrx7vf2ty9qBPrTbGn+XINxXh0bAhsNKwua6kjQzPQmmUJBeJM7JltRbR1korgk6AK/u0dhpU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682629967707103.59411048457036; Thu, 27 Apr 2023 14:12:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ps8tL-0005wu-AG; Thu, 27 Apr 2023 17:11:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps8tJ-0005wD-I5 for qemu-devel@nongnu.org; Thu, 27 Apr 2023 17:11:01 -0400 Received: from esa6.hc2706-39.iphmx.com ([216.71.137.79]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps8tI-0005Ov-22 for qemu-devel@nongnu.org; Thu, 27 Apr 2023 17:11:01 -0400 Received: from mail-qt1-f197.google.com ([209.85.160.197]) by ob1.hc2706-39.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 27 Apr 2023 17:10:49 -0400 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-3ef3fc80bb6so103868531cf.1 for ; Thu, 27 Apr 2023 14:10:49 -0700 (PDT) Received: from mozz.bu.edu (mozz.bu.edu. [128.197.127.33]) by smtp.gmail.com with ESMTPSA id z16-20020a05620a08d000b0074acaeeb7c3sm6204862qkz.91.2023.04.27.14.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 14:10:47 -0700 (PDT) X-IronPort-RemoteIP: 209.85.160.197 X-IronPort-MID: 279189031 X-IronPort-Reputation: None X-IronPort-Listener: OutgoingMail X-IronPort-SenderGroup: RELAY_GSUITE X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:NWQ9OatJlLyuki7FmAlnZjIIHOfnVO9cMUV32f8akzHdYApBsoF/q tZmKT3SbvvbM2HxeookPN/n9E4C7cCDz95nS1Rlqn1kHnwR9ZOVVN+UEBzMMnLJJKUvbq7GA +byyDXkBJppJpMJjk71atANlVEliefTAOK6ULWeUsxIbVcMYD87jh5+kPIOjIdtgNyoayuAo tq3qMDEULOf82cc3lk8tuTS+XuDgNyo4GlD5gBkOqgQ1LPjvyJ94Kw3dPnZw0TQH9E88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IPM0SQqkEqSh8ai87XAMEhhXJ/0F1lqTzQJ OJl7vRcQS9xVkHFdX90vxNwSkmSNoUfkFPLzOTWXWV+ACQqflO1q8iCAn3aMqU34PZ4CkVp5 cZFFxAEaQu8v8WYyZuCH7wEasQLdKEHPasas3BkiCjFVLMoGMGcBarN4tBc0XE7gcUm8fT2P ZJIL2oyKk2eO1sWawh/5JEWxY9EglH2dy1epEi9r7dx7mTOpOB0+OKyYYOFK4TRHK25mG6Su U/Lr07EOi1DJfOuzh+C43eOi9L2yHaTtIU6UefQGuRRqESew3FWBBAIWF+Tp/6/hUijHdVFJ CQpFjEGqKEz8AmyUoC4UUTp/ziLuRkTX9cWGOo/gO2Q9pfpD8+iLjBsZlZ8hBYO75FeqeACv rNRo+7UOA== IronPort-HdrOrdr: A9a23:0y2CWageyocUg78Kg6URRATF4HBQXgwji2hC6mlwRA09TyVXrb HLoB19726JtN91YhsdcL+7Sc+9qB/nhPxICMwqTMyftWrdyRaVxf9ZnPLfKlTbckWUh41gPO VbAtJD4bXLbWSS5vyKhzVQfexQpeWvweSDqd2b4U1QbTxHXYld0iYRMHflLqS0fmV77FgCea Z0KvAom9PZQwVuUi1zPBZlY9T+ X-Talos-CUID: 9a23:Y/Yitm7s+1NR90DwZtss21QEFcsBVW3nkUjwKkijNl5OZrS8cArF X-Talos-MUID: 9a23:y0solQsOaw4xytAJdM2nji5POZdC3pySUVEioJIjvNiBFyFNAmLI DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bu.edu; s=s1gsbu; t=1682629848; x=1685221848; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=68oaiYGL7UhG3W5jva6oSZ0GIeZDrcn2k6P7uHwGxlY=; b=YSJAwvgbkH9fCZCzgmtIGlAln585VR2jxmWRALT8Yi2/XojQ5qUBmUfQEzau/aCnEK 7DCedm+QrBtV8fCgFzEBNcckbrbiaGOzt7ihuhMcFBsWIuVhuNq4x9thhQST/QW/mWbR 5sdJ0Ydw8YVaTPhpoBKMYZfOedNPehCOATEndJ2fmVdQDYcTrHzryH0sp4dZwvUgDjNK u9XAsGMywpSbUoVvtSIf7QqAPMLp85ZkX1/yuZsdo0j7phkruWM7ZjL5KfmffM7Cjw0b WwKizpYWu4jEYS4o8XqazzJoMXFZeYbZhLSdZQc6Bs+HQsSSwm04Gaaqyl5V6sbvYP6C AnCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682629848; x=1685221848; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=68oaiYGL7UhG3W5jva6oSZ0GIeZDrcn2k6P7uHwGxlY=; b=adMb1cepxVE144y9Xzi56+dSBgLJ1tk8vfCacMYy4ya6YCNJXzR4XQ8ZBmFSz8+3Or KuoRT6Ot4VstozyBvMM8UL2IROUPQHmaATNvNgZffurNq6GscbAmbt2n8DLjRKltGoOr 5YYjX/F2JNmR2JsR41+jLYrpN0vuWNg2JsSSknw/E1t8jdQz3GDZ8kW3UrcTl24wNHfU k8j35JoBusxM68sAXFeBnYOdlDXxCpcn4Z9tifZBaaBfKRVTUpVd/8Bif802HoF4Osd9 t4sRd9K+wrx2q7Q53GrlxfQiMP/NbAUQxk1QTjOxFlJxhg1W/4h+vPVIegaSJ11nuO/y Fg1Q== X-Gm-Message-State: AC+VfDzDnTPNIOs5iiAcmbuGLj5us/qV3tF9uD4iESB/w/gzt8gJYvJo rrz/fLdJX1cVhdztPG7DAvD2zmZhgNwig/9MWZMhlKVdaD33rPUgcu36O5CC5+BGA72mF3fxfy/ sfmgHbgtF1QDgE+Z/2bNjyERarmgp3mbcl0Rl5hzUc08= X-Received: by 2002:a05:622a:649:b0:3ef:3bad:6d24 with SMTP id a9-20020a05622a064900b003ef3bad6d24mr4087797qtb.47.1682629848454; Thu, 27 Apr 2023 14:10:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6wcIS9ZrvhiadDC7X/QUy+vREYVt3Z6AlKXrwXCOzQvwDK1XzR/bvOsR0KVROqeeeemzrb7g== X-Received: by 2002:a05:622a:649:b0:3ef:3bad:6d24 with SMTP id a9-20020a05622a064900b003ef3bad6d24mr4087748qtb.47.1682629848140; Thu, 27 Apr 2023 14:10:48 -0700 (PDT) From: Alexander Bulekov To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Stefan Hajnoczi , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mauro Matteo Cascella , Peter Xu , Jason Wang , David Hildenbrand , Gerd Hoffmann , Thomas Huth , Laurent Vivier , Bandan Das , "Edgar E . Iglesias" , Darren Kenny , Bin Meng , Paolo Bonzini , "Michael S . Tsirkin" , Marcel Apfelbaum , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Eduardo Habkost , Jon Maloy , Siqi Chen , Michael Tokarev , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , qemu-ppc@nongnu.org (open list:PReP) Subject: [PATCH v10 7/8] raven: disable reentrancy detection for iomem Date: Thu, 27 Apr 2023 17:10:12 -0400 Message-Id: <20230427211013.2994127-8-alxndr@bu.edu> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230427211013.2994127-1-alxndr@bu.edu> References: <20230427211013.2994127-1-alxndr@bu.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CES-GSUITE_AUTH: bf3aNvsZpxl8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.137.79; envelope-from=alxndr@bu.edu; helo=esa6.hc2706-39.iphmx.com X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.266, HK_RANDOM_FROM=0.999, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bu.edu) X-ZM-MESSAGEID: 1682629969323100003 Content-Type: text/plain; charset="utf-8" As the code is designed for re-entrant calls from raven_io_ops to pci-conf, mark raven_io_ops as reentrancy-safe. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny --- hw/pci-host/raven.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c index 072ffe3c5e..9a11ac4b2b 100644 --- a/hw/pci-host/raven.c +++ b/hw/pci-host/raven.c @@ -294,6 +294,13 @@ static void raven_pcihost_initfn(Object *obj) memory_region_init(&s->pci_memory, obj, "pci-memory", 0x3f000000); address_space_init(&s->pci_io_as, &s->pci_io, "raven-io"); =20 + /* + * Raven's raven_io_ops use the address-space API to access pci-conf-i= dx + * (which is also owned by the raven device). As such, mark the + * pci_io_non_contiguous as re-entrancy safe. + */ + s->pci_io_non_contiguous.disable_reentrancy_guard =3D true; + /* CPU address space */ memory_region_add_subregion(address_space_mem, PCI_IO_BASE_ADDR, &s->pci_io); --=20 2.39.0 From nobody Sat May 11 12:35:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=bu.edu ARC-Seal: i=1; a=rsa-sha256; t=1682629914; cv=none; d=zohomail.com; s=zohoarc; b=BTjB7/IosgmtC4mGz3e/Y9MX9Qc43XBbjcXyKhgF6tuz138S1/5YYWKrvBWMPOfNMJ1tvPecVrO194mfTYCy0BV7jlpu2hTFCmhNq+1qrF3iuTk4XwKfpOjGMi7934+o72TzzOTUVSkWh3nb4ANmfPqm50sdopH91uW4Di/0u3I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682629914; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VCVW0/HeXmkSG974OczBBkQKZv6zFcpwChDreWsVAYs=; b=KPkz2PuWlH21ZeVxjMXunCYziG2AGAw1DDkEcWF+fLEX3LDk6FqA4jwFqn9WmMAcCIPYoNIupdzpSfrrRE1xTDdOsafxxyQ4SvKMgFYKjACM/SAAjqOi/zTE/icHeTsZDdxpgfFRrIrMYW99rf27Q8C6J1ZeLzLCZx6DpVmjAfU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682629914770325.6788472431922; Thu, 27 Apr 2023 14:11:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ps8tN-0005xN-V1; Thu, 27 Apr 2023 17:11:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps8tM-0005ww-BQ for qemu-devel@nongnu.org; Thu, 27 Apr 2023 17:11:04 -0400 Received: from esa10.hc2706-39.iphmx.com ([216.71.140.198]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ps8tJ-0005P8-U5 for qemu-devel@nongnu.org; Thu, 27 Apr 2023 17:11:03 -0400 Received: from mail-qt1-f199.google.com ([209.85.160.199]) by ob1.hc2706-39.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 27 Apr 2023 17:10:52 -0400 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-3ef34e947edso103958281cf.3 for ; Thu, 27 Apr 2023 14:10:52 -0700 (PDT) Received: from mozz.bu.edu (mozz.bu.edu. [128.197.127.33]) by smtp.gmail.com with ESMTPSA id e21-20020ac84e55000000b003bd0f0b26b0sm6515099qtw.77.2023.04.27.14.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 14:10:51 -0700 (PDT) X-IronPort-RemoteIP: 209.85.160.199 X-IronPort-MID: 277337817 X-IronPort-Reputation: None X-IronPort-Listener: OutgoingMail X-IronPort-SenderGroup: RELAY_GSUITE X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:Jmu5rapF85A5OqOpdiULYmbY/z1eBmKhZxIvgKrLsJaIsI4StFCzt garIBmPPviDZmqjL9p1bIrl8BxTsZWEzIQyTlFv+308RXlG95acVYWSI3mrAy7DdceroGCLT ik9hnssCOhuExcwcz/0auCJQUFUjP3OHfykTrafYEidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw//F+UIHUMja4mtC5QRiP68T5zcyqlFOZH4hDfDpR5fHatQMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+AsBOsDAbzsAB+v9T2M4nVKtio27hc+ada Tl6ncfYpQ8BZsUgkQmGOvVSO3gW0aZuodcrLZUj2CA6IoKvn3bEmp1T4E8K0YIw++pqLHNc0 sEjeDlURTmunPyq5o21Y7w57igjBJGD0II3v3hhyXTAEa9jT8mSEuPF4thX2Dp2jcdLdRrcT 5BBOHw/MVKZPUUJYwZGYH49tL7Aan3XejlIrl6PjaAqpWXf0WSd1ZC3b4WOIYPaHJo9ckCwp Wni9kegICMgBdWTlxPYzyPzvsWSpHauMG4VPPjinhJwu3WKy2kOTREbS1a/if++jEG4RpRYM UN8x8Y1ha079UjuV8WkGhPh8S/CsRkbVN5dVeY97Wlh15bp3upQPUBcJhYpVTDsnJVnLdD2/ jdlR+/UOAE= IronPort-HdrOrdr: A9a23:35YZdaqQflGr/aJv84lw8MEaV5oleYIsimQD101hICG9Afb5qy nOpp4mPHDP5Ar5NEtQ/OxofZPwJU80lqQb3WByB9qftWDd0QPCEGgh1/qA/9SKIUzDH4BmpM VdmuRFZuEZUDVB/KHH3DU= X-Talos-CUID: 9a23:+g5BYG8iTi6sqYbBezOVv08YB+03YFrg9yfZemSRJH13VJuqR3bFrQ== X-Talos-MUID: 9a23:AHs5UQloJ7KgL6L03XvkdnphP+NhwP2MOno8mJlYkpS5ZHNIEWqk2WE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bu.edu; s=s1gsbu; t=1682629852; x=1685221852; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VCVW0/HeXmkSG974OczBBkQKZv6zFcpwChDreWsVAYs=; b=CG3zTuVEJhKMbMyUfD7jzbWH2W3t7/iYo37X7NCBLfzng8x292K0RSLSF3tqXgOCk4 T4hz68fxCMTzvNTeeACo85dj0LaeUqfdzxQTHyxI0wL6P0HevMrtL2UgoxoOQRCwMQ9q th0cD4hqU6LU7R1Xjw+PPynexCAPEGWk0kr6KFFvKZ9hV1Iv3F1uzRw/Ge8yb1GXJ76A J5qNmgaBollGNoG/+9/TSMxHYXJ7WOkEVS0ZKUkRxfFyDCC6reYAhGAeBhLafitNiQuI Ck2mDY2LRMgyF/JM+3DFLlZlh52z6NGOQsrIVf5sZfspZ6JiCVzKuAroWzEu7QcyPg5w Qgug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682629852; x=1685221852; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VCVW0/HeXmkSG974OczBBkQKZv6zFcpwChDreWsVAYs=; b=HeISDYN+VOCKCyHUE9efTyujRJ6O2HprF7PIMQQ8bD7qhMosiyrV/1jHa9rmAIANZa qI/orAZ7Q+gOR6OEWxRawfyTq4CP5wei3P4MLTG/fPPayp+oRBxP9/hM8tuNztlw1GfU W0JWRuURGgEyA/uEko0iagdLBD29LNIB7/Kbc28k/xZyasc2d/oXzMGZPovmgzfWVSbd oj0r8t5j22g0Z0h9NdHjVPGVPKlZBXG6AvHYfS4ADNutN36/htXofWJlsYict6xhtSM/ PPZ1WTUQMfoNvH52qHKXMNuG8TtRtFbYJG2bHZFYhM5GhSyTg+EXvxipgQGuBhdf9AcH 9YjA== X-Gm-Message-State: AC+VfDwYzAFylnwH7jjzDkPuiaGiVboxM4LwUxWDnLMAvzGWl50o8BPp hoSp8Bey4arglfwxBzsvJcCSZlq/8I/pxIVESdqdKPBMBt65IDvV3vFzOLgRxsJzaTutr3BVuLz uOHswpQqdvrvtqacOXsz29+51PeBWce9Asj0qby3WIGQ= X-Received: by 2002:a05:622a:1ba0:b0:3ef:7d5d:9c41 with SMTP id bp32-20020a05622a1ba000b003ef7d5d9c41mr4651247qtb.59.1682629851969; Thu, 27 Apr 2023 14:10:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6qfpiBBwJj/WJmQRZMq3EbZALbqLQ558wusxGNjmhoQhcSYVCsLMMSDSX6i3qHnzxmLF3GlA== X-Received: by 2002:a05:622a:1ba0:b0:3ef:7d5d:9c41 with SMTP id bp32-20020a05622a1ba000b003ef7d5d9c41mr4651192qtb.59.1682629851634; Thu, 27 Apr 2023 14:10:51 -0700 (PDT) From: Alexander Bulekov To: qemu-devel@nongnu.org Cc: Alexander Bulekov , Stefan Hajnoczi , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mauro Matteo Cascella , Peter Xu , Jason Wang , David Hildenbrand , Gerd Hoffmann , Thomas Huth , Laurent Vivier , Bandan Das , "Edgar E . Iglesias" , Darren Kenny , Bin Meng , Paolo Bonzini , "Michael S . Tsirkin" , Marcel Apfelbaum , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Eduardo Habkost , Jon Maloy , Siqi Chen , Michael Tokarev Subject: [PATCH v10 8/8] apic: disable reentrancy detection for apic-msi Date: Thu, 27 Apr 2023 17:10:13 -0400 Message-Id: <20230427211013.2994127-9-alxndr@bu.edu> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230427211013.2994127-1-alxndr@bu.edu> References: <20230427211013.2994127-1-alxndr@bu.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CES-GSUITE_AUTH: bf3aNvsZpxl8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.140.198; envelope-from=alxndr@bu.edu; helo=esa10.hc2706-39.iphmx.com X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.266, HK_RANDOM_FROM=0.999, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bu.edu) X-ZM-MESSAGEID: 1682629916301100007 Content-Type: text/plain; charset="utf-8" As the code is designed for re-entrant calls to apic-msi, mark apic-msi as reentrancy-safe. Signed-off-by: Alexander Bulekov Reviewed-by: Darren Kenny Acked-by: Michael S. Tsirkin --- hw/intc/apic.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/intc/apic.c b/hw/intc/apic.c index 20b5a94073..ac3d47d231 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -885,6 +885,13 @@ static void apic_realize(DeviceState *dev, Error **err= p) memory_region_init_io(&s->io_memory, OBJECT(s), &apic_io_ops, s, "apic= -msi", APIC_SPACE_SIZE); =20 + /* + * apic-msi's apic_mem_write can call into ioapic_eoi_broadcast, which= can + * write back to apic-msi. As such mark the apic-msi region re-entrancy + * safe. + */ + s->io_memory.disable_reentrancy_guard =3D true; + s->timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, apic_timer, s); local_apics[s->id] =3D s; =20 --=20 2.39.0