From patchwork Fri Jun 15 10:48:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 138669 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp678325lji; Fri, 15 Jun 2018 03:48:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI03dj+HQhtlPTHrJhfXvVQhAHTMTqcSeAYPv3wZQT6G69lwR/S/t5cgIIoLcVWjuer4eWp X-Received: by 2002:a17:902:2f84:: with SMTP id t4-v6mr1452613plb.24.1529059708753; Fri, 15 Jun 2018 03:48:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529059708; cv=none; d=google.com; s=arc-20160816; b=dCylSNkYAvARz930HUth7ythEVa+RxQPoyUE2CqGG2EUvpN7emxxAOuP0c7rmAeH6Q bvZfKaGEuT86hQc1x30m8dOOqT3Lw34hB7718h2smFKYZorUQU2DaCS4qAOfPdwghAyB uOr5okINObNHx0JYQOdxTkM7MU6elMKTx/SsmNCNsSY0VoLvPANSwzlAuOg3vPXVWE8W HHqLyEFHfxesQX8OhI+uZcb/bRCMSAA/u2Kyz9bWPMc2nkOmLZTiNAOJlo6BbUvE4uzG qN5cMbftzl0W5sSyC662BcJVvrFROZOmCHWqbrwhfbE2OdIzxr6wxLJy8ixRHbfZdj/F nEpw== 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=9288kZXrtrpdgykxekSKaXamAxLBJxcMOlMMQ/XhKNo=; b=NpDlyvS0rxbVk2MNvc2ZRu0B/AaE8w+nfemEYFT3GhAKAzHYxGllOnFYod1a0A1V7d 68X9Q24dP9GT8kNlD/KAwftJlMRqr3+4QZqG6VpR8Pi8FdppVwWlt3AL0DO4qZ+z0l8a 64PXXTBOzrLaNrYbCXXeU9LwCK+NfF+F308VTdAY8pJdqemMhj1m38+NU7HwOlryRTV7 u3BUDnWPw+swbUxyIcRhjPmgfHp2zVDMNg0H0966CnD1kwwHR/L7CRfhwhrLZziUDY7P 8PP+b7TkAWFUuP1F8ORCM+RmIKqZK3n/AWaTz6/3Ej7ogIU8+KDQEa7oIbltwLMzFhqD IL0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UTu5pkts; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-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 m12-v6si7693135pll.461.2018.06.15.03.48.28; Fri, 15 Jun 2018 03:48:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-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=UTu5pkts; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-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 S965650AbeFOKs2 (ORCPT + 2 others); Fri, 15 Jun 2018 06:48:28 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35282 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965590AbeFOKs1 (ORCPT ); Fri, 15 Jun 2018 06:48:27 -0400 Received: by mail-wm0-f67.google.com with SMTP id j15-v6so3102423wme.0 for ; Fri, 15 Jun 2018 03:48:26 -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=BHhUxkxl1ZsxG3tQPx8viBrXAf9Z3cQcqB/rSx04Qy4=; b=UTu5pktsLxp1Ac2eUNjqbPEzkjk0H2yPp3mmSmWEiERwD0Yy5Z6O5iiXsvef+uJ+N9 E9Bpj1qj66d+d8UFo/j/CzQZzwjtifnB2WuiihjvWaAFh++BYDrxOhbviUlYkgfOLI6L TdpLVjqz8S1u0NlDfH00gT4K90ss4OnOoLQpk= 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=BHhUxkxl1ZsxG3tQPx8viBrXAf9Z3cQcqB/rSx04Qy4=; b=GZDtr1uUNjcZ28a0I4D1omR9atWYNV3uy0xWUux17L3AOl9HBE+kecL6h/b/zSExpd TMxV36YP5IQvl3r5exopHlf6B1f5X4+86Ukqd4dBtgJ0Fj0h6N6sK0N6D01gkAmPS8iZ txiyqYh6wH0Q5uHD6Ag6RFV7CgxhMrcgRUAH1idm8CHqFMREiHHxIg6Z+Oz8OBe1gNvs Kb15h2j1VkC1UY6I7NsSENOxvA5vDVhhB/z13tz1I+EYCzuv1haR3YTXiKz9fuPhMaFD 9PKQMozV7SyLcJXlO+4AT1D8P1mD9g6a+G5qmBaA5IIqR5dv2bqnYXnuuDVqag/0XQzE royQ== X-Gm-Message-State: APt69E2D9eHpW6r0T9zUyPtlnFj2fbu4lBbSP5EqShB1X7wGrHVHTwQ9 BOOmkDKXRqQhkD3FK7UjR0WZGlMy10E= X-Received: by 2002:a1c:40d4:: with SMTP id n203-v6mr834298wma.101.1529059705948; Fri, 15 Jun 2018 03:48:25 -0700 (PDT) Received: from dogfood.home ([2a01:cb1d:112:6f00:3805:d7d2:48be:b40a]) by smtp.gmail.com with ESMTPSA id a9-v6sm1393914wmh.38.2018.06.15.03.48.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jun 2018 03:48:25 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: lersek@redhat.com, pjones@redhat.com, kraxel@redhat.com, Ard Biesheuvel , Peter Jones Subject: [PATCH 1/2] efi: drop type and attribute checks in efi_mem_desc_lookup() Date: Fri, 15 Jun 2018 12:48:17 +0200 Message-Id: <20180615104818.23013-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180615104818.23013-1-ard.biesheuvel@linaro.org> References: <20180615104818.23013-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@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 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-efi" 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 15 10:48:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 138670 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp678336lji; Fri, 15 Jun 2018 03:48:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIga/TM05ZVTg+49JM56vfKXC725rV0ukD2teqfjFI2oj4UXQvJ7uRszEn3+zPayJWpUnWJ X-Received: by 2002:a17:902:b590:: with SMTP id a16-v6mr1436812pls.225.1529059709921; Fri, 15 Jun 2018 03:48:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529059709; cv=none; d=google.com; s=arc-20160816; b=GGht3aak9M/Ps4BIeb3/OW5vqdO4EqhwsjJEuGV5UKl5cFCMkocDoXly+nt44+ropE lfl6wtaf/hMpipGiO9kum1GY5hMCPRjC98fnEV9hXbIOIxQDbVLfPwxaEVioJHTsUWxc xx6HYeR3mQDXtgN7Ffw0fF8ALpMUwy6LZEB6vD6PtIKnSVjbPHX/3zFVOqtqm3Vat+Mc N4F1VfJ1Bh26rpEgMYz+FgPTy9t3Ypa81tTMtP44xFcw5B0kp06zo5vBy3iAa9NwA8uw ZMG/cV6Gx2VDRqaqs+hkOKE6klZiUbVVaCITnpoK7GVDPSSqb8DBV5fOABF7gMVBpzy0 sQdg== 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=1SdQvxHegKb61jUCxAbFzgSxIklJHsiu2JVHK+f79Zs=; b=LBuKOmqOcEeGR2as9CYMMTgiQSBQcOLeorgc01Vv6on90IZROO/x4vYbk3viCnduLl XlQMRjs8XwDzg4IWzp+JKMI/nmsCdVMQJH0v9mlWUoLIeDdE6nlVU7ZZNXdAq70mMcl9 tRAt78wctaD77J4P/Z5luEpGixJYfvaKmJAQhW5FWPjcbLA5YQt88IgXzqG612PTtM6F uE0EIZGS6eC0ooNZDoCrCXKn9LvpWednWdw9YJNuqv4ofaI0hG/ZZAlGBha0EQXo1LBD dGI4ijJw0Rw7tpvUZncN+JQTWS89rGwTlkf/KqKoSO0XgUL6sCvKfR7m9B1K5t6qMrIs bW1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=iLGdoZ25; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-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 m12-v6si7693135pll.461.2018.06.15.03.48.29; Fri, 15 Jun 2018 03:48:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-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=iLGdoZ25; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-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 S965590AbeFOKs3 (ORCPT + 2 others); Fri, 15 Jun 2018 06:48:29 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:45103 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965639AbeFOKs2 (ORCPT ); Fri, 15 Jun 2018 06:48:28 -0400 Received: by mail-wr0-f196.google.com with SMTP id o12-v6so9448347wrm.12 for ; Fri, 15 Jun 2018 03:48:28 -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=cPKfVWxcLbqfV3prDZofsBTbyU28R8bjcFrDo3puhRg=; b=iLGdoZ25xdxSv0AuZWNEnxo4lQpfp+JENR0CREQx3p5IFbMzM8Hp464TAszaFttI3+ mwrbIrGNNFRpEiZmwrWwbRCOUF0j+mItnfTHQxvibKP4GpcJko0GS0IBvK6sc1lMFGAd Gjd2EsvklRZEWSsCsevnY8aKmWkRK1qow+ktk= 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=cPKfVWxcLbqfV3prDZofsBTbyU28R8bjcFrDo3puhRg=; b=Qa/GaGGKLtjXU2hjDMNogsWQupdqmMk35Hz6WAyZkGiOnjLo9eCUNROO04g+HtIzYa zIbx2ypvnpT+4/1p6BHHdHukiemn9zyTIxJuTL9BXoI8SQ9zDpC7+hHAxCA4DnwccKeS /01CPEFjR1yubmOcm7QPJMwkDp7VFt/qn0VNTvamIhiW/20ZfY+cy1a1Unir7SipAQuX BkeUQ/uGjlwFpsm43rDCOn1BbGZ0/3D2rM2tUoAD8yjPnFLTWGs+yi9g6p+S3Wks3V/j nselaqXK7ijriQkjtntXwNdAcKX/ABVGCqZFBk3fw+gHDEv8xfpqGsVuFIRYScj5onZz HzbQ== X-Gm-Message-State: APt69E181zZhpm7ychfGZB4mL2U9BFrRLcxc5UzZ4yogQvv7+XgqXJGR 6oz/RpHsQia73GGXzguqmIfpGlDe86s= X-Received: by 2002:adf:9487:: with SMTP id 7-v6mr1263438wrr.82.1529059707153; Fri, 15 Jun 2018 03:48:27 -0700 (PDT) Received: from dogfood.home ([2a01:cb1d:112:6f00:3805:d7d2:48be:b40a]) by smtp.gmail.com with ESMTPSA id a9-v6sm1393914wmh.38.2018.06.15.03.48.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jun 2018 03:48:26 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: lersek@redhat.com, pjones@redhat.com, kraxel@redhat.com, Ard Biesheuvel Subject: [PATCH 2/2] fbdev/efifb: honour UEFI memory map attributes when mapping the fb Date: Fri, 15 Jun 2018 12:48:18 +0200 Message-Id: <20180615104818.23013-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180615104818.23013-1-ard.biesheuvel@linaro.org> References: <20180615104818.23013-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@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: Peter Jones 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-efi" 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: