From: David Herrmann <dh.herrmann@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Matt Fleming <matt.fleming@intel.com>,
Ingo Molnar <mingo@kernel.org>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>, Tom Gundersen <teg@jklm.no>,
David Herrmann <dh.herrmann@gmail.com>
Subject: [PATCH 1/2] x86/sysfb: add support for 64bit EFI lfb_base
Date: Tue, 15 Nov 2016 13:01:57 +0100 [thread overview]
Message-ID: <20161115120158.15388-2-dh.herrmann@gmail.com> (raw)
In-Reply-To: <20161115120158.15388-1-dh.herrmann@gmail.com>
The screen_info object was extended to support 64bit lfb_base addresses
in:
commit ae2ee627dc87a70910de91b791b3cd0e9c6facdd
Author: Matt Fleming <matt.fleming@intel.com>
Date: Tue Aug 25 16:32:55 2015 +0100
efifb: Add support for 64-bit frame buffer addresses
However, the x86 simple-framebuffer setup code never made use of it. Fix
it to properly assemble and verify the lfb_base before advertising
simple-framebuffer devices.
In particular, this means if VIDEO_CAPABILITY_64BIT_BASE is set, the
screen_info->ext_lfb_base field will contain the upper 32bit of the
actual lfb_base. Make sure the address is not 0 (i.e., unset), as well as
does not overflow the physical address type.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
arch/x86/kernel/sysfb_simplefb.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/sysfb_simplefb.c b/arch/x86/kernel/sysfb_simplefb.c
index 764a29f..35b8641 100644
--- a/arch/x86/kernel/sysfb_simplefb.c
+++ b/arch/x86/kernel/sysfb_simplefb.c
@@ -67,6 +67,20 @@ __init int create_simplefb(const struct screen_info *si,
struct platform_device *pd;
struct resource res;
unsigned long len;
+ u64 base;
+
+ /*
+ * 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 it may contain the whole VMEM instead of only
* the part that is occupied by the framebuffer */
@@ -81,8 +95,8 @@ __init int create_simplefb(const struct screen_info *si,
memset(&res, 0, sizeof(res));
res.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
res.name = simplefb_resname;
- res.start = si->lfb_base;
- res.end = si->lfb_base + len - 1;
+ res.start = base;
+ res.end = res.start + len - 1;
if (res.end <= res.start)
return -EINVAL;
--
2.10.2
next prev parent reply other threads:[~2016-11-15 12:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-15 12:01 [PATCH 0/2] x86 Simplefb Fixes David Herrmann
2016-11-15 12:01 ` David Herrmann [this message]
2016-11-15 12:08 ` [PATCH 1/2] x86/sysfb: add support for 64bit EFI lfb_base Tom Gundersen
2016-11-16 12:07 ` [tip:x86/urgent] x86/sysfb: Add " tip-bot for David Herrmann
2016-11-15 12:01 ` [PATCH 2/2] x86/sysfb: fix lfb_size calculation David Herrmann
2016-11-15 12:13 ` Tom Gundersen
2016-11-16 12:07 ` [tip:x86/urgent] x86/sysfb: Fix " tip-bot for David Herrmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161115120158.15388-2-dh.herrmann@gmail.com \
--to=dh.herrmann@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.fleming@intel.com \
--cc=mingo@kernel.org \
--cc=teg@jklm.no \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).