diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-08 17:43:59 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-08 18:04:03 +0300 |
| commit | e134202611a50b358c147c92bfb8a7f443030b8b (patch) | |
| tree | ac7c31824adcf41a63e4d2c5e141f5149cc55b1a /arch/riscv64/kernel/smp.c | |
| parent | 7e828ec1e1479ff9a8afe845539d08ca0dfada5f (diff) | |
| download | kmi-e134202611a50b358c147c92bfb8a7f443030b8b.tar.gz kmi-e134202611a50b358c147c92bfb8a7f443030b8b.zip | |
fix LLVM
+ Anything extern is right out as LLVM doesn't produce correct code for
them. Maybe if I added some extra attributes but I'm skeptical.
Replaced with static variables and getters/setters.
+ Inline ASM is apparently a bit buggy, so use an assembly stub when jumping to init.
+ Minimize work done in main() to minimize chance of LLVM doing something silly.
Still not 100% certain that I shouldn't just write the main() as an assembly stub
in arch/riscv64 to be absolutely sure everything works as intended.
+ Make .kernel.start section SHF_ALLOC, otherwise lld complains about
pc-relative addressing
Probably some other stuff as well that I'm forgetting right now. But at least with
LLVM14 LTO seems to work, which is pretty cool?
Diffstat (limited to 'arch/riscv64/kernel/smp.c')
| -rw-r--r-- | arch/riscv64/kernel/smp.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/riscv64/kernel/smp.c b/arch/riscv64/kernel/smp.c index e48a216..425d3ce 100644 --- a/arch/riscv64/kernel/smp.c +++ b/arch/riscv64/kernel/smp.c @@ -59,7 +59,7 @@ void smp_bringup(struct vmem *b, void *fdt) extern void riscv_bringup(void); /* mark first hart available */ - cpuid_to_hartid(0) = -1; + set_hartid(0, -1); /* assume we're in default Sv mode, in the future this will have to be * fixed if we start implementing Sv48 etc. */ @@ -87,12 +87,12 @@ void smp_bringup(struct vmem *b, void *fdt) if (r.value == SBI_HART_STARTED) { /* there should ever only be one started hart */ assert(cpuid_to_hartid(0) == -1); - cpuid_to_hartid(0) = hartid; + set_hartid(0, hartid); continue; } /** @todo should check that cpus doesn't go over MAX_CPUS */ - cpuid_to_hartid(cpus++) = hartid; + set_hartid(cpus++, hartid); /** @todo try to remember to free these as well */ smp_init_stacks[hartid] = (void *)alloc_page(BASE_PAGE) + |
