Skip to contentSkip to conversation

x86: selective remapping in parse_setup_data()

PATCH Superseded Linn Crosetto 5 participants 13 messages Aug 12, 2013 – Sep 6, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: selective remapping in parse_setup_data()

PCI devices may advertise a ROM size larger than early_memremap() is able to handle. If this occurs it leads to a NULL dereference in parse_setup_data(). Avoid this by remapping the data only when necessary.

---
 arch/x86/kernel/setup.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
arch/x86/kernel/setup.c +14 -5
index f8ec578..2063a49 100644
@@ -423,6 +423,17 @@ static void __init reserve_initrd(void)
 }
 #endif /* CONFIG_BLK_DEV_INITRD */
 
+static void __init remap_setup_data(u64 pa_data, u32 data_len,
+				    struct setup_data **data, u32 *map_len)
+{
+	if (data_len <= *map_len)
+		return;
+
+	early_iounmap(*data, *map_len);
+	*data = early_memremap(pa_data, data_len);
+	*map_len = data_len;
+}
+
 static void __init parse_setup_data(void)
 {
 	struct setup_data *data;
@@ -432,18 +443,16 @@ static void __init parse_setup_data(void)
 	while (pa_data) {
 		u32 data_len, map_len;
 
+		/* The data length may be too large for early remapping,
+		   remap the data only when needed. */
 		map_len = max(PAGE_SIZE - (pa_data & ~PAGE_MASK),
 			      (u64)sizeof(struct setup_data));
 		data = early_memremap(pa_data, map_len);
 		data_len = data->len + sizeof(struct setup_data);
-		if (data_len > map_len) {
-			early_iounmap(data, map_len);
-			data = early_memremap(pa_data, data_len);
-			map_len = data_len;
-		}
 
 		switch (data->type) {
 		case SETUP_E820_EXT:
+			remap_setup_data(pa_data, data_len, &data, &map_len);
 			parse_e820_ext(data);
 			break;
 		case SETUP_DTB:
Signature · 1 line
1.7.11.3
#1 lore raw
Quoted 6 lines · Linn Crosetto

PCI devices may advertise a ROM size larger than early_memremap() is able to handle. If this occurs it leads to a NULL dereference in parse_setup_data(). Avoid this by remapping the data only when necessary.

I think you need to clarify the various subcases (the code looks right, but the explanation needs to be improved.)

-hpa

#2 lore raw

PATCH v2 1/1 x86: selective remapping in parse_setup_data()

Type SETUP_PCI, added by setup_efi_pci(), may advertise a ROM size larger than early_memremap() is able to handle, which is currently limited to 256kB. If this occurs it leads to a NULL dereference in parse_setup_data().

To avoid this, first remap the setup_data header, and remap the data only for types actually parsed in parse_setup_data(). Type SETUP_PCI is handled later by pcibios_add_device(), when ioremap() is available.

---
v2: add more detail to the explanation as requested by hpa

---
 arch/x86/kernel/setup.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
arch/x86/kernel/setup.c +14 -5
index f8ec578..2063a49 100644
@@ -423,6 +423,17 @@ static void __init reserve_initrd(void)
 }
 #endif /* CONFIG_BLK_DEV_INITRD */
 
+static void __init remap_setup_data(u64 pa_data, u32 data_len,
+				    struct setup_data **data, u32 *map_len)
+{
+	if (data_len <= *map_len)
+		return;
+
+	early_iounmap(*data, *map_len);
+	*data = early_memremap(pa_data, data_len);
+	*map_len = data_len;
+}
+
 static void __init parse_setup_data(void)
 {
 	struct setup_data *data;
@@ -432,18 +443,16 @@ static void __init parse_setup_data(void)
 	while (pa_data) {
 		u32 data_len, map_len;
 
+		/* The data length may be too large for early remapping,
+		   remap the data only when needed. */
 		map_len = max(PAGE_SIZE - (pa_data & ~PAGE_MASK),
 			      (u64)sizeof(struct setup_data));
 		data = early_memremap(pa_data, map_len);
 		data_len = data->len + sizeof(struct setup_data);
-		if (data_len > map_len) {
-			early_iounmap(data, map_len);
-			data = early_memremap(pa_data, data_len);
-			map_len = data_len;
-		}
 
 		switch (data->type) {
 		case SETUP_E820_EXT:
+			remap_setup_data(pa_data, data_len, &data, &map_len);
 			parse_e820_ext(data);
 			break;
 		case SETUP_DTB:
Signature · 1 line
1.7.11.3
#3 lore raw
Quoted 50 lines · Linn Crosetto

Type SETUP_PCI, added by setup_efi_pci(), may advertise a ROM size larger than early_memremap() is able to handle, which is currently limited to 256kB. If this occurs it leads to a NULL dereference in parse_setup_data().

To avoid this, first remap the setup_data header, and remap the data only for types actually parsed in parse_setup_data(). Type SETUP_PCI is handled later by pcibios_add_device(), when ioremap() is available.

---
v2: add more detail to the explanation as requested by hpa

---
 arch/x86/kernel/setup.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
arch/x86/kernel/setup.c +13 -2
index f8ec578..2063a49 100644
@@ -423,6 +423,17 @@ static void __init reserve_initrd(void)
 }
 #endif /* CONFIG_BLK_DEV_INITRD */
 
+static void __init remap_setup_data(u64 pa_data, u32 data_len,
+                                   struct setup_data **data, u32 *map_len)
+{
+       if (data_len <= *map_len)
+               return;
+
+       early_iounmap(*data, *map_len);
+       *data = early_memremap(pa_data, data_len);
+       *map_len = data_len;
+}
+
 static void __init parse_setup_data(void)
 {
        struct setup_data *data;
@@ -432,18 +443,16 @@ static void __init parse_setup_data(void)
        while (pa_data) {
                u32 data_len, map_len;
 
+               /* The data length may be too large for early remapping,
+                  remap the data only when needed. */
                map_len = max(PAGE_SIZE - (pa_data & ~PAGE_MASK),
                              (u64)sizeof(struct setup_data));
                data = early_memremap(pa_data, map_len);
                data_len = data->len + sizeof(struct setup_data);
-               if (data_len > map_len) {
-                       early_iounmap(data, map_len);

arch/x86/kernel/setup.c static void __init parse_setup_data(void) · line 458

Quoted 10 lines
arch/x86/kernel/setup.c +1 -3
-                       data = early_memremap(pa_data, data_len);
-                       map_len = data_len;
-               }
 
                switch (data->type) {
                case SETUP_E820_EXT:
+                       remap_setup_data(pa_data, data_len, &data, &map_len);
                        parse_e820_ext(data);
                        break;
                case SETUP_DTB:

how about just passing phys_addr and length with parse_e820_ext and parse_dtb? let them to worry about length and handle oversize case.

Thanks

Yinghai

#4 lore raw

PATCH v3 1/1 x86: avoid remapping data in parse_setup_data()

In reply to Linn Crosetto

Type SETUP_PCI, added by setup_efi_pci(), may advertise a ROM size larger than early_memremap() is able to handle, which is currently limited to 256kB. If this occurs it leads to a NULL dereference in parse_setup_data().

To avoid this, remap the setup_data header and allow parsing functions for individual types to handle their own data remapping.

---
v3: Remove data remapping code from parse_setup_data() and add it to parse_e820_ext().

 arch/x86/include/asm/e820.h |  2 +-
 arch/x86/kernel/e820.c      |  5 ++++-
 arch/x86/kernel/setup.c     | 19 ++++++++-----------
 3 files changed, 13 insertions(+), 13 deletions(-)
arch/x86/include/asm/e820.h +1 -1
index cccd07f..779c2ef 100644
@@ -29,7 +29,7 @@ extern void e820_setup_gap(void);
 extern int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize,
 			unsigned long start_addr, unsigned long long end_addr);
 struct setup_data;
-extern void parse_e820_ext(struct setup_data *data);
+extern void parse_e820_ext(u64 phys_addr, u32 data_len);
 
 #if defined(CONFIG_X86_64) || \
 	(defined(CONFIG_X86_32) && defined(CONFIG_HIBERNATION))
arch/x86/kernel/e820.c +4 -1
index d32abea..174da5f 100644
@@ -658,15 +658,18 @@ __init void e820_setup_gap(void)
  * boot_params.e820_map, others are passed via SETUP_E820_EXT node of
  * linked list of struct setup_data, which is parsed here.
  */
-void __init parse_e820_ext(struct setup_data *sdata)
+void __init parse_e820_ext(u64 phys_addr, u32 data_len)
 {
 	int entries;
 	struct e820entry *extmap;
+	struct setup_data *sdata;
 
+	sdata = early_memremap(phys_addr, data_len);
 	entries = sdata->len / sizeof(struct e820entry);
 	extmap = (struct e820entry *)(sdata->data);
 	__append_e820_map(extmap, entries);
 	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
+	early_iounmap(sdata, data_len);
 	printk(KERN_INFO "e820: extended physical RAM map:\n");
 	e820_print_map("extended");
 }
arch/x86/kernel/setup.c +8 -11
index f8ec578..234e1e3 100644
@@ -426,25 +426,23 @@ static void __init reserve_initrd(void)
 static void __init parse_setup_data(void)
 {
 	struct setup_data *data;
-	u64 pa_data;
+	u64 pa_data, pa_next;
 
 	pa_data = boot_params.hdr.setup_data;
 	while (pa_data) {
-		u32 data_len, map_len;
+		u32 data_len, map_len, data_type;
 
 		map_len = max(PAGE_SIZE - (pa_data & ~PAGE_MASK),
 			      (u64)sizeof(struct setup_data));
 		data = early_memremap(pa_data, map_len);
 		data_len = data->len + sizeof(struct setup_data);
-		if (data_len > map_len) {
-			early_iounmap(data, map_len);
-			data = early_memremap(pa_data, data_len);
-			map_len = data_len;
-		}
+		data_type = data->type;
+		pa_next = data->next;
+		early_iounmap(data, map_len);
 
-		switch (data->type) {
+		switch (data_type) {
 		case SETUP_E820_EXT:
-			parse_e820_ext(data);
+			parse_e820_ext(pa_data, data_len);
 			break;
 		case SETUP_DTB:
 			add_dtb(pa_data);
@@ -452,8 +450,7 @@ static void __init parse_setup_data(void)
 		default:
 			break;
 		}
-		pa_data = data->next;
-		early_iounmap(data, map_len);
+		pa_data = pa_next;
 	}
 }
 
Signature · 1 line
1.7.11.3
Acked-by on v3 1/1
#5 lore raw

Re: [PATCH v3] x86: avoid remapping data in parse_setup_data()

Quoted 5 lines · Linn Crosetto

Type SETUP_PCI, added by setup_efi_pci(), may advertise a ROM size larger than early_memremap() is able to handle, which is currently limited to 256kB. If this occurs it leads to a NULL dereference in parse_setup_data().

Quoted 7 lines

To avoid this, remap the setup_data header and allow parsing functions for individual types to handle their own data remapping.

---
v3: Remove data remapping code from parse_setup_data() and add it to parse_e820_ext().

Quoted 89 lines
 arch/x86/include/asm/e820.h |  2 +-
 arch/x86/kernel/e820.c      |  5 ++++-
 arch/x86/kernel/setup.c     | 19 ++++++++-----------
 3 files changed, 13 insertions(+), 13 deletions(-)
arch/x86/include/asm/e820.h +1 -1
index cccd07f..779c2ef 100644
@@ -29,7 +29,7 @@ extern void e820_setup_gap(void);
 extern int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize,
                        unsigned long start_addr, unsigned long long end_addr);
 struct setup_data;
-extern void parse_e820_ext(struct setup_data *data);
+extern void parse_e820_ext(u64 phys_addr, u32 data_len);
 
 #if defined(CONFIG_X86_64) || \
        (defined(CONFIG_X86_32) && defined(CONFIG_HIBERNATION))
arch/x86/kernel/e820.c +4 -1
index d32abea..174da5f 100644
@@ -658,15 +658,18 @@ __init void e820_setup_gap(void)
  * boot_params.e820_map, others are passed via SETUP_E820_EXT node of
  * linked list of struct setup_data, which is parsed here.
  */
-void __init parse_e820_ext(struct setup_data *sdata)
+void __init parse_e820_ext(u64 phys_addr, u32 data_len)
 {
        int entries;
        struct e820entry *extmap;
+       struct setup_data *sdata;
 
+       sdata = early_memremap(phys_addr, data_len);
        entries = sdata->len / sizeof(struct e820entry);
        extmap = (struct e820entry *)(sdata->data);
        __append_e820_map(extmap, entries);
        sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
+       early_iounmap(sdata, data_len);
        printk(KERN_INFO "e820: extended physical RAM map:\n");
        e820_print_map("extended");
 }
arch/x86/kernel/setup.c +8 -11
index f8ec578..234e1e3 100644
@@ -426,25 +426,23 @@ static void __init reserve_initrd(void)
 static void __init parse_setup_data(void)
 {
        struct setup_data *data;
-       u64 pa_data;
+       u64 pa_data, pa_next;
 
        pa_data = boot_params.hdr.setup_data;
        while (pa_data) {
-               u32 data_len, map_len;
+               u32 data_len, map_len, data_type;
 
                map_len = max(PAGE_SIZE - (pa_data & ~PAGE_MASK),
                              (u64)sizeof(struct setup_data));
                data = early_memremap(pa_data, map_len);
                data_len = data->len + sizeof(struct setup_data);
-               if (data_len > map_len) {
-                       early_iounmap(data, map_len);
-                       data = early_memremap(pa_data, data_len);
-                       map_len = data_len;
-               }
+               data_type = data->type;
+               pa_next = data->next;
+               early_iounmap(data, map_len);
 
-               switch (data->type) {
+               switch (data_type) {
                case SETUP_E820_EXT:
-                       parse_e820_ext(data);
+                       parse_e820_ext(pa_data, data_len);
                        break;
                case SETUP_DTB:
                        add_dtb(pa_data);
@@ -452,8 +450,7 @@ static void __init parse_setup_data(void)
                default:
                        break;
                }
-               pa_data = data->next;
-               early_iounmap(data, map_len);
+               pa_data = pa_next;
        }
 }
Reviewed-by on v3 1/1
#6 lore raw

Re: [PATCH v3] x86: avoid remapping data in parse_setup_data()

In reply to Linn Crosetto
Quoted 9 lines · Linn Crosetto

Type SETUP_PCI, added by setup_efi_pci(), may advertise a ROM size larger than early_memremap() is able to handle, which is currently limited to 256kB. If this occurs it leads to a NULL dereference in parse_setup_data().

To avoid this, remap the setup_data header and allow parsing functions for individual types to handle their own data remapping.

#7 lore raw

[tip:x86/mm] x86: avoid remapping data in parse_setup_data()

In reply to Linn Crosetto
x86: avoid remapping data in parse_setup_data()
Commit-ID:  30e46b574a1db7d14404e52dca8e1aa5f5155fd2
Gitweb:     http://git.kernel.org/tip/30e46b574a1db7d14404e52dca8e1aa5f5155fd2
Author:     Linn Crosetto <[email protected]>
AuthorDate: Tue, 13 Aug 2013 15:46:41 -0600
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 13 Aug 2013 23:29:19 -0700

x86: avoid remapping data in parse_setup_data()

Type SETUP_PCI, added by setup_efi_pci(), may advertise a ROM size larger than early_memremap() is able to handle, which is currently limited to 256kB. If this occurs it leads to a NULL dereference in parse_setup_data().

To avoid this, remap the setup_data header and allow parsing functions for individual types to handle their own data remapping.

---
 arch/x86/include/asm/e820.h |  2 +-
 arch/x86/kernel/e820.c      |  5 ++++-
 arch/x86/kernel/setup.c     | 19 ++++++++-----------
 3 files changed, 13 insertions(+), 13 deletions(-)
arch/x86/include/asm/e820.h +1 -1
index cccd07f..779c2ef 100644
@@ -29,7 +29,7 @@ extern void e820_setup_gap(void);
 extern int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize,
 			unsigned long start_addr, unsigned long long end_addr);
 struct setup_data;
-extern void parse_e820_ext(struct setup_data *data);
+extern void parse_e820_ext(u64 phys_addr, u32 data_len);
 
 #if defined(CONFIG_X86_64) || \
 	(defined(CONFIG_X86_32) && defined(CONFIG_HIBERNATION))
arch/x86/kernel/e820.c +4 -1
index d32abea..174da5f 100644
@@ -658,15 +658,18 @@ __init void e820_setup_gap(void)
  * boot_params.e820_map, others are passed via SETUP_E820_EXT node of
  * linked list of struct setup_data, which is parsed here.
  */
-void __init parse_e820_ext(struct setup_data *sdata)
+void __init parse_e820_ext(u64 phys_addr, u32 data_len)
 {
 	int entries;
 	struct e820entry *extmap;
+	struct setup_data *sdata;
 
+	sdata = early_memremap(phys_addr, data_len);
 	entries = sdata->len / sizeof(struct e820entry);
 	extmap = (struct e820entry *)(sdata->data);
 	__append_e820_map(extmap, entries);
 	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
+	early_iounmap(sdata, data_len);
 	printk(KERN_INFO "e820: extended physical RAM map:\n");
 	e820_print_map("extended");
 }
arch/x86/kernel/setup.c +8 -11
index de33798..b6b45e4 100644
@@ -426,25 +426,23 @@ static void __init reserve_initrd(void)
 static void __init parse_setup_data(void)
 {
 	struct setup_data *data;
-	u64 pa_data;
+	u64 pa_data, pa_next;
 
 	pa_data = boot_params.hdr.setup_data;
 	while (pa_data) {
-		u32 data_len, map_len;
+		u32 data_len, map_len, data_type;
 
 		map_len = max(PAGE_SIZE - (pa_data & ~PAGE_MASK),
 			      (u64)sizeof(struct setup_data));
 		data = early_memremap(pa_data, map_len);
 		data_len = data->len + sizeof(struct setup_data);
-		if (data_len > map_len) {
-			early_iounmap(data, map_len);
-			data = early_memremap(pa_data, data_len);
-			map_len = data_len;
-		}
+		data_type = data->type;
+		pa_next = data->next;
+		early_iounmap(data, map_len);
 
-		switch (data->type) {
+		switch (data_type) {
 		case SETUP_E820_EXT:
-			parse_e820_ext(data);
+			parse_e820_ext(pa_data, data_len);
 			break;
 		case SETUP_DTB:
 			add_dtb(pa_data);
@@ -452,8 +450,7 @@ static void __init parse_setup_data(void)
 		default:
 			break;
 		}
-		pa_data = data->next;
-		early_iounmap(data, map_len);
+		pa_data = pa_next;
 	}
 }
 
#8 lore raw

Re: [PATCH v3] x86: avoid remapping data in parse_setup_data()

In reply to Linn Crosetto
Quoted 9 lines · Linn Crosetto

Type SETUP_PCI, added by setup_efi_pci(), may advertise a ROM size larger than early_memremap() is able to handle, which is currently limited to 256kB. If this occurs it leads to a NULL dereference in parse_setup_data().

To avoid this, remap the setup_data header and allow parsing functions for individual types to handle their own data remapping.

So it seems this patch generates some new sparse warnings. Can you please create an incremental fixup patch to address those sparse warnings? (See email from Fengguang Wu's robot.)

-hpa

#9 lore raw

cover x86/mm: fix early_memremap() sparse warnings

This set of patches cleans up some sparse warnings generated by callers of early_memremap().

early_memremap() was created as an interface to to map normal memory (commit 1494177), in contrast to early_ioremap() for IO mappings. Later on, early_memremap() was annotated with __iomem (commit 1d6cf1f) which generates sparse warnings for callers using pointers not declared with __iomem. Callers of early_memremap() were expected to use early_iounmap() to remove the mapping, which generates more sparse warnings as the argument to early_iounmap() is also annotated with __iomem.

To clean this up, remove __iomem from early_memremap() and create early_memunmap() to be used for removing normal memory mappings.

Removes the following warnings:

arch/x86/kernel/setup.c:353:19: warning: incorrect type in assignment (different address spaces) arch/x86/kernel/setup.c:355:31: warning: incorrect type in argument 1 (different address spaces) arch/x86/kernel/setup.c:437:22: warning: incorrect type in assignment (different address spaces) arch/x86/kernel/setup.c:441:31: warning: incorrect type in argument 1 (different address spaces) arch/x86/kernel/setup.c:465:22: warning: incorrect type in assignment (different address spaces) arch/x86/kernel/setup.c:470:31: warning: incorrect type in argument 1 (different address spaces) arch/x86/kernel/setup.c:488:22: warning: incorrect type in assignment (different address spaces) arch/x86/kernel/setup.c:491:31: warning: incorrect type in argument 1 (different address spaces) arch/x86/kernel/e820.c:667:15: warning: incorrect type in assignment (different address spaces) arch/x86/kernel/e820.c:672:23: warning: incorrect type in argument 1 (different address spaces)

Linn Crosetto (3):
x86/mm: fix sparse warnings from early_memremap()
x86: fix sparse warning in parse_e820_ext()
x86: fix early_iounmap() sparse warnings in setup.c

 arch/x86/include/asm/io.h | 4 ++--
 arch/x86/kernel/e820.c    | 2 +-
 arch/x86/kernel/setup.c   | 8 ++++----
 arch/x86/mm/ioremap.c     | 9 +++++++--
 4 files changed, 14 insertions(+), 9 deletions(-)
Signature · 1 line
1.7.11.3
#10 lore raw

PATCH 1/3 x86/mm: fix sparse warnings from early_memremap()

This patch creates consistent early interfaces for mapping normal memory and eliminates some sparse warnings.

early_memremap() was created to map normal memory, as opposed to the ioremap interfaces for actual IO mappings, so remove the __iomem annotation from early_memremap(). In addition, early_memunmap() is added to provide an interface analogous to early_iounmap() for normal memory.

Fixes the following warnings:

arch/x86/kernel/setup.c:353:19: warning: incorrect type in assignment (different address spaces) arch/x86/kernel/setup.c:437:22: warning: incorrect type in assignment (different address spaces) arch/x86/kernel/setup.c:465:22: warning: incorrect type in assignment (different address spaces) arch/x86/kernel/setup.c:488:22: warning: incorrect type in assignment (different address spaces) arch/x86/kernel/e820.c:667:15: warning: incorrect type in assignment (different address spaces)

---
 arch/x86/include/asm/io.h | 4 ++--
 arch/x86/mm/ioremap.c     | 9 +++++++--
 2 files changed, 9 insertions(+), 4 deletions(-)
arch/x86/include/asm/io.h +2 -2
index 34f69cb..ae1ef3e 100644
@@ -325,8 +325,8 @@ extern void early_ioremap_init(void);
 extern void early_ioremap_reset(void);
 extern void __iomem *early_ioremap(resource_size_t phys_addr,
 				   unsigned long size);
-extern void __iomem *early_memremap(resource_size_t phys_addr,
-				    unsigned long size);
+extern void *early_memremap(resource_size_t phys_addr, unsigned long size);
+extern void early_memunmap(void *addr, unsigned long size);
 extern void early_iounmap(void __iomem *addr, unsigned long size);
 extern void fixup_early_ioremap(void);
 extern bool is_early_ioremap_ptep(pte_t *ptep);
arch/x86/mm/ioremap.c +7 -2
index 799580c..a144929 100644
@@ -562,10 +562,15 @@ early_ioremap(resource_size_t phys_addr, unsigned long size)
 }
 
 /* Remap memory */
-void __init __iomem *
+void __init *
 early_memremap(resource_size_t phys_addr, unsigned long size)
 {
-	return __early_ioremap(phys_addr, size, PAGE_KERNEL);
+	return (__force void *)__early_ioremap(phys_addr, size, PAGE_KERNEL);
+}
+
+void __init early_memunmap(void *addr, unsigned long size)
+{
+	early_iounmap((void __iomem *)addr, size);
 }
 
 void __init early_iounmap(void __iomem *addr, unsigned long size)
Signature · 1 line
1.7.11.3
#11 lore raw

PATCH 2/3 x86: fix sparse warning in parse_e820_ext()

In reply to Linn Crosetto

Replace the call to early_iounmap() with early_memunmap() to eliminate the following sparse warning:

arch/x86/kernel/e820.c:672:23: sparse: incorrect type in argument 1 (different address spaces)

---
 arch/x86/kernel/e820.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/e820.c +1 -1
index 174da5f..06e0c4a 100644
@@ -669,7 +669,7 @@ void __init parse_e820_ext(u64 phys_addr, u32 data_len)
 	extmap = (struct e820entry *)(sdata->data);
 	__append_e820_map(extmap, entries);
 	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
-	early_iounmap(sdata, data_len);
+	early_memunmap(sdata, data_len);
 	printk(KERN_INFO "e820: extended physical RAM map:\n");
 	e820_print_map("extended");
 }
Signature · 1 line
1.7.11.3
#12 lore raw

PATCH 3/3 x86: fix early_iounmap() sparse warnings in setup.c

In reply to Linn Crosetto

Replace calls to early_iounmap() with early_memunmap() for pointers mapped with early_memremap() to eliminate the following sparse warnings:

arch/x86/kernel/setup.c:355:31: warning: incorrect type in argument 1 (different address spaces) arch/x86/kernel/setup.c:441:31: warning: incorrect type in argument 1 (different address spaces) arch/x86/kernel/setup.c:470:31: warning: incorrect type in argument 1 (different address spaces) arch/x86/kernel/setup.c:491:31: warning: incorrect type in argument 1 (different address spaces)

---
 arch/x86/kernel/setup.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/kernel/setup.c +4 -4
index f0de629..3081fc6 100644
@@ -352,7 +352,7 @@ static void __init relocate_initrd(void)
 		mapaddr = ramdisk_image & PAGE_MASK;
 		p = early_memremap(mapaddr, clen+slop);
 		memcpy(q, p+slop, clen);
-		early_iounmap(p, clen+slop);
+		early_memunmap(p, clen+slop);
 		q += clen;
 		ramdisk_image += clen;
 		ramdisk_size  -= clen;
@@ -438,7 +438,7 @@ static void __init parse_setup_data(void)
 		data_len = data->len + sizeof(struct setup_data);
 		data_type = data->type;
 		pa_next = data->next;
-		early_iounmap(data, map_len);
+		early_memunmap(data, map_len);
 
 		switch (data_type) {
 		case SETUP_E820_EXT:
@@ -467,7 +467,7 @@ static void __init e820_reserve_setup_data(void)
 			 E820_RAM, E820_RESERVED_KERN);
 		found = 1;
 		pa_data = data->next;
-		early_iounmap(data, sizeof(*data));
+		early_memunmap(data, sizeof(*data));
 	}
 	if (!found)
 		return;
@@ -488,7 +488,7 @@ static void __init memblock_x86_reserve_range_setup_data(void)
 		data = early_memremap(pa_data, sizeof(*data));
 		memblock_reserve(pa_data, sizeof(*data) + data->len);
 		pa_data = data->next;
-		early_iounmap(data, sizeof(*data));
+		early_memunmap(data, sizeof(*data));
 	}
 }
 
Signature · 1 line
1.7.11.3