Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753137AbcKPMJU (ORCPT ); Wed, 16 Nov 2016 07:09:20 -0500 Received: from terminus.zytor.com ([198.137.202.10]:34988 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751802AbcKPMJS (ORCPT ); Wed, 16 Nov 2016 07:09:18 -0500 Date: Wed, 16 Nov 2016 04:07:09 -0800 From: tip-bot for David Herrmann Message-ID: Cc: hpa@zytor.com, mingo@kernel.org, peterz@infradead.org, matt.fleming@intel.com, teg@jklm.no, linux-kernel@vger.kernel.org, tglx@linutronix.de, dh.herrmann@gmail.com, torvalds@linux-foundation.org Reply-To: hpa@zytor.com, mingo@kernel.org, matt.fleming@intel.com, peterz@infradead.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, teg@jklm.no, torvalds@linux-foundation.org, dh.herrmann@gmail.com In-Reply-To: <20161115120158.15388-2-dh.herrmann@gmail.com> References: <20161115120158.15388-2-dh.herrmann@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/sysfb: Add support for 64bit EFI lfb_base Git-Commit-ID: 9164b4ceb7b492a77c7fe770a4b9d1375c9cd45a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2730 Lines: 71 Commit-ID: 9164b4ceb7b492a77c7fe770a4b9d1375c9cd45a Gitweb: http://git.kernel.org/tip/9164b4ceb7b492a77c7fe770a4b9d1375c9cd45a Author: David Herrmann AuthorDate: Tue, 15 Nov 2016 13:01:57 +0100 Committer: Ingo Molnar CommitDate: Wed, 16 Nov 2016 09:38:22 +0100 x86/sysfb: Add support for 64bit EFI lfb_base The screen_info object was extended to support 64-bit lfb_base addresses in: ae2ee627dc87 ("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 Acked-by: Thomas Gleixner Cc: Linus Torvalds Cc: Matt Fleming Cc: Peter Zijlstra Cc: Tom Gundersen Link: http://lkml.kernel.org/r/20161115120158.15388-2-dh.herrmann@gmail.com Signed-off-by: Ingo Molnar --- 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;