From: Yu Chen <33988979@163•com>
To: rmk+kernel@armlinux•org.uk, linux@armlinux•org.uk
Cc: yu.chen3@zte•com.cn, linux-kernel@vger•kernel.org,
linux-arm-kernel@lists•infradead.org
Subject: [PATCH] arm: export memblock_reserve()d regions via /proc/iomem
Date: Sat, 21 Sep 2019 21:02:49 +0800 [thread overview]
Message-ID: <1569070969-5168-1-git-send-email-33988979@163.com> (raw)
From: Yu Chen <yu.chen3@zte•com.cn>
memblock reserved regions are not reported via /proc/iomem on ARM, kexec's
user-space doesn't know about memblock_reserve()d regions and thus
possible for kexec to overwrite with the new kernel or initrd.
[ 0.000000] Booting Linux on physical CPU 0xf00
[ 0.000000] Linux version 4.9.115-rt93-dirty (yuchen@localhost•localdomain) (gcc version 6.2.0 (ZTE Embsys-TSP V3.07.2
0) ) #62 SMP PREEMPT Fri Sep 20 10:39:29 CST 2019
[ 0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=30c5387d
[ 0.000000] CPU: div instructions available: patching division code
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] OF: fdt:Machine model: LS1021A TWR Board
[ 0.000000] INITRD: 0x80f7f000+0x03695e40 overlaps in-use memory region - disabling initrd
Signed-off-by: Yu Chen <yu.chen3@zte•com.cn>
Reviewed-by: Junhua Huang <huang.junhua@zte•com.cn>
---
arch/arm/kernel/setup.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index d0a464e..606d1ac 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -911,6 +911,34 @@ static void __init request_standard_resources(const struct machine_desc *mdesc)
request_resource(&ioport_resource, &lp2);
}
+static int __init reserve_memblock_reserved_regions(void)
+{
+ u64 i, j;
+
+ for (i = 0; i < num_standard_resources; ++i) {
+ struct resource *mem = &standard_resources[i];
+ phys_addr_t r_start, r_end, mem_size = resource_size(mem);
+
+ if (!memblock_is_region_reserved(mem->start, mem_size))
+ continue;
+
+ for_each_reserved_mem_region(j, &r_start, &r_end) {
+ resource_size_t start, end;
+
+ start = max(PFN_PHYS(PFN_DOWN(r_start)), mem->start);
+ end = min(PFN_PHYS(PFN_UP(r_end)) - 1, mem->end);
+
+ if (start > mem->end || end < mem->start)
+ continue;
+
+ reserve_region_with_split(mem, start, end, "reserved");
+ }
+ }
+
+ return 0;
+}
+arch_initcall(reserve_memblock_reserved_regions);
+
#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE) || \
defined(CONFIG_EFI)
struct screen_info screen_info = {
--
2.7.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists•infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2019-09-21 13:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-21 13:02 Yu Chen [this message]
2019-09-21 14:51 ` [PATCH] arm: export memblock_reserve()d regions via /proc/iomem Russell King - ARM Linux admin
2019-09-22 8:36 ` kbuild test robot
[not found] <1569253374-3631-1-git-send-email-33988979@163.com>
2019-09-23 16:14 ` Russell King - ARM Linux admin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1569070969-5168-1-git-send-email-33988979@163.com \
--to=33988979@163$(echo .)com \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux@armlinux$(echo .)org.uk \
--cc=rmk+kernel@armlinux$(echo .)org.uk \
--cc=yu.chen3@zte$(echo .)com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox