]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/5.1.5/fbdev-efifb-ignore-framebuffer-memmap-entries-that-lack-any-memory-types.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 5.1.5 / fbdev-efifb-ignore-framebuffer-memmap-entries-that-lack-any-memory-types.patch
CommitLineData
6be6d5d0
GKH
1From f8585539df0a1527c78b5d760665c89fe1c105a9 Mon Sep 17 00:00:00 2001
2From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
3Date: Thu, 16 May 2019 23:31:59 +0200
4Subject: fbdev/efifb: Ignore framebuffer memmap entries that lack any memory types
5
6From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
7
8commit f8585539df0a1527c78b5d760665c89fe1c105a9 upstream.
9
10The following commit:
11
12 38ac0287b7f4 ("fbdev/efifb: Honour UEFI memory map attributes when mapping the FB")
13
14updated the EFI framebuffer code to use memory mappings for the linear
15framebuffer that are permitted by the memory attributes described by the
16EFI memory map for the particular region, if the framebuffer happens to
17be covered by the EFI memory map (which is typically only the case for
18framebuffers in shared memory). This is required since non-x86 systems
19may require cacheable attributes for memory mappings that are shared
20with other masters (such as GPUs), and this information cannot be
21described by the Graphics Output Protocol (GOP) EFI protocol itself,
22and so we rely on the EFI memory map for this.
23
24As reported by James, this breaks some x86 systems:
25
26 [ 1.173368] efifb: probing for efifb
27 [ 1.173386] efifb: abort, cannot remap video memory 0x1d5000 @ 0xcf800000
28 [ 1.173395] Trying to free nonexistent resource <00000000cf800000-00000000cf9d4bff>
29 [ 1.173413] efi-framebuffer: probe of efi-framebuffer.0 failed with error -5
30
31The problem turns out to be that the memory map entry that describes the
32framebuffer has no memory attributes listed at all, and so we end up with
33a mem_flags value of 0x0.
34
35So work around this by ensuring that the memory map entry's attribute field
36has a sane value before using it to mask the set of usable attributes.
37
38Reported-by: James Hilliard <james.hilliard1@gmail.com>
39Tested-by: James Hilliard <james.hilliard1@gmail.com>
40Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
41Cc: <stable@vger.kernel.org> # v4.19+
42Cc: Borislav Petkov <bp@alien8.de>
43Cc: James Morse <james.morse@arm.com>
44Cc: Linus Torvalds <torvalds@linux-foundation.org>
45Cc: Matt Fleming <matt@codeblueprint.co.uk>
46Cc: Peter Jones <pjones@redhat.com>
47Cc: Peter Zijlstra <peterz@infradead.org>
48Cc: Thomas Gleixner <tglx@linutronix.de>
49Cc: linux-efi@vger.kernel.org
50Fixes: 38ac0287b7f4 ("fbdev/efifb: Honour UEFI memory map attributes when ...")
51Link: http://lkml.kernel.org/r/20190516213159.3530-2-ard.biesheuvel@linaro.org
52Signed-off-by: Ingo Molnar <mingo@kernel.org>
53Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
54
55---
56 drivers/video/fbdev/efifb.c | 8 ++++++--
57 1 file changed, 6 insertions(+), 2 deletions(-)
58
59--- a/drivers/video/fbdev/efifb.c
60+++ b/drivers/video/fbdev/efifb.c
61@@ -476,8 +476,12 @@ static int efifb_probe(struct platform_d
62 * If the UEFI memory map covers the efifb region, we may only
63 * remap it using the attributes the memory map prescribes.
64 */
65- mem_flags |= EFI_MEMORY_WT | EFI_MEMORY_WB;
66- mem_flags &= md.attribute;
67+ md.attribute &= EFI_MEMORY_UC | EFI_MEMORY_WC |
68+ EFI_MEMORY_WT | EFI_MEMORY_WB;
69+ if (md.attribute) {
70+ mem_flags |= EFI_MEMORY_WT | EFI_MEMORY_WB;
71+ mem_flags &= md.attribute;
72+ }
73 }
74 if (mem_flags & EFI_MEMORY_WC)
75 info->screen_base = ioremap_wc(efifb_fix.smem_start,