lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <88f6b45d-64e9-49d3-9480-c85b8636f339@collabora.com>
Date: Thu, 15 Jan 2026 13:12:16 +0300
From: Dmitry Osipenko <dmitry.osipenko@...labora.com>
To: Zack Rusin <zack.rusin@...adcom.com>, dri-devel@...ts.freedesktop.org
Cc: David Airlie <airlied@...hat.com>, Gerd Hoffmann <kraxel@...hat.com>,
 Gurchetan Singh <gurchetansingh@...omium.org>, Chia-I Wu
 <olvaffe@...il.com>, Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
 Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
 Simona Vetter <simona@...ll.ch>, virtualization@...ts.linux.dev,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH 05/12] drm/virtio: Add sysfb restore on probe failure

On 12/30/25 00:58, Zack Rusin wrote:
> Register a devm action on the virtio device to restore the system
> framebuffer (efifb/simpledrm) if the driver's probe fails after
> removing the firmware framebuffer.
> 
> Unlike PCI drivers, virtio-gpu cannot use the
> devm_aperture_remove_conflicting_pci_devices() helper because the
> PCI device is managed by the virtio-pci driver, not by virtio-gpu.
> When virtio-gpu probe fails, the PCI device remains bound to
> virtio-pci, so devm actions registered on the PCI device won't fire.
> 
> Instead, register the sysfb restore action on the virtio device
> (&vdev->dev) which will be released if virtio-gpu probe fails.
> Cancel the action after successful probe since the driver is now
> responsible for display output.
> 
> This only applies to VGA devices where aperture_remove_conflicting_pci_devices()
> is called to remove the firmware framebuffer.
> 
> Signed-off-by: Zack Rusin <zack.rusin@...adcom.com>
> Cc: David Airlie <airlied@...hat.com>
> Cc: Gerd Hoffmann <kraxel@...hat.com>
> Cc: Dmitry Osipenko <dmitry.osipenko@...labora.com>
> Cc: Gurchetan Singh <gurchetansingh@...omium.org>
> Cc: Chia-I Wu <olvaffe@...il.com>
> Cc: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>
> Cc: Maxime Ripard <mripard@...nel.org>
> Cc: Thomas Zimmermann <tzimmermann@...e.de>
> Cc: Simona Vetter <simona@...ll.ch>
> Cc: dri-devel@...ts.freedesktop.org
> Cc: virtualization@...ts.linux.dev
> Cc: linux-kernel@...r.kernel.org
> ---
>  drivers/gpu/drm/virtio/virtgpu_drv.c | 29 ++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c
> index a5ce96fb8a1d..13cc8396fc78 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_drv.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
> @@ -30,6 +30,7 @@
>  #include <linux/module.h>
>  #include <linux/pci.h>
>  #include <linux/poll.h>
> +#include <linux/sysfb.h>
>  #include <linux/vgaarb.h>
>  #include <linux/wait.h>
>  
> @@ -52,6 +53,11 @@ static int virtio_gpu_modeset = -1;
>  MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
>  module_param_named(modeset, virtio_gpu_modeset, int, 0400);
>  
> +static void virtio_gpu_restore_sysfb(void *unused)
> +{
> +	sysfb_restore();
> +}
> +
>  static int virtio_gpu_pci_quirk(struct drm_device *dev)
>  {
>  	struct pci_dev *pdev = to_pci_dev(dev->dev);
> @@ -75,6 +81,7 @@ static int virtio_gpu_probe(struct virtio_device *vdev)
>  {
>  	struct drm_device *dev;
>  	int ret;
> +	bool sysfb_restore_registered = false;
>  
>  	if (drm_firmware_drivers_only() && virtio_gpu_modeset == -1)
>  		return -EINVAL;
> @@ -97,6 +104,21 @@ static int virtio_gpu_probe(struct virtio_device *vdev)
>  		ret = virtio_gpu_pci_quirk(dev);
>  		if (ret)
>  			goto err_free;
> +
> +		/*
> +		 * For VGA devices, register sysfb restore on the virtio device.
> +		 * We can't use devm_aperture_remove_conflicting_pci_devices()
> +		 * because the PCI device is managed by virtio-pci, not us.
> +		 * Register on &vdev->dev so it fires if our probe fails.
> +		 */
> +		if (pci_is_vga(to_pci_dev(vdev->dev.parent))) {
> +			ret = devm_add_action_or_reset(&vdev->dev,
> +						       virtio_gpu_restore_sysfb,
> +						       NULL);
> +			if (ret)
> +				goto err_free;
> +			sysfb_restore_registered = true;
> +		}
>  	}
>  
>  	dma_set_max_seg_size(dev->dev, dma_max_mapping_size(dev->dev) ?: UINT_MAX);
> @@ -110,6 +132,13 @@ static int virtio_gpu_probe(struct virtio_device *vdev)
>  
>  	drm_client_setup(vdev->priv, NULL);
>  
> +	/*
> +	 * Probe succeeded - cancel sysfb restore. We're now responsible
> +	 * for display output.
> +	 */
> +	if (sysfb_restore_registered)
> +		devm_remove_action(&vdev->dev, virtio_gpu_restore_sysfb, NULL);
> +
>  	return 0;
>  
>  err_deinit:

Acked-by: Dmitry Osipenko <dmitry.osipenko@...labora.com>

-- 
Best regards,
Dmitry


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ