|
@@ -66,13 +66,36 @@ __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;
|
|
|
|
+ u32 length;
|
|
|
|
|
|
- /* don't use lfb_size as it may contain the whole VMEM instead of only
|
|
|
|
- * the part that is occupied by the framebuffer */
|
|
|
|
- len = mode->height * mode->stride;
|
|
|
|
- len = PAGE_ALIGN(len);
|
|
|
|
- if (len > (u64)si->lfb_size << 16) {
|
|
|
|
|
|
+ /*
|
|
|
|
+ * If the 64BIT_BASE capability is set, ext_lfb_base will contain the
|
|
|
|
+ * upper half of the base address. Assemble the address, then make sure
|
|
|
|
+ * it is valid and we can actually access it.
|
|
|
|
+ */
|
|
|
|
+ base = si->lfb_base;
|
|
|
|
+ if (si->capabilities & VIDEO_CAPABILITY_64BIT_BASE)
|
|
|
|
+ base |= (u64)si->ext_lfb_base << 32;
|
|
|
|
+ if (!base || (u64)(resource_size_t)base != base) {
|
|
|
|
+ printk(KERN_DEBUG "sysfb: inaccessible VRAM base\n");
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * Don't use lfb_size as IORESOURCE size, since it may contain the
|
|
|
|
+ * entire VMEM, and thus require huge mappings. Use just the part we
|
|
|
|
+ * need, that is, the part where the framebuffer is located. But verify
|
|
|
|
+ * 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;
|
|
}
|
|
}
|
|
@@ -81,8 +104,8 @@ __init int create_simplefb(const struct screen_info *si,
|
|
memset(&res, 0, sizeof(res));
|
|
memset(&res, 0, sizeof(res));
|
|
res.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
|
|
res.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
|
|
res.name = simplefb_resname;
|
|
res.name = simplefb_resname;
|
|
- res.start = si->lfb_base;
|
|
|
|
- res.end = si->lfb_base + len - 1;
|
|
|
|
|
|
+ res.start = base;
|
|
|
|
+ res.end = res.start + length - 1;
|
|
if (res.end <= res.start)
|
|
if (res.end <= res.start)
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|