From 3fedbb6e1f849c5e0a4033d68201d60c2fc48121 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sat, 6 Jul 2024 23:37:11 +0300 Subject: core bringup + various warnings + dbg_fdt() is apparently broken, possibly due to UB or something, but it causes some issues with optimizations enabled. Remove it temporarily --- arch/riscv64/kernel/core_bringup.S | 4 ++-- arch/riscv64/kernel/smp.c | 5 +++-- arch/riscv64/kernel/vmem.c | 2 +- arch/riscv64/source.mk | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) (limited to 'arch/riscv64') diff --git a/arch/riscv64/kernel/core_bringup.S b/arch/riscv64/kernel/core_bringup.S index aff9b0b..83b017c 100644 --- a/arch/riscv64/kernel/core_bringup.S +++ b/arch/riscv64/kernel/core_bringup.S @@ -12,12 +12,12 @@ riscv_bringup: sfence.vma /* fetch the stack allocated to us at our hart index in smp_init_stacks */ - la t0, smp_init_stacks + lla t0, smp_init_stacks slli t1, a0, RW_SHIFT add t0, t0, t1 lr sp, 0(t0) mv tp, sp /* jump to C to handle rest of bringup */ - la t0, core_bringup + lla t0, core_bringup jr t0 diff --git a/arch/riscv64/kernel/smp.c b/arch/riscv64/kernel/smp.c index 8d04491..74cc930 100644 --- a/arch/riscv64/kernel/smp.c +++ b/arch/riscv64/kernel/smp.c @@ -93,8 +93,9 @@ void smp_bringup(struct vmem *b, void *fdt) /** @todo try to remember to free these as well */ smp_init_stacks[hartid] = (void *)alloc_page(BASE_PAGE) + BASE_PAGE_SIZE; - r = sbi_hart_start(hartid, - (unsigned long)__pa(riscv_bringup), satp); + + pm_t bringup = (pm_t)__pa(riscv_bringup); + r = sbi_hart_start(hartid, bringup, satp); if (r.error) { warn("failed bringing up hart %ld: %ld\n", diff --git a/arch/riscv64/kernel/vmem.c b/arch/riscv64/kernel/vmem.c index 00752c1..97b9cce 100644 --- a/arch/riscv64/kernel/vmem.c +++ b/arch/riscv64/kernel/vmem.c @@ -536,7 +536,7 @@ void setup_rpc_stack(struct tcb *t) * which means that it must also be the leaf */ t->arch.rpc_leaf = (struct vmem *)__find_vmem(t->rpc.vmem, RPC_STACK_BASE, - BASE_PAGE); + NULL); /* we count downward in base pages */ t->arch.rpc_idx = rpc_pages; } diff --git a/arch/riscv64/source.mk b/arch/riscv64/source.mk index e4c1f10..6e72c85 100644 --- a/arch/riscv64/source.mk +++ b/arch/riscv64/source.mk @@ -3,7 +3,7 @@ KERNEL_SOURCES += $(KERNEL_LOCAL) INIT_SOURCES += $(ARCH_SOURCE)/init/*.[cS] # this doesn't work for rv32, but fine for now */ -ARCH_CFLAGS += -mcmodel=medany +ARCH_CFLAGS := $(ARCH_CFLAGS) -mcmodel=medany # oof, LLVM's riscv support has become better since I last looked into # it, but for some reason LTO still causes a crash. Meaning it has to be -- cgit v1.3