EFI fix for v5.2
Subsystems (3)
The following changes since commit a455eda33faafcaac1effb31d682765b14ef868c:
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal (2019-05-16 07:56:57 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git tags/efi-urgent
for you to fetch changes up to 7993a1d12c712a3e2cce8e334dd1a4ab8b93128e:
fbdev/efifb: ignore framebuffer memmap entries that lack any memory types (2019-05-16 18:25:41 +0200)
----------------------------------------------------------------
EFI fix for v5.2:
- ignore bogus EFI memory map attributes for EFIFB region
----------------------------------------------------------------
Ard Biesheuvel (1):
fbdev/efifb: ignore framebuffer memmap entries that lack any memory types
drivers/video/fbdev/efifb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
PATCH 1/1 fbdev/efifb: ignore framebuffer memmap entries that lack any memory types
Commit 38ac0287b7f4
("fbdev/efifb: Honour UEFI memory map attributes when mapping the FB")
updated the EFI framebuffer code to use memory mappings for the linear framebuffer that are permitted by the memory attributes described by the EFI memory map for the particular region, if the framebuffer happens to be covered by the EFI memory map (which is typically only the case for framebuffers in shared memory). This is required since non-X86 systems may require cacheable attributes for memory mappings that are shared with other masters (such as GPUs), and this information cannot be described by the Graphics Output Protocol (GOP) EFI protocol itself, and so we rely on the EFI memory map for this.
As reported by James, this breaks some x86 systems:
[ 1.173368] efifb: probing for efifb [ 1.173386] efifb: abort, cannot remap video memory 0x1d5000 @ 0xcf800000 [ 1.173395] Trying to free nonexistent resource <00000000cf800000-00000000cf9d4bff> [ 1.173413] efi-framebuffer: probe of efi-framebuffer.0 failed with error -5
The problem turns out to be that the memory map entry that describes the framebuffer has no memory attributes listed at all, and so we end up with a mem_flags value of 0x0.
So work around this by ensuring that the memory map entry's attribute field has a sane value before using it to mask the set of usable attributes.
--- drivers/video/fbdev/efifb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/video/fbdev/efifb.c +6 -2
@@ -477,8 +477,12 @@ static int efifb_probe(struct platform_device *dev)* If the UEFI memory map covers the efifb region, we may only * remap it using the attributes the memory map prescribes. */ - mem_flags |=EFI_MEMORY_WT |EFI_MEMORY_WB ; - mem_flags &= md.attribute; + md.attribute &=EFI_MEMORY_UC |EFI_MEMORY_WC | +EFI_MEMORY_WT |EFI_MEMORY_WB ; +if (md.attribute) { + mem_flags |=EFI_MEMORY_WT |EFI_MEMORY_WB ; + mem_flags &= md.attribute; + } }if (mem_flags &EFI_MEMORY_WC ) info->screen_base = ioremap_wc(efifb_fix.smem_start,
Signature · 1 line
2.20.1
tip-bot for Ard Biesheuvel
merge bot[tip:efi/urgent] fbdev/efifb: Ignore framebuffer memmap entries that lack any memory types
fbdev/efifb: Ignore framebuffer memmap entries that lack any memory types
Commit-ID: f8585539df0a1527c78b5d760665c89fe1c105a9 Gitweb: https://git.kernel.org/tip/f8585539df0a1527c78b5d760665c89fe1c105a9 Author: Ard Biesheuvel <[email protected]> AuthorDate: Thu, 16 May 2019 23:31:59 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 17 May 2019 11:07:42 +0200
fbdev/efifb: Ignore framebuffer memmap entries that lack any memory types
The following commit:
38ac0287b7f4 ("fbdev/efifb: Honour UEFI memory map attributes when mapping the FB")
updated the EFI framebuffer code to use memory mappings for the linear framebuffer that are permitted by the memory attributes described by the EFI memory map for the particular region, if the framebuffer happens to be covered by the EFI memory map (which is typically only the case for framebuffers in shared memory). This is required since non-x86 systems may require cacheable attributes for memory mappings that are shared with other masters (such as GPUs), and this information cannot be described by the Graphics Output Protocol (GOP) EFI protocol itself, and so we rely on the EFI memory map for this.
As reported by James, this breaks some x86 systems:
[ 1.173368] efifb: probing for efifb [ 1.173386] efifb: abort, cannot remap video memory 0x1d5000 @ 0xcf800000 [ 1.173395] Trying to free nonexistent resource <00000000cf800000-00000000cf9d4bff> [ 1.173413] efi-framebuffer: probe of efi-framebuffer.0 failed with error -5
The problem turns out to be that the memory map entry that describes the framebuffer has no memory attributes listed at all, and so we end up with a mem_flags value of 0x0.
So work around this by ensuring that the memory map entry's attribute field has a sane value before using it to mask the set of usable attributes.
--- drivers/video/fbdev/efifb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/video/fbdev/efifb.c +6 -2
@@ -477,8 +477,12 @@ static int efifb_probe(struct platform_device *dev)* If the UEFI memory map covers the efifb region, we may only * remap it using the attributes the memory map prescribes. */ - mem_flags |=EFI_MEMORY_WT |EFI_MEMORY_WB ; - mem_flags &= md.attribute; + md.attribute &=EFI_MEMORY_UC |EFI_MEMORY_WC | +EFI_MEMORY_WT |EFI_MEMORY_WB ; +if (md.attribute) { + mem_flags |=EFI_MEMORY_WT |EFI_MEMORY_WB ; + mem_flags &= md.attribute; + } }if (mem_flags &EFI_MEMORY_WC ) info->screen_base = ioremap_wc(efifb_fix.smem_start,