Commit f96acec8 authored by David Herrmann's avatar David Herrmann Committed by Ingo Molnar

x86/sysfb: Fix lfb_size calculation

The screen_info.lfb_size field is shifted by 16 bits *only* in case of
VBE. This has historical reasons since VBE advertised it similarly.
However, in case of EFI framebuffers, the size is no longer shifted. Fix
the x86 simple-framebuffer setup code to use the correct size in the
non-VBE case.

While at it, avoid variable abbreviations and rename 'len' to 'length',
and use the correct types matching the screen_info definition.
Signed-off-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt.fleming@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tom Gundersen <teg@jklm.no>
Link: http://lkml.kernel.org/r/20161115120158.15388-3-dh.herrmann@gmail.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 9164b4ce
...@@ -66,8 +66,8 @@ __init int create_simplefb(const struct screen_info *si, ...@@ -66,8 +66,8 @@ __init int create_simplefb(const struct screen_info *si,
{ {
struct platform_device *pd; struct platform_device *pd;
struct resource res; struct resource res;
unsigned long len; u64 base, size;
u64 base; u32 length;
/* /*
* If the 64BIT_BASE capability is set, ext_lfb_base will contain the * If the 64BIT_BASE capability is set, ext_lfb_base will contain the
...@@ -82,11 +82,20 @@ __init int create_simplefb(const struct screen_info *si, ...@@ -82,11 +82,20 @@ __init int create_simplefb(const struct screen_info *si,
return -EINVAL; return -EINVAL;
} }
/* don't use lfb_size as it may contain the whole VMEM instead of only /*
* the part that is occupied by the framebuffer */ * Don't use lfb_size as IORESOURCE size, since it may contain the
len = mode->height * mode->stride; * entire VMEM, and thus require huge mappings. Use just the part we
len = PAGE_ALIGN(len); * need, that is, the part where the framebuffer is located. But verify
if (len > (u64)si->lfb_size << 16) { * that it does not exceed the advertised VMEM.
* Note that in case of VBE, the lfb_size is shifted by 16 bits for
* historical reasons.
*/
size = si->lfb_size;
if (si->orig_video_isVGA == VIDEO_TYPE_VLFB)
size <<= 16;
length = mode->height * mode->stride;
length = PAGE_ALIGN(length);
if (length > size) {
printk(KERN_WARNING "sysfb: VRAM smaller than advertised\n"); printk(KERN_WARNING "sysfb: VRAM smaller than advertised\n");
return -EINVAL; return -EINVAL;
} }
...@@ -96,7 +105,7 @@ __init int create_simplefb(const struct screen_info *si, ...@@ -96,7 +105,7 @@ __init int create_simplefb(const struct screen_info *si,
res.flags = IORESOURCE_MEM | IORESOURCE_BUSY; res.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
res.name = simplefb_resname; res.name = simplefb_resname;
res.start = base; res.start = base;
res.end = res.start + len - 1; res.end = res.start + length - 1;
if (res.end <= res.start) if (res.end <= res.start)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment