From nobody Mon Sep 16 19:17:11 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1721304864; cv=none; d=zohomail.com; s=zohoarc; b=KmHYMtNuhf73LBwBkDJ2LsHcDOQW45cBeZN5Jb4sDgBtF/zW3qGXbttTle0kgNRUU37tu68VNHRnuJpEgNd2X6My6yHgJIra9gGwXv+M6SP9Ii+QAQASJSlt7AmQx9F2cslDkfmSWMC74/SLEmyvm3YEJzsCo3Yu8FBTakmelao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721304864; 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=n4S4lHex2sv4HdAai4U1J0JqRHbZAZJuivl1Rp1CucQ=; b=SetjJD7UW8Zoe2dhoWO+Z9zYDlYYAqmlWRka2O4UQIQW/slBDtasUz/3m6nE4VpYKbg8a/FwGULk6I8oy81FD9iJO0G0tzIqlB1ORaz4XwQR5uAYN52TyGWfUdrVHscFgrJtvKim0/rtQ/JzWfLL/WyfqBhLJUOhvoYL5S786Rk= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721304864738632.6336966352675; Thu, 18 Jul 2024 05:14:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUQ1D-00082i-Bf; Thu, 18 Jul 2024 08:13:55 -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 1sUQ1A-0007wi-KA for qemu-devel@nongnu.org; Thu, 18 Jul 2024 08:13:52 -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 1sUQ18-00013h-4q for qemu-devel@nongnu.org; Thu, 18 Jul 2024 08:13:51 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-536-IA96ULi6NMS5Igetr_EJsw-1; Thu, 18 Jul 2024 08:13:47 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 68DFA1955D42 for ; Thu, 18 Jul 2024 12:13:46 +0000 (UTC) Received: from m-rh-lap.brq.redhat.com (unknown [10.43.17.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 548FA19560AA; Thu, 18 Jul 2024 12:13:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721304828; 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=n4S4lHex2sv4HdAai4U1J0JqRHbZAZJuivl1Rp1CucQ=; b=YcEMTu0URPs8/6EkksnO9LyW0H7NpMKEa2u9ZVGXasBnkpJaFd2uFHQcASI5G4TggzcyI7 1gpT9Geqk/iq9Z36kODcyRAJpd9fpuVxBq8wZFW/MF2XLXXQOmhfrbeCSZrGS/Z32Wgrhp ALY+5JyXh21JnIi7tSmFigLhwhJrKBQ= X-MC-Unique: IA96ULi6NMS5Igetr_EJsw-1 From: Matej Hrica To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, dbassey@redhat.com, aesteve@redhat.com, slp@redhat.com, Matej Hrica Subject: [RFC PATCH 1/2] vhost-user-gpu: Forward RESOURCE_BLOB and CONTEXT_INIT flags Date: Thu, 18 Jul 2024 14:12:46 +0200 Message-ID: <20240718121247.181510-2-mhrica@redhat.com> In-Reply-To: <20240718121247.181510-1-mhrica@redhat.com> References: <20240718121247.181510-1-mhrica@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mhrica@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1721304865327116600 Content-Type: text/plain; charset="utf-8" Forward VIRTIO_GPU_F_RESOURCE_BLOB and VIRTIO_GPU_F_CONTEXT_INIT recieved f= rom a vhost backend to expose it to the guest. Signed-off-by: Matej Hrica --- 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 63c64ddde6..0ebc2218b9 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -631,6 +631,12 @@ vhost_user_gpu_device_realize(DeviceState *qdev, Error= **errp) error_report("EDID requested but the backend doesn't support it."); g->parent_obj.conf.flags &=3D ~(1 << VIRTIO_GPU_FLAG_EDID_ENABLED); } + if (virtio_has_feature(g->vhost->dev.features, VIRTIO_GPU_F_RESOURCE_B= LOB)) { + g->parent_obj.conf.flags |=3D 1 << VIRTIO_GPU_FLAG_BLOB_ENABLED; + } + if (virtio_has_feature(g->vhost->dev.features, VIRTIO_GPU_F_CONTEXT_IN= IT)) { + 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.45.2 From nobody Mon Sep 16 19:17:11 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1721304893; cv=none; d=zohomail.com; s=zohoarc; b=fwrgyk88SCpnpOIMSdB5xhtjB9vU9ve6NryrDv62v5UPaVIAJGK7HpFXpga/YqDXYSfIU/B2GxsIRaEpRlHhxibQ1SOobhhlXeepaLcCPftISRgvd1iK51eFIjSKIhObcg9BB87FQjdah8LgSQdlxfhRmZEaD9fEUO/PKAEDpAs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721304893; 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=Bd1PuNKdySoFnT6EiD3AS0xMqjrcrTU1xer1swDRTcQ=; b=W32PXxhikErsGM/jaS8xWvLGVt0ouv4Sg+dH6Z2M9gjQTIDFL7paEaG5JSPMmo3j4brsTHv/pYsHlPgvLbg0LPTNHwiwFoGt0+sFIDcZdmfwrI3LAH/r1hg91H197qs1pSqSGspcD68Wg2y4X3vctA6K8kUqJO/zRJqXf/ksnms= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721304893436844.1414680844837; Thu, 18 Jul 2024 05:14:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUQ1G-0008Hs-02; Thu, 18 Jul 2024 08:13:58 -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 1sUQ1E-00088K-CM for qemu-devel@nongnu.org; Thu, 18 Jul 2024 08:13:56 -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 1sUQ1C-00014J-NP for qemu-devel@nongnu.org; Thu, 18 Jul 2024 08:13:56 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-634-wsX8-TdyPga9eMKNp7zByg-1; Thu, 18 Jul 2024 08:13:52 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A96A81955D48 for ; Thu, 18 Jul 2024 12:13:51 +0000 (UTC) Received: from m-rh-lap.brq.redhat.com (unknown [10.43.17.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 990E319560AA; Thu, 18 Jul 2024 12:13:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721304834; 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=Bd1PuNKdySoFnT6EiD3AS0xMqjrcrTU1xer1swDRTcQ=; b=EF4UHBwJixkrq6V7cOYl0+K0ocmGI+2O1dVkWhXwWESt8om5mTMEIxb4Kq2m/QkLW+WuKJ HkwWyzTdjQXAszooFBZU12JuC5NEgcNtqJ85WSRerxMwg/nvE/rv4GTjog2P8HJrCByrys kEnDV/rMN0hmcvZGy+kBO+dsNxGH8Pw= X-MC-Unique: wsX8-TdyPga9eMKNp7zByg-1 From: Matej Hrica To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, dbassey@redhat.com, aesteve@redhat.com, slp@redhat.com, Matej Hrica Subject: [RFC PATCH 2/2] vhost-user-gpu: Add shared memory region support Date: Thu, 18 Jul 2024 14:12:47 +0200 Message-ID: <20240718121247.181510-3-mhrica@redhat.com> In-Reply-To: <20240718121247.181510-1-mhrica@redhat.com> References: <20240718121247.181510-1-mhrica@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mhrica@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1721304895424116600 Content-Type: text/plain; charset="utf-8" Add a 'hostmem' property to the vhost-user-gpu which enables the shared mem= ory in the parent object. The memory region is created by the parent object (virtio-gpu-pci or virtio= -vga) Add a subregion (which spans the whole region) in vhost-user-gpu and regist= er it in the shmem_list, which enables the usage of SHMEM_MMAP/UNMAP operations. Signed-off-by: Matej Hrica --- hw/display/vhost-user-gpu.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 0ebc2218b9..78a1d090d8 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -643,6 +643,30 @@ vhost_user_gpu_device_realize(DeviceState *qdev, Error= **errp) } =20 g->vhost_gpu_fd =3D -1; + + /* + * If shared memory is enabled in the config, the parent (virtio-gpu-p= ci, + * virtio-vga) has already added a shared memory region at this point. + * Add a subregion that spans the whole region and register it in + * the shmem_list to be usable for SHMEM_MMAP/UNMAP operations. + */ + if (virtio_gpu_hostmem_enabled(g->parent_obj.conf)) { + void *hostmem_ptr =3D mmap(NULL, g->parent_obj.conf.hostmem, + PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_SHARED, -1, 0); + if (hostmem_ptr =3D=3D MAP_FAILED) { + error_setg(errp, "Unable to mmap blank hostmem"); + return; + } + + virtio_new_shmem_region(vdev); + MemoryRegion *mr =3D &vdev->shmem_list[vdev->n_shmem_regions - 1]; + memory_region_init_ram_ptr(mr, + OBJECT(vdev), + "vhost-user-gpu-hostmem", + g->parent_obj.conf.hostmem, hostmem_ptr= ); + memory_region_add_subregion(&g->parent_obj.hostmem, 0, mr); + } } =20 static struct vhost_dev *vhost_user_gpu_get_vhost(VirtIODevice *vdev) @@ -653,6 +677,7 @@ static struct vhost_dev *vhost_user_gpu_get_vhost(VirtI= ODevice *vdev) =20 static Property vhost_user_gpu_properties[] =3D { VIRTIO_GPU_BASE_PROPERTIES(VhostUserGPU, parent_obj.conf), + DEFINE_PROP_SIZE("hostmem", VhostUserGPU, parent_obj.conf.hostmem, 0), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.45.2