Author: ed Date: Thu Oct 22 11:09:25 2015 New Revision: 289752 URL: https://svnweb.freebsd.org/changeset/base/289752
Log: Add support for CloudABI on ARM64. It turns out that it is pretty easy to make CloudABI work on ARM64. We essentially only need to copy over the sysvec from AMD64 and ensure that we use ARM64 specific registers. As there is an overlap between function argument and return registers, we do need to extend cloudabi64_schedtail() to only set its values if we're actually forking. Not when we're creating a new thread. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D3917 Added: head/sys/arm64/cloudabi64/ head/sys/arm64/cloudabi64/cloudabi64_sysvec.c - copied, changed from r289747, head/sys/amd64/cloudabi64/cloudabi64_sysvec.c Modified: head/share/man/man4/cloudabi.4 head/sys/conf/files.arm64 head/sys/modules/Makefile Modified: head/share/man/man4/cloudabi.4 ============================================================================== --- head/share/man/man4/cloudabi.4 Thu Oct 22 10:57:15 2015 (r289751) +++ head/share/man/man4/cloudabi.4 Thu Oct 22 11:09:25 2015 (r289752) @@ -22,7 +22,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd July 31, 2015 +.Dd October 22, 2015 .Dt CLOUDABI 4 .Os .Sh NAME @@ -73,7 +73,7 @@ module can be loaded on any architecture .Fx , the .Nm cloudabi64 -module is only available for amd64. +module is only available for amd64 and arm64. .Pp A full cross compilation toolchain for CloudABI is available in the .Pa devel/cloudabi-toolchain @@ -95,6 +95,9 @@ restricted set of resources. .Pp cloudlibc on GitHub: .Pa https://github.com/NuxiNL/cloudlibc . +.Pp +The CloudABI Ports Collection on GitHub: +.Pa https://github.com/NuxiNL/cloudabi-ports . .Sh HISTORY CloudABI support first appeared in .Fx 11.0 . Copied and modified: head/sys/arm64/cloudabi64/cloudabi64_sysvec.c (from r289747, head/sys/amd64/cloudabi64/cloudabi64_sysvec.c) ============================================================================== --- head/sys/amd64/cloudabi64/cloudabi64_sysvec.c Thu Oct 22 09:07:53 2015 (r289747, copy source) +++ head/sys/arm64/cloudabi64/cloudabi64_sysvec.c Thu Oct 22 11:09:25 2015 (r289752) @@ -51,24 +51,21 @@ static int cloudabi64_fetch_syscall_args(struct thread *td, struct syscall_args *sa) { struct trapframe *frame = td->td_frame; + int i; /* Obtain system call number. */ - sa->code = frame->tf_rax; + sa->code = frame->tf_x[8]; if (sa->code >= CLOUDABI64_SYS_MAXSYSCALL) return (ENOSYS); sa->callp = &cloudabi64_sysent[sa->code]; /* Fetch system call arguments. */ - sa->args[0] = frame->tf_rdi; - sa->args[1] = frame->tf_rsi; - sa->args[2] = frame->tf_rdx; - sa->args[3] = frame->tf_rcx; /* Actually %r10. */ - sa->args[4] = frame->tf_r8; - sa->args[5] = frame->tf_r9; + for (i = 0; i < MAXARGS; i++) + sa->args[i] = frame->tf_x[i]; /* Default system call return values. */ td->td_retval[0] = 0; - td->td_retval[1] = frame->tf_rdx; + td->td_retval[1] = frame->tf_x[1]; return (0); } @@ -80,22 +77,20 @@ cloudabi64_set_syscall_retval(struct thr switch (error) { case 0: /* System call succeeded. */ - frame->tf_rax = td->td_retval[0]; - frame->tf_rdx = td->td_retval[1]; - frame->tf_rflags &= ~PSL_C; + frame->tf_x[0] = td->td_retval[0]; + frame->tf_x[1] = td->td_retval[1]; + frame->tf_spsr &= ~PSR_C; break; case ERESTART: /* Restart system call. */ - frame->tf_rip -= frame->tf_err; - frame->tf_r10 = frame->tf_rcx; - set_pcb_flags(td->td_pcb, PCB_FULL_IRET); + frame->tf_elr -= 4; break; case EJUSTRETURN: break; default: /* System call returned an error. */ - frame->tf_rax = cloudabi_convert_errno(error); - frame->tf_rflags |= PSL_C; + frame->tf_x[0] = cloudabi_convert_errno(error); + frame->tf_spsr |= PSR_C; break; } } @@ -105,9 +100,15 @@ cloudabi64_schedtail(struct thread *td) { struct trapframe *frame = td->td_frame; - /* Initial register values for processes returning from fork. */ - frame->tf_rax = CLOUDABI_PROCESS_CHILD; - frame->tf_rdx = td->td_tid; + /* + * Initial register values for processes returning from fork. + * Make sure that we only set these values when forking, not + * when creating a new thread. + */ + if ((td->td_pflags & TDP_FORKING) != 0) { + frame->tf_x[0] = CLOUDABI_PROCESS_CHILD; + frame->tf_x[1] = td->td_tid; + } } void @@ -128,8 +129,8 @@ cloudabi64_thread_setregs(struct thread * entry point. */ frame = td->td_frame; - frame->tf_rdi = td->td_tid; - frame->tf_rsi = attr->argument; + frame->tf_x[0] = td->td_tid; + frame->tf_x[1] = attr->argument; } static struct sysentvec cloudabi64_elf_sysvec = { @@ -155,7 +156,7 @@ INIT_SYSENTVEC(elf_sysvec, &cloudabi64_e Elf64_Brandinfo cloudabi64_brand = { .brand = ELFOSABI_CLOUDABI, - .machine = EM_X86_64, + .machine = EM_AARCH64, .sysvec = &cloudabi64_elf_sysvec, .compat_3_brand = "CloudABI", }; Modified: head/sys/conf/files.arm64 ============================================================================== --- head/sys/conf/files.arm64 Thu Oct 22 10:57:15 2015 (r289751) +++ head/sys/conf/files.arm64 Thu Oct 22 11:09:25 2015 (r289752) @@ -53,6 +53,7 @@ arm64/arm64/vm_machdep.c standard arm64/cavium/thunder_pcie.c optional soc_cavm_thunderx pci fdt arm64/cavium/thunder_pcie_pem.c optional soc_cavm_thunderx pci arm64/cavium/thunder_pcie_common.c optional soc_cavm_thunderx pci +arm64/cloudabi64/cloudabi64_sysvec.c optional compat_cloudabi64 crypto/blowfish/bf_enc.c optional crypto | ipsec crypto/des/des_enc.c optional crypto | ipsec | netsmb dev/acpica/acpi_if.m optional acpi Modified: head/sys/modules/Makefile ============================================================================== --- head/sys/modules/Makefile Thu Oct 22 10:57:15 2015 (r289751) +++ head/sys/modules/Makefile Thu Oct 22 11:09:25 2015 (r289752) @@ -633,7 +633,6 @@ _x86bios= x86bios .endif .if ${MACHINE_CPUARCH} == "amd64" -_cloudabi64= cloudabi64 _ioat= ioat _ixl= ixl _ixlv= ixlv @@ -749,6 +748,10 @@ _zfs= zfs .endif .endif +.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" +_cloudabi64= cloudabi64 +.endif + .endif SUBDIR+=${MODULES_EXTRA} _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"