[Devel] [PATCH RHEL7 COMMIT] ms/x86/efi-bgrt: Replace early_memremap() with memremap()

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jul 2 13:20:05 MSK 2018


The commit is pushed to "branch-rh7-3.10.0-862.3.2.vz7.61.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.3.2.vz7.61.7
------>
commit 96281c58371f0079e5d046411abe31643a4d0b62
Author: Matt Fleming <matt at codeblueprint.co.uk>
Date:   Mon Jul 2 13:20:05 2018 +0300

    ms/x86/efi-bgrt: Replace early_memremap() with memremap()
    
    Môshe reported the following warning triggered on his machine since
    commit 50a0cb565246 ("x86/efi-bgrt: Fix kernel panic when mapping BGRT
    data"),
    
      [    0.026936] ------------[ cut here ]------------
      [    0.026941] WARNING: CPU: 0 PID: 0 at mm/early_ioremap.c:137 __early_ioremap+0x102/0x1bb()
      [    0.026941] Modules linked in:
      [    0.026944] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.4.0-rc1 #2
      [    0.026945] Hardware name: Dell Inc. XPS 13 9343/09K8G1, BIOS A05 07/14/2015
      [    0.026946]  0000000000000000 900f03d5a116524d ffffffff81c03e60 ffffffff813a3fff
      [    0.026948]  0000000000000000 ffffffff81c03e98 ffffffff810a0852 00000000d7b76000
      [    0.026949]  0000000000000000 0000000000000001 0000000000000001 000000000000017c
      [    0.026951] Call Trace:
      [    0.026955]  [<ffffffff813a3fff>] dump_stack+0x44/0x55
      [    0.026958]  [<ffffffff810a0852>] warn_slowpath_common+0x82/0xc0
      [    0.026959]  [<ffffffff810a099a>] warn_slowpath_null+0x1a/0x20
      [    0.026961]  [<ffffffff81d8c395>] __early_ioremap+0x102/0x1bb
      [    0.026962]  [<ffffffff81d8c602>] early_memremap+0x13/0x15
      [    0.026964]  [<ffffffff81d78361>] efi_bgrt_init+0x162/0x1ad
      [    0.026966]  [<ffffffff81d778ec>] efi_late_init+0x9/0xb
      [    0.026968]  [<ffffffff81d58ff5>] start_kernel+0x46f/0x49f
      [    0.026970]  [<ffffffff81d58120>] ? early_idt_handler_array+0x120/0x120
      [    0.026972]  [<ffffffff81d58339>] x86_64_start_reservations+0x2a/0x2c
      [    0.026974]  [<ffffffff81d58485>] x86_64_start_kernel+0x14a/0x16d
      [    0.026977] ---[ end trace f9b3812eb8e24c58 ]---
      [    0.026978] efi_bgrt: Ignoring BGRT: failed to map image memory
    
    early_memremap() has an upper limit on the size of mapping it can
    handle which is ~200KB. Clearly the BGRT image on Môshe's machine is
    much larger than that.
    
    There's actually no reason to restrict ourselves to using the early_*
    version of memremap() - the ACPI BGRT driver is invoked late enough in
    boot that we can use the standard version, with the benefit that the
    late version allows mappings of arbitrary size.
    
    Reported-by: Môshe van der Sterre <me at moshe.nl>
    Tested-by: Môshe van der Sterre <me at moshe.nl>
    Signed-off-by: Matt Fleming <matt at codeblueprint.co.uk>
    Cc: Josh Triplett <josh at joshtriplett.org>
    Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya at intel.com>
    Cc: Borislav Petkov <bp at suse.de>
    Link: http://lkml.kernel.org/r/1450707172-12561-1-git-send-email-matt@codeblueprint.co.uk
    Signed-off-by: Thomas Gleixner <tglx at linutronix.de>
    
    https://jira.sw.ru/browse/PSBM-85888
    (cherry picked from commit e2c90dd7e11e3025b46719a79fb4bb1e7a5cef9f)
    Signed-off-by: Jan Dakinevich <jan.dakinevich at virtuozzo.com>
    
    Note: original (ms) patch substitutes early_memremap() with memremap(), while
    the current patch does ioremap() -> memremap() substitution. This is because
    RedHat changes early_memremap() to ioremap() in these places.
---
 arch/x86/platform/efi/efi-bgrt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/x86/platform/efi/efi-bgrt.c b/arch/x86/platform/efi/efi-bgrt.c
index 9fbcf9ba37b5..3e5292b386a4 100644
--- a/arch/x86/platform/efi/efi-bgrt.c
+++ b/arch/x86/platform/efi/efi-bgrt.c
@@ -15,6 +15,7 @@
 #include <linux/acpi.h>
 #include <linux/efi.h>
 #include <linux/efi-bgrt.h>
+#include <linux/io.h>
 
 struct acpi_table_bgrt *bgrt_tab;
 void *__initdata bgrt_image;
@@ -46,21 +47,21 @@ void __init efi_bgrt_init(void)
 	if (bgrt_tab->image_type != 0 || !bgrt_tab->image_address)
 		return;
 
-	image = ioremap(bgrt_tab->image_address, sizeof(bmp_header));
+	image = memremap(bgrt_tab->image_address, sizeof(bmp_header), MEMREMAP_WB);
 	if (!image) {
 		pr_err("Ignoring BGRT: failed to map image header memory\n");
 		return;
 	}
 
 	memcpy(&bmp_header, image, sizeof(bmp_header));
-	iounmap(image);
+	memunmap(image);
 	bgrt_image_size = bmp_header.size;
 
 	bgrt_image = kmalloc(bgrt_image_size, GFP_KERNEL);
 	if (!bgrt_image)
 		return;
 
-	image = ioremap(bgrt_tab->image_address, bmp_header.size);
+	image = memremap(bgrt_tab->image_address, bmp_header.size, MEMREMAP_WB);
 	if (!image) {
 		pr_err("Ignoring BGRT: failed to map image memory\n");
 		kfree(bgrt_image);
@@ -69,5 +70,5 @@ void __init efi_bgrt_init(void)
 	}
 
 	memcpy(bgrt_image, image, bgrt_image_size);
-	iounmap(image);
+	memunmap(image);
 }


More information about the Devel mailing list