diff --git a/Docker/Dockerfile.e2e b/Docker/Dockerfile.e2e index dc7a8b1bd..a8c7fbcbf 100644 --- a/Docker/Dockerfile.e2e +++ b/Docker/Dockerfile.e2e @@ -105,7 +105,7 @@ RUN rustup component add rust-src --toolchain nightly-2026-02-11-x86_64-unknown- # Build lind-boot FROM base as build-lind-boot # NOTE: Using 'make' risks cache invalidation on unrelated Makefile changes -COPY --parents src/lind-boot src/wasmtime src/rawposix src/cage src/threei src/typemap src/fdtables src/sysdefs Makefile rust-toolchain.toml . +COPY --parents src/lind-boot src/wasmtime src/rawposix src/cage src/threei src/typemap src/fdtables src/sysdefs src/glibc scripts Makefile rust-toolchain.toml . RUN rm -f src/wasmtime/crates/cage \ src/wasmtime/crates/threei \ src/wasmtime/crates/fdtables \ @@ -126,7 +126,7 @@ FROM base AS build-glibc # NOTE: Using 'make' risks cache invalidation on unrelated Makefile changes COPY scripts ./scripts COPY tools ./tools -COPY --parents src/glibc Makefile . +COPY --parents src/glibc src/sysdefs Makefile . COPY --from=build-lind-boot --parents build/lind-boot . RUN make sysroot \ && test -f lindfs/lib/libc.cwasm \ diff --git a/Makefile b/Makefile index 694abd000..7ddd362cb 100644 --- a/Makefile +++ b/Makefile @@ -22,19 +22,19 @@ LINDFS_DIRS := \ WITH_FPCAST ?= .PHONY: build -build: lindfs lind-boot sysroot +build: generate-syscall-mappings lindfs lind-boot sysroot @echo "Build complete" .PHONY: all all: build .PHONY: sysroot -sysroot: build-dir +sysroot: build-dir generate-syscall-mappings ./scripts/make_glibc_and_sysroot.sh $(if $(WITH_FPCAST),--with-fpcast) $(MAKE) sync-sysroot .PHONY: lind-boot -lind-boot: build-dir +lind-boot: build-dir generate-syscall-mappings # Build lind-boot with `--release` flag for faster runtime (e.g. for tests) cargo build --manifest-path src/lind-boot/Cargo.toml --release cp src/lind-boot/target/release/lind-boot $(LINDBOOT_BIN) @@ -50,14 +50,15 @@ lindfs: cp -rT scripts/lindfs-conf/usr/share/zoneinfo $(LINDFS_ROOT)/usr/share/zoneinfo .PHONY: lind-debug -lind-debug: lindfs build-dir +lind-debug: lindfs build-dir generate-syscall-mappings # Build lind-boot with the lind_debug feature enabled cargo build --manifest-path src/lind-boot/Cargo.toml --features lind_debug cp src/lind-boot/target/debug/lind-boot $(LINDBOOT_BIN) # Build glibc with LIND_DEBUG enabled (by setting the LIND_DEBUG variable) $(MAKE) build_glibc LIND_DEBUG=1 -build_glibc: + +build_glibc: generate-syscall-mappings # build sysroot passing -DLIND_DEBUG if LIND_DEBUG is set if [ "$(LIND_DEBUG)" = "1" ]; then \ echo "Building glibc with LIND_DEBUG enabled"; \ @@ -69,6 +70,10 @@ build_glibc: build-dir: mkdir -p $(BUILD_DIR) +.PHONY: generate-syscall-mappings +generate-syscall-mappings: build-dir + python3 scripts/generate_syscall_mappings.py + .PHONY: sync-sysroot sync-sysroot: $(RM) -r $(SYSROOT_DIR) diff --git a/docs/contribute/testing.md b/docs/contribute/testing.md index 454c04556..6f1ed9ecf 100644 --- a/docs/contribute/testing.md +++ b/docs/contribute/testing.md @@ -34,6 +34,7 @@ docker run --platform=linux/amd64 -v $(PWD):/lind -w /lind -it dev /bin/bash 5. Build toolchain (glibc and wasmtime) ``` # this may take a while ... +make generate-syscall-mappings make lind-boot sysroot ``` 6. Run the test suite diff --git a/docs/contribute/toolchain.md b/docs/contribute/toolchain.md index 6760a6df8..6fa24f2d0 100644 --- a/docs/contribute/toolchain.md +++ b/docs/contribute/toolchain.md @@ -35,7 +35,18 @@ options. Matching builtins are available in the *lind-wasm* repo under [`src/glibc/wasi`](https://github.com/Lind-Project/lind-wasm/tree/main/src/glibc/wasi). -3. __Build *glibc* and generate sysroot__ (see [`make sysroot`](https://github.com/Lind-Project/lind-wasm/blob/main/Makefile)) +3. __Generate syscall mappings__ (see [`make generate-syscall-mappings`](https://github.com/Lind-Project/lind-wasm/blob/main/Makefile)) + + Auto-generates syscall mapping constants from `src/glibc/lind_syscall/lind_syscall_num.h` + and produces `src/sysdefs/src/constants/syscall_const.rs`. This must run before building *lind-boot*, *glibc* and *wasmtime* to ensure Rust code has the correct syscall definitions. + + ```bash + python3 scripts/generate_syscall_mappings.py + ``` + + The source of truth is the Linux x86_64 syscall table as defined in the *glibc* header file. + +4. __Build *glibc* and generate sysroot__ (see [`make sysroot`](https://github.com/Lind-Project/lind-wasm/blob/main/Makefile)) 1. Configure and compile *glibc* for the *WASI* target with *Clang* 2. Compile extra files: @@ -51,10 +62,10 @@ options. along with headers and a pre-built C runtime into a sysroot directory structure as required by *Clang*. -4. __Build custom wasmtime__ (see [`make wasmtime`](https://github.com/Lind-Project/lind-wasm/blob/main/Makefile)) +5. __Build lind-boot__ (see [`make lind-boot`](https://github.com/Lind-Project/lind-wasm/blob/main/Makefile)) - Builds `src/wasmtime` workspace. Custom dependencies `fdtables`, `RawPOSIX` - and `sysdefs` are included in the build automatically. + Builds `src/lind-boot` workspace, which provides the *WebAssembly* runtime (`wasmtime`). + Custom dependencies `fdtables`, `RawPOSIX` and `sysdefs` are included in the build automatically. A customized `wasm-opt` binary is included in the *lind-wasm* repo under diff --git a/docs/getting-started.md b/docs/getting-started.md index a3b6c65e7..241facce3 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -38,9 +38,9 @@ EOF Lind-wasm runtime must be compiled before running the program. To compile the lind-wasm runtime, you will first go to the `lind-wasm/` directory. At there, you can choose: -3.a. use `make all` to compile both lind-glibc and rust code at once. +3.a. use `make all` to compile both lind-glibc and rust code at once. (this automatically generates syscall mappings) -3.b. use `make lind-boot` to compile runtime(lind-boot/wasmtime/rawposix/3i/etc.), and `make sysroot` to compile lind-glibc. +3.b. use `make generate-syscall-mappings` to auto-generate system call constants. Then use `make lind-boot` to compile runtime(lind-boot/wasmtime/rawposix/3i/etc.), and `make sysroot` to compile lind-glibc. **NOTES: More options can be found in lind-wasm/Makefile** diff --git a/scripts/generate_syscall_mappings.py b/scripts/generate_syscall_mappings.py new file mode 100644 index 000000000..83f85aec5 --- /dev/null +++ b/scripts/generate_syscall_mappings.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python3 +# Auto-generates syscall mapping constants for lind-wasm. +# +# Reads syscall definitions from glibc's lind_syscall_num.h and generates: +# - src/sysdefs/src/constants/syscall_const.rs (full set of syscalls) +# +# This script should be run before building lind-boot and glibc. +# +# Source of truth: src/glibc/lind_syscall/lind_syscall_num.h + +from __future__ import annotations + +import re +import sys +from pathlib import Path + + +def parse_c_header(header_path: str) -> dict[str, int]: + """Parse syscall constants from glibc's lind_syscall_num.h header file.""" + syscalls = {} + + try: + with open(header_path) as f: + content = f.read() + except FileNotFoundError: + print(f"Error: Could not find {header_path}", file=sys.stderr) + sys.exit(1) + + # Match #define SYSCALL_NAME number + pattern = r'#define\s+(\w+)\s+(\d+)' + + for match in re.finditer(pattern, content): + name, number = match.groups() + syscalls[name] = int(number) + + if not syscalls: + print(f"Error: Could not parse any syscalls from {header_path}", file=sys.stderr) + sys.exit(1) + + return syscalls + + +def generate_rust_constants(syscalls: dict[str, int]) -> str: + """Generate Rust constants for sysdefs/constants/syscall_const.rs.""" + lines = [ + "//! Syscall number constants for the Lind platform.", + "//!", + "//! Includes both standard Linux x86_64 syscalls and Lind-specific extensions:", + "//! - REGISTER_HANDLER_SYSCALL (1001)", + "//! - COPY_DATA_BETWEEN_CAGES_SYSCALL (1002)", + "//! - COPY_HANDLER_TABLE_TO_CAGE_SYSCALL (1003)", + "//!", + "//! Source of truth: Linux x86_64 syscall table", + "//! https://github.com/torvalds/linux/blob/v6.16-rc1/arch/x86/entry/syscalls/syscall_64.tbl", + "//! (Historical overview: https://filippo.io/linux-syscall-table/)", + "//!", + "//! Keep these in sync with glibc's lind_syscall_num.h and RawPOSIX dispatcher.", + "", + ] + + # Sort by syscall number for readability + sorted_syscalls = sorted(syscalls.items(), key=lambda x: x[1]) + + for name, number in sorted_syscalls: + lines.append(f"pub const {name}: i32 = {number};") + + lines.append("") + return "\n".join(lines) + + + + + +def write_file(path: str, content: str) -> None: + """Write content to file, creating directories if needed.""" + Path(path).parent.mkdir(parents=True, exist_ok=True) + with open(path, 'w') as f: + f.write(content) + print(f"Generated: {path}") + + +def main() -> None: + """Generate syscall mapping constants from glibc header.""" + # Find workspace root (should be run from lind-wasm directory) + workspace_root = Path(__file__).parent.parent + + c_header = workspace_root / "src/glibc/lind_syscall/lind_syscall_num.h" + rust_sysdefs_out = workspace_root / "src/sysdefs/src/constants/syscall_const.rs" + + print("Parsing syscall definitions...") + syscalls = parse_c_header(str(c_header)) + print(f"Found {len(syscalls)} syscall definitions") + + # Generate Rust constants for sysdefs + print("\nGenerating sysdefs constants...") + rust_content = generate_rust_constants(syscalls) + write_file(str(rust_sysdefs_out), rust_content) + + print("Done!") + + +if __name__ == "__main__": + main() diff --git a/src/glibc/lind_syscall/lind_syscall_num.h b/src/glibc/lind_syscall/lind_syscall_num.h index 6a24cd669..45d792eb2 100644 --- a/src/glibc/lind_syscall/lind_syscall_num.h +++ b/src/glibc/lind_syscall/lind_syscall_num.h @@ -16,8 +16,8 @@ #define WRITE_SYSCALL 1 #define OPEN_SYSCALL 2 #define CLOSE_SYSCALL 3 -#define XSTAT_SYSCALL 4 -#define FXSTAT_SYSCALL 5 +#define STAT_SYSCALL 4 +#define FSTAT_SYSCALL 5 #define LSTAT_SYSCALL 6 #define POLL_SYSCALL 7 @@ -46,7 +46,7 @@ #define DUP_SYSCALL 32 #define DUP2_SYSCALL 33 -#define NANOSLEEP_TIME64_SYSCALL 35 +#define NANOSLEEP_SYSCALL 35 #define SETITIMER_SYSCALL 38 #define GETPID_SYSCALL 39 @@ -69,7 +69,6 @@ #define CLONE_SYSCALL 56 #define FORK_SYSCALL 57 #define EXEC_SYSCALL 59 -#define EXECVE_SYSCALL 59 #define EXIT_SYSCALL 60 #define EXIT_GROUP_SYSCALL 231 #define WAITPID_SYSCALL 61 @@ -119,7 +118,7 @@ #define SYMLINKAT_SYSCALL 266 #define READLINKAT_SYSCALL 267 #define PPOLL_SYSCALL 271 -#define SYNC_FILE_RANGE 277 +#define SYNC_FILE_RANGE_SYSCALL 277 #define ACCEPT4_SYSCALL 288 #define EPOLL_CREATE1_SYSCALL 291 #define DUP3_SYSCALL 292 diff --git a/src/glibc/sysdeps/unix/sysv/linux/clock_nanosleep.c b/src/glibc/sysdeps/unix/sysv/linux/clock_nanosleep.c index 379678a1c..034109db1 100644 --- a/src/glibc/sysdeps/unix/sysv/linux/clock_nanosleep.c +++ b/src/glibc/sysdeps/unix/sysv/linux/clock_nanosleep.c @@ -38,6 +38,6 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, uint64_t host_req = TRANSLATE_GUEST_POINTER_TO_HOST (req); uint64_t host_rem = TRANSLATE_GUEST_POINTER_TO_HOST (rem); return MAKE_LEGACY_SYSCALL ( - NANOSLEEP_TIME64_SYSCALL, "syscall|nanosleep", (uint64_t) clock_id, + NANOSLEEP_SYSCALL, "syscall|nanosleep", (uint64_t) clock_id, (uint64_t) flags, host_req, host_rem, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); } diff --git a/src/glibc/sysdeps/unix/sysv/linux/fstat.c b/src/glibc/sysdeps/unix/sysv/linux/fstat.c index 625e73921..03bcfaa52 100644 --- a/src/glibc/sysdeps/unix/sysv/linux/fstat.c +++ b/src/glibc/sysdeps/unix/sysv/linux/fstat.c @@ -36,7 +36,7 @@ __fstat (int fd, struct stat *buf) uint64_t host_buf = TRANSLATE_GUEST_POINTER_TO_HOST (buf); - return MAKE_LEGACY_SYSCALL (FXSTAT_SYSCALL, "syscall|fstat", (uint64_t) fd, + return MAKE_LEGACY_SYSCALL (FSTAT_SYSCALL, "syscall|fstat", (uint64_t) fd, host_buf, NOTUSED, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); } diff --git a/src/glibc/sysdeps/unix/sysv/linux/fstat64.c b/src/glibc/sysdeps/unix/sysv/linux/fstat64.c index 069c288b2..bac0e1e9e 100644 --- a/src/glibc/sysdeps/unix/sysv/linux/fstat64.c +++ b/src/glibc/sysdeps/unix/sysv/linux/fstat64.c @@ -31,7 +31,7 @@ int __fstat64_time64 (int fd, struct __stat64_t64 *buf) { - return MAKE_LEGACY_SYSCALL(FXSTAT_SYSCALL, "syscall|fstat", (uint64_t)fd, (uint64_t) TRANSLATE_GUEST_POINTER_TO_HOST(buf), NOTUSED, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); + return MAKE_LEGACY_SYSCALL(FSTAT_SYSCALL, "syscall|fstat", (uint64_t)fd, (uint64_t) TRANSLATE_GUEST_POINTER_TO_HOST(buf), NOTUSED, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); } #if __TIMESIZE != 64 hidden_def (__fstat64_time64) @@ -45,7 +45,7 @@ hidden_def (__fstat64_time64) } // Added MAKE_SYSCALL macro to interface with Lind - Qianxi Chen uint64_t host_buf = TRANSLATE_GUEST_POINTER_TO_HOST (buf); - return MAKE_LEGACY_SYSCALL (FXSTAT_SYSCALL, "syscall|fstat", (uint64_t) fd, + return MAKE_LEGACY_SYSCALL (FSTAT_SYSCALL, "syscall|fstat", (uint64_t) fd, host_buf, NOTUSED, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); } #endif diff --git a/src/glibc/sysdeps/unix/sysv/linux/fxstat.c b/src/glibc/sysdeps/unix/sysv/linux/fxstat.c index c53103e58..571bde1d9 100644 --- a/src/glibc/sysdeps/unix/sysv/linux/fxstat.c +++ b/src/glibc/sysdeps/unix/sysv/linux/fxstat.c @@ -35,7 +35,7 @@ int __fxstat (int vers, int fd, struct stat *buf) { uint64_t host_buf = TRANSLATE_GUEST_POINTER_TO_HOST (buf); - return MAKE_LEGACY_SYSCALL (FXSTAT_SYSCALL, "syscall|fxstat", (uint64_t) vers, + return MAKE_LEGACY_SYSCALL (FSTAT_SYSCALL, "syscall|fstat", (uint64_t) vers, (uint64_t) fd, host_buf, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); } diff --git a/src/glibc/sysdeps/unix/sysv/linux/fxstat64.c b/src/glibc/sysdeps/unix/sysv/linux/fxstat64.c index 264fe87db..829782737 100644 --- a/src/glibc/sysdeps/unix/sysv/linux/fxstat64.c +++ b/src/glibc/sysdeps/unix/sysv/linux/fxstat64.c @@ -37,7 +37,7 @@ int ___fxstat64 (int vers, int fd, struct stat64 *buf) { uint64_t host_buf = TRANSLATE_GUEST_POINTER_TO_HOST (buf); - return MAKE_LEGACY_SYSCALL (FXSTAT_SYSCALL, "syscall|fxstat", (uint64_t) vers, + return MAKE_LEGACY_SYSCALL (FSTAT_SYSCALL, "syscall|fstat", (uint64_t) vers, (uint64_t) fd, host_buf, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); } diff --git a/src/glibc/sysdeps/unix/sysv/linux/i386/execve.c b/src/glibc/sysdeps/unix/sysv/linux/i386/execve.c index 9544c2de0..ab745ade5 100644 --- a/src/glibc/sysdeps/unix/sysv/linux/i386/execve.c +++ b/src/glibc/sysdeps/unix/sysv/linux/i386/execve.c @@ -44,7 +44,7 @@ int __execve (const char *__path, char *const __argv[], char *const __envp[]) uint64_t host_argv_ptr = TRANSLATE_GUEST_POINTER_TO_HOST(host_argv); uint64_t host_envp_ptr = TRANSLATE_GUEST_POINTER_TO_HOST(host_envp); - return MAKE_LEGACY_SYSCALL(EXECVE_SYSCALL, "syscall|execve", host_path, host_argv_ptr, host_envp_ptr, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); + return MAKE_LEGACY_SYSCALL(EXEC_SYSCALL, "syscall|execve", host_path, host_argv_ptr, host_envp_ptr, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); } strong_alias (__execve, execve) libc_hidden_def (__execve) diff --git a/src/glibc/sysdeps/unix/sysv/linux/lstat64.c b/src/glibc/sysdeps/unix/sysv/linux/lstat64.c index 77c958b95..9aeb16ad5 100644 --- a/src/glibc/sysdeps/unix/sysv/linux/lstat64.c +++ b/src/glibc/sysdeps/unix/sysv/linux/lstat64.c @@ -30,10 +30,10 @@ int __lstat64_time64 (const char *file, struct __stat64_t64 *buf) { // BUG: we do not have fstatat syscall in rawposix - // so let's just use xstat - Qianxi Chen + // so let's just use stat - Qianxi Chen uint64_t host_file = TRANSLATE_GUEST_POINTER_TO_HOST (file); uint64_t host_buf = TRANSLATE_GUEST_POINTER_TO_HOST (buf); - return MAKE_LEGACY_SYSCALL (XSTAT_SYSCALL, "syscall|xstat", + return MAKE_LEGACY_SYSCALL (STAT_SYSCALL, "syscall|stat", host_file, host_buf, NOTUSED, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); } @@ -45,7 +45,7 @@ __lstat64 (const char *file, struct stat64 *buf) { uint64_t host_file = TRANSLATE_GUEST_POINTER_TO_HOST (file); uint64_t host_buf = TRANSLATE_GUEST_POINTER_TO_HOST (buf); - return MAKE_LEGACY_SYSCALL (XSTAT_SYSCALL, "syscall|xstat", + return MAKE_LEGACY_SYSCALL (STAT_SYSCALL, "syscall|stat", host_file, host_buf, NOTUSED, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); } diff --git a/src/glibc/sysdeps/unix/sysv/linux/stat.c b/src/glibc/sysdeps/unix/sysv/linux/stat.c index ffae56eb1..f86f9e7aa 100644 --- a/src/glibc/sysdeps/unix/sysv/linux/stat.c +++ b/src/glibc/sysdeps/unix/sysv/linux/stat.c @@ -29,7 +29,7 @@ __stat (const char *fd, struct stat *buf) uint64_t host_fd = TRANSLATE_GUEST_POINTER_TO_HOST (fd); uint64_t host_buf = TRANSLATE_GUEST_POINTER_TO_HOST (buf); - return MAKE_LEGACY_SYSCALL (XSTAT_SYSCALL, "syscall|xstat", + return MAKE_LEGACY_SYSCALL (STAT_SYSCALL, "syscall|stat", host_fd, host_buf, NOTUSED, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); } diff --git a/src/glibc/sysdeps/unix/sysv/linux/stat64.c b/src/glibc/sysdeps/unix/sysv/linux/stat64.c index 8079276bb..007be3ff8 100644 --- a/src/glibc/sysdeps/unix/sysv/linux/stat64.c +++ b/src/glibc/sysdeps/unix/sysv/linux/stat64.c @@ -30,10 +30,10 @@ int __stat64_time64 (const char *file, struct __stat64_t64 *buf) { // BUG: we do not have fstatat syscall in rawposix - // so let's just use xstat - Qianxi Chen + // so let's just use stat - Qianxi Chen uint64_t host_file = TRANSLATE_GUEST_POINTER_TO_HOST (file); uint64_t host_buf = TRANSLATE_GUEST_POINTER_TO_HOST (buf); - return MAKE_LEGACY_SYSCALL (XSTAT_SYSCALL, "syscall|xstat", + return MAKE_LEGACY_SYSCALL (STAT_SYSCALL, "syscall|stat", host_file, host_buf, NOTUSED, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); } @@ -45,7 +45,7 @@ __stat64 (const char *file, struct stat64 *buf) { uint64_t host_file = TRANSLATE_GUEST_POINTER_TO_HOST (file); uint64_t host_buf = TRANSLATE_GUEST_POINTER_TO_HOST (buf); - return MAKE_LEGACY_SYSCALL (XSTAT_SYSCALL, "syscall|xstat", + return MAKE_LEGACY_SYSCALL (STAT_SYSCALL, "syscall|stat", host_file, host_buf, NOTUSED, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); } diff --git a/src/glibc/sysdeps/unix/sysv/linux/sync_file_range.c b/src/glibc/sysdeps/unix/sysv/linux/sync_file_range.c index e43bd124f..5f2fddb9c 100644 --- a/src/glibc/sysdeps/unix/sysv/linux/sync_file_range.c +++ b/src/glibc/sysdeps/unix/sysv/linux/sync_file_range.c @@ -24,5 +24,5 @@ int sync_file_range (int fd, __off64_t offset, __off64_t len, unsigned int flags) { - return MAKE_LEGACY_SYSCALL(SYNC_FILE_RANGE, "syscall|sync_file_range", (uint64_t) fd, (uint64_t) offset, (uint64_t) len, (uint64_t) flags, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); + return MAKE_LEGACY_SYSCALL(SYNC_FILE_RANGE_SYSCALL, "syscall|sync_file_range", (uint64_t) fd, (uint64_t) offset, (uint64_t) len, (uint64_t) flags, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); } diff --git a/src/glibc/sysdeps/unix/sysv/linux/xstat.c b/src/glibc/sysdeps/unix/sysv/linux/xstat.c index eff05599a..b94d5ec77 100644 --- a/src/glibc/sysdeps/unix/sysv/linux/xstat.c +++ b/src/glibc/sysdeps/unix/sysv/linux/xstat.c @@ -36,7 +36,7 @@ __xstat (int vers, const char *name, struct stat *buf) { uint64_t host_name = TRANSLATE_GUEST_POINTER_TO_HOST (name); uint64_t host_buf = TRANSLATE_GUEST_POINTER_TO_HOST (buf); - return MAKE_LEGACY_SYSCALL (XSTAT_SYSCALL, "syscall|xstat", (uint64_t) vers, + return MAKE_LEGACY_SYSCALL (STAT_SYSCALL, "syscall|stat", (uint64_t) vers, host_name, host_buf, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); } diff --git a/src/glibc/sysdeps/unix/sysv/linux/xstat64.c b/src/glibc/sysdeps/unix/sysv/linux/xstat64.c index a3a508693..cb809e911 100644 --- a/src/glibc/sysdeps/unix/sysv/linux/xstat64.c +++ b/src/glibc/sysdeps/unix/sysv/linux/xstat64.c @@ -39,7 +39,7 @@ ___xstat64 (int vers, const char *name, struct stat64 *buf) uint64_t host_name = TRANSLATE_GUEST_POINTER_TO_HOST (name); uint64_t host_buf = TRANSLATE_GUEST_POINTER_TO_HOST (buf); - return MAKE_LEGACY_SYSCALL(XSTAT_SYSCALL, "syscall|xstat", (uint64_t) vers, host_name, host_buf, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); + return MAKE_LEGACY_SYSCALL(STAT_SYSCALL, "syscall|stat", (uint64_t) vers, host_name, host_buf, NOTUSED, NOTUSED, NOTUSED, TRANSLATE_ERRNO_ON); } #if XSTAT_IS_XSTAT64 diff --git a/src/sysdefs/src/constants/syscall_const.rs b/src/sysdefs/src/constants/syscall_const.rs index 3d896277a..d38b5e971 100644 --- a/src/sysdefs/src/constants/syscall_const.rs +++ b/src/sysdefs/src/constants/syscall_const.rs @@ -1,5 +1,10 @@ //! Syscall number constants for the Lind platform. //! +//! Includes both standard Linux x86_64 syscalls and Lind-specific extensions: +//! - REGISTER_HANDLER_SYSCALL (1001) +//! - COPY_DATA_BETWEEN_CAGES_SYSCALL (1002) +//! - COPY_HANDLER_TABLE_TO_CAGE_SYSCALL (1003) +//! //! Source of truth: Linux x86_64 syscall table //! https://github.com/torvalds/linux/blob/v6.16-rc1/arch/x86/entry/syscalls/syscall_64.tbl //! (Historical overview: https://filippo.io/linux-syscall-table/) @@ -91,8 +96,8 @@ pub const FSTATFS_SYSCALL: i32 = 138; pub const GETHOSTNAME_SYSCALL: i32 = 170; pub const FUTEX_SYSCALL: i32 = 202; pub const EPOLL_CREATE_SYSCALL: i32 = 213; -pub const EXIT_GROUP_SYSCALL: i32 = 231; pub const CLOCK_GETTIME_SYSCALL: i32 = 228; +pub const EXIT_GROUP_SYSCALL: i32 = 231; pub const EPOLL_WAIT_SYSCALL: i32 = 232; pub const EPOLL_CTL_SYSCALL: i32 = 233; pub const OPENAT_SYSCALL: i32 = 257; @@ -102,10 +107,13 @@ pub const READLINKAT_SYSCALL: i32 = 267; pub const PPOLL_SYSCALL: i32 = 271; pub const SYNC_FILE_RANGE_SYSCALL: i32 = 277; pub const ACCEPT4_SYSCALL: i32 = 288; -pub const PREADV_SYSCALL: i32 = 295; -pub const PWRITEV_SYSCALL: i32 = 296; -pub const PRLIMIT64_SYSCALL: i32 = 302; pub const EPOLL_CREATE1_SYSCALL: i32 = 291; pub const DUP3_SYSCALL: i32 = 292; pub const PIPE2_SYSCALL: i32 = 293; +pub const PREADV_SYSCALL: i32 = 295; +pub const PWRITEV_SYSCALL: i32 = 296; +pub const PRLIMIT64_SYSCALL: i32 = 302; pub const GETRANDOM_SYSCALL: i32 = 318; +pub const REGISTER_HANDLER_SYSCALL: i32 = 1001; +pub const COPY_DATA_BETWEEN_CAGES_SYSCALL: i32 = 1002; +pub const COPY_HANDLER_TABLE_TO_CAGE_SYSCALL: i32 = 1003;