Patch "efi/fb: Avoid reconfiguration of BAR that covers the framebuffer" has been added to the 4.9-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
efi/fb: Avoid reconfiguration of BAR that covers the framebuffer
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
efi-fb-avoid-reconfiguration-of-bar-that-covers-the-framebuffer.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
55d728a40d368ba80443be85c02e641fc9082a3fMon Sep 17 00:00:00 2001
From: Ard Biesheuvel <[email protected]>
Date: Tue, 4 Apr 2017 16:27:44 +0100
Subject: efi/fb: Avoid reconfiguration of BAR that covers the framebuffer
From: Ard Biesheuvel <[email protected]>
commit 55d728a40d368ba80443be85c02e641fc9082a3f upstream.
On UEFI systems, the PCI subsystem is enumerated by the firmware, and if a graphical framebuffer is exposed via a PCI device, its base address and size are exposed to the OS via the Graphics Output Protocol (GOP).
On arm64 PCI systems, the entire PCI hierarchy is reconfigured from scratch at boot. This may result in the GOP framebuffer address to become stale, if the BAR covering the framebuffer is modified. This will cause the framebuffer to become unresponsive, and may in some cases result in unpredictable behavior if the range is reassigned to another device.
So add a non-x86 quirk to the EFI fb driver to find the BAR associated with the GOP base address, and claim the BAR resource so that the PCI core will not move it.
--- drivers/video/fbdev/efifb.c | 66 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-)
drivers/video/fbdev/efifb.c +65 -1
@@ -10,6 +10,7 @@#include <linux/efi.h> #include <linux/errno.h> #include <linux/fb.h> +#include <linux/pci.h> #include <linux/platform_device.h> #include <linux/screen_info.h> #include <video/vga.h>
@@ -118,6 +119,8 @@ static inline bool fb_base_is_valid(voidreturn false; } +static bool pci_dev_disabled;/* FB base matches BAR of a disabled device */ +static int efifb_probe (struct platform_device *dev) {struct fb_info *info;
@@ -127,7 +130,7 @@ static int efifb_probe(struct platform_dunsigned int size_total;char *option =NULL ; -if (screen_info.orig_video_isVGA !=VIDEO_TYPE_EFI ) +if (screen_info.orig_video_isVGA !=VIDEO_TYPE_EFI || pci_dev_disabled)return -ENODEV ;if (fb_get_options ("efifb" , &option))
@@ -327,3 +330,64 @@ static struct platform_driver efifb_driv };builtin_platform_driver (efifb_driver); + +#if defined(CONFIG_PCI ) && !defined(CONFIG_X86 ) + +static bool pci_bar_found;/* did we find a BAR matching the efifb base? */ + +static void claim_efifb_bar (struct pci_dev *dev,int idx) +{ +u16 word; + + pci_bar_found = true; + +pci_read_config_word (dev,PCI_COMMAND , &word); +if (!(word &PCI_COMMAND_MEMORY )) { + pci_dev_disabled = true; +dev_err (&dev->dev, +"BAR %d: assigned to efifb but device is disabled!\n" , + idx); +return ; + } + +if (pci_claim_resource (dev, idx)) { + pci_dev_disabled = true; +dev_err (&dev->dev, +"BAR %d: failed to claim resource for efifb!\n" , idx); +return ; + } + +dev_info (&dev->dev,"BAR %d: assigned to efifb\n" , idx); +} + +static void efifb_fixup_resources (struct pci_dev *dev) +{ +u64 base = screen_info.lfb_base; +u64 size = screen_info.lfb_size; +int i; + +if (pci_bar_found || screen_info.orig_video_isVGA !=VIDEO_TYPE_EFI ) +return ; + +if (screen_info.capabilities &VIDEO_CAPABILITY_64BIT_BASE ) + base |= (u64 )screen_info.ext_lfb_base <<32 ; + +if (!base) +return ; + +for (i =0 ; i <PCI_STD_RESOURCE_END ; i++) { +struct resource *res = &dev->resource[i]; + +if (!(res->flags &IORESOURCE_MEM )) +continue ; + +if (res->start <= base && res->end >= base + size -1 ) { +claim_efifb_bar (dev, i); +break ; + } + } +} +DECLARE_PCI_FIXUP_CLASS_HEADER (PCI_ANY_ID ,PCI_ANY_ID ,PCI_BASE_CLASS_DISPLAY , +16 , efifb_fixup_resources); + +#endif
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/x86-efi-don-t-try-to-reserve-runtime-regions.patch queue-4.9/efi-libstub-skip-gop-with-pixel_blt_only-format.patch queue-4.9/efi-fb-avoid-reconfiguration-of-bar-that-covers-the-framebuffer.patch