From nobody Wed Jun 17 01:51:18 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B99A53C3437 for ; Wed, 29 Apr 2026 09:53:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777456383; cv=none; b=oyWNX0lO7MtNKqHeC4LmG2fOXIMkGu/DRNBwQ0BtAabGSPYcBG5dp2VvAgQh8yLkn1fcFQhi+sQc9SXv8B/9Hvmboaz8n5ZdsaUdrHmKm60If6Y1iUQrjVH7daZ5X0mrGf2J56eNZJWZMZazJQIzV9frN5i/S0xO+RB4EmPuzYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777456383; c=relaxed/simple; bh=XJMe2SxZosU5QmL4e24ONrrUGq9qrGZ9VXzkthzrqQQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z80g1tKVmosVMAszPGLcfO/5/I81ibiM8pSfInZrUdJToioLkFSSNdjQSY7QO3NuHzBJ2wDw+jOrSQOpud5r6M2UVIzYeA8JDCvpUeYjaZHcVpObBDxn+czl0kYNByFaTYjEtV8Ujs4dHreXfnCXbGvUztbKq5I/oie3t7Hedj4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dtZc4nk1; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dtZc4nk1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777456380; 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=S7d9HRXIZr6YBjR7KSZJasFC5Toh9rkq+TmxxYCXJJ8=; b=dtZc4nk17CRYVuUHwTKr7yUa7r5dyR0O7pwIkLNufk+wghW8+I4/LEfHkzcpBUCLyh0Mjv /EWIapQcBJzCdtF9VsL4HWrxHBFV/SES8eDIep0pXgMqzUKF64tT1jWfLeqZfPwIaAbn9v XQYUXltsgzOy7/qy7LW5lwXj6ZJ3PKo= Received: from mx-prod-mc-03.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-450-c5r8KJh4NriXzCj1f9KJVA-1; Wed, 29 Apr 2026 05:52:55 -0400 X-MC-Unique: c5r8KJh4NriXzCj1f9KJVA-1 X-Mimecast-MFC-AGG-ID: c5r8KJh4NriXzCj1f9KJVA_1777456373 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 299E5195606E; Wed, 29 Apr 2026 09:52:53 +0000 (UTC) Received: from f43vm.redhat.corp (headnet01.pony-001.prod.iad2.dc.redhat.com [10.2.32.101]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B56781800347; Wed, 29 Apr 2026 09:52:48 +0000 (UTC) From: Sergio Lopez To: Chia-I Wu , Jason Wang , "Michael S. Tsirkin" , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Xuan Zhuo , linux-kernel@vger.kernel.org, Simona Vetter , Dmitry Osipenko , Thomas Zimmermann , David Airlie , Gurchetan Singh , Gerd Hoffmann , virtualization@lists.linux.dev, dri-devel@lists.freedesktop.org, Maxime Ripard , Maarten Lankhorst Cc: Sergio Lopez Subject: [PATCH v2 1/3] drm/virtio: support VIRTIO_GPU_F_BLOB_ALIGNMENT Date: Tue, 28 Apr 2026 21:44:48 +0200 Message-ID: <20260428194450.518296-2-slp@redhat.com> In-Reply-To: <20260428194450.518296-1-slp@redhat.com> References: <20260428194450.518296-1-slp@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" Support VIRTIO_GPU_F_BLOB_ALIGNMENT, a feature that indicates the device provides a valid blob_alignment field in its configuration, and that both RESOURCE_CREATE_BLOB and RESOURCE_MAP_BLOB requests must be aligned to that value. Signed-off-by: Sergio Lopez --- drivers/gpu/drm/virtio/virtgpu_drv.c | 1 + drivers/gpu/drm/virtio/virtgpu_drv.h | 2 ++ drivers/gpu/drm/virtio/virtgpu_kms.c | 14 +++++++++++--- include/uapi/linux/virtio_gpu.h | 9 +++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/= virtgpu_drv.c index a5ce96fb8a1d..812ee3f5e4aa 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.c +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c @@ -163,6 +163,7 @@ static unsigned int features[] =3D { VIRTIO_GPU_F_RESOURCE_UUID, VIRTIO_GPU_F_RESOURCE_BLOB, VIRTIO_GPU_F_CONTEXT_INIT, + VIRTIO_GPU_F_BLOB_ALIGNMENT, }; static struct virtio_driver virtio_gpu_driver =3D { .feature_table =3D features, diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/= virtgpu_drv.h index f17660a71a3e..d1fa386a5a99 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -257,6 +257,7 @@ struct virtio_gpu_device { bool has_resource_blob; bool has_host_visible; bool has_context_init; + bool has_blob_alignment; struct virtio_shm_region host_visible_region; struct drm_mm host_visible_mm; =20 @@ -270,6 +271,7 @@ struct virtio_gpu_device { uint32_t num_capsets; uint64_t capset_id_mask; struct list_head cap_cache; + uint32_t blob_alignment; =20 /* protects uuid state when exporting */ spinlock_t resource_export_lock; diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/= virtgpu_kms.c index 80ba69b4860b..cfde9f573df6 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -124,7 +124,7 @@ int virtio_gpu_init(struct virtio_device *vdev, struct = drm_device *dev) struct virtio_gpu_device *vgdev; /* this will expand later */ struct virtqueue *vqs[2]; - u32 num_scanouts, num_capsets; + u32 num_scanouts, num_capsets, blob_alignment; int ret =3D 0; =20 if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) @@ -198,14 +198,22 @@ int virtio_gpu_init(struct virtio_device *vdev, struc= t drm_device *dev) if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_CONTEXT_INIT)) vgdev->has_context_init =3D true; =20 + if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_BLOB_ALIGNMENT)) { + vgdev->has_blob_alignment =3D true; + virtio_cread_le(vgdev->vdev, struct virtio_gpu_config, + blob_alignment, &blob_alignment); + vgdev->blob_alignment =3D blob_alignment; + } + DRM_INFO("features: %cvirgl %cedid %cresource_blob %chost_visible", vgdev->has_virgl_3d ? '+' : '-', vgdev->has_edid ? '+' : '-', vgdev->has_resource_blob ? '+' : '-', vgdev->has_host_visible ? '+' : '-'); =20 - DRM_INFO("features: %ccontext_init\n", - vgdev->has_context_init ? '+' : '-'); + DRM_INFO("features: %ccontext_init %cblob_alignment\n", + vgdev->has_context_init ? '+' : '-', + vgdev->has_blob_alignment ? '+' : '-'); =20 ret =3D virtio_find_vqs(vgdev->vdev, 2, vqs, vqs_info, NULL); if (ret) { diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/virtio_gp= u.h index be109777d10d..4f530d90058c 100644 --- a/include/uapi/linux/virtio_gpu.h +++ b/include/uapi/linux/virtio_gpu.h @@ -64,6 +64,14 @@ * context_init and multiple timelines */ #define VIRTIO_GPU_F_CONTEXT_INIT 4 +/* + * The device provides a valid blob_alignment + * field in its configuration and both + * VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB and + * VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB requests + * must be aligned to that value. + */ +#define VIRTIO_GPU_F_BLOB_ALIGNMENT 5 =20 enum virtio_gpu_ctrl_type { VIRTIO_GPU_UNDEFINED =3D 0, @@ -365,6 +373,7 @@ struct virtio_gpu_config { __le32 events_clear; __le32 num_scanouts; __le32 num_capsets; + __le32 blob_alignment; }; =20 /* simple formats for fbcon/X use */ --=20 2.53.0 From nobody Wed Jun 17 01:51:18 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59D173BA229 for ; Wed, 29 Apr 2026 09:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777456386; cv=none; b=BGsLfM0kDa3zErD7nlOaEzlTq4ZlDn5LhcJYPS6faz/Y9qgp4X0BEFSH48/vb/Hjxnmuq/INBqZajaUtMyWuuoNBuxPZlGBafhuJHzKkNEqIUvo7SKAco/6MKf1MyDKzBbC2aOAuWC8pnAbiP9me39RjD+Umvt2F3//8w8Ljtzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777456386; c=relaxed/simple; bh=ARMJiQK4b4zHEIL+biAYPcz6LCdoox4fSNhJKM3B3YA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tf0HN5jjYPTnOoGhtwfVZKFzAiAyl1SKyzhEDaV7SEZXcBGGFZZPKj1YkdKLgobNjX99hj4i9zBYyxxDNVPMVTQj9m/oIIL4pkv6/XqzWzsPm3+IKxCoQE5TQBM57xm8JjtQnlO18Vwpk/CjkhhN3+FR3EJeYG+jTi8D9KMovBE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SxAWgOEs; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SxAWgOEs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777456384; 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=jvJ3vxSBzk5FsPg5bvaaE5ZBFTyjjD6iz6OfCrAzyHs=; b=SxAWgOEssDdKMhOW2nBB0Mwd3EV4Rx1GhF2vYNrAGkzz6pPKuYULjUOW5h99PpDjek2Nov LKWady962esaFtRD4NyQtFWQzjUOEo6Gv9SNHabwNWKs1Z8agZBYz4KSXO/iYE53g1o7EP hDmV2q7Z60TrPnDAmcUK4yJ8tlKFqWQ= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-V9A2mvalNouziWZdFQOlFQ-1; Wed, 29 Apr 2026 05:53:00 -0400 X-MC-Unique: V9A2mvalNouziWZdFQOlFQ-1 X-Mimecast-MFC-AGG-ID: V9A2mvalNouziWZdFQOlFQ_1777456378 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 56E531800D92; Wed, 29 Apr 2026 09:52:58 +0000 (UTC) Received: from f43vm.redhat.corp (headnet01.pony-001.prod.iad2.dc.redhat.com [10.2.32.101]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 897461800480; Wed, 29 Apr 2026 09:52:53 +0000 (UTC) From: Sergio Lopez To: Chia-I Wu , Jason Wang , "Michael S. Tsirkin" , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Xuan Zhuo , linux-kernel@vger.kernel.org, Simona Vetter , Dmitry Osipenko , Thomas Zimmermann , David Airlie , Gurchetan Singh , Gerd Hoffmann , virtualization@lists.linux.dev, dri-devel@lists.freedesktop.org, Maxime Ripard , Maarten Lankhorst Cc: Sergio Lopez Subject: [PATCH v2 2/3] drm/virtio: honor blob_alignment requirements Date: Tue, 28 Apr 2026 21:44:49 +0200 Message-ID: <20260428194450.518296-3-slp@redhat.com> In-Reply-To: <20260428194450.518296-1-slp@redhat.com> References: <20260428194450.518296-1-slp@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" If VIRTIO_GPU_F_BLOB_ALIGNMENT has been negotiated, blob size must be aligned to blob_alignment. Validate this in verify_blob() so that invalid requests are rejected early. Signed-off-by: Sergio Lopez --- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virti= o/virtgpu_ioctl.c index c33c057365f8..d0c4edf1eaf4 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -489,6 +489,11 @@ static int verify_blob(struct virtio_gpu_device *vgdev, params->size =3D rc_blob->size; params->blob =3D true; params->blob_flags =3D rc_blob->blob_flags; + + if (vgdev->has_blob_alignment && + !IS_ALIGNED(params->size, vgdev->blob_alignment)) + return -EINVAL; + return 0; } =20 --=20 2.53.0 From nobody Wed Jun 17 01:51:18 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA34133B97A for ; Wed, 29 Apr 2026 09:53:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777456405; cv=none; b=t8yHC9Cg6rrJV64ezH18uIMvyHlPF2nB+4NH/le5A3ZwucyJ2DSgUxGgRzI28/GBpysPrShMMr8Fg921sxG07gOO8ciPBlhtEzQJR0Ehd05eQx4C2sLXCeUihUAv3IQfEbIXX/yKNU8F1igos+5VeL5QdwZBtFeZFU26Z9NAtiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777456405; c=relaxed/simple; bh=/ReN6K+0yo9euoyN9evyrR42IX6RvMM/bMgT1hfvlFY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hRcU4w/2djcGs2K3vsmhAkOmbquyJRVxhwj78YApW6BCvm/Mbf5LVnKqREdVshCHM+ggFWk60XgxfR9kQkfctFtNRObRLdsgfoIiKynYBBO8gIAwIa0LQ3CdJJtCSxotDA/OM7l41FBvpa3h0G2M3YXjVJu0+0RnJ7DJzOUVJWY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=S1UQSNmW; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="S1UQSNmW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777456402; 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=qq68cDnnkQDnhZ7FI3gXWBcfZHPGoFfOX51hOZJBhgs=; b=S1UQSNmWN1CENfrQv7Y9yncTWsEyHc+gDzmtoC2yPqt7mnD9yxXOmRLMxHzOyuxxEV69Ms 5b0oIuhK4eoytMNGtCHNCU1H02//qOfeBgJg1YIrtFSnQ8laX0uMDRaElV9O7PPtL0rSxN olGf6Z7uPqz5YP9Uj4PcpVi0jAf/Nvo= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-288-zKQ7loXTOOy2OOTEaOvsFA-1; Wed, 29 Apr 2026 05:53:13 -0400 X-MC-Unique: zKQ7loXTOOy2OOTEaOvsFA-1 X-Mimecast-MFC-AGG-ID: zKQ7loXTOOy2OOTEaOvsFA_1777456382 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A22F81800378; Wed, 29 Apr 2026 09:53:02 +0000 (UTC) Received: from f43vm.redhat.corp (headnet01.pony-001.prod.iad2.dc.redhat.com [10.2.32.101]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B47B41800349; Wed, 29 Apr 2026 09:52:58 +0000 (UTC) From: Sergio Lopez To: Chia-I Wu , Jason Wang , "Michael S. Tsirkin" , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Xuan Zhuo , linux-kernel@vger.kernel.org, Simona Vetter , Dmitry Osipenko , Thomas Zimmermann , David Airlie , Gurchetan Singh , Gerd Hoffmann , virtualization@lists.linux.dev, dri-devel@lists.freedesktop.org, Maxime Ripard , Maarten Lankhorst Cc: Sergio Lopez Subject: [PATCH v2 3/3] drm/virtio: add VIRTGPU_PARAM_BLOB_ALIGNMENT to params Date: Tue, 28 Apr 2026 21:44:50 +0200 Message-ID: <20260428194450.518296-4-slp@redhat.com> In-Reply-To: <20260428194450.518296-1-slp@redhat.com> References: <20260428194450.518296-1-slp@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" Add VIRTGPU_PARAM_BLOB_ALIGNMENT as a param that can be read with VIRTGPU_GETPARAM by userspace applications running in the guest to obtain the host's page size and find out the right alignment to be used in shared memory allocations. Signed-off-by: Sergio Lopez --- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 5 +++++ include/uapi/drm/virtgpu_drm.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virti= o/virtgpu_ioctl.c index d0c4edf1eaf4..146ff25396c2 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -117,6 +117,11 @@ static int virtio_gpu_getparam_ioctl(struct drm_device= *dev, void *data, case VIRTGPU_PARAM_EXPLICIT_DEBUG_NAME: value =3D vgdev->has_context_init ? 1 : 0; break; + case VIRTGPU_PARAM_BLOB_ALIGNMENT: + if (!vgdev->has_blob_alignment) + return -ENOENT; + value =3D vgdev->blob_alignment; + break; default: return -EINVAL; } diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h index 9debb320c34b..7d4e4884d942 100644 --- a/include/uapi/drm/virtgpu_drm.h +++ b/include/uapi/drm/virtgpu_drm.h @@ -98,6 +98,7 @@ struct drm_virtgpu_execbuffer { #define VIRTGPU_PARAM_CONTEXT_INIT 6 /* DRM_VIRTGPU_CONTEXT_INIT */ #define VIRTGPU_PARAM_SUPPORTED_CAPSET_IDs 7 /* Bitmask of supported capab= ility set ids */ #define VIRTGPU_PARAM_EXPLICIT_DEBUG_NAME 8 /* Ability to set debug name f= rom userspace */ +#define VIRTGPU_PARAM_BLOB_ALIGNMENT 9 /* Device alignment requirements fo= r blobs */ =20 struct drm_virtgpu_getparam { __u64 param; --=20 2.53.0