The current state of the kernel starts userland processes with register
a0 pointing to the stack, with a comment mentioning this is copied from
FreeBSD.
But while FreeBSD userland startup code (lib/csu) depends on this,
OpenBSD binaries do not need this.
Thus, don't bother setting up a0 upon startup.
Completely untested.
Index: machdep.c
===================================================================
RCS file: /OpenBSD/src/sys/arch/riscv64/riscv64/machdep.c,v
retrieving revision 1.26
diff -u -p -r1.26 machdep.c
--- machdep.c 14 Sep 2021 12:03:49 -0000 1.26
+++ machdep.c 21 Mar 2022 19:58:15 -0000
@@ -418,7 +418,6 @@ setregs(struct proc *p, struct exec_pack
tf->tf_sstatus |= SSTATUS_FS_OFF;
memset(tf, 0, sizeof(*tf));
- tf->tf_a[0] = stack; // XXX Inherited from FreeBSD. Why?
tf->tf_sp = STACKALIGN(stack);
tf->tf_ra = pack->ep_entry;
tf->tf_sepc = pack->ep_entry;