XNU as a loadable kernel module inside Linux (macOS personality for arm64 Linux)
C
From: xnulinux
Subject: [PATCH] linux64: the host-file md disk calls the host through linux64_call2
memdev.c had its own copy of the call into the host (mdev_host_call: the `blr` and its list of registers the call
does not keep), from before linux64.h had linux64_call2. The list now also names the FP/SIMD registers, which the host
does not keep (linux64.h); a second copy of it would have to follow every such change. The disk's two calls
(LINUX64_CALL_RAMDISK_SIZE, LINUX64_CALL_RAMDISK_RW) go through linux64_call2 like every other host call.
---
--- a/bsd/dev/memdev.c
+++ b/bsd/dev/memdev.c
@@ -194,13 +194,8 @@ struct mdev_host_req { uint64_t write, off, len; void *buf; long result; }; /* t
static long
mdev_host_call(unsigned long stage, unsigned long arg)
{
- register unsigned long x0 __asm__("x0") = stage;
- register unsigned long x1 __asm__("x1") = arg;
- register unsigned long x2 __asm__("x2") = 0;
- __asm__ volatile ("blr %3" : "+r"(x0), "+r"(x1), "+r"(x2) : "r"(linux64_hook)
- : "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10", "x11", "x12", "x13",
- "x14", "x15", "x16", "x17", "x30", "cc", "memory");
- return (long)x0;
+ /* through linux64_call2, which says what a host call does not keep (the FP/SIMD registers too) */
+ return (long)linux64_call2((enum linux64_call)stage, arg, 0);
}
static int