From patchwork Fri Sep 2 08:22:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 9310551 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C70FC60865 for ; Fri, 2 Sep 2016 08:23:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA2F72970C for ; Fri, 2 Sep 2016 08:23:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AECBA2970E; Fri, 2 Sep 2016 08:23:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CE4FD2970C for ; Fri, 2 Sep 2016 08:23:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CA0756EA35; Fri, 2 Sep 2016 08:23:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 457B96EA30 for ; Fri, 2 Sep 2016 08:23:18 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id w207so1850000wmw.0 for ; Fri, 02 Sep 2016 01:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yKmAGzDvON2ue54Kp4F4wEWvE9j0FEv3SbWpWkImZEo=; b=pAW1FQLKWo0ly1NtRdjJG+Me/kq7WqIcVZpXQudsgRzcdO920skr5HqpyvTfd5GAkW +dboTkjIKlu0xepJLj2xWK9t7uIpj/A7b+bDCLJu9taX3O+P+UH10aavDS69rZJekAAt C02R8dkDwPNv20oiSnttvjV6S7pZNdQKAsRRQHrFQA0B8x6OGPDo3nDl47pPXlKNtYaB 1DG/XugEnPcgh9TpxzC9momMSP0ydDmMd3ISqTOv5TE8pYmUEIO5AM+tU1zV4EgjmMT8 TmZ4a/fH0do0nCePfe6XCD3Bf3BfO52H4gsiZEIAzBnFoSKMq8kU+nx3eUXEWYDcgCPR ubjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yKmAGzDvON2ue54Kp4F4wEWvE9j0FEv3SbWpWkImZEo=; b=Uwev3nclwi04jw0nKCwbJviw0JGRzRGhtEP89WtSPsQcsOuFO7Uj2QexQ4JMknYEY3 FNHPB7xhbnQndzXPjLv1M72AIVMpLmicKphoblEsJhhwHfe+cALV8341DwfDl96wmhJv dTWpLM+Ktr31AcZ6qRzAAg/1NapZ+v1xwkaDsMS+Ln7HYVcS+mpZKvCzTJHss0ai/GXB /6R/k3IwMssUTaDPQAy/znFMYkAAZsm39nwNydnuLaQPOaPQlA828GBUGWz3Y7HIZ/K4 kVp48iymxZDlSqlhVKV6qfqbGw9+61QfnZyn3LPV2OhgUk4cIFRSGYtoL5I7R+sROsWa HDSg== X-Gm-Message-State: AE9vXwPeP0EeDmbNtua7we280lSJVS0weJV7+n3Hx03f2vjYL1/OVHvD/ZPYhEmo+rTtBw== X-Received: by 10.28.191.14 with SMTP id p14mr1914827wmf.39.1472804596754; Fri, 02 Sep 2016 01:23:16 -0700 (PDT) Received: from localhost.localdomain ([37.120.93.201]) by smtp.gmail.com with ESMTPSA id gg10sm9325662wjd.4.2016.09.02.01.23.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Sep 2016 01:23:15 -0700 (PDT) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [PATCH v5 1/7] x86/sysfb: add support for 64bit EFI lfb_base Date: Fri, 2 Sep 2016 10:22:39 +0200 Message-Id: <20160902082245.7119-2-dh.herrmann@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160902082245.7119-1-dh.herrmann@gmail.com> References: <20160902082245.7119-1-dh.herrmann@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The screen_info object was extended to support 64bit lfb_base addresses in: commit ae2ee627dc87a70910de91b791b3cd0e9c6facdd Author: Matt Fleming 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 Reviewed-by: Tom Gundersen --- 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;