aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-11-21 18:01:25 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2022-11-21 18:01:25 +0200
commite25f1e7a8f8f2320546ad4950464713d85b47785 (patch)
treec92025b1efbf756e0663de4bb62f3e36a61868c0 /arch
parente1599d8ab33f3f7d09c6a8a05f954209c969c8c1 (diff)
downloadkmi-e25f1e7a8f8f2320546ad4950464713d85b47785.tar.gz
kmi-e25f1e7a8f8f2320546ad4950464713d85b47785.zip
fix llvm
Diffstat (limited to 'arch')
-rw-r--r--arch/riscv64/kernel/cpu.c3
-rw-r--r--arch/riscv64/kernel/proc.c11
2 files changed, 11 insertions, 3 deletions
diff --git a/arch/riscv64/kernel/cpu.c b/arch/riscv64/kernel/cpu.c
index 60140e6..e8c8f34 100644
--- a/arch/riscv64/kernel/cpu.c
+++ b/arch/riscv64/kernel/cpu.c
@@ -39,7 +39,8 @@ id_t cpu_id()
/* @todo should this be the default for all arches? */
struct tcb *cur_tcb()
{
- register struct tcb *t __asm__ ("tp");
+ struct tcb *t;
+ __asm__ volatile ("mv %0, tp" : "=r" (t) ::);
return t;
}
diff --git a/arch/riscv64/kernel/proc.c b/arch/riscv64/kernel/proc.c
index 1990523..0f19789 100644
--- a/arch/riscv64/kernel/proc.c
+++ b/arch/riscv64/kernel/proc.c
@@ -20,9 +20,16 @@ void run_init(struct tcb *t, void *fdt)
/** \todo actually map fdt into the target address space */
csr_write(CSR_SSCRATCH, t);
csr_write(CSR_SEPC, t->exec);
+ /* gcc gives a warning 'the value of the stack pointer after an asm
+ * statement must be the same as it was before the statement', so this
+ * is technically speaking undefined behavior, I think.
+ *
+ * Could be fixed with a separate pure asm run_init, but I guess this
+ * works for now.
+ */
__asm__ volatile ("mv sp, %0\n" : : "r" (t->thread_stack_top) : "memory");
- __asm__ volatile ("mv a0, %0\n" : : "r" (t->tid) : );
- __asm__ volatile ("mv a1, %0\n" : : "r" (fdt) : );
+ __asm__ volatile ("mv a0, %0\n" : : "r" (t->tid) : "a0");
+ __asm__ volatile ("mv a1, %0\n" : : "r" (fdt) : "a1");
__asm__ volatile ("sret\n" ::: "memory");
/* we should never reach this */
unreachable();