Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,16 @@ jobs:
# access since it loads files and runs LiteBox on a hosted platform.
#
# - `litebox_runner_linux_on_windows_userland` is allowed to have `std`
# access since it needs to actually access the file-system, pull in
# relevant files, and then actually trigger LiteBox itself.
# access since it is a hosted executable that connects to the broker
# and launches the LiteBox guest.
#
# - `litebox_runner_windows_on_linux_userland` is allowed to have `std`
# access since it needs to actually access the file-system, pull in
# relevant files, and then actually trigger LiteBox itself.
#
# - `litebox_runner_linux_userland` is allowed to have `std` access
# since it needs to actually access the file-system, pull in
# relevant files, and then actually trigger LiteBox itself.
# since it is a hosted executable that connects to the broker and
# launches the LiteBox guest.
#
# - `litebox_runner_windows_userland` is allowed to have `std` access
# since it needs to actually access the file-system, pull in
Expand Down
28 changes: 12 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 22 additions & 4 deletions dev_bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,16 @@ fn run_rewritten_hello_static(ctx: BenchCtx<'_>) -> Result<()> {
is_init,
lock_tracing,
} = ctx;
let tar_file = sh.current_dir().join("hello_static_rootfs.tar");
if is_init {
rewriter_hello_static(ctx.with_init(true))?;
rewriter_hello_static(ctx.with_init(false))?;
sh.remove_path(&tar_file)?;
cmd!(
sh,
"tar --format=ustar -cf {tar_file} hello_static_rewritten"
)
.run()?;
let features: &[&str] = if lock_tracing {
&["--features", "lock_tracing"]
} else {
Expand All @@ -463,11 +470,15 @@ fn run_rewritten_hello_static(ctx: BenchCtx<'_>) -> Result<()> {
"cargo build -p litebox_runner_linux_userland --release {features...}"
)
.run()?;
cmd!(sh, "cargo build -p litebox_broker_userland --release").run()?;
} else {
let broker = project_root.join("target/release/litebox-broker-userland");
let runner = project_root.join("target/release/litebox_runner_linux_userland");
cmd!(
sh,
"{project_root}/target/release/litebox_runner_linux_userland --unstable hello_static_rewritten"
).run()?;
"{broker} --fs-initial-files {tar_file} --runner {runner} /hello_static_rewritten"
)
.run()?;
}
Ok(())
}
Expand Down Expand Up @@ -586,9 +597,13 @@ fn run_rewritten_node(ctx: BenchCtx<'_>) -> Result<()> {
rewriter_node(ctx.with_init(false))?;

let tar_base_dir = sh.current_dir().join("node_tar_base");
sh.create_dir(&tar_base_dir)?;
sh.write_file(tar_base_dir.join("hello_world.js"), HELLO_WORLD_JS)?;
std::fs::copy(
sh.current_dir().join("node_rewritten"),
tar_base_dir.join("node_rewritten"),
)?;
let libs = find_dependencies(sh, "node")?;
sh.create_dir(&tar_base_dir)?;
for lib in libs {
let dest_path = tar_base_dir
.join(lib.strip_prefix("/").unwrap_or_else(|_| {
Expand Down Expand Up @@ -618,11 +633,14 @@ fn run_rewritten_node(ctx: BenchCtx<'_>) -> Result<()> {
"cargo build -p litebox_runner_linux_userland {release...} {features...}"
)
.run()?;
cmd!(sh, "cargo build -p litebox_broker_userland {release...}").run()?;
} else {
let mode = if release_mode { "release" } else { "debug" };
let broker = project_root.join(format!("target/{mode}/litebox-broker-userland"));
let runner = project_root.join(format!("target/{mode}/litebox_runner_linux_userland"));
cmd!(
sh,
"{project_root}/target/{mode}/litebox_runner_linux_userland --unstable --env HOME=/ --initial-files {tar_file} node_rewritten hello_world.js"
"{broker} --fs-initial-files {tar_file} --runner {runner} --env HOME=/ /node_rewritten hello_world.js"
).run()?;
}
Ok(())
Expand Down
5 changes: 2 additions & 3 deletions dev_bench/unixbench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ Run [byte-unixbench](https://github.com/kdlucas/byte-unixbench) benchmarks nativ
- The UnixBench source tree at `byte-unixbench-6.0.0/UnixBench/` (extracted from `v6.0.0.zip`).
- `gcc`, `make`, `ldd`, `tar` on the host.
- Pre-built LiteBox binaries (`litebox-broker-userland`,
`litebox_runner_linux_userland`, and `litebox_syscall_rewriter`).
`litebox_runner_linux_userland`, and `litebox_packager`).

Build LiteBox (from workspace root):
```bash
cargo build --release -p litebox_broker_userland -p litebox_runner_linux_userland -p litebox_syscall_rewriter
cargo build --release -p litebox_broker_userland -p litebox_runner_linux_userland -p litebox_packager
```

## Quick Start
Expand Down Expand Up @@ -144,5 +144,4 @@ python run_unixbench.py --mode litebox --windows --prepared-dir ./prepared --run
```

**Key differences from Linux mode:**
- No `--rewrite-syscalls` needed — binaries are already pre-rewritten
- No native baseline (Linux binaries can't run natively on Windows)
31 changes: 14 additions & 17 deletions dev_bench/unixbench/run_unixbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,11 @@ def prepare_litebox_rootfs(

The packager discovers shared-library dependencies via ldd, rewrites all
ELF files with the syscall rewriter, and produces a tar suitable for
``--initial-files``. The rewritten main binary is then extracted from
the tar so it can be passed to the runner as the program to execute.
broker ``--fs-initial-files``.

Returns (tar_path, rewritten_binary_path) or None on failure.
Returns (tar_path, guest_program_path) or None on failure.
"""
binary = pgms_dir / bench.binary
binary = (pgms_dir / bench.binary).resolve()
if not binary.exists():
print(f" [SKIP] {bench.name}: binary not found at {binary}")
return None
Expand All @@ -323,19 +322,17 @@ def prepare_litebox_rootfs(
print(f" Error: packager failed for {bench.name}: {stderr[:500]}")
return None

# Extract the rewritten main binary from the tar
rewritten = work_dir / f"{bench.binary}.hooked"
try:
extract_rewritten_binary(tar_path, binary, rewritten)
except RuntimeError as e:
print(f" Error: {e}")
return None

# For execl: add the rewritten binary at /pgms/execl in the tar
if bench.name == "execl":
rewritten = work_dir / f"{bench.binary}.hooked"
try:
extract_rewritten_binary(tar_path, binary, rewritten)
except RuntimeError as e:
print(f" Error: {e}")
return None
add_execl_to_tar(tar_path, rewritten)

return tar_path, rewritten
return tar_path, binary


def _run_litebox_cmd(
Expand Down Expand Up @@ -433,11 +430,12 @@ def run_litebox(
if prepared is None:
return None

tar_path, rewritten = prepared
tar_path, guest_program = prepared
broker_path = runner_path.with_name("litebox-broker-userland")

cmd = [
str(broker_path),
"--fs-initial-files", str(tar_path),
"--runner", str(runner_path),
"--env", "LD_LIBRARY_PATH=/lib64:/lib32:/lib",
"--env", "HOME=/",
Expand All @@ -447,8 +445,7 @@ def run_litebox(
if bench.name == "execl":
cmd += ["--env", "UB_BINDIR=/pgms"]

cmd += ["--initial-files", str(tar_path)]
cmd += [str(rewritten)]
cmd += [str(guest_program)]

return _run_litebox_cmd(bench, duration, cmd)

Expand Down Expand Up @@ -491,6 +488,7 @@ def run_litebox_windows(
broker_path = runner_path.with_name("litebox-broker-userland.exe")
cmd = [
str(broker_path),
"--fs-initial-files", str(tar_path),
"--runner", str(runner_path),
"--env", "LD_LIBRARY_PATH=/lib64:/lib32:/lib",
"--env", "HOME=/",
Expand All @@ -500,7 +498,6 @@ def run_litebox_windows(
if bench.name == "execl":
cmd += ["--env", "UB_BINDIR=/pgms"]

cmd += ["--initial-files", str(tar_path)]
cmd += [tar_program_path]

return _run_litebox_cmd(bench, duration, cmd)
Expand Down
4 changes: 4 additions & 0 deletions litebox/src/mm/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1033,9 +1033,13 @@ pub enum MappingError {
NotAFile,
#[error("file not open for reading")]
NotForReading,
#[error("invalid memory permissions")]
InvalidPermissions,

#[error("mapping failed: {0}")]
MapError(#[from] crate::platform::page_mgmt::AllocationError),
#[error("failed to apply mapping permissions: {0}")]
ProtectError(#[from] VmemProtectError),
}

/// Enable [`super::PageManager`] to handle page faults if its platform implements this trait
Expand Down
Loading
Loading