aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/init/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/riscv64/init/init.c')
-rw-r--r--arch/riscv64/init/init.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/arch/riscv64/init/init.c b/arch/riscv64/init/init.c
index 2c71ea4..c91d192 100644
--- a/arch/riscv64/init/init.c
+++ b/arch/riscv64/init/init.c
@@ -33,9 +33,14 @@ static void init_bootmem()
{
size_t flags = VM_V | VM_X | VM_R | VM_W;
- extern char *__init_start;
- root_branch = (struct vmem *)align_down(
- (uintptr_t)&__init_start - SZ_4K, SZ_4K);
+ extern char *__init_end;
+ extern char *__kernel_size;
+ uintptr_t top = (uintptr_t)&__init_end + (uintptr_t)&__kernel_size;
+
+ /* this could be risky, as we might overwrite some bits of initrd or fdt
+ * if they're allocated too close to the kernel payload.
+ * @todo Allocate root_branch statically? */
+ root_branch = (struct vmem *)align_up(top, SZ_4K);
/* direct mapping (temp) */
for (size_t i = 0; i < CSTACK_PAGE; ++i)