linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: mark reserved memblock regions explicitly in iomem
@ 2016-08-22  6:55 AKASHI Takahiro
  2016-08-25 14:25 ` Catalin Marinas
  2016-08-25 15:27 ` James Morse
  0 siblings, 2 replies; 3+ messages in thread
From: AKASHI Takahiro @ 2016-08-22  6:55 UTC (permalink / raw)
  To: linux-arm-kernel

Kdump(kexec-tools) parses /proc/iomem to identify all the memory regions
on the system. Since the current kernel names "nomap" regions, like UEFI
runtime services code/data, as "System RAM," kexec-tools sets up elf core
header to include them in a crash dump file (/proc/vmcore).

Then crash dump kernel parses UEFI memory map again, re-marks those regions
as "nomap" and does not create a memory mapping for them unlike the other
areas of System RAM. In this case, copying /proc/vmcore through
copy_oldmem_page() on crash dump kernel will end up with a kernel abort,
as reported in [1].

This patch names all the "nomap" regions explicitly as "reserved" so that
we can exclude them from a crash dump file. acpi_os_ioremap() must also
be modified because those regions have WB attributes [2].

Apart from kdump, this change also matches x86's use of acpi (and
/proc/iomem).

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-August/448186.html
[2] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-August/450089.html

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
 arch/arm64/include/asm/acpi.h | 8 ++++++--
 arch/arm64/kernel/setup.c     | 9 +++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
index 5420cb0..e517088 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -12,7 +12,7 @@
 #ifndef _ASM_ACPI_H
 #define _ASM_ACPI_H
 
-#include <linux/mm.h>
+#include <linux/memblock.h>
 #include <linux/psci.h>
 
 #include <asm/cputype.h>
@@ -32,7 +32,11 @@
 static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
 					    acpi_size size)
 {
-	if (!page_is_ram(phys >> PAGE_SHIFT))
+	/*
+	 * EFI's reserve_regions() call adds memory with the WB attribute
+	 * to memblock via early_init_dt_add_memory_arch().
+	 */
+	if (!memblock_is_memory(phys))
 		return ioremap(phys, size);
 
 	return ioremap_cache(phys, size);
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 38eda13..38589b5 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -205,10 +205,15 @@ static void __init request_standard_resources(void)
 
 	for_each_memblock(memory, region) {
 		res = alloc_bootmem_low(sizeof(*res));
-		res->name  = "System RAM";
+		if (memblock_is_nomap(region)) {
+			res->name  = "reserved";
+			res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+		} else {
+			res->name  = "System RAM";
+			res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
+		}
 		res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region));
 		res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1;
-		res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
 
 		request_resource(&iomem_resource, res);
 
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] arm64: mark reserved memblock regions explicitly in iomem
  2016-08-22  6:55 [PATCH] arm64: mark reserved memblock regions explicitly in iomem AKASHI Takahiro
@ 2016-08-25 14:25 ` Catalin Marinas
  2016-08-25 15:27 ` James Morse
  1 sibling, 0 replies; 3+ messages in thread
From: Catalin Marinas @ 2016-08-25 14:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Aug 22, 2016 at 03:55:24PM +0900, AKASHI Takahiro wrote:
> Kdump(kexec-tools) parses /proc/iomem to identify all the memory regions
> on the system. Since the current kernel names "nomap" regions, like UEFI
> runtime services code/data, as "System RAM," kexec-tools sets up elf core
> header to include them in a crash dump file (/proc/vmcore).
> 
> Then crash dump kernel parses UEFI memory map again, re-marks those regions
> as "nomap" and does not create a memory mapping for them unlike the other
> areas of System RAM. In this case, copying /proc/vmcore through
> copy_oldmem_page() on crash dump kernel will end up with a kernel abort,
> as reported in [1].
> 
> This patch names all the "nomap" regions explicitly as "reserved" so that
> we can exclude them from a crash dump file. acpi_os_ioremap() must also
> be modified because those regions have WB attributes [2].
> 
> Apart from kdump, this change also matches x86's use of acpi (and
> /proc/iomem).
> 
> [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-August/448186.html
> [2] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-August/450089.html
> 
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> ---
>  arch/arm64/include/asm/acpi.h | 8 ++++++--
>  arch/arm64/kernel/setup.c     | 9 +++++++--
>  2 files changed, 13 insertions(+), 4 deletions(-)

The patch looks fine to me but it would be good if James gave it a try.
FWIW:

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] arm64: mark reserved memblock regions explicitly in iomem
  2016-08-22  6:55 [PATCH] arm64: mark reserved memblock regions explicitly in iomem AKASHI Takahiro
  2016-08-25 14:25 ` Catalin Marinas
@ 2016-08-25 15:27 ` James Morse
  1 sibling, 0 replies; 3+ messages in thread
From: James Morse @ 2016-08-25 15:27 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Akashi,

On 22/08/16 07:55, AKASHI Takahiro wrote:
> Kdump(kexec-tools) parses /proc/iomem to identify all the memory regions
> on the system. Since the current kernel names "nomap" regions, like UEFI
> runtime services code/data, as "System RAM," kexec-tools sets up elf core
> header to include them in a crash dump file (/proc/vmcore).
> 
> Then crash dump kernel parses UEFI memory map again, re-marks those regions
> as "nomap" and does not create a memory mapping for them unlike the other
> areas of System RAM. In this case, copying /proc/vmcore through
> copy_oldmem_page() on crash dump kernel will end up with a kernel abort,
> as reported in [1].
> 
> This patch names all the "nomap" regions explicitly as "reserved" so that
> we can exclude them from a crash dump file. acpi_os_ioremap() must also
> be modified because those regions have WB attributes [2].
> 
> Apart from kdump, this change also matches x86's use of acpi (and
> /proc/iomem).
> 
> [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-August/448186.html
> [2] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-August/450089.html


Tested on Seattle on v4.8-rc3, /proc/iomem Before:
8000000000-8001e7ffff : System RAM
8001e80000-83ff186fff : System RAM
  8002080000-8002baffff : Kernel code
  8002ca0000-8002db1fff : Kernel data
83ff187000-83ff1c4fff : System RAM
83ff1c5000-83ff224fff : System RAM
83ff225000-83ffe42fff : System RAM
83ffe43000-83ffffffff : System RAM

/proc/iomem After:
8000000000-8001e7ffff : reserved
8001e80000-83ff186fff : System RAM
  8002080000-8002baffff : Kernel code
  8002ca0000-8002db1fff : Kernel data
83ff187000-83ff1c4fff : reserved
83ff1c5000-83ff224fff : System RAM
83ff225000-83ffe42fff : reserved
83ffe43000-83ffffffff : System RAM

Which matches the output from 'efi=debug'.

I can also kdump with v24 of your series, and copy the vmcore file with
read()/mmap() and dig through it with crash.

Tested-by: James Morse <james.morse@arm.com>
Reviewed-by: James Morse <james.morse@arm.com>


The only side-effect of this I could find is we now allow access to the UEFI
areas when built with CONFIG_STRICT_DEVMEM, which is what the help text says
should happen, so it was broken before.



Thanks,

James

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-25 15:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-22  6:55 [PATCH] arm64: mark reserved memblock regions explicitly in iomem AKASHI Takahiro
2016-08-25 14:25 ` Catalin Marinas
2016-08-25 15:27 ` James Morse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).