diff --git a/.github/workflows/smoke-soak.yml b/.github/workflows/smoke-soak.yml index c70a7839..250d9403 100644 --- a/.github/workflows/smoke-soak.yml +++ b/.github/workflows/smoke-soak.yml @@ -106,7 +106,7 @@ jobs: with: # The fork/exec surface PR #206 introduced and epic #501 is # actively de-risking, plus the reproducer harness itself — a - # change to `scripts/repro-fork.sh`, `userspace/repro_fork/`, + # change to `scripts/repro-fork.sh`, `tests/userspace/repro_fork/`, # or the `repro-fork` xtask subcommand could silently # invalidate the soak, so it must trigger too. # Deliberately does NOT include this workflow file — a @@ -120,7 +120,7 @@ jobs: - 'kernel/src/process/**' - 'xtask/src/main.rs' - 'scripts/repro-fork.sh' - - 'userspace/repro_fork/**' + - 'tests/userspace/repro_fork/**' - name: Decide id: decide diff --git a/Cargo.toml b/Cargo.toml index 5c8b1bef..fd2df575 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,16 +16,16 @@ members = [ # dispatches to its `bench-page-cache` binary. "bench/page-cache", "xtask", - "userspace/hello", - "userspace/init", - "userspace/pjdfstest_runner", - "userspace/repro_fork", - "userspace/shell_pipeline", - "userspace/vibix_abi", - "userspace/vibix_libc", - "userspace/vibix_libc_defs", - "userspace/ld_vibix", - "userspace/hello_dyn", + "base/init", + "base/vibix_abi", + "base/vibix_libc", + "base/vibix_libc_defs", + "base/ld_vibix", + "tests/userspace/hello", + "tests/userspace/hello_dyn", + "tests/userspace/pjdfstest_runner", + "tests/userspace/repro_fork", + "tests/userspace/shell_pipeline", ] # tests/pjdfstest is a vendored copy of saidsay-so/pjdfstest (2-clause BSD). It # is intentionally kept outside the workspace until #581 wires it into xtask — @@ -38,7 +38,7 @@ members = [ # `host-fuzz` feature; pulling it into the workspace would force the host # feature surface on the kernel-target build graph. `cargo xtask fuzz ext2` # drives it directly. -exclude = ["tests/pjdfstest", "kernel/fuzz", "userspace/std_hello"] +exclude = ["tests/pjdfstest", "kernel/fuzz", "tests/userspace/std_hello"] resolver = "2" [workspace.package] diff --git a/userspace/init/Cargo.toml b/base/init/Cargo.toml similarity index 100% rename from userspace/init/Cargo.toml rename to base/init/Cargo.toml diff --git a/userspace/init/link.ld b/base/init/link.ld similarity index 100% rename from userspace/init/link.ld rename to base/init/link.ld diff --git a/userspace/init/src/main.rs b/base/init/src/main.rs similarity index 100% rename from userspace/init/src/main.rs rename to base/init/src/main.rs diff --git a/userspace/ld_vibix/Cargo.toml b/base/ld_vibix/Cargo.toml similarity index 100% rename from userspace/ld_vibix/Cargo.toml rename to base/ld_vibix/Cargo.toml diff --git a/userspace/ld_vibix/link.ld b/base/ld_vibix/link.ld similarity index 100% rename from userspace/ld_vibix/link.ld rename to base/ld_vibix/link.ld diff --git a/userspace/ld_vibix/src/elf.rs b/base/ld_vibix/src/elf.rs similarity index 100% rename from userspace/ld_vibix/src/elf.rs rename to base/ld_vibix/src/elf.rs diff --git a/userspace/ld_vibix/src/main.rs b/base/ld_vibix/src/main.rs similarity index 100% rename from userspace/ld_vibix/src/main.rs rename to base/ld_vibix/src/main.rs diff --git a/userspace/ld_vibix/src/reloc.rs b/base/ld_vibix/src/reloc.rs similarity index 100% rename from userspace/ld_vibix/src/reloc.rs rename to base/ld_vibix/src/reloc.rs diff --git a/userspace/ld_vibix/src/serial.rs b/base/ld_vibix/src/serial.rs similarity index 100% rename from userspace/ld_vibix/src/serial.rs rename to base/ld_vibix/src/serial.rs diff --git a/userspace/lib/ld-musl-x86_64.so.1 b/base/lib/ld-musl-x86_64.so.1 similarity index 100% rename from userspace/lib/ld-musl-x86_64.so.1 rename to base/lib/ld-musl-x86_64.so.1 diff --git a/userspace/vibix_abi/Cargo.toml b/base/vibix_abi/Cargo.toml similarity index 100% rename from userspace/vibix_abi/Cargo.toml rename to base/vibix_abi/Cargo.toml diff --git a/userspace/vibix_abi/src/alloc.rs b/base/vibix_abi/src/alloc.rs similarity index 100% rename from userspace/vibix_abi/src/alloc.rs rename to base/vibix_abi/src/alloc.rs diff --git a/userspace/vibix_abi/src/errno.rs b/base/vibix_abi/src/errno.rs similarity index 100% rename from userspace/vibix_abi/src/errno.rs rename to base/vibix_abi/src/errno.rs diff --git a/userspace/vibix_abi/src/fs.rs b/base/vibix_abi/src/fs.rs similarity index 100% rename from userspace/vibix_abi/src/fs.rs rename to base/vibix_abi/src/fs.rs diff --git a/userspace/vibix_abi/src/futex.rs b/base/vibix_abi/src/futex.rs similarity index 100% rename from userspace/vibix_abi/src/futex.rs rename to base/vibix_abi/src/futex.rs diff --git a/userspace/vibix_abi/src/lib.rs b/base/vibix_abi/src/lib.rs similarity index 100% rename from userspace/vibix_abi/src/lib.rs rename to base/vibix_abi/src/lib.rs diff --git a/userspace/vibix_abi/src/process.rs b/base/vibix_abi/src/process.rs similarity index 100% rename from userspace/vibix_abi/src/process.rs rename to base/vibix_abi/src/process.rs diff --git a/userspace/vibix_abi/src/stdio.rs b/base/vibix_abi/src/stdio.rs similarity index 100% rename from userspace/vibix_abi/src/stdio.rs rename to base/vibix_abi/src/stdio.rs diff --git a/userspace/vibix_abi/src/syscall.rs b/base/vibix_abi/src/syscall.rs similarity index 100% rename from userspace/vibix_abi/src/syscall.rs rename to base/vibix_abi/src/syscall.rs diff --git a/userspace/vibix_abi/src/thread.rs b/base/vibix_abi/src/thread.rs similarity index 100% rename from userspace/vibix_abi/src/thread.rs rename to base/vibix_abi/src/thread.rs diff --git a/userspace/vibix_libc/Cargo.toml b/base/vibix_libc/Cargo.toml similarity index 100% rename from userspace/vibix_libc/Cargo.toml rename to base/vibix_libc/Cargo.toml diff --git a/userspace/vibix_libc/src/errno.rs b/base/vibix_libc/src/errno.rs similarity index 100% rename from userspace/vibix_libc/src/errno.rs rename to base/vibix_libc/src/errno.rs diff --git a/userspace/vibix_libc/src/fcntl.rs b/base/vibix_libc/src/fcntl.rs similarity index 100% rename from userspace/vibix_libc/src/fcntl.rs rename to base/vibix_libc/src/fcntl.rs diff --git a/userspace/vibix_libc/src/helpers.rs b/base/vibix_libc/src/helpers.rs similarity index 100% rename from userspace/vibix_libc/src/helpers.rs rename to base/vibix_libc/src/helpers.rs diff --git a/userspace/vibix_libc/src/lib.rs b/base/vibix_libc/src/lib.rs similarity index 100% rename from userspace/vibix_libc/src/lib.rs rename to base/vibix_libc/src/lib.rs diff --git a/userspace/vibix_libc/src/stat.rs b/base/vibix_libc/src/stat.rs similarity index 100% rename from userspace/vibix_libc/src/stat.rs rename to base/vibix_libc/src/stat.rs diff --git a/userspace/vibix_libc/src/unistd.rs b/base/vibix_libc/src/unistd.rs similarity index 100% rename from userspace/vibix_libc/src/unistd.rs rename to base/vibix_libc/src/unistd.rs diff --git a/userspace/vibix_libc_defs/Cargo.toml b/base/vibix_libc_defs/Cargo.toml similarity index 100% rename from userspace/vibix_libc_defs/Cargo.toml rename to base/vibix_libc_defs/Cargo.toml diff --git a/userspace/vibix_libc_defs/src/lib.rs b/base/vibix_libc_defs/src/lib.rs similarity index 100% rename from userspace/vibix_libc_defs/src/lib.rs rename to base/vibix_libc_defs/src/lib.rs diff --git a/docs/RFC/0009-std-on-vibix.md b/docs/RFC/0009-std-on-vibix.md index 639dc101..4a2fe367 100644 --- a/docs/RFC/0009-std-on-vibix.md +++ b/docs/RFC/0009-std-on-vibix.md @@ -251,7 +251,7 @@ Key choices: #### vibix_abi crate structure ``` -userspace/vibix_abi/ +base/vibix_abi/ ├── Cargo.toml # #![no_std], no deps └── src/ ├── lib.rs # pub mod syscall, alloc, thread, ... @@ -268,7 +268,7 @@ userspace/vibix_abi/ #### vibix_libc crate structure ``` -userspace/vibix_libc/ +base/vibix_libc/ ├── Cargo.toml # cdylib + staticlib, depends on vibix_abi ├── cbindgen.toml # generates libc-compatible C headers └── src/ @@ -599,7 +599,7 @@ Porting it to vibix would give immediate ecosystem compatibility. musl introduces 100K lines of C that must be audited, cross-compiled, and maintained. The Rust-based approach (`vibix_libc`) is smaller, memory-safe, and can share syscall stubs with `vibix_abi`. The -`ld-musl-x86_64.so.1` already present in `userspace/lib/` was +`ld-musl-x86_64.so.1` already present in `base/lib/` was shipped for PT_INTERP testing (#762), not as a long-term libc strategy. diff --git a/docs/design/dst-478-investigation.md b/docs/design/dst-478-investigation.md index 002305f0..15ed4cc8 100644 --- a/docs/design/dst-478-investigation.md +++ b/docs/design/dst-478-investigation.md @@ -17,7 +17,7 @@ on the failure being scheduler-driven rather than hardware-fault-driven. [#478](https://github.com/dburkart/vibix/issues/478)'s production evidence is unambiguous about the failure shape: the kernel emits `init: iretq to ring-3` to the serial port, then **no userspace output -ever appears**. In particular, the `userspace/init/src/main.rs::_start` +ever appears**. In particular, the `base/init/src/main.rs::_start` diagnostic markers `init: pre-write marker` (a `write(2, …)` immediately on entry, before any other userspace work) never appear in failing runs. That makes the failure window strictly the gap between IRETQ @@ -175,5 +175,5 @@ analogue of #478. [`kernel/src/arch/x86_64/syscall.rs`](../../kernel/src/arch/x86_64/syscall.rs) `jump_to_ring3` — the kernel-side seam the trap-frame surface would intercept. -- [`userspace/init/src/main.rs`](../../userspace/init/src/main.rs) +- [`base/init/src/main.rs`](../../base/init/src/main.rs) `_start` (~line 103) — the userspace side of the failure window. diff --git a/docs/repros/fork-loop.md b/docs/repros/fork-loop.md index 55840dba..71d35774 100644 --- a/docs/repros/fork-loop.md +++ b/docs/repros/fork-loop.md @@ -9,7 +9,7 @@ reproducer. ## What it does -Replaces PID 1 with a userspace binary (`userspace/repro_fork/`) that runs +Replaces PID 1 with a userspace binary (`tests/userspace/repro_fork/`) that runs a tight `fork → child execve → parent wait4` loop for `CYCLES` iterations (default 500). Every 50 cycles it writes `repro: cycle K alive` to serial; every cycle it reads the TSC before and after and prints a watchdog @@ -72,7 +72,7 @@ exits 0. Failure: any of — to a large value for soak runs. (Implemented as `option_env!` inside the binary, so cargo rebuilds when the value changes.) - The per-cycle TSC budget is a compile-time constant - (`STALL_TSC_BUDGET` in `userspace/repro_fork/src/main.rs`). Bump it + (`STALL_TSC_BUDGET` in `tests/userspace/repro_fork/src/main.rs`). Bump it if unaccelerated CI QEMU is hitting spurious watchdog trips on a healthy kernel. @@ -105,7 +105,7 @@ invocation per iteration, with `SOAK_COUNT` iterations per job run Nightly `schedule` and manual `workflow_dispatch` runs exercise this path today; the `pull_request` trigger is still gated off while the fork flake is live (see #517). Changes to this harness — either the -wrapper script or `userspace/repro_fork/` — trigger the workflow's +wrapper script or `tests/userspace/repro_fork/` — trigger the workflow's path filter so the soak runs on any PR that touches them. The harness amplifies opportunity to hit the hang; whether it trips diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 51f334b7..1209bc83 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -79,7 +79,7 @@ hermit-abi = { version = "0.5.0", features = [ ], public = true } [target.'cfg(target_os = "vibix")'.dependencies] -vibix_abi = { path = "../../userspace/vibix_abi", features = [ +vibix_abi = { path = "../../base/vibix_abi", features = [ 'rustc-dep-of-std', ] } diff --git a/userspace/hello/Cargo.toml b/tests/userspace/hello/Cargo.toml similarity index 100% rename from userspace/hello/Cargo.toml rename to tests/userspace/hello/Cargo.toml diff --git a/userspace/hello/link.ld b/tests/userspace/hello/link.ld similarity index 100% rename from userspace/hello/link.ld rename to tests/userspace/hello/link.ld diff --git a/userspace/hello/src/main.rs b/tests/userspace/hello/src/main.rs similarity index 100% rename from userspace/hello/src/main.rs rename to tests/userspace/hello/src/main.rs diff --git a/userspace/hello_dyn/Cargo.toml b/tests/userspace/hello_dyn/Cargo.toml similarity index 85% rename from userspace/hello_dyn/Cargo.toml rename to tests/userspace/hello_dyn/Cargo.toml index 112f437d..a48a74ba 100644 --- a/userspace/hello_dyn/Cargo.toml +++ b/tests/userspace/hello_dyn/Cargo.toml @@ -11,4 +11,4 @@ name = "userspace_hello_dyn" path = "src/main.rs" [dependencies] -vibix_libc = { path = "../vibix_libc" } +vibix_libc = { path = "../../../base/vibix_libc" } diff --git a/userspace/hello_dyn/link.ld b/tests/userspace/hello_dyn/link.ld similarity index 100% rename from userspace/hello_dyn/link.ld rename to tests/userspace/hello_dyn/link.ld diff --git a/userspace/hello_dyn/src/main.rs b/tests/userspace/hello_dyn/src/main.rs similarity index 100% rename from userspace/hello_dyn/src/main.rs rename to tests/userspace/hello_dyn/src/main.rs diff --git a/userspace/pjdfstest_runner/Cargo.toml b/tests/userspace/pjdfstest_runner/Cargo.toml similarity index 100% rename from userspace/pjdfstest_runner/Cargo.toml rename to tests/userspace/pjdfstest_runner/Cargo.toml diff --git a/userspace/pjdfstest_runner/link.ld b/tests/userspace/pjdfstest_runner/link.ld similarity index 100% rename from userspace/pjdfstest_runner/link.ld rename to tests/userspace/pjdfstest_runner/link.ld diff --git a/userspace/pjdfstest_runner/src/main.rs b/tests/userspace/pjdfstest_runner/src/main.rs similarity index 100% rename from userspace/pjdfstest_runner/src/main.rs rename to tests/userspace/pjdfstest_runner/src/main.rs diff --git a/userspace/repro_fork/Cargo.toml b/tests/userspace/repro_fork/Cargo.toml similarity index 100% rename from userspace/repro_fork/Cargo.toml rename to tests/userspace/repro_fork/Cargo.toml diff --git a/userspace/repro_fork/link.ld b/tests/userspace/repro_fork/link.ld similarity index 100% rename from userspace/repro_fork/link.ld rename to tests/userspace/repro_fork/link.ld diff --git a/userspace/repro_fork/src/main.rs b/tests/userspace/repro_fork/src/main.rs similarity index 100% rename from userspace/repro_fork/src/main.rs rename to tests/userspace/repro_fork/src/main.rs diff --git a/userspace/shell_pipeline/Cargo.toml b/tests/userspace/shell_pipeline/Cargo.toml similarity index 100% rename from userspace/shell_pipeline/Cargo.toml rename to tests/userspace/shell_pipeline/Cargo.toml diff --git a/userspace/shell_pipeline/link.ld b/tests/userspace/shell_pipeline/link.ld similarity index 100% rename from userspace/shell_pipeline/link.ld rename to tests/userspace/shell_pipeline/link.ld diff --git a/userspace/shell_pipeline/src/main.rs b/tests/userspace/shell_pipeline/src/main.rs similarity index 100% rename from userspace/shell_pipeline/src/main.rs rename to tests/userspace/shell_pipeline/src/main.rs diff --git a/userspace/std_hello/Cargo.toml b/tests/userspace/std_hello/Cargo.toml similarity index 100% rename from userspace/std_hello/Cargo.toml rename to tests/userspace/std_hello/Cargo.toml diff --git a/userspace/std_hello/src/main.rs b/tests/userspace/std_hello/src/main.rs similarity index 100% rename from userspace/std_hello/src/main.rs rename to tests/userspace/std_hello/src/main.rs diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 167feb50..a1fba4ee 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -577,13 +577,13 @@ fn build_userspace_binary(package: &str, link_ld: &str) -> R { } fn build_userspace_init() -> R { - build_userspace_binary("userspace_init", "userspace/init/link.ld") + build_userspace_binary("userspace_init", "base/init/link.ld") } /// Build the hello binary — the exec() target for the fork+exec+wait test. /// Links at 0x400000 (lower half) just like init so load_user_elf accepts it. fn build_userspace_hello() -> R { - build_userspace_binary("userspace_hello", "userspace/hello/link.ld") + build_userspace_binary("userspace_hello", "tests/userspace/hello/link.ld") } /// Build the fork-loop reproducer harness (issue #506). @@ -592,7 +592,7 @@ fn build_userspace_hello() -> R { /// this binary runs a tight fork+exec+wait loop as PID 1 to amplify the /// ~50 %-rate flake bisected to PR #206 into a deterministic repro. fn build_userspace_repro_fork() -> R { - build_userspace_binary("userspace_repro_fork", "userspace/repro_fork/link.ld") + build_userspace_binary("userspace_repro_fork", "tests/userspace/repro_fork/link.ld") } /// Build the shell-pipeline integration binary (issue #462). @@ -600,12 +600,12 @@ fn build_userspace_repro_fork() -> R { /// Shipped as `userspace_init.elf` when `cargo xtask shell-pipeline` is /// used — the binary internally simulates `echo foo | cat | wc -c` /// using pipe2/fork/dup2/close/wait4 and prints `SHELL_PIPELINE_OK: 4` -/// on success. See `userspace/shell_pipeline/src/main.rs` for the +/// on success. See `tests/userspace/shell_pipeline/src/main.rs` for the /// rationale on why all three pipeline stages live in one binary. fn build_userspace_shell_pipeline() -> R { build_userspace_binary( "userspace_shell_pipeline", - "userspace/shell_pipeline/link.ld", + "tests/userspace/shell_pipeline/link.ld", ) } @@ -614,7 +614,10 @@ fn build_userspace_shell_pipeline() -> R { /// `cargo xtask pjdfstest`. Same link layout as `userspace_init` so /// the kernel's ELF loader doesn't need any new code paths. pub(crate) fn build_pjdfstest_runner() -> R { - build_userspace_binary("pjdfstest_runner", "userspace/pjdfstest_runner/link.ld") + build_userspace_binary( + "pjdfstest_runner", + "tests/userspace/pjdfstest_runner/link.ld", + ) } /// Build the vibix dynamic linker (`ld-vibix.so`). @@ -624,7 +627,7 @@ pub(crate) fn build_pjdfstest_runner() -> R { /// Uses `-C relocation-model=pic` and `-C link-arg=-shared` to get /// position-independent code in a shared-object container. fn build_ld_vibix() -> R { - let link_ld = "userspace/ld_vibix/link.ld"; + let link_ld = "base/ld_vibix/link.ld"; let rustflags = [ &format!("-C link-arg=-T{link_ld}"), "-C relocation-model=pic", @@ -713,7 +716,7 @@ fn build_libc_so() -> R { /// The kernel loads ld-vibix.so and transfers control to it, which then /// processes relocations and jumps to this binary's entry point. fn build_userspace_hello_dyn() -> R { - let link_ld = "userspace/hello_dyn/link.ld"; + let link_ld = "tests/userspace/hello_dyn/link.ld"; let rustflags = [ &format!("-C link-arg=-T{link_ld}"), "-C relocation-model=pic", @@ -751,7 +754,7 @@ fn build_userspace_hello_dyn() -> R { fn build_userspace_std_hello() -> R { let ws = workspace_root(); let target_spec = ws.join(VIBIX_USERSPACE_TARGET); - let manifest = ws.join("userspace/std_hello/Cargo.toml"); + let manifest = ws.join("tests/userspace/std_hello/Cargo.toml"); let library_root = ws.join("library"); let target_dir = ws.join("target"); @@ -1283,7 +1286,7 @@ fn ensure_initrd() -> R { // DIRS headers + 4 file headers + (3 small + LDSO_BLOCKS) data blocks + 2 end blocks. const EXPECTED_SIZE: u64 = (DIRS.len() as u64 + 4 + 3 + LDSO_BLOCKS + 2) * 512; - let ldso_src = workspace_root().join("userspace/lib/ld-musl-x86_64.so.1"); + let ldso_src = workspace_root().join("base/lib/ld-musl-x86_64.so.1"); // Size + magic aren't sufficient — changing MOTD_PAYLOAD to another // equal-or-shorter string would leave the old payload on disk (same @@ -1551,7 +1554,7 @@ fn make_iso_inner( fs::copy(userspace_hello, iso_root.join("boot/userspace_hello.elf"))?; fs::copy(&initrd, iso_root.join("boot/rootfs.tar"))?; fs::copy( - workspace_root().join("userspace/lib/ld-musl-x86_64.so.1"), + workspace_root().join("base/lib/ld-musl-x86_64.so.1"), iso_root.join("boot/ld-musl-x86_64.so.1"), )?; // #764: stub dynamic-linker fixture for the dynlinker_stub integration test. @@ -2275,7 +2278,7 @@ fn repro_fork_build(opts: &BuildOpts) -> R { /// heartbeat-aware watchdog. Issue #506 / epic #501. /// /// Replaces `/boot/userspace_init.elf` in the ISO with the -/// `userspace_repro_fork` binary (see `userspace/repro_fork/`). That +/// `userspace_repro_fork` binary (see `tests/userspace/repro_fork/`). That /// binary runs `CYCLES` fork+exec+wait iterations, emitting /// `repro: cycle K alive` every 50 cycles and `repro: fork loop /// complete` on success. The loop in this function follows those @@ -3687,6 +3690,7 @@ repro: starting fork loop cycles=500 hb=50 fn repro_fork_default_cycles_is_500() { let source = std::fs::read_to_string( workspace_root() + .join("tests") .join("userspace") .join("repro_fork") .join("src") @@ -3701,7 +3705,7 @@ repro: starting fork loop cycles=500 hb=50 // timing budget / this test." assert!( source.contains("None => 500,"), - "userspace/repro_fork/src/main.rs must keep the default CYCLES=500; \ + "tests/userspace/repro_fork/src/main.rs must keep the default CYCLES=500; \ if you genuinely need to change this, also update \ .github/workflows/smoke-soak.yml timing budgets and issue #531's context" ); @@ -3720,6 +3724,7 @@ repro: starting fork loop cycles=500 hb=50 fn repro_fork_syscall_blocks_clobber_all_sysv_caller_saved() { let source = std::fs::read_to_string( workspace_root() + .join("tests") .join("userspace") .join("repro_fork") .join("src")