From nobody Sat Jul 25 14:32:34 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=1784284452; cv=none; d=zohomail.com; s=zohoarc; b=BoaChj6T2YNJ+uIIuRm9vpJ3qvyL0ZqaMPBInJHmEUiNBZme7+bY0f3OrB21K119wr1fO7Egr2pQ3t3ihDReeDynYhKdcUZnUWqzvvTphoV0mxKVv3SCYBCrVJfyq0TlKj+GevoOSNTzY3+1RaTZF4OQZJT4kFJN0QhWuRkH7Nc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784284452; 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=Jf30dL8Lh4Vek0qz4aE62PpGyRERpDruf5mfOsXxdLI=; b=K7+ZGZeM9+PHzt3GHezPTmwN9Gzsdl2Ukf9nDDl85vIfpHtWlfY/olfwwnvC93RfzuE65LhKLzJpVwq9uEOybmkOoDJifwOdFnUXz/R5iYzV4o3BC3myoL0dyYUiBRxdPXD6tlXZuuIK7tGaXdyDsb7dVaPtiiPMkgU8nKJVyxs= 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 1784284452638875.9744671338474; Fri, 17 Jul 2026 03:34:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wkfsz-0003KU-Jt; Fri, 17 Jul 2026 06:33:41 -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 1wkfsv-0003Je-OW for qemu-devel@nongnu.org; Fri, 17 Jul 2026 06:33:37 -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 1wkfsr-0001QZ-J7 for qemu-devel@nongnu.org; Fri, 17 Jul 2026 06:33:37 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-346-ZEHkV15jOZuz-pkywX5wEg-1; Fri, 17 Jul 2026 06:33:25 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-47f2ed7cc45so5104744f8f.2 for ; Fri, 17 Jul 2026 03:33:25 -0700 (PDT) Received: from fedora (cst-prg-95-48.cust.vodafone.cz. [46.135.95.48]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63ed2313sm2523298f8f.23.2026.07.17.03.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 03:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784284407; 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=Jf30dL8Lh4Vek0qz4aE62PpGyRERpDruf5mfOsXxdLI=; b=JDf3fgQRLPJ0I+0TlUztxQBlsdcZSulX3HnwPeb89NdtAMSNtncZ8Jb4vJvylz/KrN+ZEM aopl7W6sSx1pnDTwB6jp8Mr1Ao7Drx0zFjNkLlPyHaJCSUrEy7ykmMb3ea7JqYXTqLN6L+ WZkJpvXLpSWUJ3MukoBwNo3yO7ZsLBQ= X-MC-Unique: ZEHkV15jOZuz-pkywX5wEg-1 X-Mimecast-MFC-AGG-ID: ZEHkV15jOZuz-pkywX5wEg_1784284404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1784284404; x=1784889204; 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=Jf30dL8Lh4Vek0qz4aE62PpGyRERpDruf5mfOsXxdLI=; b=ZL3by/EZTU+FRnfKJ80YOWjrS5zGnVeWi7Vmws9m4DXlMnIK0fjbA7piq63owhGoyZ 4RgI+wlNIwYmdGhgi7P/MsAs+w2gZvvHrqoQE8N/0OdwObHgyUh8yMxoD43xlKBDWh4o kdu4IuufUTPGopY4p+fGgRHey2/6LNRU2NJKflhPEQUkVM+7NwQkpepgjRz3jI/uED2O 0Bz68sY7gLU7einAgMicMqiPRsqrTNxt6FdAIQQyC6FkrKdoq1zv+TV0C7q6sPDtH8PF HSS2DtanKPmO09LDGTJLNuhRR5VgLQJolW1DGT0pldq8EYRyRDdZfKahKDSeGvDzj25P F9nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784284404; x=1784889204; 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=Jf30dL8Lh4Vek0qz4aE62PpGyRERpDruf5mfOsXxdLI=; b=nSfuxxWkKIljZ9eH/AH8ZdcZR0LXnJmnrGORYNE1PXSva1o3xEZk/dQDHFxBWUf/tW NbEuho8bDFziL+Fnpn97DQcm6O0SKoAAZ2cmz5f6kmERcx8nCnBKW61NjVXa1ocq8HkP 2TFaNCFb2z0XwAEQkmYRPFY1a9s8fHRyzBasRPO9HM25vRuZD/YvRqT80Uu3LhCK3nS/ heRtS7uQr9ZRYOoDF8gd3FBy9KaUlhj2VN54HU5jEMWHdMXwRxvVwk2tFVOdWBLg8AZ6 BNuvoJgLi+BXKRFwbT0y6Hq5vFp2SPmA1dGQ5DWV9nWRymD8v3Dssf3VYaIAAD10W/Y0 jh1A== X-Gm-Message-State: AOJu0Yw+wwia7eUofEDCO3eF/5AY8pUOwxxYGM1Tg3agMN6ybZt7EhQG DPzT6mWFZqtzwq6Nfpe6qKgeNQO3tirExp2xYCRFOuZCe7Xm6/NNtfQWz95fDCidVWuc9iRXfeX cwFDLXTNp1A+t7iLOBSSIa9wv0pZdHlnyNpicn1Yz7XCY0IfzCp8/Pn1GmN6P/reZSrZw6cjd/f fkzwwu725XXAm+AEOPSS+sESEE/xjrXQ/L4io95ZtxlAGS X-Gm-Gg: AfdE7clqvdxa7ZCAm1ljDTWQzywwqHWLwzIjrEU45MwqNG+iWN21Cob3oCcGr66FzAx T0r/iDYCjDjw8NwghaMjLQQsBBguGvMAptKM+7gOuJPYou5rrbr5XCPKyolNhNTyKXlBVywLPCJ cD69iDDM+BEMg0ePS28w9mdOF0epTKCzMk57ObFNlqxYzh8cPxgsal7WgbxHQwqnMC90f7PsQa4 ga6Qt1S5FgNzN0xKg2XRU1wxreGMu52eRr2t9674bGQvW8lRhNI5q7AAKaB4k5X+KLk9e0mBB0i dZOk2BP3zhrjzOVumxujSzKyvObvPxQuA69gLQO8H3gXzBxFlFxjJrL0VfBF9+Xha/Poua+1WuS y+0C/YxaBUPUVdwHOIk9tibNfB4C2qZGHAHa3mqEzciQ7UnHl58Kx34wkEd0GcMsuwLgrx2/Rhx sHYWPsEi0= X-Received: by 2002:a05:6000:2f83:b0:476:504f:7a8 with SMTP id ffacd0b85a97d-47f6233ee55mr2759533f8f.55.1784284404440; Fri, 17 Jul 2026 03:33:24 -0700 (PDT) X-Received: by 2002:a05:6000:2f83:b0:476:504f:7a8 with SMTP id ffacd0b85a97d-47f6233ee55mr2759483f8f.55.1784284403923; Fri, 17 Jul 2026 03:33:23 -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 v3 1/3] vhost: Fix SHMEM_MAP transaction ordering and resulting deadlock Date: Fri, 17 Jul 2026 12:32:59 +0200 Message-ID: <20260717103301.228974-2-dbassey@redhat.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260717103301.228974-1-dbassey@redhat.com> References: <20260717103301.228974-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: 1784284454776158500 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(). Fixes: b52e1896e764 ("vhost-user: Add VirtIO Shared Memory map request") Suggested-by: Albert Esteve Signed-off-by: Dorinda Bassey Reviewed-by: Albert Esteve Tested-by: Albert Esteve --- 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:32:34 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=1784284432; cv=none; d=zohomail.com; s=zohoarc; b=UpmbgNIV+7ovKB3B7qkv7kK5mIylG6OBU2+xfDfjL+bwBSt2HSqu7FJtLHQgNOLvemYvV6+iw5NSbAfAHFJLhWComjkYSt2bLZbBSplW6pgDIpZxMPX7OMUhBnOCJO2Q62gFoX3U8cUWAKqLPvru2yvBz7nBobbg/yNTAUA7w6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784284432; 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=AYSfFq9oXIBf3ZUfwtzjbA8CNeqsnosYDVtMJ70W6gE=; b=OQt87oCy1tQ18pc+P9XK9B4fzgoC84z6I8bjKp0mpGv+SxXSACCsJCMKw/HY9yFQcBOn9i4Ss/TOzZe0VdKBC1DI+TAW+fySglLUeOyaWvQYzIHzimHEr+K30U+eJ48rIwasGpAXyBPjI3DckbpBzoh/+DDKRYnijKswdcrwffk= 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 1784284432795287.22924734241883; Fri, 17 Jul 2026 03:33:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wkft0-0003Ke-JL; Fri, 17 Jul 2026 06:33:42 -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 1wkfsv-0003Jf-Ol for qemu-devel@nongnu.org; Fri, 17 Jul 2026 06:33:37 -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 1wkfst-0001Ql-Li for qemu-devel@nongnu.org; Fri, 17 Jul 2026 06:33:37 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-175-T9jMUWbKMZeygPEwpx2TFw-1; Fri, 17 Jul 2026 06:33:31 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-47f24a50f0cso6684991f8f.3 for ; Fri, 17 Jul 2026 03:33:31 -0700 (PDT) Received: from fedora (cst-prg-95-48.cust.vodafone.cz. [46.135.95.48]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63ed2313sm2523298f8f.23.2026.07.17.03.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 03:33:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784284412; 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=AYSfFq9oXIBf3ZUfwtzjbA8CNeqsnosYDVtMJ70W6gE=; b=fxP0nSptRENhFZfulRhG7uMCLmfBLREdcIB9TEmpmWicYN5Lx7HEj3hyRzcCJI0wW2fwZE PLwBv5C/DvdN9m0AmHIwfCjmo7IdGpO0ilVvkrlRi1/xwiU8iuWzaCu0/NYhCpGVFwi+vU +IOyqOF0733NTnyVGmr9GKv/XlNQjzU= X-MC-Unique: T9jMUWbKMZeygPEwpx2TFw-1 X-Mimecast-MFC-AGG-ID: T9jMUWbKMZeygPEwpx2TFw_1784284410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1784284410; x=1784889210; 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=AYSfFq9oXIBf3ZUfwtzjbA8CNeqsnosYDVtMJ70W6gE=; b=BmtEuIHMTMrrgec/p2uAyXeDkfe3ZcCjXyVTDp5xiXgRU5oeeY/eHNMEhm/6venJke OAsYygkE4W+W4hjXzZAqqO3UvXnv1wXKBOacYph6Ah8qPv47C3LoyrxD9YeyaNad0PsA 8G2v9bQ1ZHzXygKwVh1HVkqdgpq2NETgtUDgD5u7YE+4ZOeYsrr0UViPT3olbGAKhW5E s+funcffVR6WTYY/TwLp6cix4n+TGmg0MZd0q60ELj1XKfTqYwcSb3/BD8onhMj2zgVJ XIYzSNSaXoWlKzqNgR7oxrSUpsHbqKbhD04IJfCKT2zargh6VUnppN+AhikYfSEcy0NN TBqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784284410; x=1784889210; 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=AYSfFq9oXIBf3ZUfwtzjbA8CNeqsnosYDVtMJ70W6gE=; b=g0dolh2A7sCWv5303OwG9IzhOwtKEovrcNP+uYNSI4qvhHEpMn7iBTSTVSAr3avQQv hN/SGBRWwIgQSbQLYKkJrJiadJm8C/R/bkMYA65cwjD5iS7WrVolsOtQEIi0+zNLV0BJ /z5aAx5a6cwSl3f/b10vQdVse1+qbsWMj61f+9PBELeixaLqAGOI7kTM+UNleH6lrU+q pVbP406Mm1mO5zD2peZnlqDm+bAvm2RXB/DVS0wjfwtb/6r710Eip5PuZkHfgXN8b9KZ ton2Yq01Pbb9Fs5ozJLuP5ZqQqwwOVWaMO7tZuQJci2DoSPnFZ+CskwQHqHYi4nkPs/n QU6Q== X-Gm-Message-State: AOJu0YxXOC1eR8eylv1Su5VJUL6KR+PXI/hQeSoQRVqJANBT3zsOO7no A6CUqPZlsP/5oVIQgmuD/F9z+FiWLHbZaPPVZTLJAZmhpe168MEV0SEqhElBbCbq/Kc+ikLSszM KpRRE52muJ26/TMfdGPeRI6vtqO9OLlb09Cuq+25cqvGaNIDumuA+1OOhCLOEidrTkgtYj9o0C3 j82fK26m8SISVoaHihVzrYnbJ9cFP28I+IPVzOnauD4tWd X-Gm-Gg: AfdE7cka2JHrZSM+mvnpn4vdWULJbAh2g5z6UUdLaj/h0ja3W5oxcTAA4E7DwIxkkvA KmzmxYtqhKUVVkHcaq20InAFjwyjaxNvYJSCeDmACw7zRT9tvisnM7wCN9En+Uue4Fr0XtR2pUY Y7JrsCrM5thQyU0agr4iLsYDc4HFJjScfa6wDd7b83IHCpFUuTGB2/Rt8MFiubUw7Z+0/+Ba8GJ SXvrVJedJqkTZ3Uy9mhx44FQ/lTGkgN/Aw+s3sl5AbZ0J7uT8WcEcGOs6j4YE9lPSNYmtFNLLow zIlCYUtYdmnD9Us+zudYspFmnLWsYyC5fnoAVNtDHjrmO43wdeOZslP8s1Tt7uwXTeuQmTioCZD XgldsbPfVXupIWn0f1Bdzcw9TOjGIZTGZpgjDO6udM/BCnk4HkAn1AFCvv7NyfX9f6nIKznhIFJ EiYN4OzmY= X-Received: by 2002:adf:e19b:0:b0:46d:d90b:bbe4 with SMTP id ffacd0b85a97d-47f6232c546mr2474855f8f.40.1784284410102; Fri, 17 Jul 2026 03:33:30 -0700 (PDT) X-Received: by 2002:adf:e19b:0:b0:46d:d90b:bbe4 with SMTP id ffacd0b85a97d-47f6232c546mr2474801f8f.40.1784284409517; Fri, 17 Jul 2026 03:33:29 -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 v3 2/3] vhost-user-gpu: Add shared memory region support Date: Fri, 17 Jul 2026 12:33:00 +0200 Message-ID: <20260717103301.228974-3-dbassey@redhat.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260717103301.228974-1-dbassey@redhat.com> References: <20260717103301.228974-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: 1784284434846158500 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 Signed-off-by: Matej Hrica Signed-off-by: Dorinda Bassey Reviewed-by: Albert Esteve --- 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:32:34 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=1784284457; cv=none; d=zohomail.com; s=zohoarc; b=JdDTJvfA/BRfmaCoNsCEPY9zk8ti7ZW9DGknUeYz3qqEXyETn/vKhvp07M6A53TE7a1mjmCU47bms9vPilsYX791Lf4wE09KY0zRxvakMfjz/SKvTEL0nHPqgq+v9uWvEYPVs2Cs9mWz7iAKb81tdKZCjPGKhh1hBVYCGQt+6yo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784284457; 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=boA8D3ki4eN5Q8tmpTti1ZMYlWMW/7uXMsxh75vwYnBbxEmgzAQG4V6JjYgBVm5BM1IoYL9VyZWThPSiGzmLsOBKhdoNBePu8oJSTUfECwFfwGJmIVvxUpy9igBtwdmTpW+Uyv1pH/T/zhzdmFAA+K1/ERo97TKZPYTTA/6WxQg= 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 1784284457091453.0177596198939; Fri, 17 Jul 2026 03:34:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wkft1-0003Kx-A3; Fri, 17 Jul 2026 06:33:43 -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 1wkfsz-0003KW-NO for qemu-devel@nongnu.org; Fri, 17 Jul 2026 06:33:41 -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 1wkfsx-0001R6-09 for qemu-devel@nongnu.org; Fri, 17 Jul 2026 06:33:40 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-643-E_jOMVZZOxSGfUa0BwQZLg-1; Fri, 17 Jul 2026 06:33:35 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-474170b59dfso4439645f8f.3 for ; Fri, 17 Jul 2026 03:33:35 -0700 (PDT) Received: from fedora (cst-prg-95-48.cust.vodafone.cz. [46.135.95.48]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63ed2313sm2523298f8f.23.2026.07.17.03.33.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 03:33:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784284418; 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=MbkdbBsOAhOQM6wtjkSY5CTI/hSF5IpACPX1wbdZFm0KgxbC805AJR6u/+72QKL4WHaerc xsPBWmPZiQP2YxLTa3MvkCKgirfdMMXr6QK0X4FO/yzhZTg4wmEK5XSCMQ5mZk8QfjH+9C r/8DPQsP4fzLpLLBqi/CvDHZlIYbyS8= X-MC-Unique: E_jOMVZZOxSGfUa0BwQZLg-1 X-Mimecast-MFC-AGG-ID: E_jOMVZZOxSGfUa0BwQZLg_1784284415 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1784284414; x=1784889214; 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=e62vF6paSLs4DJ8KqX8JKMmmyjFzKTvSaudSDiOIO0CcpeFWmLUCy76iHlF1/Jf+lg 72DlMLxrKkH2QisE3B/NNBn1MRq3dQuAB0/hcYfYgf0DYYrPq+xLoIb/g/Z/FMh73PuS ie3gb5sbJPFoJrNNUPtvpkyq5znSTIlzNDBqmsOvf0ms8ie7kccIP8U/6919Ma62kTuy nUFI6XnX3xHMP/Jhinn/Bp2p6wz4KSx/D8gmgW56tryBbhcXHrCiHvmY8KBaHPRUbGHc NOa04p7AHbpGhFkI9EXk1/XCWV51Y29R2EsUUpZ9kHRJpYhWQgo2XdySO61JFs32ZKI9 2KYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784284414; x=1784889214; 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=H1sKXPjYjmc8u1tVigG73DbZI0K1FDkZRduu5qLTLmq8s7idDXYkkZxDnGzu3v05CZ 6FYoG519IMWLl7KxdjDR4NbZds2zR2F87Mv8Vdiu+F3LjRLIDF/sKl5gYuBOztEkMht0 RNA2DzyCZVZ9iRzSLz2votrcx40oWZZoFSnA9rStp6yo2R6rCu9zT+7vQN7aaDqBaNxV wesgN6bF7V6xXdHDWt7S/4s/Ehj4ovSjZO0Dc6CzEEQVIF+tdiJkRgsqDqFDQO6pEXQm tus4NhxuDIJ3esfcX2XZjbvzoWZdMUIgKX9i6ssj6dR5yZjJne+6QRx7AgjYTBkhfFwx s/yA== X-Gm-Message-State: AOJu0YwlCrcsejKgoWU0sh4UROZxo+6ukjgbWK25HpfbuMqEgFdLTvU4 Yj/OmENghzQJQArPwVUBUb0T7QEI1rahAlUTOeRn+fFz7YZP+CztH/immgwBDKAdn79BHfZzjJr hbEqiHQc23di/JJPnItq3CR4R3nX6MJQZ9Stcm7tEDNL6F3NO1TTetE2nWmf8Vrurm8h+j0a+5U Bz5Dl5QH6uJkd79M2cZPvifM3+9ObPVzILUEkOO2zmwJcF X-Gm-Gg: AfdE7cn8+7vEFWVRS/KUPN/AYi8C4h/yA7YVkqSGyUQAPEOlR4oc0F3OBHEt+I1cMcz 22QvRn4XxBi+nbMm8S/h21IC8qAODbiH/hq8Hur/SG16G4+dw+GCggk+phIL+Zls1pT8Bxg2SrI pnZOzU3x+r4dP8rRjI7U9EAp0PTUtNfa7D7tfgsy4NNoK3iZkF5U9rMtemJjRtfOsqONus2Bqzz CCefqK6cSs+D4hBlnW6MNsBkvCxaMRAX3iDNkxpgLqgdlrulRu9xk/pBFH+c0OfbgC9veES15X1 GDE4KjoNXaqLn7kTh2PWGYzK5Z1tR58cwbL2GV6z7H+EsKNS6nwZczb3u9xFJDM+OftxxaenA9q VsM4kolIHv9tfttxJ9mLj+B9prnxXCl26eRNf6v7I56Vuw6eDpkOY+JyXHFUnxky+0k6avueO4v iIUvJa7Z4= X-Received: by 2002:a05:6000:41e7:b0:465:81cb:bb20 with SMTP id ffacd0b85a97d-47f6230767dmr2793949f8f.9.1784284414627; Fri, 17 Jul 2026 03:33:34 -0700 (PDT) X-Received: by 2002:a05:6000:41e7:b0:465:81cb:bb20 with SMTP id ffacd0b85a97d-47f6230767dmr2793894f8f.9.1784284414113; Fri, 17 Jul 2026 03:33:34 -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 v3 3/3] vhost-user-gpu: Forward RESOURCE_BLOB and CONTEXT_INIT flags Date: Fri, 17 Jul 2026 12:33:01 +0200 Message-ID: <20260717103301.228974-4-dbassey@redhat.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260717103301.228974-1-dbassey@redhat.com> References: <20260717103301.228974-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: 1784284458709158500 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