From patchwork Thu Apr 4 19:13:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 785823 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp995099wro; Thu, 4 Apr 2024 12:14:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVY5hjcg/l4J0VpnJvZtNIzSKHPGFBjZyYezlceHT7nMuoJkWRcAb11Y0ZjZvzriWbVTojCcT9uhbmrbTYNiCNU X-Google-Smtp-Source: AGHT+IFz66rOdVATpizH/Km8amBn4t6ohFt95NcrCfQfRfUhp0zcuhgvzbrISUb8YoZCVhAYHu8b X-Received: by 2002:ac8:7d48:0:b0:432:ec80:728a with SMTP id h8-20020ac87d48000000b00432ec80728amr3657627qtb.48.1712258076563; Thu, 04 Apr 2024 12:14:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712258076; cv=none; d=google.com; s=arc-20160816; b=0pFSK6ZCquHL+GXi/rTmTQyqjGVr7kMYNzw4BOJDQz/D7uLJS2+vuUKh7S/WGk/aWd 7fKNCCVn/T3hNzZXjvrSyYgp/5r1wobviv+3ek+/fLzUIcKsCpykeRmxPnPIlyyv0ONj ZxeZ2dePz5Q87LscqL3le5FDd4wDNyGNNhPGzJ9K3V3yWH/auugt3HX93A6a4GOyhkXl GaoLqZaQQs7ZzKO1uvzc637ShVymr0S6TVi3cDWQIflRAHpbr6hDimEsscb6pPBNdYL8 d5QS48dtYEMRRh5Q2NZSzQboxml19bPC3DvxNMDI7GxhemAoURikItON/YcrEqijvLEo H+eA== 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:dkim-signature; bh=bvdlQf7pHfui8YenaIyIB+vGNyHogH/cKFxc4FINeZE=; fh=IgWjBQE846jA7jrnvhZ0hLzTyLYirmOOtnItXRlZ4Ow=; b=N5IUP46R98GMUzoChF9rg3YXG1ML65jqbK+WbOr6AuKXiwKZI4uEnlvFdw3sY9x9ZH FVI4DoHAD6ULQYq66Kj55rilIyhsPqzBWb7Q83tYAY1eBFk7ZTs+8A/6h2nHqfoEmL6X HqGQceTXe5/nzdsyCOhpY1nRe7HZRI9vCcIPc4XdwjXGM+2eO7hmJzrx3QPtMa2OIzp9 bUmXyHnrmPn83S4OxmazfgOY0a4LZVQt729HChUudFiQyuKc19WZ9T/7tqt8amUTTed+ eNXfSaljCOjC/Whpol/dhvrGrmfu5SLxbbrEM+I6GzVdhRBUwXBRdVMRvJh4GuGfanhj v4tg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M0cAWhJT; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x19-20020ac85f13000000b00432d57f5307si12375906qta.346.2024.04.04.12.14.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 12:14:36 -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; dkim=pass header.i=@linaro.org header.s=google header.b=M0cAWhJT; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rsSX9-00063Z-Lm; Thu, 04 Apr 2024 15:13: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 1rsSX8-00063Q-8z for qemu-devel@nongnu.org; Thu, 04 Apr 2024 15:13:58 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsSX0-0005Vd-BC for qemu-devel@nongnu.org; Thu, 04 Apr 2024 15:13:56 -0400 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a4e60a64abcso432933266b.1 for ; Thu, 04 Apr 2024 12:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712258028; x=1712862828; darn=nongnu.org; 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=bvdlQf7pHfui8YenaIyIB+vGNyHogH/cKFxc4FINeZE=; b=M0cAWhJTFpiVlffZ/nFFvGuzM/ygkEABDYooHYY0Jum7VIJ9TlF/TE8e+HuM9eG3F9 8q0YjPI1iQfFOHBum8MB/H5X066Jems9A/XGoCsOj9DGWHIYKB65scHuvV32hlxzEaBH mlc3amRoFprS3XB+mxmS3Hrcv7E3gLHL7/Usw7SGg/QwAE8Z3iKRRGL+egc4quEeIEdE iqNUxPZ1TUjoQ4cziIPUd43mEhQytP2nI33z4VtgWhE+oNxCjY5L7g+C0nSEtrT4OiFB AYCL0wByeql+1kU1CuXLHgOdwqZLnVQx1+vVko5PxjduF2N7SsOzx/RYjsdQf1qsigTL uHug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712258028; x=1712862828; 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=bvdlQf7pHfui8YenaIyIB+vGNyHogH/cKFxc4FINeZE=; b=FW5cUj4X8Qc7VuJgC9iOJCE6Jgr6CMdSs0ihk5CRg1flrj73OR/Y2eC1/3NevI0udc DiTZHJ0SAmgJSPVV83QKCJTPgQ1UGdXJ1yV24nA4bolk8pLzmKxKpxmZ7LUB04VeMuQI 0k16DssEfgeio7KDmFyV0+NM0P8iG+Dna1+/4PqCjZG/rfZVdIihtchEF0pu6Ntmzhpu gDD2TMyp3aGO4vX+YhtmTa4ZgktAva0AHEt5XMVhOGZQWVKDkr34hWFq06OKqToSGo34 6s5AhLO35fmAR+yOGWbinvW96FQq6Dc6R9zjBsnBEnvytouX24SYhu0YuziGayENQLls XMdg== X-Gm-Message-State: AOJu0YyGJ5ZKaci4zZT2H1Ah2Ks3GRy/F8KLwOy0PwdPqJO2MsJa/F3g Q57ZC/teWNGEiLocc/qxI/+9EWkFQqvJpSLP8+mTB+EtKV2rl52La+DcskQCnfOchs0AIJP5UFl P X-Received: by 2002:a17:906:ae8e:b0:a51:931a:f82c with SMTP id md14-20020a170906ae8e00b00a51931af82cmr292258ejb.32.1712258028223; Thu, 04 Apr 2024 12:13:48 -0700 (PDT) Received: from m1x-phil.lan ([176.187.216.111]) by smtp.gmail.com with ESMTPSA id bu8-20020a170907930800b00a4e451724ffsm7302786ejc.166.2024.04.04.12.13.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 04 Apr 2024 12:13:47 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Amit Shah , "Michael S. Tsirkin" , Alexander Bulekov , "Gonglei (Arei)" , =?utf-8?q?Marc-Andr=C3=A9_Lurea?= =?utf-8?q?u?= , Laurent Vivier , Mauro Matteo Cascella , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.0 1/4] hw/virtio: Introduce virtio_bh_new_guarded() helper Date: Thu, 4 Apr 2024 21:13:36 +0200 Message-ID: <20240404191339.5688-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240404191339.5688-1-philmd@linaro.org> References: <20240404191339.5688-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=philmd@linaro.org; helo=mail-ej1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_NONE=-0.0001, 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 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 Signed-off-by: Philippe Mathieu-Daudé --- include/hw/virtio/virtio.h | 7 +++++++ hw/virtio/virtio.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b3c74a1bca..12419d6355 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 @@ -527,4 +528,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(VirtIODevice *vdev, + QEMUBHFunc *cb, void *opaque, + const char *name); +#define virtio_bh_new_guarded(vdev, cb, opaque) \ + virtio_bh_new_guarded_full((vdev), (cb), (opaque), (stringify(cb))) + #endif diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index fb6b4ccd83..e1735cf7fd 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -4176,3 +4176,13 @@ static void virtio_register_types(void) } type_init(virtio_register_types) + +QEMUBH *virtio_bh_new_guarded_full(VirtIODevice *vdev, + QEMUBHFunc *cb, void *opaque, + const char *name) +{ + BusState *virtio_bus = qdev_get_parent_bus(DEVICE(vdev)); + DeviceState *transport = virtio_bus->parent; + + return qemu_bh_new_full(cb, opaque, name, &transport->mem_reentrancy_guard); +}