From nobody Sat Jul 25 14:08:02 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1784296261; cv=none; d=zohomail.com; s=zohoarc; b=TCmpFbpIdZtW8LZMgV4cCkFS/wPk8ZS+coDmq5z7GhsbFtCNZmaMRZAQ+o7FESqkiHlaTvBBPPBK3HLXiQ6KUriBBO6M7+mN/cOtZibo/w2So71WTEzHicsX9Ew0Twyos014GStTTxBfLiIhih8mQSbKyJW089T7Otcj/RTtSdw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784296261; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=f7fEN9p3YFcRJxQVbUrtqGwOhTf7ACd7FeDVIrSzydk=; b=DiSxc02sniSKwSzd8hMsoxFgahU/CO/p9f93oMxMTlgyOiRf6N5Q361+n/e+tooj3WGNTF0WJv9ckiIO7ug2LPhBf4S//nGI3fQ5sWxagaCBAm0IqxaZDgH8NHK6zSlafvYJV9rf1X4K3U98WgtInPny1TN3j5lRmrFesXXkzGU= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178429626102435.22716711053488; Fri, 17 Jul 2026 06:51:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wkixW-0004St-W2; Fri, 17 Jul 2026 09:50:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wkiwo-0004FH-Ii for qemu-devel@nongnu.org; Fri, 17 Jul 2026 09:49:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wkiwm-0001Xt-Uh for qemu-devel@nongnu.org; Fri, 17 Jul 2026 09:49:50 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-203-__mWVRIUOaqKbISoLkJP-Q-1; Fri, 17 Jul 2026 09:49:46 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49547298689so5745895e9.1 for ; Fri, 17 Jul 2026 06:49:46 -0700 (PDT) Received: from fedora (cst-prg-27-253.cust.vodafone.cz. [46.135.27.253]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4954ba2abd0sm30049525e9.15.2026.07.17.06.49.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 06:49:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784296187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f7fEN9p3YFcRJxQVbUrtqGwOhTf7ACd7FeDVIrSzydk=; b=eJG+B2Cgsjd5821Bgs99yyH734CVHGorJJCOtkkHa227PvF9CcA7FnboLXE96gkCRFo85C qgCvl0FqWSyeS+EIGkp2DBaVobCKMrNGrO3+kIgN6ZVjCcoSLqIXydIfe+TtLc9ZHmb+0w gHnBT2VHmMs9RC24Op8tDsD1D7WigYE= X-MC-Unique: __mWVRIUOaqKbISoLkJP-Q-1 X-Mimecast-MFC-AGG-ID: __mWVRIUOaqKbISoLkJP-Q_1784296185 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1784296185; x=1784900985; 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:content-type; bh=f7fEN9p3YFcRJxQVbUrtqGwOhTf7ACd7FeDVIrSzydk=; b=YBsp6Y8tOJ1XqF0Ah9Nk9k4n+G6DnmYC4PslaXzHwfrzqdD6wJ8m3BNaWvfLUqXvPO 1VqlgQFcLQ0Lc8shb5AepNJQ67O/ky5cicYaih3629O5iL1+r5rBUT0FBIetXoMs5Eqs ufoYjUJZkhM9JPihVrMHNbtAElY9FOmHsiaKny8+HaZ0SULB4ul5vuBzoLb//XPQHJLS zJ19pkDYcw1KnkrqBKgrYDNxFCxBD+IWUf0JiahrfhFKjZtT4gTJ7hESywGpd7GXD82I RMIDhbJbqgZ7JLf14N+zySzyTpTctWwYaEb1VzIdb4M4yuUNh436vOOdYHFyRzuVyUmD haYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784296185; x=1784900985; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=f7fEN9p3YFcRJxQVbUrtqGwOhTf7ACd7FeDVIrSzydk=; b=pNSEj2NP1uQPcyqnIfqpwzqzRjDsVIP0wJCTYHEg6tGB4Edt0sgkeyQyAaV7QGurLf lcZAO/66b+PzOFgksUWUrCfIl+gPGtAckn0zg1WoppP+Iz8jhPI5j1IFbHJeEBLxLCSb 0lLqXnhEPXzKotfK4lK/G7smah4vPAoWqtcKpjynJ1Ev203WWjcAmmEGwW2SpOCGxbkq g+jeJplmu1VX9/zuDSaHas1rRq8fe9prMTq1VAhpHj/zQ1Fjws47QhenF6fIcPHqMd9E CyX3LFJV0y9x4IUhnjxWiXwh3vm41J0nsGM/6NcYdILAiSaIITjjdmS2SbN6Cifd5EOw PZCQ== X-Gm-Message-State: AOJu0Yzrn8QWBzZuEbxVMZXn7sTukqO0Cr5VPwZDuGV7jHYnJWiu/BsJ 5Pf7wLwzfGFkPmjb7w8XGjGe85AMRK4BHR8cAKGD61iT9rDz2/lzr1o9Cx0yjr+H9Aydojz7GmC KyOkfsZmR7MQW6BxwUeYKvNQIabvQgUY2sDGO7V2Mcz7gmGbWcqKuAjp47tPcNHpNbHpoJmsMFW /xNwuXEbiI1MsUP7yLZvuIEElqAypVxHkUuss91R1GPZ+x X-Gm-Gg: AfdE7cnXFgPJ8fpb9t4s1Em11rirBNyeN33G1sGDGEWhyvlJrA005kXBShYhNriZ2AZ 9a+0SZulInsDPbWESWh1+R4p7m3wY1LLOrOBQTdCr03+eSYGyCau3Y7ifAu/83stuiAoma3M7tL WMZfmTGbR0KVtcqneloPi2Wxa3MspPvTUnkvSzzTUqwOFB/nVDlPd4T9Ef52Wd8cajCHttGLm13 XK+8LTOvqX/utb4V5b+6qLbceRyniHzZlWVACvRuz9XZpGly0p+qo+7exkfrC/L4acbJjsq07HT 2aGr77dSfIPA6sWhRvgjdZ6YZyB5Q/bIn4ZAxb2SvC+GJtfJFP1BvCcxqTBfphA+lkJZ7OPYWQb 1nb4tUCwauDxHwPpSuh6rzihZf+KluEj2n13pJHv9nb6/Wpk08+Vmw4HgIRgJukiucrW+BdJOn9 WgVYUZKnYSdw== X-Received: by 2002:a05:600c:1554:b0:495:3de8:33a6 with SMTP id 5b1f17b1804b1-4954a3dc7bcmr33652195e9.16.1784296185021; Fri, 17 Jul 2026 06:49:45 -0700 (PDT) X-Received: by 2002:a05:600c:1554:b0:495:3de8:33a6 with SMTP id 5b1f17b1804b1-4954a3dc7bcmr33651715e9.16.1784296184487; Fri, 17 Jul 2026 06:49:44 -0700 (PDT) From: Dorinda Bassey To: qemu-devel@nongnu.org Cc: mhrica@redhat.com, mst@redhat.com, sgarzare@redhat.com, manos.pitsidianakis@linaro.org, marcandre.lureau@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, aesteve@redhat.com, Dorinda Bassey Subject: [PATCH v4 1/3] vhost: Fix SHMEM_MAP transaction ordering and resulting deadlock Date: Fri, 17 Jul 2026 15:49:18 +0200 Message-ID: <20260717134920.265128-2-dbassey@redhat.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260717134920.265128-1-dbassey@redhat.com> References: <20260717134920.265128-1-dbassey@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: permerror client-ip=170.10.129.124; envelope-from=dbassey@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.01, SPF_HELO_PASS=-0.001, T_SPF_PERMERROR=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: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1784296262553158500 Content-Type: text/plain; charset="utf-8" Commit the memory region transaction before sending the SHMEM_MAP reply so the KVM memory slot exists before the guest can access the mapped region. This moves the commit to while the backend is still blocked waiting for the reply, which can trigger ADD_MEM_REG back to the backend and deadlock. Filter shmem mapping regions out of vhost_section() by checking the MR owner type to prevent this. The explicit transaction begin/commit wrapping is dropped since virtio_add_shmem_map() already commits via memory_region_add_subregion(). The unmap handler keeps the original ordering: reply before delete, so the backend is unblocked before the transaction commit. Fixes: b52e1896e764 ("vhost-user: Add VirtIO Shared Memory map request") Suggested-by: Albert Esteve Reviewed-by: Albert Esteve Tested-by: Albert Esteve Signed-off-by: Dorinda Bassey --- hw/virtio/vhost-user.c | 20 ++------------------ hw/virtio/vhost.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 517cc4ca716..01468f7441a 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1977,8 +1977,6 @@ vhost_user_backend_handle_shmem_map(struct vhost_dev = *dev, } } =20 - memory_region_transaction_begin(); - /* Create VirtioSharedMemoryMapping object */ VirtioSharedMemoryMapping *mapping =3D virtio_shared_memory_mapping_ne= w( vu_mmap->shmid, fd, vu_mmap->fd_offset, vu_mmap->shm_offset, @@ -1986,7 +1984,7 @@ vhost_user_backend_handle_shmem_map(struct vhost_dev = *dev, =20 if (!mapping) { ret =3D -EFAULT; - goto send_reply_commit; + goto send_reply; } =20 /* Add the mapping to the shared memory region */ @@ -1994,22 +1992,8 @@ vhost_user_backend_handle_shmem_map(struct vhost_dev= *dev, error_report("Failed to add shared memory mapping"); object_unref(OBJECT(mapping)); ret =3D -EFAULT; - goto send_reply_commit; - } - -send_reply_commit: - /* Send reply and commit after transaction started */ - if (hdr->flags & VHOST_USER_NEED_REPLY_MASK) { - payload->u64 =3D !!ret; - hdr->size =3D sizeof(payload->u64); - if (!vhost_user_send_resp(ioc, hdr, payload, &local_err)) { - error_report_err(local_err); - memory_region_transaction_commit(); - return -EFAULT; - } + goto send_reply; } - memory_region_transaction_commit(); - return 0; =20 send_reply: if (hdr->flags & VHOST_USER_NEED_REPLY_MASK) { diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index af41841b529..e5c219be095 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -636,6 +636,16 @@ static bool vhost_section(struct vhost_dev *dev, Memor= yRegionSection *section) { MemoryRegion *mr =3D section->mr; =20 + /* + * Skip shmem mapping regions, they are managed via SHMEM_MAP/UNMAP. + * Including them triggers ADD_MEM_REG during the SHMEM_MAP transaction + * commit, deadlocking the backend. + */ + if (object_dynamic_cast(memory_region_owner(mr), + TYPE_VIRTIO_SHARED_MEMORY_MAPPING)) { + return false; + } + if (memory_region_is_ram(mr) && !memory_region_is_rom(mr)) { uint8_t dirty_mask =3D memory_region_get_dirty_log_mask(mr); uint8_t handled_dirty; --=20 2.52.0 From nobody Sat Jul 25 14:08:02 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1784296246; cv=none; d=zohomail.com; s=zohoarc; b=OVPoVEp18tX0FEvysOrR3TNrAK/vGMuhomXVgklR2cgAjxLeERHTFp6BfVnBNfAxmEWaSKw4CHsP2SLxgiBmvtT3e6sTAgT6fEzPRrF5nxkXS/0e1OhI+vewQsscrSGtlgwW9dWg1xMuFEhVwZfCzPQn/8BJdkYgPyjKwljKvJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784296246; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PPiM/aoeSCDxMW8QTDsfI2a1F6P28NxKwnIXOOJ69Is=; b=mu6zaV8I/tiLs0LXjZc6UfC7unZoM5YME0mJiq9zqp0cG8wsDxqzyP9LWsmvugUqRn55HCaSOs30qbpgLuW48ErS1/on+iA4FZts1WLZXQMXyH3TXhQQwVSVG47Y+WYmH7NdBWPNM3vrTPpdbX7X0uKNdJhgPqRLlO/WuttuuzI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784296246000467.5123107331219; Fri, 17 Jul 2026 06:50:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wkixP-0004RC-QO; Fri, 17 Jul 2026 09:50:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wkiws-0004Fy-87 for qemu-devel@nongnu.org; Fri, 17 Jul 2026 09:49:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wkiwp-0001YM-BY for qemu-devel@nongnu.org; Fri, 17 Jul 2026 09:49:52 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-294-mQPgLhGxN_e9BvQZmKrGkQ-1; Fri, 17 Jul 2026 09:49:49 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-493c47a09b5so42836875e9.2 for ; Fri, 17 Jul 2026 06:49:49 -0700 (PDT) Received: from fedora (cst-prg-27-253.cust.vodafone.cz. [46.135.27.253]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4954ba2abd0sm30049525e9.15.2026.07.17.06.49.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 06:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784296190; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PPiM/aoeSCDxMW8QTDsfI2a1F6P28NxKwnIXOOJ69Is=; b=P/SmubCn0XzEmRG4VnEgVTO+wdjjK+wljKZ+neghDTa97JRSkbdMPG0lvUG/Q7iMWfQ/// 0b8fUSKxz8T2P7BUtckBdek2iGBDQiyez+M6fMTY1/+ZDJHPRbdj9dp6GmBWJbfgQ1XAqz 6dg+x7spE+Wrb4cO8ELko7nd2IR+Oe8= X-MC-Unique: mQPgLhGxN_e9BvQZmKrGkQ-1 X-Mimecast-MFC-AGG-ID: mQPgLhGxN_e9BvQZmKrGkQ_1784296188 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1784296188; x=1784900988; 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:content-type; bh=PPiM/aoeSCDxMW8QTDsfI2a1F6P28NxKwnIXOOJ69Is=; b=c3I3wV85a93LlL7JndB0jx8ORjCDvHC9IEqvYgDilJcYoWOqMYo5CiknY/OI6QEfq5 mIM0M0kfnVrrE9sv9zF1gphlWi2I5I1uqE2uKQf9gcETiDPyJagMNzc2d3PgFhVkZ4eQ z4ZYOCGla0HIMFs3haGu+B27FnXFIsOa5M90M2M2Npc3eoJcFxueBY0QH7lSbCls6S7l 7y8fObVTykHQtsHD5vbJca/eJakk/T3tBKmiBYPRfEpvBTcNbTml6W257rYhSZ7al1Iq pgfI/y2lEgveSW67oVpaxMPVZqoofBfkQ94YUygNy1gvDn94RudYYK5mCkpchLL5wQKO bn9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784296188; x=1784900988; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=PPiM/aoeSCDxMW8QTDsfI2a1F6P28NxKwnIXOOJ69Is=; b=CWEHKUkaDkpEjIeQQ74ErZFeqTjdNM8SUaoLIFaIg2XU40r6nLxZ5XgtY3Hd607H4C Nwq6FduasFkMt4gcSQ+vatrV+eoxe5fLBCBA04I0Z0nG/s6ZT3FR08ZVXIxZbvVv0WYD REVQZxgQNTatWDIbg2ir0O1ZjVshx8dj2agN72jX+pME/2bYjotVz5BPnpTcB2CvVQIQ xS0hYki7uhzQKvM6e5X7ePOZOHqzIe8tl2PKJCLwThOqx0JiPiS2Q0G/unWGsOhQFalf 5CCPtUnWohbC7C931JWUFg8+Nf3nYXOCuQFTFFjio78vk5t4Y8kHHR23wyO37eiDEsEL ZW5g== X-Gm-Message-State: AOJu0YxFVAmpq2PwUOtb0Xo7sYu6KJne5GSAt0dhV+c3yGWm03lvxBKn z4L931tjwfhXVJpvMUSF4yLpIZoS9748geyp1rTm67fQfEbQTyB6sC5GJhJuDeU/f1KK5ny7bLH XBtuserNUFsAZM9QOH9c+uOOKvBonsHYe2J3v7InXDJQkA2EpPw8JH/0IzA9nZEMImwxSDPdirb Kxwtd6xLUZ7bJZTYX3DAVMwkycuzgmh4vfVdnqi7Ls72JN X-Gm-Gg: AfdE7ck9Pr17Yxcpc9LX9caNcfn1cTIsh0rxf0YGfZhJuQCovw3yS6unoH+ABlUqHnt sfTmRpWiS94viAt+heMwSlFHseq87DLzfzLWtZana+AZbFkB+y103dQBRnAR4WrqYRdspFcMXoy RjvZZWJhiTWi0Nw5Ay49DqrgNdsE9lr3VYzTA8PNZvXU+6ONgZXH1SLFwM1ZPIhfzBMzk8Pd13N eNGSB3oQpfMcL3k/DO6LoyINPnKypvsSqxBISPZ0Z6x5X545y0wsQi3EGhrmyTpipQjC9WhlBTY gGoVdIedGosXJabj3tTQgLyUu7Q5SUnmEt3lZqrYKyF5/gGiL2pojHOdof0DvriRIYsnG6VsMwl ZeAL7SsVh1iicOFHbgyMaxYc1R9rN1WwBIBTyifeYTyZRxDAzVmtEiyxS42WQJQyzSAzE8gXnhR vlPxaRtNbHfw== X-Received: by 2002:a05:600c:4ed0:b0:493:c634:952 with SMTP id 5b1f17b1804b1-4954a3d0872mr31772365e9.7.1784296187916; Fri, 17 Jul 2026 06:49:47 -0700 (PDT) X-Received: by 2002:a05:600c:4ed0:b0:493:c634:952 with SMTP id 5b1f17b1804b1-4954a3d0872mr31771465e9.7.1784296187075; Fri, 17 Jul 2026 06:49:47 -0700 (PDT) From: Dorinda Bassey To: qemu-devel@nongnu.org Cc: mhrica@redhat.com, mst@redhat.com, sgarzare@redhat.com, manos.pitsidianakis@linaro.org, marcandre.lureau@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, aesteve@redhat.com, Dorinda Bassey Subject: [PATCH v4 2/3] vhost-user-gpu: Add shared memory region support Date: Fri, 17 Jul 2026 15:49:19 +0200 Message-ID: <20260717134920.265128-3-dbassey@redhat.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260717134920.265128-1-dbassey@redhat.com> References: <20260717134920.265128-1-dbassey@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: permerror client-ip=170.10.133.124; envelope-from=dbassey@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, T_SPF_PERMERROR=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: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1784296248349158500 Content-Type: text/plain; charset="utf-8" From: Matej Hrica Add a 'hostmem' property to the vhost-user-gpu which enables the shared memory in the parent object. Register a container MR in the shmem_list for SHMEM_MAP/UNMAP operations. A container MR is used so that SHMEM_MAP FD-backed subregions each get their own KVM memory slot with the correct backing fd. Suggested-by: Albert Esteve Reviewed-by: Albert Esteve Signed-off-by: Matej Hrica Signed-off-by: Dorinda Bassey --- hw/display/vhost-user-gpu.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 57360898ca0..dbba80c7783 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -649,6 +649,16 @@ vhost_user_gpu_device_realize(DeviceState *qdev, Error= **errp) } =20 g->vhost_gpu_fd =3D -1; + + /* + * If shared memory is enabled, register the hostmem region for + * SHMEM_MAP/UNMAP operations. + */ + if (virtio_gpu_hostmem_enabled(g->parent_obj.conf)) { + VirtioSharedMemory *shmem =3D virtio_new_shmem_region( + vdev, VIRTIO_GPU_SHM_ID_HOST_VISIBLE, g->parent_obj.conf.hostm= em); + memory_region_add_subregion(&g->parent_obj.hostmem, 0, &shmem->mr); + } } =20 static struct vhost_dev *vhost_user_gpu_get_vhost(VirtIODevice *vdev) @@ -659,6 +669,7 @@ static struct vhost_dev *vhost_user_gpu_get_vhost(VirtI= ODevice *vdev) =20 static const Property vhost_user_gpu_properties[] =3D { VIRTIO_GPU_BASE_PROPERTIES(VhostUserGPU, parent_obj.conf), + DEFINE_PROP_SIZE("hostmem", VhostUserGPU, parent_obj.conf.hostmem, 0), }; =20 static void --=20 2.52.0 From nobody Sat Jul 25 14:08:02 2026 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1784296283; cv=none; d=zohomail.com; s=zohoarc; b=ljIFJSUh6dYu9unV66/UdBFriCXjk9g4ijieHV6Smseg1HxXCIXYFDtTmCicrBseJBBzE+Tzt8lIUQEOjV/g9ZtAFzYC5/7qI1+LHOAspNcvFcq7x/z6/MSfMFmDbSvbtMNzKZT7dpScnVSZ1+qUhXEfMoJrXqJY5Rra0TYigDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784296283; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4s1N6E1ijreaKGc1qpNnCMTcrq6TD6MWW0x4mk/QYbs=; b=VhGTxAdtAISCAsETBgxtD6plUX1osHQdpHtI9T1+m7r1RpD7au/N7qVVyoO4oxYSv4fXdku35/SqxMQoJlqE88fvpxtCx/+nRUSlL/hQnapam4aC0uH+HBGFNrNwgTydMcTWVkPZWtogQriPPtkQ9sWOao8gwG76ev5Uo5MiH6U= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784296283613558.3724575202572; Fri, 17 Jul 2026 06:51:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wkixo-0004Zn-Gs; Fri, 17 Jul 2026 09:50:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wkiwt-0004GV-Q7 for qemu-devel@nongnu.org; Fri, 17 Jul 2026 09:50:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wkiws-0001Yt-1e for qemu-devel@nongnu.org; Fri, 17 Jul 2026 09:49:55 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-113-eDhVVv3aP42x7Z20YC70Gw-1; Fri, 17 Jul 2026 09:49:51 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-493e94719e7so52444055e9.0 for ; Fri, 17 Jul 2026 06:49:50 -0700 (PDT) Received: from fedora (cst-prg-27-253.cust.vodafone.cz. [46.135.27.253]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4954ba2abd0sm30049525e9.15.2026.07.17.06.49.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 06:49:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784296192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4s1N6E1ijreaKGc1qpNnCMTcrq6TD6MWW0x4mk/QYbs=; b=ZQ2GH7iKxuxmpVlp5Pu88pyH3JrSIUtgMq6F0GIEZ3AnFWIlaPNXaIMVPjdGTcZsCVLqv9 sDVO6AvuZTswFeeFX92F52N8rRCzebtumhdgxpd35kIQ0nXabH8m3vOTcCzRibFm4UKV1J wibLmq1V98kBs6/TRAT5fsWqZ0dYS3M= X-MC-Unique: eDhVVv3aP42x7Z20YC70Gw-1 X-Mimecast-MFC-AGG-ID: eDhVVv3aP42x7Z20YC70Gw_1784296190 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1784296190; x=1784900990; 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:content-type; bh=4s1N6E1ijreaKGc1qpNnCMTcrq6TD6MWW0x4mk/QYbs=; b=X7nSxTqbGEwlQNDJGNupFBudjzauepbP+EbGMCM/YzvDGchoF6e/E3lIPlyAqcXy9V ZdjmQh6Y0CbbuAXU8oLtF+C3X52MWfBAjxKGnyrPLr7RRmFx2f88dHAKIEhm3fBEMa8r OtqQyu01c5XDiZnBDZVjBEZmVdPKE/z7KIbBRLz9SsLckcdkTYeYzl+bLPioGrNjyAJM MFElPDenjC2QzFP9SIzosJmFhyGNttZAzujfYTaDm8eA7otC5yOcQtCuqUD5ATvryayB hLDgP7PO2HFs45JFQ97CJwGB7GX5PAn2RV3+ha0FI+ncP+E4q02hT++9OMG6zB82Fwr6 lh+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784296190; x=1784900990; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=4s1N6E1ijreaKGc1qpNnCMTcrq6TD6MWW0x4mk/QYbs=; b=H1bPdBROaqIHBKNf+/pUIz8bx+Jflo0/7Q39jF5IShwggUHrWmf0CXtmk+s1AyFqtm N9JUSmrSwsbbAtCg7rFYiNmsqp3E9SWlJi1Vt94ZWS6pNbUsyX+xuHaTiP2Q1COtzK6k 6XdNH7IWCFFHspqIuVRWd8q6FupfOw8zqyFUIUZ2+2W0OhBzGhZvopeJlG3ggaeronIH 8f8AB/plZL+27mvriaSM947B7WeBXOrD+D8AS28uBw8bF2SHMgH1PfTmyjE4FK/HRqt3 pwIIk2qQGWRzr0ZESjVvxCJE+gE0FwIqKwJY7loDqa5xucN9Km9OpPP/NfvrQIB4y1Be Ztsw== X-Gm-Message-State: AOJu0Ywf5PpLwbuvIEUP+FKwKKaCzSDc44adkcS1loDOLkqaY8HtbCFY 2Vs5M1ZpZDJX/6/km3RVD3Z/NVYUjS/GsvXBURz9YF62HAUOGtiGZc3QlV62hZl9u9TGZy/w66U By5Ran+KihlhjqjghJQLRfwQn0UhAToT1IBVDEx7Fa0UyzDZy4uhaqTTPH4zP1050ZM9tsN1YBy wWJZ7YpTpzmsYwK3xFN/4KqMh60bTQzdl2vcaj37E9tVy+ X-Gm-Gg: AfdE7ckOYfhcjycGlsOgaOISZklLcwCDCqxjfX85FLtTDCrioQ32jOoeXBvgEs8F90j pcQj0qZR0sKytt1VYM3ZQtFmsnMkVjIb87cqxO6jTxD0b9BhJrT42cUxsY1ZAiMOPiXQSrk4Ikh dT5y7nbG+zypy1n1LyzJDi/UaraS/YfB2DAaNis6a0dLuoILo+omQRu+heS0UOk2lL0PbNJy6Na uaVpzZvgEOhySJw2oVfWGePJy3OuroW4dAw0P/jUyN87NDInB2sdAw+K7frQLQVLx788BU8O0mt mdrJ7mdskOXqNftio9LM4XP3nrUc0R5bYj6o99JW2qKvTn+weqjwTQNPnWUKEFEP38q/TLqQrwX 9ds6uUS8DuUmN1UZ5AEzS86SyFOfbZqRTzt76j/iF+LvG3La3ac44CwLAvVlEBhov+/BJ1uAqlJ N0rbxEAi6MGA== X-Received: by 2002:a05:600c:55c9:b0:493:bd2f:c5fc with SMTP id 5b1f17b1804b1-4954a3e4926mr25258345e9.15.1784296189865; Fri, 17 Jul 2026 06:49:49 -0700 (PDT) X-Received: by 2002:a05:600c:55c9:b0:493:bd2f:c5fc with SMTP id 5b1f17b1804b1-4954a3e4926mr25257585e9.15.1784296189193; Fri, 17 Jul 2026 06:49:49 -0700 (PDT) From: Dorinda Bassey To: qemu-devel@nongnu.org Cc: mhrica@redhat.com, mst@redhat.com, sgarzare@redhat.com, manos.pitsidianakis@linaro.org, marcandre.lureau@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, aesteve@redhat.com, Dorinda Bassey Subject: [PATCH v4 3/3] vhost-user-gpu: Forward RESOURCE_BLOB and CONTEXT_INIT flags Date: Fri, 17 Jul 2026 15:49:20 +0200 Message-ID: <20260717134920.265128-4-dbassey@redhat.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260717134920.265128-1-dbassey@redhat.com> References: <20260717134920.265128-1-dbassey@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: permerror client-ip=170.10.129.124; envelope-from=dbassey@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.01, SPF_HELO_PASS=-0.001, T_SPF_PERMERROR=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: qemu development 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 @redhat.com) X-ZM-MESSAGEID: 1784296284651158500 Content-Type: text/plain; charset="utf-8" From: Matej Hrica Forward VIRTIO_GPU_F_RESOURCE_BLOB and VIRTIO_GPU_F_CONTEXT_INIT received from a vhost backend to expose it to the guest. Use vhost_dev_has_feature() to query the backend features, matching the existing pattern for RESOURCE_UUID. This allows the guest to negotiate blob resource support and context initialization when the backend (e.g., vhost-device-gpu with Venus) advertises these capabilities. Reviewed-by: Manos Pitsidianakis Signed-off-by: Matej Hrica Signed-off-by: Dorinda Bassey --- hw/display/vhost-user-gpu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index dbba80c7783..4022a3026ca 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -643,6 +643,12 @@ vhost_user_gpu_device_realize(DeviceState *qdev, Error= **errp) if (vhost_dev_has_feature(&g->vhost->dev, VIRTIO_GPU_F_RESOURCE_UUID))= { g->parent_obj.conf.flags |=3D 1 << VIRTIO_GPU_FLAG_RESOURCE_UUID_E= NABLED; } + if (vhost_dev_has_feature(&g->vhost->dev, VIRTIO_GPU_F_RESOURCE_BLOB))= { + g->parent_obj.conf.flags |=3D 1 << VIRTIO_GPU_FLAG_BLOB_ENABLED; + } + if (vhost_dev_has_feature(&g->vhost->dev, VIRTIO_GPU_F_CONTEXT_INIT)) { + g->parent_obj.conf.flags |=3D 1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_EN= ABLED; + } =20 if (!virtio_gpu_base_device_realize(qdev, NULL, NULL, errp)) { return; --=20 2.52.0