From patchwork Wed Apr 10 09:13:00 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: 787491 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp598071wrs; Wed, 10 Apr 2024 02:15:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWVGASKusR7nXMBQuPTAQ+XXGHQTPPu2Ha8I/gDssFqWiNxt8+T8UPjS0SkTTtrSkDG+e/KsEWgCADqwo/btwoT X-Google-Smtp-Source: AGHT+IEzJC8XPZELn25R7bwcS9qq26Sp2mzFg22hLKfPedPuOjoQy8vM7m4HKMgvPpybogajwfmQ X-Received: by 2002:ac8:5a8a:0:b0:434:b300:1132 with SMTP id c10-20020ac85a8a000000b00434b3001132mr2070960qtc.0.1712740517085; Wed, 10 Apr 2024 02:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712740517; cv=none; d=google.com; s=arc-20160816; b=Asf2AV8GApYbhGiVwVzbcO7heMifsLX3ZG2IC2Wb5URLN/w5LEU1iGxMuaDQCVsv2L VzE9OmjCRmjkfIVUjp6Iv5ujENawGRoENOlS1lBJb0+KHpxP5TKQQQcsQYcSlOOcydiV LAlCzrOyEmmsijhoaK34aQT4AAYa+IcVPcKocFsaRbR63NegsLS8Zkxyn6mJtTzThpHB SizD21kr1rlZ4thN26gbsQRODQweuG7r6moKl8b+Fqv/+ZfaiXGk1VxvH7gUyJZWUc/0 BWHJ4SwdeDMQmi27WS6jaC2j4h6RltIUbydFiT76bnU5zUKyFRAxaBMFaaVPeowb97Nn kzIQ== 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=KjsuSCcLyjpkQOiK5wnHTdf6ojU2i1M+lbXXnXeIWDo=; fh=G7LyGBWIaUPckE/0zW41pvRsibr2BJSA5k4Onpwwz18=; b=Rc0jjQPjCpNPOfC3eMQhCic1P9vBcGAZxary3ViZhnWtQKt0SLqCxKq2TyHdp6aPdU oPkFwPkSH/n8nwzaDD/tDroo29BIWWRDU5dgksypNjyEU7vGQ/XQSeE96cxNUxMwBlbV ni9fxIBxx9nKZhP8xOCiwVHCNv7shrXVozIOkBTWRpQ8x1WdthwX6/4hb1fQ7cJ0xTDP cKcuz22BOpdIe4IBHCCuyiXfk2FOlo0RlYC6BQXZQLPyTY5Gnwu5BPSF+pZ2FDxzrHuf MytIxa4Je5pfBg5+yiraq2HkIGfomwx8v48BgxXKSx2D88B9GYKPs45kYFx5Dzcb6HLP EQjA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pBK7reAo; 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 b5-20020ac87fc5000000b004347ca5db8asi8839744qtk.79.2024.04.10.02.15.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Apr 2024 02:15:17 -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=pBK7reAo; 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 1ruU1c-0005kQ-UK; Wed, 10 Apr 2024 05:13:48 -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 1ruU1J-0005iR-RP for qemu-devel@nongnu.org; Wed, 10 Apr 2024 05:13:29 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ruU1I-0005XX-9v for qemu-devel@nongnu.org; Wed, 10 Apr 2024 05:13:29 -0400 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a51abd0d7c2so685373066b.2 for ; Wed, 10 Apr 2024 02:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712740404; x=1713345204; 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=KjsuSCcLyjpkQOiK5wnHTdf6ojU2i1M+lbXXnXeIWDo=; b=pBK7reAoK4GVpnPUAIwz53JETgFfJSUTV4yRpbHGKDk5vF2OAZMmBipa2brUgaB582 SDp9xHccX3QTDmbocoO5k6u4vgGUxvLQojGlJfCFyDAK78Na0JTlPBd1LXzM4Dq9bjhH 0K7BvxB+5K3oHoq1Ca+lSEY7sj3U1ohgi1a5GseRWZWea1zAZsVnZtMgvYeFMcbF8cp+ 9EHTJzLGjJgXVwQCtNugGOh1NwdxZDXFE6rRq8TLTyjHOzqmDe3c19eXGPC29+790hqA aWfS1Tq+By2vl3cy4r35KZ28Af5qH5wkYuFFTLFfxBCtqjeqZcQCIx5mWgoEFYt3ijjT V9oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712740404; x=1713345204; 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=KjsuSCcLyjpkQOiK5wnHTdf6ojU2i1M+lbXXnXeIWDo=; b=q1X9t8MiSJf6WUHUkL0QzjP/kP3Kd7+juRFHcBwEOvz6I7KNSuMr+ZR0VkO/Lr2/mJ tLACh+xFlolYsNbdqGRudfxPf/6/i7WtWg3gQkK7hc0N1DxuNnZpEtMEqQ4HBznEYhHG 8UonOegfGX9KfuXNRKYs/c4U/336h+P4OUbDqoXOGAi8N2QDP2Z18RvHngf31Q7fDPVw xADks+N1iJkjYJASdBpSQh9WF7NaLiWS85BAZ8FcpaU82LQCzt6aD9KZ2hzTM6znz8eD /OhT2Wl05TzeKMFOBZSYRJCwb4dLC73ApcNMxWxTC+w1zimIvhNmg4L7UR8rWTN8qEys rOJQ== X-Gm-Message-State: AOJu0YxBfqDuHa/E64U9braCc/hAY1dPxZPaEbpm4TesEVj9tFdaw6Ck qg6C6i7HyOjTIYxEPP7woiAOALZqMmWJLtO1H9jMjhpUlRPE9jdXeNoldgpnIQfNOFRxcUeaSZh 2 X-Received: by 2002:a17:906:dc8f:b0:a51:c975:f02a with SMTP id cs15-20020a170906dc8f00b00a51c975f02amr1377951ejc.65.1712740404712; Wed, 10 Apr 2024 02:13:24 -0700 (PDT) Received: from m1x-phil.lan (arl95-h02-176-184-34-173.dsl.sta.abo.bbox.fr. [176.184.34.173]) by smtp.gmail.com with ESMTPSA id d3-20020a170907272300b00a518a133d77sm6858396ejl.144.2024.04.10.02.13.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 10 Apr 2024 02:13:24 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , "Michael S . Tsirkin" Subject: [PULL 01/16] hw/virtio: Introduce virtio_bh_new_guarded() helper Date: Wed, 10 Apr 2024 11:13:00 +0200 Message-ID: <20240410091315.57241-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240410091315.57241-1-philmd@linaro.org> References: <20240410091315.57241-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=philmd@linaro.org; helo=mail-ej1-x62b.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 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> --- 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 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 diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index c5bedca848..871674f9be 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); +}