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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0c45183c-cdb8-4578-e346-bc4855be038f@suse.de>
Date:   Wed, 8 Jun 2022 13:11:21 +0200
From:   Thomas Zimmermann <tzimmermann@...e.de>
To:     Alex Williamson <alex.williamson@...hat.com>,
        maarten.lankhorst@...ux.intel.com, mripard@...nel.org,
        airlied@...ux.ie, daniel@...ll.ch
Cc:     kvm@...r.kernel.org, Laszlo Ersek <lersek@...hat.com>,
        Gerd Hoffmann <kraxel@...hat.com>,
        dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] vfio/pci: Remove console drivers

Hi Alex

Am 06.06.22 um 19:53 schrieb Alex Williamson:
> Console drivers can create conflicts with PCI resources resulting in
> userspace getting mmap failures to memory BARs.  This is especially evident
> when trying to re-use the system primary console for userspace drivers.
> Attempt to remove all nature of conflicting drivers as part of our VGA
> initialization.

First a dumb question about your use case.  You want to assign a PCI 
graphics card to a virtual machine and need to remove the generic driver 
from the framebuffer?

> 
> Reported-by: Laszlo Ersek <lersek@...hat.com>
> Tested-by: Laszlo Ersek <lersek@...hat.com>
> Suggested-by: Gerd Hoffmann <kraxel@...hat.com>
> Signed-off-by: Alex Williamson <alex.williamson@...hat.com>
> ---
>   drivers/vfio/pci/vfio_pci_core.c |   17 +++++++++++++++++
>   1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
> index a0d69ddaf90d..e0cbcbc2aee1 100644
> --- a/drivers/vfio/pci/vfio_pci_core.c
> +++ b/drivers/vfio/pci/vfio_pci_core.c
> @@ -13,6 +13,7 @@
>   #include <linux/device.h>
>   #include <linux/eventfd.h>
>   #include <linux/file.h>
> +#include <linux/fb.h>
>   #include <linux/interrupt.h>
>   #include <linux/iommu.h>
>   #include <linux/module.h>
> @@ -29,6 +30,8 @@
>   
>   #include <linux/vfio_pci_core.h>
>   
> +#include <drm/drm_aperture.h>
> +
>   #define DRIVER_AUTHOR   "Alex Williamson <alex.williamson@...hat.com>"
>   #define DRIVER_DESC "core driver for VFIO based PCI devices"
>   
> @@ -1793,6 +1796,20 @@ static int vfio_pci_vga_init(struct vfio_pci_core_device *vdev)
>   	if (!vfio_pci_is_vga(pdev))
>   		return 0;
>   
> +#if IS_REACHABLE(CONFIG_DRM)
> +	drm_aperture_detach_platform_drivers(pdev);
> +#endif
> +
> +#if IS_REACHABLE(CONFIG_FB)
> +	ret = remove_conflicting_pci_framebuffers(pdev, vdev->vdev.ops->name);
> +	if (ret)
> +		return ret;
> +#endif
> +
> +	ret = vga_remove_vgacon(pdev);
> +	if (ret)
> +		return ret;
> +

You shouldn't have to copy any of the implementation of the aperture 
helpers.

If you call drm_aperture_remove_conflicting_pci_framebuffers() it should 
work correctly. The only reason why it requires a DRM driver structure 
as second argument is for the driver's name. [1] And that name is only 
used for printing an info message. [2]

The plan forward would be to drop patch 1 entirely.

For patch 2, the most trivial workaround is to instanciate struct 
drm_driver here and set the name field to 'vdev->vdev.ops->name'. In the 
longer term, the aperture helpers will be moved out of DRM and into a 
more prominent location. That workaround will be cleaned up then.

Alternatively, drm_aperture_remove_conflicting_pci_framebuffers() could 
be changed to accept the name string as second argument, but that's 
quite a bit of churn within the DRM code.

Best regards
Thomas

[1] 
https://elixir.bootlin.com/linux/v5.18.2/source/drivers/gpu/drm/drm_aperture.c#L347
[2] 
https://elixir.bootlin.com/linux/v5.18.2/source/drivers/video/fbdev/core/fbmem.c#L1570


>   	ret = vga_client_register(pdev, vfio_pci_set_decode);
>   	if (ret)
>   		return ret;
> 
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

Download attachment "OpenPGP_signature" of type "application/pgp-signature" (841 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ