Skip to content
Open
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
9 changes: 9 additions & 0 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions dev_tests/src/ratchet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ fn ratchet_globals() -> Result<()> {
("litebox_platform_multiplex/", 1),
("litebox_platform_windows_userland/", 8),
("litebox_runner_linux_userland/", 1),
("litebox_runner_lvbs/", 5),
("litebox_runner_snp/", 1),
("litebox_runner_lvbs/", 6),
("litebox_runner_snp/", 2),
("litebox_shim_linux/", 1),
("litebox_shim_optee/", 3),
],
Expand Down
2 changes: 2 additions & 0 deletions litebox_runner_linux_on_windows_userland/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ litebox_common_linux = { version = "0.1.0", path = "../litebox_common_linux" }
litebox_platform_windows_userland = { version = "0.1.0", path = "../litebox_platform_windows_userland" }
litebox_platform_multiplex = { version = "0.1.0", path = "../litebox_platform_multiplex", default-features = false, features = ["platform_windows_userland"] }
litebox_shim_linux = { version = "0.1.0", path = "../litebox_shim_linux", default-features = false, features = ["platform_windows_userland"] }
litebox_util_log = { version = "0.1.0", path = "../litebox_util_log", features = ["backend_tracing"] }
tracing-subscriber = { version = "0.3.22", features = ["env-filter"] }
[lints]
workspace = true
10 changes: 10 additions & 0 deletions litebox_runner_linux_on_windows_userland/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ pub struct CliArgs {
/// panic. If it does actually panic, then ping the authors of LiteBox, and likely a better error
/// message could be thrown instead.
pub fn run(cli_args: CliArgs) -> Result<()> {
tracing_subscriber::fmt()
.with_timer(tracing_subscriber::fmt::time::uptime())
.with_level(true)
.with_env_filter(
tracing_subscriber::EnvFilter::builder()
.with_env_var("LITEBOX_LOG")
.from_env_lossy(),
)
.init();

let tar_file = &cli_args.initial_files;
if tar_file.extension().and_then(|x| x.to_str()) != Some("tar") {
anyhow::bail!("Expected a .tar file, found {}", tar_file.display());
Expand Down
3 changes: 3 additions & 0 deletions litebox_runner_lvbs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ version = "0.1.0"
edition = "2024"

[dependencies]
arrayvec = { version = "0.7.6", default-features = false }
litebox = { version = "0.1.0", path = "../litebox" }
litebox_platform_lvbs = { version = "0.1.0", path = "../litebox_platform_lvbs", default-features = false }
litebox_platform_multiplex = { version = "0.1.0", path = "../litebox_platform_multiplex", default-features = false, features = ["platform_lvbs"] }
litebox_common_optee = { path = "../litebox_common_optee/", version = "0.1.0" }
litebox_common_linux = { path = "../litebox_common_linux/", version = "0.1.0" }
litebox_shim_optee = { path = "../litebox_shim_optee/", version = "0.1.0" }
litebox_util_log = { version = "0.1.0", path = "../litebox_util_log" }
log = { version = "0.4", default-features = false }
spin = { version = "0.10.0", default-features = false, features = ["spin_mutex"] }
once_cell = { version = "1.21.3", default-features = false, features = ["race", "alloc"] }

Expand Down
23 changes: 23 additions & 0 deletions litebox_runner_lvbs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ use litebox_platform_lvbs::{
use x86_64::VirtAddr;
use x86_64::structures::paging::PageTableFlags;

/// `log` backend that forwards to the serial console.
struct HostLogger;

impl log::Log for HostLogger {
fn enabled(&self, _metadata: &log::Metadata) -> bool {
true
}

fn log(&self, record: &log::Record) {
use core::fmt::Write;
let mut buf: arrayvec::ArrayString<1024> = arrayvec::ArrayString::new();
let _ = writeln!(buf, "[{}] {}", record.level(), record.args());
litebox_platform_lvbs::arch::ioport::serial_print_string(&buf);
}

fn flush(&self) {}
}

static HOST_LOGGER: HostLogger = HostLogger;

/// Spinlock protecting the shared AP boot stack (`VTL1_KERNEL_STACK_PAGE`).
///
/// All APs receive the same initial RSP via `hvcall_enable_vp_vtl`. VTL0
Expand Down Expand Up @@ -425,6 +445,9 @@ pub unsafe extern "C" fn _start() -> ! {

unsafe extern "C" fn kernel_main(is_bsp: bool) -> ! {
if is_bsp {
let _ = log::set_logger(&HOST_LOGGER);
log::set_max_level(log::LevelFilter::Trace);

serial_println!("==============================");
serial_println!(" Hello from LiteBox for LVBS! ");
serial_println!("==============================");
Expand Down
2 changes: 2 additions & 0 deletions litebox_runner_optee_on_linux_userland/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ litebox_platform_linux_userland = { version = "0.1.0", path = "../litebox_platfo
litebox_platform_multiplex = { version = "0.1.0", path = "../litebox_platform_multiplex", default-features = false, features = ["platform_linux_userland_with_optee_syscall", "systrap_backend"] }
litebox_shim_optee = { version = "0.1.0", path = "../litebox_shim_optee", default-features = false, features = ["platform_linux_userland"] }
litebox_syscall_rewriter = { version = "0.1.0", path = "../litebox_syscall_rewriter" }
litebox_util_log = { version = "0.1.0", path = "../litebox_util_log", features = ["backend_tracing"] }
tracing-subscriber = { version = "0.3.22", features = ["env-filter"] }
serde = { version = "1.0.142", features = ["derive"] }
serde_json = "1.0.142"

Expand Down
10 changes: 10 additions & 0 deletions litebox_runner_optee_on_linux_userland/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ pub enum InterceptionBackend {
/// panic. If it does actually panic, then ping the authors of LiteBox, and likely a better error
/// message could be thrown instead.
pub fn run(cli_args: CliArgs) -> Result<()> {
tracing_subscriber::fmt()
.with_timer(tracing_subscriber::fmt::time::uptime())
.with_level(true)
.with_env_filter(
tracing_subscriber::EnvFilter::builder()
.with_env_var("LITEBOX_LOG")
.from_env_lossy(),
)
.init();

let ldelf_data: Vec<u8> = {
let ldelf = PathBuf::from(&cli_args.ldelf);
let data = std::fs::read(ldelf).unwrap();
Expand Down
2 changes: 2 additions & 0 deletions litebox_runner_snp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ litebox_common_linux = { path = "../litebox_common_linux/", version = "0.1.0" }
litebox_platform_multiplex = { path = "../litebox_platform_multiplex", version = "0.1.0", default-features = false, features = ["platform_linux_snp"] }
litebox_platform_linux_kernel = { path = "../litebox_platform_linux_kernel/", version = "0.1.0" }
litebox_shim_linux = { version = "0.1.0", path = "../litebox_shim_linux", default-features = false, features = ["platform_linux_snp"] }
litebox_util_log = { version = "0.1.0", path = "../litebox_util_log" }
log = { version = "0.4", default-features = false }

[lints]
workspace = true
24 changes: 24 additions & 0 deletions litebox_runner_snp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@ use litebox::{
};
use litebox_platform_linux_kernel::{HostInterface, host::snp::ghcb::ghcb_prints};

/// `log` backend that forwards to the GHCB serial console.
struct HostLogger;

impl log::Log for HostLogger {
fn enabled(&self, _metadata: &log::Metadata) -> bool {
true
}

fn log(&self, record: &log::Record) {
use core::fmt::Write;
let mut buf: arrayvec::ArrayString<1024> = arrayvec::ArrayString::new();
let _ = writeln!(buf, "[{}] {}", record.level(), record.args());
ghcb_prints(&buf);
}

fn flush(&self) {}
}

static HOST_LOGGER: HostLogger = HostLogger;

type Platform = litebox_platform_linux_kernel::host::snp::snp_impl::SnpLinuxKernel;
type DefaultFS = litebox::fs::layered::FileSystem<
Platform,
Expand Down Expand Up @@ -104,6 +124,10 @@ pub extern "C" fn sandbox_kernel_init(
boot_params: &'static litebox_platform_linux_kernel::host::snp::snp_impl::vmpl2_boot_params,
) {
ghcb_prints("sandbox_kernel_init called\n");

let _ = log::set_logger(&HOST_LOGGER);
log::set_max_level(log::LevelFilter::Trace);

let ghcb_page = litebox_platform_linux_kernel::arch::PhysAddr::new(boot_params.ghcb_page);
let ghcb_page_va = litebox_platform_linux_kernel::arch::VirtAddr::new(boot_params.ghcb_page_va);
if litebox_platform_linux_kernel::host::snp::ghcb::GhcbProtocol::setup_ghcb_page(
Expand Down
Loading