[<prev] [next>] [day] [month] [year] [list]
Message-Id: <60bfb194e0b9c2f80b21cf5e4b9548039c0c6eec.1606304684.git.michal.simek@xilinx.com>
Date: Wed, 25 Nov 2020 12:44:47 +0100
From: Michal Simek <michal.simek@...inx.com>
To: linux-kernel@...r.kernel.org, monstr@...str.eu,
michal.simek@...inx.com, git@...inx.com
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Arnd Bergmann <arnd@...db.de>,
Arvind Sankar <nivedita@...m.mit.edu>,
Catalin Marinas <catalin.marinas@....com>,
Ira Weiny <ira.weiny@...el.com>,
Mike Rapoport <rppt@...nel.org>,
Randy Dunlap <rdunlap@...radead.org>,
Stefan Asserhall <stefan.asserhall@...inx.com>
Subject: [PATCH] microblaze: Swap location of bss and INIT_RAM_FS
Microblaze is doing early mapping with two TLBs with 16MB each. It means
machine_early_init() with MMU ON can work just with 32MB memory max. If
kernel includes initramfs which increase kernel footprint above 32MB bss
section can't be clear and HW exception happens because memory is not
mapped.
Swapping bss section with INIT_RAM_FS ensures that bss section stays in
mapped region and bss can be cleared by machine_early_init() code.
The patch is causing hole in binary and extend binary with bss size but it
is better to apply this patch and support bigger initramfs size then 32MB
in total with kernel.
Also there is need to allocate initramfs because origin mapping is done
only to the _end symbol which stayed at the same location. The follow up
patch will explain reasons behind it.
Signed-off-by: Michal Simek <michal.simek@...inx.com>
---
arch/microblaze/include/asm/sections.h | 2 ++
arch/microblaze/kernel/vmlinux.lds.S | 11 +++++------
arch/microblaze/mm/init.c | 7 ++++++-
3 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/arch/microblaze/include/asm/sections.h b/arch/microblaze/include/asm/sections.h
index a9311ad84a67..b5bef96cdcd5 100644
--- a/arch/microblaze/include/asm/sections.h
+++ b/arch/microblaze/include/asm/sections.h
@@ -14,6 +14,8 @@
extern char _ssbss[], _esbss[];
extern unsigned long __ivt_start[], __ivt_end[];
+extern char __initramfs_end[];
+
extern u32 _fdt_start[], _fdt_end[];
# endif /* !__ASSEMBLY__ */
diff --git a/arch/microblaze/kernel/vmlinux.lds.S b/arch/microblaze/kernel/vmlinux.lds.S
index df07b3d06cd6..77a5e71af22f 100644
--- a/arch/microblaze/kernel/vmlinux.lds.S
+++ b/arch/microblaze/kernel/vmlinux.lds.S
@@ -120,12 +120,6 @@ SECTIONS {
CON_INITCALL
}
- __init_end_before_initramfs = .;
-
- .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
- INIT_RAM_FS
- }
-
__init_end = .;
.bss ALIGN (PAGE_SIZE) : AT(ADDR(.bss) - LOAD_OFFSET) {
@@ -139,5 +133,10 @@ SECTIONS {
. = ALIGN(PAGE_SIZE);
_end = .;
+ .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
+ INIT_RAM_FS
+ }
+ __initramfs_end = . ;
+
DISCARDS
}
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 7129a20881ea..85daa77ff061 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -197,6 +197,7 @@ static void __init mmu_init_hw(void)
asmlinkage void __init mmu_init(void)
{
unsigned int kstart, ksize;
+ phys_addr_t __maybe_unused size;
if (!memblock.reserved.cnt) {
pr_emerg("Error memory count\n");
@@ -238,10 +239,14 @@ asmlinkage void __init mmu_init(void)
#if defined(CONFIG_BLK_DEV_INITRD)
/* Remove the init RAM disk from the available memory. */
if (initrd_start) {
- unsigned long size;
size = initrd_end - initrd_start;
memblock_reserve(__virt_to_phys(initrd_start), size);
}
+
+ size = __initramfs_end - __initramfs_start;
+ if (size)
+ memblock_reserve((phys_addr_t)__virt_to_phys(__initramfs_start),
+ size);
#endif /* CONFIG_BLK_DEV_INITRD */
/* Initialize the MMU hardware */
--
2.29.2
Powered by blists - more mailing lists