From patchwork Fri Jun 22 07:52:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 139576 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp566077lji; Fri, 22 Jun 2018 00:52:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK57u2+4NdHJz5KvHgIslTSWlbTsJ177KcJ8TYX04GJfyKQUjKYMpb1xmgXfJ09+zFs0FR0 X-Received: by 2002:a63:6dc3:: with SMTP id i186-v6mr467182pgc.316.1529653979260; Fri, 22 Jun 2018 00:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529653979; cv=none; d=google.com; s=arc-20160816; b=w9VKeqQrBchTO3mOls4TjRgD/NMOkWwMhKlupCE6XcUCvfBjzAL6OYar1hRcqSXt1W h3ZO5P1y81rd4GcP6gGWoBk0nPT/QCDjJKwEN+2O5zG20Pi6KIGs/qQbE/1nM+zCWKkN MI3qZRZ7VdojUgmWw9sn40VDHl3pfxhmcSrHXAOUdI7X1YyKuZlbmahuEc/tZu3Luzj0 LMyx9vxrUEro6570skvqioxkyQMGFXFhIGFLRtTzs1YQHnv7vhzoIqCeEaLDKFG1o/Q5 6H2cnamIUVF1+eGWSn9HbqFr0hCRGs9iQNwCW9DRzsrr5/WnjKqryespvUj6zdxyNawD FaLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Q2XuOri+JVM6ImVFtLbgQBKSDNTsDNy3BV6eRf4anZw=; b=EsqgVA2LZzJ5YZwhaHl8aYLs5YxOCVUQb0B0+TNlha+b+DmymYaVpgo9XC5pYRBrBU 9+N4Mc4wTy28vloAt3hWhYnwukdx7n6nKVMJN7hgw+m++KuJAiOCB/TjnN7NMmcGaZO1 nRZDUBgr56tnxz5jF2YhIzMYHoEefADjMF6Cf5LmV7eBKfKh/KebraAC5++fwKX4xETU Dsr0tOzdo8Ji9xN45XrUeEXaD33nj9zVzpbp5SVyspru5gizufshTzZrPJ+MTsuPxT8J JN7AdAxdWFKLADsv6/5/SDrTTH9icY8wK4ANKnb/jPGtUa2A+qcIPha0zSN0CgqM9S0p oesQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EjjEPdJt; spf=pass (google.com: best guess record for domain of linux-fbdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-fbdev-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k5-v6si5551493pgn.258.2018.06.22.00.52.59; Fri, 22 Jun 2018 00:52:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-fbdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EjjEPdJt; spf=pass (google.com: best guess record for domain of linux-fbdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-fbdev-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751170AbeFVHw6 (ORCPT + 1 other); Fri, 22 Jun 2018 03:52:58 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:36770 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751097AbeFVHw5 (ORCPT ); Fri, 22 Jun 2018 03:52:57 -0400 Received: by mail-wm0-f67.google.com with SMTP id v131-v6so1372214wma.1 for ; Fri, 22 Jun 2018 00:52:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5yqDQVXFHG9zNz/s7WheSQglr6r1NfrOVua9fkr0Jus=; b=EjjEPdJt/CaRindtzlMlN6Bd+5/nbUrzDUGt//7mWr2+zK7Xr0QbWsQkRe7KUbjmv5 DTPXaBYa1/VHmLFTs44pPtApU5PNugdGsBsmEkjm15zPfxBeEBWzrdkriRFenSvgeZpC eI9f7SxY8XVhb7/kSnD/4MWhtFxfJmqFG+Nqw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5yqDQVXFHG9zNz/s7WheSQglr6r1NfrOVua9fkr0Jus=; b=PFIJI2WUQKhZ+m5rCVSnnNmOWT4o3NkIFN3yk2123QZ7yyKOV96FDV2QI7Vl9p1aic UjsCjMqndR9Hu67p29zNJF6gcAEAtdLnJF0p9HU40mudR7Jthq7KVcWj9yLvHkO+VeXT 5gACrefjzMLioXDwmPyUQFsx0xL+72M37Z3Esux+iLFDv6NO4X5EJpB+UO793iBRzq8A FE8vLxuUckS8kviVCCahgDiF/jv8iCazF7uhZzu69TuzQeGCThzf+vlXjgp8qTt5jGSA DEzIHX6gaVPvDVb/38Xcb04+TWbwr8sMfH9KJ4FTlzr6WdTauTfJKh2vNRAvwo5cDHWj lAuw== X-Gm-Message-State: APt69E3kVpEbJxbKduW6WrGR4ja3Rrep/geyiIpLR4lS0HKoCEl3BI5H OpEoKoyROcYNc1x5kdyj47XIwA== X-Received: by 2002:a1c:110a:: with SMTP id 10-v6mr745825wmr.130.1529653976476; Fri, 22 Jun 2018 00:52:56 -0700 (PDT) Received: from dogfood.home ([2a01:cb1d:112:6f00:d0d9:3abb:8cc4:581c]) by smtp.gmail.com with ESMTPSA id s10-v6sm1593986wmb.12.2018.06.22.00.52.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jun 2018 00:52:55 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: lersek@redhat.com, Ard Biesheuvel , linux-fbdev@vger.kernel.org, Bartlomiej Zolnierkiewicz , Peter Jones Subject: [PATCH v2 1/2] efi: drop type and attribute checks in efi_mem_desc_lookup() Date: Fri, 22 Jun 2018 09:52:49 +0200 Message-Id: <20180622075250.14075-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180622075250.14075-1-ard.biesheuvel@linaro.org> References: <20180622075250.14075-1-ard.biesheuvel@linaro.org> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org The current implementation of efi_mem_desc_lookup() includes the following check on the memory descriptor it returns: if (!(md->attribute & EFI_MEMORY_RUNTIME) && md->type != EFI_BOOT_SERVICES_DATA && md->type != EFI_RUNTIME_SERVICES_DATA) { continue; } This means that only EfiBootServicesData or EfiRuntimeServicesData regions are considered, or any other region type provided that it has the EFI_MEMORY_RUNTIME attribute set. Given what the name of the function implies, and the fact that any physical address can be described in the UEFI memory map only a single time, it does not make sense to impose this condition in the body of the loop, but instead, should be imposed by the caller depending on the value that is returned to it. Two such callers exist at the moment: - The BGRT code when running on x86, via efi_mem_reserve() and efi_arch_mem_reserve(). In this case, the region is already known to be EfiBootServicesData, and so the check is redundant. - The ESRT handling code which introduced this function, which calls it both directly from efi_esrt_init() and again via efi_mem_reserve() and efi_arch_mem_reserve() [on x86]. So let's move this check into the callers instead. This preserves the current behavior both for BGRT and ESRT handling, and allows the lookup routine to be reused by other [upcoming] users that don't have this limitation. In the ESRT case, keep the entire condition, so that platforms that deviate from the UEFI spec and use something other than EfiBootServicesData for the ESRT table will keep working as before. For x86's efi_arch_mem_reserve() implementation, limit the type to EfiBootServicesData, since it is the only type the reservation code expects to operate on in the first place. While we're at it, drop the __init annotation so that drivers can use it as well. Cc: Peter Jones Tested-by: Laszlo Ersek Signed-off-by: Ard Biesheuvel --- arch/x86/platform/efi/quirks.c | 3 ++- drivers/firmware/efi/efi.c | 8 +------- drivers/firmware/efi/esrt.c | 5 ++++- 3 files changed, 7 insertions(+), 9 deletions(-) -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c index 36c1f8b9f7e0..4ee6f4980afe 100644 --- a/arch/x86/platform/efi/quirks.c +++ b/arch/x86/platform/efi/quirks.c @@ -249,7 +249,8 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size) int num_entries; void *new; - if (efi_mem_desc_lookup(addr, &md)) { + if (efi_mem_desc_lookup(addr, &md) || + md.type != EFI_BOOT_SERVICES_DATA) { pr_err("Failed to lookup EFI memory descriptor for %pa\n", &addr); return; } diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 232f4915223b..cbc25d1c40bb 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -388,7 +388,7 @@ subsys_initcall(efisubsys_init); * and if so, populate the supplied memory descriptor with the appropriate * data. */ -int __init efi_mem_desc_lookup(u64 phys_addr, efi_memory_desc_t *out_md) +int efi_mem_desc_lookup(u64 phys_addr, efi_memory_desc_t *out_md) { efi_memory_desc_t *md; @@ -406,12 +406,6 @@ int __init efi_mem_desc_lookup(u64 phys_addr, efi_memory_desc_t *out_md) u64 size; u64 end; - if (!(md->attribute & EFI_MEMORY_RUNTIME) && - md->type != EFI_BOOT_SERVICES_DATA && - md->type != EFI_RUNTIME_SERVICES_DATA) { - continue; - } - size = md->num_pages << EFI_PAGE_SHIFT; end = md->phys_addr + size; if (phys_addr >= md->phys_addr && phys_addr < end) { diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c index 1ab80e06e7c5..375a77c1c6e5 100644 --- a/drivers/firmware/efi/esrt.c +++ b/drivers/firmware/efi/esrt.c @@ -250,7 +250,10 @@ void __init efi_esrt_init(void) return; rc = efi_mem_desc_lookup(efi.esrt, &md); - if (rc < 0) { + if (rc < 0 || + (!(md.attribute & EFI_MEMORY_RUNTIME) && + md.type != EFI_BOOT_SERVICES_DATA && + md.type != EFI_RUNTIME_SERVICES_DATA)) { pr_warn("ESRT header is not in the memory map.\n"); return; } From patchwork Fri Jun 22 07:52:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 139577 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp566098lji; Fri, 22 Jun 2018 00:53:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL4cTwQFV2FevGzIvTwGHQf3T/7DkdTPDc6+6jf+3t/XW6EhkNXHNapkTvG+HhW2fBiKkNh X-Received: by 2002:a17:902:2702:: with SMTP id c2-v6mr524136plb.297.1529653980666; Fri, 22 Jun 2018 00:53:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529653980; cv=none; d=google.com; s=arc-20160816; b=oQ5RHCx1L2U8Wr75V0hR8SihxrhngOS2UDDOK0uUZw9o/wInN8v9/cwIh9jhvVumHp 2dgW9AhHWbO+QD0rfiSC8Vb3cMG+o2bsrHjihnVZe2STyrf2UCVIz0tLu/8a2O0W8ubk UU5PeFCQSuzKWdIJLy9YAMCq3HYJXmI4SzmGq13Jgv9hTnFkxzuwnuKU1o4dsoPqAHcn jYcVmWjHljcJ6IFU0BbXlBBB4PyLkAtd5JHXXvJ5ui1VDFVLZItCJLLNpDKd7xaHHgXa Or/o0IOm0/EgGT56g1B4pDvVK6lCEnf39DG1d2ieI7jQrqYmdfC9dlm+imG83Sxa5gcB wlxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=i8KutELxKug5fy98E51Jqd4KXgxdrZFalJzZgxgNupY=; b=VUoeWNwMGFoXRff/Xeh9Zrb9NWgtp+ddb+MvNVrcnI5VUE0c7ojqutMpvzkVICSR+q lyM+C18jB9246EZOc/eG02xAhNOQWK2miMzAUghwfa2OYuvTUFpua7mrtbY3NUDFmgPg 0hD4JWrkLqzmCpC70b9Ty73UYYT8Z2f6gdCJjRb/4RdO9onQACaQoNeEpas84ojzTQ+E I3OLgdxF1GBfjITny4h0clQlK6DWH33lcAsK++n2HfOEzHuV8XkC0YtffrYkQlZpftrZ TN3SQusasL69sVv8eG9tuvpBADeFbfJ4/7iaNZtvX1DN23rx1lHw1rOiGAw2wp9ZUGAc fXmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=MURbYCHb; spf=pass (google.com: best guess record for domain of linux-fbdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-fbdev-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k5-v6si5551493pgn.258.2018.06.22.00.53.00; Fri, 22 Jun 2018 00:53:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-fbdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=MURbYCHb; spf=pass (google.com: best guess record for domain of linux-fbdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-fbdev-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751187AbeFVHw7 (ORCPT + 1 other); Fri, 22 Jun 2018 03:52:59 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:41840 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751042AbeFVHw6 (ORCPT ); Fri, 22 Jun 2018 03:52:58 -0400 Received: by mail-wr0-f193.google.com with SMTP id h10-v6so5681116wrq.8 for ; Fri, 22 Jun 2018 00:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xg6I/N+SYXziOfRG5OVxZyF2OqOKsFg8pNoHQMqpD2E=; b=MURbYCHbVE0uJNogIXaZSfhvhVOIhHrMDQYu4SXU3uuoKVFmf2QMY5x/gzc69ssZTM yajhTcq4rSXLXtl34LjIMcRyuBB72NsqJNdTaAl7vkuP1Yp4cxebRyClCXn791J6lmAS y0T0ViOmYhE0JLYpd2a/7/4ewiEduirri5W+8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xg6I/N+SYXziOfRG5OVxZyF2OqOKsFg8pNoHQMqpD2E=; b=cW5i6uDqNL7pTYu/X0F8yNH+s/6UjQVX23twRmDFowPyQcYEG22DvoK4tLMvHP6nsu ohpBIRJHH+f5GeMx7L9w4JaIGBjABt0At5K70U+7h0wLtzzsOdi+Q2IBXoQf+0mXinlF SbqXW8SoSk/JAkk3ucCJsWwTjY4GVONc/P3MvmP5yCuEx/GlTslo5PBqg/Hh0tpGYB+2 JIjvo9yXkcU7i/zisbJhdxGDAFPiokc4GRNbntv41uERDiK8pJRu1VQGPkL3c1PnlyxQ mUtY8Ezo9DQrc2PVZEXdDR2BI23THB8qUsE9eFDmLk/H8Enrk5Mbp3S4rM4BhsPlvnv4 7mIw== X-Gm-Message-State: APt69E11k++KAh0L5AESCA8H75M4QFZRF+rCmH1RZ3xP1FBEbjyqZGvU NwvrWg/9ICrOclX72SbnkaHAOg== X-Received: by 2002:adf:88ca:: with SMTP id g10-v6mr571571wrg.62.1529653977514; Fri, 22 Jun 2018 00:52:57 -0700 (PDT) Received: from dogfood.home ([2a01:cb1d:112:6f00:d0d9:3abb:8cc4:581c]) by smtp.gmail.com with ESMTPSA id s10-v6sm1593986wmb.12.2018.06.22.00.52.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jun 2018 00:52:56 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: lersek@redhat.com, Ard Biesheuvel , linux-fbdev@vger.kernel.org, Bartlomiej Zolnierkiewicz , Peter Jones Subject: [PATCH v2 2/2] fbdev/efifb: honour UEFI memory map attributes when mapping the fb Date: Fri, 22 Jun 2018 09:52:50 +0200 Message-Id: <20180622075250.14075-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180622075250.14075-1-ard.biesheuvel@linaro.org> References: <20180622075250.14075-1-ard.biesheuvel@linaro.org> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org If the framebuffer address provided by the Graphics Output Protocol (GOP) is covered by the UEFI memory map, it will tell us which memory attributes are permitted when mapping this region. In some cases, (KVM guest on ARM), violating this will result in loss of coherency, which means that updates sent to the framebuffer by the guest will not be observeable by the host, and the emulated display simply does not work. So if the memory map contains such a description, take the attributes field into account, and add support for creating WT or WB mappings of the framebuffer region. Cc: linux-fbdev@vger.kernel.org Cc: Bartlomiej Zolnierkiewicz Cc: Peter Jones Tested-by: Laszlo Ersek Signed-off-by: Ard Biesheuvel --- drivers/video/fbdev/efifb.c | 52 ++++++++++++++++---- 1 file changed, 42 insertions(+), 10 deletions(-) -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c index 46a4484e3da7..d5e0a74e6124 100644 --- a/drivers/video/fbdev/efifb.c +++ b/drivers/video/fbdev/efifb.c @@ -20,7 +20,7 @@ #include /* For DRM_MODE_PANEL_ORIENTATION_* */ static bool request_mem_succeeded = false; -static bool nowc = false; +static u64 mem_flags = EFI_MEMORY_WC | EFI_MEMORY_UC; static struct fb_var_screeninfo efifb_defined = { .activate = FB_ACTIVATE_NOW, @@ -68,8 +68,12 @@ static int efifb_setcolreg(unsigned regno, unsigned red, unsigned green, static void efifb_destroy(struct fb_info *info) { - if (info->screen_base) - iounmap(info->screen_base); + if (info->screen_base) { + if (mem_flags & (EFI_MEMORY_WT | EFI_MEMORY_WB)) + memunmap(info->screen_base); + else + iounmap(info->screen_base); + } if (request_mem_succeeded) release_mem_region(info->apertures->ranges[0].base, info->apertures->ranges[0].size); @@ -104,7 +108,7 @@ static int efifb_setup(char *options) else if (!strncmp(this_opt, "width:", 6)) screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0); else if (!strcmp(this_opt, "nowc")) - nowc = true; + mem_flags &= ~EFI_MEMORY_WC; } } @@ -164,6 +168,8 @@ static int efifb_probe(struct platform_device *dev) unsigned int size_remap; unsigned int size_total; char *option = NULL; + efi_memory_desc_t md; + if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI || pci_dev_disabled) return -ENODEV; @@ -272,12 +278,35 @@ static int efifb_probe(struct platform_device *dev) info->apertures->ranges[0].base = efifb_fix.smem_start; info->apertures->ranges[0].size = size_remap; - if (nowc) - info->screen_base = ioremap(efifb_fix.smem_start, efifb_fix.smem_len); - else - info->screen_base = ioremap_wc(efifb_fix.smem_start, efifb_fix.smem_len); + if (!efi_mem_desc_lookup(efifb_fix.smem_start, &md)) { + if ((efifb_fix.smem_start + efifb_fix.smem_len) > + (md.phys_addr + (md.num_pages << EFI_PAGE_SHIFT))) { + pr_err("efifb: video memory @ 0x%lx spans multiple EFI memory regions\n", + efifb_fix.smem_start); + err = -EIO; + goto err_release_fb; + } + /* + * If the UEFI memory map covers the efifb region, we may only + * remap it using the attributes the memory map prescribes. + */ + mem_flags |= EFI_MEMORY_WT | EFI_MEMORY_WB; + mem_flags &= md.attribute; + } + if (mem_flags & EFI_MEMORY_WC) + info->screen_base = ioremap_wc(efifb_fix.smem_start, + efifb_fix.smem_len); + else if (mem_flags & EFI_MEMORY_UC) + info->screen_base = ioremap(efifb_fix.smem_start, + efifb_fix.smem_len); + else if (mem_flags & EFI_MEMORY_WT) + info->screen_base = memremap(efifb_fix.smem_start, + efifb_fix.smem_len, MEMREMAP_WT); + else if (mem_flags & EFI_MEMORY_WB) + info->screen_base = memremap(efifb_fix.smem_start, + efifb_fix.smem_len, MEMREMAP_WB); if (!info->screen_base) { - pr_err("efifb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n", + pr_err("efifb: abort, cannot remap video memory 0x%x @ 0x%lx\n", efifb_fix.smem_len, efifb_fix.smem_start); err = -EIO; goto err_release_fb; @@ -371,7 +400,10 @@ static int efifb_probe(struct platform_device *dev) err_groups: sysfs_remove_groups(&dev->dev.kobj, efifb_groups); err_unmap: - iounmap(info->screen_base); + if (mem_flags & (EFI_MEMORY_WT | EFI_MEMORY_WB)) + memunmap(info->screen_base); + else + iounmap(info->screen_base); err_release_fb: framebuffer_release(info); err_release_mem: