From patchwork Thu Apr 18 17:49:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 789808 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp694922wrm; Thu, 18 Apr 2024 10:51:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXFvOyRuR9zBia+1g6w03vxW0WVEovaLni5fRXwySACTQlKWFBw99xBhCctfbsup6IHE61YQpj51ahegnnx8HTw X-Google-Smtp-Source: AGHT+IEJhgxJTD2vAEnalKeX8MHkUW6m5iMkPSQ2ew+Z5gRANxNcwhGm95hQ0j0WQlwf4dyl+pyn X-Received: by 2002:a05:6122:1d8a:b0:4d4:1cb7:f57a with SMTP id gg10-20020a0561221d8a00b004d41cb7f57amr4261123vkb.9.1713462685111; Thu, 18 Apr 2024 10:51:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713462685; cv=none; d=google.com; s=arc-20160816; b=TNZh5C4waeu/Ajp6b0kCbkcWMbNXE1O27PJ/ix1bt6el6D/z8I015auuW7In0yOiLx Rvr9o/ezqK9ISWmDfqOOzB+zOLbi/iV/IwhAwrp540G6wydQCf7Fc9OXvesUco0Uze7t HWAwOQeetpgnOT7CU9B0u/9Tq2jaMGSgyROYluOGDdO+bcPT0fgrZwkQgfp/rjC+MZPX RKQD1iMqjVT/c2ZtzLYKQfSk9sQ0XgLgwhAs7hF6L2ksq1ZB/+aiyOgZNm1PECNA0L86 nTZWViSA6oNL+fNiD8nYwyynmUPGNIow+ct5gBRn26t8mIjwGfzaVabGOeQUnH4Zsad1 zx7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=zuwScqC/K7PwcYf0A9dOgmG4aI+gh5JKh+pXX5Jrjfs=; fh=PkL0BgRfEM9eqzQkbTyhz2VibunL6e7EEQCkTtdX0i8=; b=BKRovs7X40kei7T9MS8h2VmlQY39TBNA96phRiyI0OYgzmAtkyopgc7MuDFyUnoXq7 ngNvscxX4RKwr2dMo8kIBcbwE+ugP2MFqGtC5O/P2DZ02OHkmU+9JeqKEI+4sW/6SV2J cm+QDTpl52ien20UfeX7ENF1v7VjrjjVoCqwTuFrhfT+cJmdjm+WZzYwb6dd/EUEIHqf LSBbDoGcCickb3DPHTy1zIlMmSwt1lakn8XWyoc86iNw9IaIjogpzq94Z2CJJZZHj8WR Kxqy12jdUdTeMemHAP21hXPlZw0h6T3m4nLxenW4RrQ3OZyFYRE/jjtNvnXV5rzfHOoe m9Bg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u10-20020a0562141c0a00b0069b0b59d115si2039979qvc.269.2024.04.18.10.51.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Apr 2024 10:51:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxVu3-0008LE-GO; Thu, 18 Apr 2024 13:50:31 -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 1rxVtq-0008H2-OD; Thu, 18 Apr 2024 13:50:18 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxVto-0007Xy-VL; Thu, 18 Apr 2024 13:50:18 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id A5BD35FD69; Thu, 18 Apr 2024 20:50:01 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 0B78BB933F; Thu, 18 Apr 2024 20:49:59 +0300 (MSK) Received: (nullmailer pid 947830 invoked by uid 1000); Thu, 18 Apr 2024 17:49:55 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , "Michael S . Tsirkin" , Michael Tokarev Subject: [Stable-8.2.3 096/116] hw/virtio: Introduce virtio_bh_new_guarded() helper Date: Thu, 18 Apr 2024 20:49:26 +0300 Message-Id: <20240418174955.947730-9-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Introduce virtio_bh_new_guarded(), similar to qemu_bh_new_guarded() but using the transport memory guard, instead of the device one (there can only be one virtio device per virtio bus). Inspired-by: Gerd Hoffmann Reviewed-by: Gerd Hoffmann Acked-by: Michael S. Tsirkin Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Message-Id: <20240409105537.18308-2-philmd@linaro.org> (cherry picked from commit ec0504b989ca61e03636384d3602b7bf07ffe4da) Signed-off-by: Michael Tokarev diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index aa02c4937c..c177c31ca0 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -4145,3 +4145,13 @@ static void virtio_register_types(void) } type_init(virtio_register_types) + +QEMUBH *virtio_bh_new_guarded_full(DeviceState *dev, + QEMUBHFunc *cb, void *opaque, + const char *name) +{ + DeviceState *transport = qdev_get_parent_bus(dev)->parent; + + return qemu_bh_new_full(cb, opaque, name, + &transport->mem_reentrancy_guard); +} diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index c8f72850bc..7d5ffdc145 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -22,6 +22,7 @@ #include "standard-headers/linux/virtio_config.h" #include "standard-headers/linux/virtio_ring.h" #include "qom/object.h" +#include "block/aio.h" /* * A guest should never accept this. It implies negotiation is broken @@ -508,4 +509,10 @@ static inline bool virtio_device_disabled(VirtIODevice *vdev) bool virtio_legacy_allowed(VirtIODevice *vdev); bool virtio_legacy_check_disabled(VirtIODevice *vdev); +QEMUBH *virtio_bh_new_guarded_full(DeviceState *dev, + QEMUBHFunc *cb, void *opaque, + const char *name); +#define virtio_bh_new_guarded(dev, cb, opaque) \ + virtio_bh_new_guarded_full((dev), (cb), (opaque), (stringify(cb))) + #endif