From nobody Sat Jul 25 14:36:38 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=1784281253; cv=none; d=zohomail.com; s=zohoarc; b=LwWOEoCwz3LbnMCzE5bo93FGOUkMVdaNN0MzG6QA55rIM7wLT5FEmp7IO2DJ7ls6WZdsh33Fjq6CPqP8j8IRPGBuqzLGjaNKPDpwZx/BYdYuy9I9KWSkMnExXYMaTHf9X8PztB5NVGvJJ1a1gTlXDzswISUSIS4SWZ7vHPfoq14= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784281253; 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=lgsm0TES/lcntTBYeKFQaSpbygyzphhJZOfk/wjZppoxFZsYCg3fVa/JjosVJxP4O1FMD1+ajgB8Fq6PwRAFMThFWuIzLtZFDR0KaRaXIxdJt3kg4eOCK1cQtv0m5QqQCsuu73mh1TZIE+PAU6nKPzYsIyoKZ/Ajv6mmSHX9sK0= 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 1784281253973656.0713489320265; Fri, 17 Jul 2026 02:40:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wkf3R-0007z8-63; Fri, 17 Jul 2026 05:40:25 -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 1wkf3P-0007yj-87 for qemu-devel@nongnu.org; Fri, 17 Jul 2026 05:40:23 -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 1wkf3N-0002sk-Ii for qemu-devel@nongnu.org; Fri, 17 Jul 2026 05:40:23 -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-206-dBjn0ArmPACEZcDzMuFFew-1; Fri, 17 Jul 2026 05:40:19 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-47f3e6cc5c4so2570136f8f.3 for ; Fri, 17 Jul 2026 02:40:18 -0700 (PDT) Received: from fedora (cst-prg-95-48.cust.vodafone.cz. [46.135.95.48]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49549a35830sm38356565e9.3.2026.07.17.02.40.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 02:40:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784281220; 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=URAQao/aA3VPUJ8OsopJkeWPBIC4UtCi6l1Y3A710PD5sX28ncZ5wY8Hb2wNuEDVdR/X8w w6YdbXKBDaJQnvJCH44tNtsIEQcT/RruFZ9v/1iAQ0/QqIuUClMju8Ar/C+jwVLKKJn1eB lmhmB93hH+BYooHLEQOisZqosNg/HRI= X-MC-Unique: dBjn0ArmPACEZcDzMuFFew-1 X-Mimecast-MFC-AGG-ID: dBjn0ArmPACEZcDzMuFFew_1784281218 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1784281218; x=1784886018; 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=iRdFEvlqyVZO/1XA3XisdUpZ0Ahcb2ob2i1XF1dZb9nIfSXAKG0QiWzVfrDi3g2akT BcSgOCVLv4X+gJs1uaY4w7kIL70oqAcQUWSt6/qobUyjh8SmiKIFr1AqpLx010g2dqXC JRK9PtNWa7ewajUfJYdeABw3Zdlo2Scw4bIKSfd8hiYk8AHx9dtoAHag+EfqBshorxnH Y1Y8irNItfJxMpbchWydK5Q4PYi+PnZfiC703F5yk/S6l2KBowTJhADvi+1xkc52oK9e OwUzlp5ctr6/kxC24g2/jZkrThlOCAtECs/krYk0esRWgk4fl2Gs2dq95dZPQb6hG7B0 MFng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784281218; x=1784886018; 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=DXr4w2bHKmGPq6mTFWF0OceNyIBsTMFEDLZ4sX0tlND5pzt2KfYThGAOjAmvflnuC+ Aiv2URg2d5cTD1WLQbS9jngDKmfjAnjTP+B9oyIXmqIbcFDg+fDlxhIduULlfYOk96U8 OJsDyCW2AqJTnYRhKOafWjenjwVjboipSuxzImT7KH9Dhje8v9EMQiLhS/TvFtaVDrpa 8fWTD3FBZj284v3kz+g0OWkat5Fyb8PJMOFU/oykFOlbJWw4l8hhp2YQNsuz9VPqFGAX hQ69GgYr6F4qJ9vpzR0udJN5JXFSUKPSyC1i2InZTvIAPjfLF4iGhue7aUTiokSR6aqd aQog== X-Gm-Message-State: AOJu0YyDw92kL1hnaUONRQ8a1GuS06pCkqQSmG1wwA1Z4pTwiaQ+HwNn VgbSUziJRH7e8GNLYGMACKb9S0b7b0aPQ8V1lU7cd+Tj5+p1P4q1Hmy4B1Gg7s0MzRVqIHZch8i xnop/WBg1moR1CTOPlBsDq2HHwyWF2OrAnn41+qrIG0FCdRcV33z5eqoPsvVaCZREjOgRQl0j3V TUI/SZs4gyQqDU+z13WUTvgphJ/BRBtUF6K3b8ZwaXuyKS X-Gm-Gg: AfdE7ckgD1tEoxtit4FXCctEzp5dWFrzL9uZFiqIGZnNHuan5nKTpFCzV9kSucSp2ke wczLSscEuquO0lGmCrB7Jy5XIGzlA9nrGuTW8uB8J4RFPI1ZxLPdcO08yi210bOrnfWJplFtiDO ydcrIWenRd/eOyi/ZK86iG55xaueTjUxb5t8+eZuNTQ5wyh71FQFqLSnN1onqQau+qZ0lyFs2F1 XxR90aarpMNXRGAt6Dm1JZmyb/YnC6ZzvYmwC5V3q5JzzKHA3NWcGKRRu5x44SFXuAnqVymgWEg /AoA3MgN+v+STEGofi1lErwl/+kJNTlFlrPLw/0DD9fG33KLUFOKqIz8+vzCCwqBfPfVmCUerGK dYoUtMQtmdPFEDfmJOaG4JQ== X-Received: by 2002:a7b:cd10:0:b0:48f:d5b8:5b07 with SMTP id 5b1f17b1804b1-4954a402e60mr14277815e9.20.1784281217709; Fri, 17 Jul 2026 02:40:17 -0700 (PDT) X-Received: by 2002:a7b:cd10:0:b0:48f:d5b8:5b07 with SMTP id 5b1f17b1804b1-4954a402e60mr14277455e9.20.1784281217284; Fri, 17 Jul 2026 02:40:17 -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 v2 1/3] vhost-user-gpu: Add shared memory region support Date: Fri, 17 Jul 2026 11:39:23 +0200 Message-ID: <20260717093925.214023-2-dbassey@redhat.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260717093925.214023-1-dbassey@redhat.com> References: <20260717093925.214023-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: 1784281255091158500 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 --- 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:36:38 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=1784281246; cv=none; d=zohomail.com; s=zohoarc; b=HPYx7ph5hC7xbPjiQ8yHgEsHGK7DWKQVBxB+OrbbbT6Cti85z0/QGxdQyxO5yjXZ64qq0CXMX0uTWstjB+0jpfBY4XYBWrhTDglcqSS9al4TSKpjSN+pyU3OhN4W2+2oc220sY9aXKwwTMEsb0eyfF5JISfxZoxNKsj6lxISfmk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784281246; 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=GnVh82ZMcs88ru82KdJa0uxW0A6lM0PnWtBkJyDgojB1X9SNKbnml9G2sBIsJ7LpvVMIsSPk9xLoEEKQaj1mX/Aeq23RhKd2/RHb6puBO5QWKLozPHfJ5KcAf3OfcB7kMUOcK75BsyjZ7tiCG/UkhczQcLsgNXOY4MKRCm6Hdj8= 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 1784281246412951.3546869247708; Fri, 17 Jul 2026 02:40:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wkf3X-00083q-2G; Fri, 17 Jul 2026 05:40:31 -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 1wkf3V-00080h-DJ for qemu-devel@nongnu.org; Fri, 17 Jul 2026 05:40:29 -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 1wkf3U-0002tL-0z for qemu-devel@nongnu.org; Fri, 17 Jul 2026 05:40:29 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-117-XqgqX2n-NmWH16sGwxyZUA-1; Fri, 17 Jul 2026 05:40:25 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4954c2d4081so1602385e9.2 for ; Fri, 17 Jul 2026 02:40:25 -0700 (PDT) Received: from fedora (cst-prg-95-48.cust.vodafone.cz. [46.135.95.48]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49549a35830sm38356565e9.3.2026.07.17.02.40.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 02:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784281227; 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=b/03hEn+Ucp4rqwJtYsZcxrvVGXJ3ZHgXKwrKhCC05Z33BEtix1dme6HuJt36k7JS/ixkB Y2oNUxM7SIhJN/CErCidGUXZLtDxaJdxsQCU/2KPIw0L4YRWa+iR6vawXZSGeogcTTCl6M 0a2OepsozZkjqOy5E6W+tB23taCWcBQ= X-MC-Unique: XqgqX2n-NmWH16sGwxyZUA-1 X-Mimecast-MFC-AGG-ID: XqgqX2n-NmWH16sGwxyZUA_1784281224 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1784281224; x=1784886024; 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=fvJNBbcDC9oez3ZrF2wXIfQl+HNuvLxUmW9W4aDOPDgIcjL9FZJ2gJZPNhwQxemNEI sNhuL/kddrO/NU4FQiIcJbQjJ7oSX5vmCeGmQj79ws1DjVMLVP/CTY883j4dyqA5itah swJMzl6VvienAdMdIfHmbWFbzj5IAGprA9+jMglpzmuDdpVDeiHI+6b+at8DDcoI0T73 KC1hYA55wDyspC8yz3fshF+lzuWJMrv7qXrpjcVkul+o3ND6xEhwneu7IOZgEAOfE5ki Dho5qmB1eLHBtmd8AuTKjCWKjuQcURkBNI3uX4va7yvsC2WED+lbr59SmU2xZCQCBGSW J5qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784281224; x=1784886024; 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=GyU6JloqPOiS604evpI9n0P/LMeHITsGC1zdsqzAvuOpR1E+ONb9ZQJgn2ZlAiKee1 NYaUaPDNJ4HRJwSwgyUmGj6wOukdlwzaNeCbtWVJUWdcrERFxwAto8GJ9Rr+voqZhPYn jn5OvlCvApcY/p3xCOZbhoFmpNkuL9sdl9nPVK4OM3bQPHWk68NxYRWeuK1N9Oddeqba C6MAWftBtnULgtwValzbwCeiNhtVrl39QfiFzw6AFWCxDrC7Fv+Bok1VoYNo7qz8RGB/ jHDeO/iTZjUpPidnqd01QqTbzRYjwrTQC4DW+R8j+Qbqy/z+/UhVKMyNhEgEBhhzLeGq Nyjw== X-Gm-Message-State: AOJu0YxUcL1e8+Q9pab94SDDpSrE1dwEoXqYcrv9JZVR2EWzBLblBMsA hw/uIyLtG560QVHu5zQZMSs7MU9hCJAGHTEBWTs10lpn+FnjLTBcWAdULopszrqYJlUW5+v4Avx RKSPfx2FVJBOHXvYumC0c3ePhDPxMftxKZtTGnjBOAwYWB1xjiZGfBZ/C+EhaBPQFNTGZtjNACh O/Y2ni0d4osU7zNBf6Fwc0liLUFWVxwx3rh5wYkaU5EeTF X-Gm-Gg: AfdE7cl7EHD1JkEJMv0sH6XWwA0SkoN2RE2JLWlXnMXnTimhUGRJTYzsJhPgOSscMXN UhT07INVY/ZyNl13Z6Sm98eZPrDEzNqvWuPeJ7xsq2a0KpcWjJiT5JAQ3YRmgIz/gKB7ka1uph7 AyPaR0F7j2mb/ufaWUz6wvSTQn0y/yK4nJYffBM41MmlacrniFTN0Aw3Hx0YL2zS+nzhPl1pkFV KYBN9Wy1oT0OBaybU48MFNaNFQPWogZmr93yEMf55NI8Ut6BR4Aht5v+UrW15MS1oEmRmlk1qDw 3GOoRkIvhKasPM+SoOzOg4Kbw+Ybn89s2P17YC6NKNvdOaICGSgXTk4gcOrrqPMC8Ww+IEoYFfm OL18ufrfjM9dCgoHNZHA5wA== X-Received: by 2002:a05:600c:4691:b0:493:c47f:3c55 with SMTP id 5b1f17b1804b1-4954a3e20a6mr21494665e9.5.1784281224054; Fri, 17 Jul 2026 02:40:24 -0700 (PDT) X-Received: by 2002:a05:600c:4691:b0:493:c47f:3c55 with SMTP id 5b1f17b1804b1-4954a3e20a6mr21493955e9.5.1784281223499; Fri, 17 Jul 2026 02:40: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 v2 2/3] vhost-user-gpu: Forward RESOURCE_BLOB and CONTEXT_INIT flags Date: Fri, 17 Jul 2026 11:39:24 +0200 Message-ID: <20260717093925.214023-3-dbassey@redhat.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260717093925.214023-1-dbassey@redhat.com> References: <20260717093925.214023-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: 1784281247079158500 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 From nobody Sat Jul 25 14:36:38 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=1784281249; cv=none; d=zohomail.com; s=zohoarc; b=SDNJXh9MWWIqX5wLmAsvdbkUd/j69vV2qlLGHGlVQmQs5M7kPini+mUQLKM2z5gA4MW6EirYocIT8VyzuLYw1vxNqQc8zc36sRf95a1RWgCgxXf80sGekpthTgTouBpznV2XFYqH+xARVvU2nKV2SZ4GFaj2ihDYgNslx0qGMO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784281249; 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=GUzQ/YUsey7xzp/ka81xsK/8+2yW+4aVogZ97KwN09c=; b=Z6viBY0DJQlYIRBlwRh/CNrW7g0YIoJLCx9YioDbSOLOJd63Cigoi9oRP+OAOkxxADae900QsuehprDFpR2EddxGaQJiCbXeQIn0qX1WLlrY1IlSLnqzCj/SvXLX3HHVk/JpM4m+Eih2BuYvNg8DXjf/Iy4AZrp50mKPWvPfx5I= 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 1784281249198605.7428279148893; Fri, 17 Jul 2026 02:40:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wkf3k-0008Ay-6r; Fri, 17 Jul 2026 05:40:44 -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 1wkf3d-0008Aa-2n for qemu-devel@nongnu.org; Fri, 17 Jul 2026 05:40: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 1wkf3b-0002u5-I4 for qemu-devel@nongnu.org; Fri, 17 Jul 2026 05:40:36 -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-284-2hwDOUuyMbqPqqQu2btPTw-1; Fri, 17 Jul 2026 05:40:33 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-493f75ebec5so51405805e9.1 for ; Fri, 17 Jul 2026 02:40:33 -0700 (PDT) Received: from fedora (cst-prg-95-48.cust.vodafone.cz. [46.135.95.48]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49549a35830sm38356565e9.3.2026.07.17.02.40.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 02:40:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784281235; 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=GUzQ/YUsey7xzp/ka81xsK/8+2yW+4aVogZ97KwN09c=; b=bR34jQvWmcLMzLxkz7lsMEmBOYBB1iudZzcZmrzYUiAySKDeYe9B2k2PZO8QIRWQ2nWV6D A9yDSo63offtbdDTMPVgetiKvmnQxlSFReP/a6FJTG3DJKACom7T8IY/3i/d0o215MdpC5 tLtT/6iWSpG+GdAgfIxbcTaXAWlP+SA= X-MC-Unique: 2hwDOUuyMbqPqqQu2btPTw-1 X-Mimecast-MFC-AGG-ID: 2hwDOUuyMbqPqqQu2btPTw_1784281233 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1784281232; x=1784886032; 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=GUzQ/YUsey7xzp/ka81xsK/8+2yW+4aVogZ97KwN09c=; b=R5nuk4Mv5X8Qo1hOk+sUWlRlwpTZpa20euHVm6oRXT5gygXeb/0+A3lWWCY6dLt8Je lce3JkvQOh1e6SfwddyK6MdKCDE+4TgJKMKKqDS8gWOwZyurwxwDBUmZgkSAMtv/FQkD UTlbeIRHNuATDRWSovP3EZ1PESw9gvCQoRRSU81f23Q0WJCiepSv9pQXj2tblftxkzkM z5QbV/pdqbkFcBApCnq9oMq0ZOAyVFRkoLhB62WctKdBehUDnTwFuOcH8GsAA4yuCvno 9Ohf1XDNL8DsgD7ICg/helv0RMwBApYKuOvpqfe+7NjW9Pu/AUya+VxXR3eBSMVUUwn9 ob3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784281232; x=1784886032; 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=GUzQ/YUsey7xzp/ka81xsK/8+2yW+4aVogZ97KwN09c=; b=k6j8kmzQ9EJfxgfhzI19mauipVAyRSJ3/83mFUz0jI32fFNxYrrsJmJ0nAdIj4UZeu CzzmEfz+FhzfU+FJQMbQN68KqDNpmnS5D9h+gn9lQXBvHuF9vjH8/bZcKNGTr4Gh6VA2 lKil2/cIn92xQHiOQFtTziFoTADOqertkeu2Hx7x6ud4lrEtPjV8WNm5nx6zEy+mz/Vm kGEIJE2DXqC/Q9AYNTvFGmlX3h+5XjpSGq9+VdkfDMKyZTGdTG6+37v+Tu58YwS7q3I1 +Ze4pAikOILPYObtckzC8C+RjppogtudkAnsMgRuPiwvw6gi15zOUvnzBexzpQTkLwky CtBQ== X-Gm-Message-State: AOJu0YzWgXxDV+e3Ao22AKLZAeD1ihEivjwPhpi4Bo60sQ0D+PH8OY1S 3ygkvAyBzm/7MTavoiCqfWrzdLaenM4hbnApjQz2FV1E1SZng5U19ZikCTOxKGhF7gRkDGwKr4o jAgrqNwM6Sm9QHECk4ptTgPy18FGV8UAD/pPL/n8MIAx/6uR8Tmh6PZIQOfokbBiiGqLJtH/dk1 HzcfjlB5q0/YxiYM2E/q2CaSv8pPjywK7x/zfyeBEtp1X9 X-Gm-Gg: AfdE7cloDzVugJxrLPY/tm2kw84KD7QMlBoGnyel6MU8gnEymubU/xNgqsqmqj10INt x9gDxPVDUIFjZKTal2zLwVHiKoy/P56gLRekLjfQtTV/sSSw6cy2RaJk9/ZRp5ZBFX9LX+7idvP aSal6nQYbfvNqiNOiuTaHLFD9xGakaJ6HpRy3HdGbqXCdiA/ciHs9e/8+aNrLVDMNZYSpitCj+Z kCkMwuC9f+BFzGYyTieoQejxMIoXxuBhooxjoVB6+fxSaeSfUCf10sFb5pnd716FomO7K/BPlFp w+GqgJeDB+Bd00HVceqSybLGeLVnRM4bg/K63i0FENDbu/ymC2I+3DofL7f6vW3pII3dd5796o9 9qQZLCYYwSjTW3Mzc9Ofryg== X-Received: by 2002:a05:600c:3baa:b0:493:b730:8d78 with SMTP id 5b1f17b1804b1-4954a514007mr24390405e9.31.1784281232348; Fri, 17 Jul 2026 02:40:32 -0700 (PDT) X-Received: by 2002:a05:600c:3baa:b0:493:b730:8d78 with SMTP id 5b1f17b1804b1-4954a514007mr24389845e9.31.1784281231789; Fri, 17 Jul 2026 02:40:31 -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 v2 3/3] vhost: Fix SHMEM_MAP transaction ordering and resulting deadlock Date: Fri, 17 Jul 2026 11:39:25 +0200 Message-ID: <20260717093925.214023-4-dbassey@redhat.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260717093925.214023-1-dbassey@redhat.com> References: <20260717093925.214023-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: 1784281251110158500 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(). Suggested-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