]>
Commit | Line | Data |
---|---|---|
6be6d5d0 GKH |
1 | From f8585539df0a1527c78b5d760665c89fe1c105a9 Mon Sep 17 00:00:00 2001 |
2 | From: Ard Biesheuvel <ard.biesheuvel@linaro.org> | |
3 | Date: Thu, 16 May 2019 23:31:59 +0200 | |
4 | Subject: fbdev/efifb: Ignore framebuffer memmap entries that lack any memory types | |
5 | ||
6 | From: Ard Biesheuvel <ard.biesheuvel@linaro.org> | |
7 | ||
8 | commit f8585539df0a1527c78b5d760665c89fe1c105a9 upstream. | |
9 | ||
10 | The following commit: | |
11 | ||
12 | 38ac0287b7f4 ("fbdev/efifb: Honour UEFI memory map attributes when mapping the FB") | |
13 | ||
14 | updated the EFI framebuffer code to use memory mappings for the linear | |
15 | framebuffer that are permitted by the memory attributes described by the | |
16 | EFI memory map for the particular region, if the framebuffer happens to | |
17 | be covered by the EFI memory map (which is typically only the case for | |
18 | framebuffers in shared memory). This is required since non-x86 systems | |
19 | may require cacheable attributes for memory mappings that are shared | |
20 | with other masters (such as GPUs), and this information cannot be | |
21 | described by the Graphics Output Protocol (GOP) EFI protocol itself, | |
22 | and so we rely on the EFI memory map for this. | |
23 | ||
24 | As 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 | ||
31 | The problem turns out to be that the memory map entry that describes the | |
32 | framebuffer has no memory attributes listed at all, and so we end up with | |
33 | a mem_flags value of 0x0. | |
34 | ||
35 | So work around this by ensuring that the memory map entry's attribute field | |
36 | has a sane value before using it to mask the set of usable attributes. | |
37 | ||
38 | Reported-by: James Hilliard <james.hilliard1@gmail.com> | |
39 | Tested-by: James Hilliard <james.hilliard1@gmail.com> | |
40 | Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> | |
41 | Cc: <stable@vger.kernel.org> # v4.19+ | |
42 | Cc: Borislav Petkov <bp@alien8.de> | |
43 | Cc: James Morse <james.morse@arm.com> | |
44 | Cc: Linus Torvalds <torvalds@linux-foundation.org> | |
45 | Cc: Matt Fleming <matt@codeblueprint.co.uk> | |
46 | Cc: Peter Jones <pjones@redhat.com> | |
47 | Cc: Peter Zijlstra <peterz@infradead.org> | |
48 | Cc: Thomas Gleixner <tglx@linutronix.de> | |
49 | Cc: linux-efi@vger.kernel.org | |
50 | Fixes: 38ac0287b7f4 ("fbdev/efifb: Honour UEFI memory map attributes when ...") | |
51 | Link: http://lkml.kernel.org/r/20190516213159.3530-2-ard.biesheuvel@linaro.org | |
52 | Signed-off-by: Ingo Molnar <mingo@kernel.org> | |
53 | Signed-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, |