Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4944455
init
CvvT Mar 10, 2026
81affce
fix: replace from_ptr with from and suppress unused import warnings f…
CvvT Mar 10, 2026
7c3e07d
fix: use from_usize for TransparentMutPtr/TransparentConstPtr constru…
CvvT Mar 11, 2026
6670699
fix: add missing RawConstPointer import and type annotation in shim t…
CvvT Mar 11, 2026
120fd4f
fix: use default remap_pages impl and add exception table lookup for …
CvvT Mar 11, 2026
be3eb60
fix: use UserMutPtr/UserConstPtr with fallible reads for FreeBSD
CvvT Mar 11, 2026
42609ce
fix: check exception table before TLS access in FreeBSD signal handler
CvvT Mar 11, 2026
2e55893
test: enable test_sigint_with_custom_handler for FreeBSD
CvvT Mar 11, 2026
1fd47ce
fix: normalize CRLF to LF in FreeBSD platform files
CvvT Mar 11, 2026
6206df7
fmt
Mar 11, 2026
ce36346
remove-stray-files
Mar 11, 2026
93001b7
Fix clippy warnings in litebox_platform_freebsd_userland
CvvT Mar 11, 2026
1811b22
Fix remaining clippy errors and warnings
CvvT Mar 11, 2026
4f5e3e4
Fix clippy errors: move let out of fn args, fix similar_names
CvvT Mar 11, 2026
a8e2dc9
Fix all remaining clippy warnings
CvvT Mar 11, 2026
da36ef4
Remove unnecessary let binding in map_err
CvvT Mar 11, 2026
bde2f6b
clippy-fmt
Mar 11, 2026
814b3ae
Add litebox_platform_freebsd_userland to no_std allow-list in CI
CvvT Mar 11, 2026
d349f56
Add copyright headers to FreeBSD files and fix ratchet count
CvvT Mar 11, 2026
e6a1bd0
Fix CRLF line endings in generated.rs
CvvT Mar 11, 2026
1eed116
Implement IPInterfaceProvider for FreeBSD using TUN device
CvvT Mar 30, 2026
56de597
Import ReinterpretSignedExt for TUN fd conversion
CvvT Mar 30, 2026
d162955
Fix clippy: use try_from for TUNSIFHEAD cast
CvvT Mar 30, 2026
d5add28
Pass tun_device_name to FreeBSD platform in shim tests
CvvT Mar 30, 2026
7877294
Enable net tests for FreeBSD, fix nc args for FreeBSD compatibility
CvvT Mar 30, 2026
af26bea
Add TUN setup script for FreeBSD
CvvT Mar 30, 2026
c7f0d62
Fix TUN setup script: FreeBSD ifconfig syntax and ANSI escapes
CvvT Mar 30, 2026
917f384
Fix TUN setup: use point-to-point ifconfig syntax, add remote IP option
CvvT Mar 30, 2026
962e516
Fix TUNSIFHEAD ioctl constant: use correct _IOW('t', 96, int) encoding
CvvT Mar 30, 2026
afd299b
freebsd: configure TUN interface IP after opening device
CvvT Mar 30, 2026
6e7f683
Revert "freebsd: configure TUN interface IP after opening device"
CvvT Mar 30, 2026
e8490d0
freebsd: disable net tests, will test TUN manually
CvvT Mar 30, 2026
6c05e3b
freebsd: simplify cfg gate in init_platform
CvvT Mar 30, 2026
1df5025
cargo fmt
CvvT Mar 30, 2026
e58931f
Merge remote-tracking branch 'origin/main' into weiteng/freebsd
CvvT Mar 30, 2026
50b2619
freebsd: implement TimerProvider trait for FreeBSDUserland
CvvT Mar 30, 2026
4b483fb
freebsd: gate timer tests to linux-only (TimerProvider unsupported)
CvvT Mar 30, 2026
1130be8
update Cargo.lock
CvvT Mar 31, 2026
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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ jobs:
# - `litebox_platform_linux_userland` is allowed to have `std` access,
# since it is a purely-userland implementation.
#
# - `litebox_platform_freebsd_userland` is allowed to have `std` access,
# since it is a purely-userland implementation.
#
# - `litebox_platform_windows_userland` is allowed to have `std` access,
# since it is a purely-userland implementation.
#
Expand Down Expand Up @@ -311,6 +314,7 @@ jobs:
find . -type f -name 'Cargo.toml' \
-not -path './Cargo.toml' \
-not -path './litebox_platform_linux_userland/Cargo.toml' \
-not -path './litebox_platform_freebsd_userland/Cargo.toml' \
-not -path './litebox_platform_windows_userland/Cargo.toml' \
-not -path './litebox_runner_linux_on_windows_userland/Cargo.toml' \
-not -path './litebox_platform_lvbs/Cargo.toml' \
Expand Down
14 changes: 14 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"litebox",
"litebox_common_linux",
"litebox_common_optee",
"litebox_platform_freebsd_userland",
"litebox_platform_linux_kernel",
"litebox_platform_linux_userland",
"litebox_platform_windows_userland",
Expand All @@ -28,6 +29,7 @@ default-members = [
"litebox",
"litebox_common_linux",
"litebox_common_optee",
"litebox_platform_freebsd_userland",
"litebox_platform_linux_kernel",
"litebox_platform_linux_userland",
"litebox_platform_windows_userland",
Expand Down
2 changes: 2 additions & 0 deletions dev_tests/src/ratchet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fn ratchet_globals() -> Result<()> {
&[
("dev_bench/", 1),
("litebox/", 9),
("litebox_platform_freebsd_userland/", 7),
("litebox_platform_linux_kernel/", 6),
("litebox_platform_linux_userland/", 5),
("litebox_platform_lvbs/", 23),
Expand Down Expand Up @@ -71,6 +72,7 @@ fn ratchet_maybe_uninit() -> Result<()> {
&[
("dev_tests/", 1),
("litebox/", 1),
("litebox_platform_freebsd_userland/", 2),
("litebox_platform_linux_userland/", 3),
("litebox_shim_linux/", 5),
],
Expand Down
4 changes: 2 additions & 2 deletions litebox/src/mm/exception_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use crate::utils::TruncateExt as _;

#[cfg(any(target_os = "linux", target_os = "none"))]
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "none"))]
macro_rules! ex_table_section {
() => {
// a = allocate, R = retain: don't discard on linking.
Expand Down Expand Up @@ -214,7 +214,7 @@ struct ExceptionTableEntry {

/// Returns the exception table, found by linker-defined symbols marking the
/// start and end of the section.
#[cfg(any(target_os = "linux", target_os = "none"))]
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "none"))]
fn exception_table() -> &'static [ExceptionTableEntry] {
// SAFETY: the linker automatically defines these symbols when the section
// is non-empty.
Expand Down
16 changes: 16 additions & 0 deletions litebox_platform_freebsd_userland/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "litebox_platform_freebsd_userland"
version = "0.1.0"
edition = "2024"

[dependencies]
libc = { version = "0.2.169", default-features = false }
litebox = { path = "../litebox/", version = "0.1.0" }
litebox_common_linux = { path = "../litebox_common_linux", version = "0.1.0" }
thiserror = { version = "2.0.6", default-features = false }
bitflags = "2.6.0"
getrandom = "0.3.4"
zerocopy = { version = "0.8", default-features = false, features = ["derive"] }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions litebox_platform_freebsd_userland/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# LiteBox Platform: FreeBSD Userland

A [LiteBox platform](../litebox/platform/index.html) for running LiteBox on userland FreeBSD.
50 changes: 50 additions & 0 deletions litebox_platform_freebsd_userland/scripts/_common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#! /bin/sh

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

# Script intended to be sourced as a common helper for other scripts.

set -e

SCRIPT_DIR=$( cd "$( dirname "$0" )" && pwd -P )

RED=$(printf '\033[0;31m')
YELLOW=$(printf '\033[0;33m')
GREEN=$(printf '\033[0;32m')
BOLD=$(printf '\033[1m')
RESET=$(printf '\033[0m')

fatal() {
printf "${RED}${BOLD}[!]${RESET} %s\n" "$1" 1>&2
exit 1
}

warn() {
printf "${YELLOW}${BOLD}[!]${RESET} %s\n" "$1" 1>&2
}

info() {
printf "${BOLD}[i]${RESET} %s\n" "$1" 1>&2
}
info2() {
printf " %s\n" "$1" 1>&2
}

success() {
printf "${GREEN}${BOLD}[+]${RESET} %s\n" "$1" 1>&2
}

check_for_tools() {
missing_tools=0
while [ $# -gt 0 ]; do
if ! command -v "$1" > /dev/null 2>&1; then
warn "Required tool ${BOLD}$1${RESET} not found"
missing_tools=1
fi
shift
done
if [ "$missing_tools" -ne 0 ]; then
fatal "Please install the missing tools and try again"
fi
}
100 changes: 100 additions & 0 deletions litebox_platform_freebsd_userland/scripts/tun-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#! /bin/sh

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

. "$(dirname "$0")/_common.sh"

# If not root, exit
if [ "$(id -u)" -ne 0 ]; then
fatal "Requires running as root"
fi

# Parse arguments
REMOVE_TUN=0
FORCE_RECREATE=0
TUN_DEV="tun99"
TUN_IP="10.0.0.1"
TUN_REMOTE_IP="10.0.0.2"
while getopts "hdft:i:r:" opt; do
case $opt in
h)
echo "Usage: $0 [-h] [-d | -f] [-t TUN] [-i IP] [-r REMOTE_IP]" 1>&2
echo " -h Show this help message" 1>&2
echo " -d Remove the TUN device" 1>&2
echo " -f Force re-create the TUN device" 1>&2
echo " -t TUN device name (default: $TUN_DEV)" 1>&2
echo " -i TUN local IP address (default: $TUN_IP)" 1>&2
echo " -r TUN remote (guest) IP address (default: $TUN_REMOTE_IP)" 1>&2
exit 0
;;
d)
REMOVE_TUN=1
;;
f)
FORCE_RECREATE=1
;;
t)
TUN_DEV="$OPTARG"
;;
i)
TUN_IP="$OPTARG"
;;
r)
TUN_REMOTE_IP="$OPTARG"
;;
\?)
fatal "Invalid option: -$OPTARG"
;;
esac
done
if [ $REMOVE_TUN -eq 1 ] && [ $FORCE_RECREATE -eq 1 ]; then
fatal "Cannot remove and force re-create at the same time"
fi

check_for_tools ifconfig

info "Script parameters:"
info2 "TUN device: ${BOLD}${TUN_DEV}${RESET}"
if [ $REMOVE_TUN -eq 1 ]; then
info2 "Remove TUN device: ${BOLD}yes${RESET}"
else
info2 "TUN local IP: ${BOLD}${TUN_IP}${RESET}"
info2 "TUN remote IP: ${BOLD}${TUN_REMOTE_IP}${RESET}"
fi
if [ $FORCE_RECREATE -eq 1 ]; then
info2 "Force recreate TUN device: ${BOLD}yes${RESET}"
fi

# Check if the TUN device already exists
if ifconfig "$TUN_DEV" > /dev/null 2>&1; then
info "TUN device already exists"
if [ $REMOVE_TUN -eq 1 ] || [ $FORCE_RECREATE -eq 1 ]; then
info "Destroying TUN device"
ifconfig "$TUN_DEV" destroy
success "Removed TUN device"
if [ $REMOVE_TUN -eq 1 ]; then
exit 0
fi
else
fatal "Use ${BOLD}-d${RESET} to remove the TUN device or ${BOLD}-f${RESET} to force re-create it"
fi
elif [ $REMOVE_TUN -eq 1 ]; then
warn "TUN device does not exist"
fatal "Nothing to remove"
fi

info "Creating TUN device"
ifconfig "$TUN_DEV" create

info "Assigning IP address (point-to-point: $TUN_IP -> $TUN_REMOTE_IP)"
ifconfig "$TUN_DEV" inet "$TUN_IP" "$TUN_REMOTE_IP" netmask 255.255.255.0

# Allow the current user to open the device node
CURRENT_USER=$(logname 2>/dev/null || echo "$SUDO_USER")
if [ -n "$CURRENT_USER" ] && [ -c "/dev/$TUN_DEV" ]; then
info "Setting ownership of /dev/$TUN_DEV to $CURRENT_USER"
chown "$CURRENT_USER" "/dev/$TUN_DEV"
fi

success "Created TUN device"
Loading
Loading