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
10 changes: 7 additions & 3 deletions src/hyperlight_guest_bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ fn _panic_handler(info: &core::panic::PanicInfo) -> ! {

unsafe extern "C" {
fn hyperlight_main();

#[cfg(feature = "libc")]
fn srand(seed: u32);
}

Expand All @@ -222,7 +224,7 @@ core::arch::global_asm!(
/// user initialisation
pub(crate) extern "C" fn generic_init(
peb_address: u64,
seed: u64,
_seed: u64,
ops: u64,
max_log_level: u64,
) -> u64 {
Expand All @@ -248,11 +250,13 @@ pub(crate) extern "C" fn generic_init(
#[cfg(feature = "trace_guest")]
let guest_start_tsc = hyperlight_guest_tracing::invariant_tsc::read_tsc();

#[cfg(feature = "libc")]
unsafe {
let srand_seed = (((peb_address << 8) ^ (seed >> 4)) >> 32) as u32;
// Set the seed for the random number generator for C code using rand;
let srand_seed = (((peb_address << 8) ^ (_seed >> 4)) >> 32) as u32;
srand(srand_seed);
Comment thread
ludfjig marked this conversation as resolved.
}

unsafe {
OS_PAGE_SIZE = ops as u32;
}

Expand Down
142 changes: 2 additions & 140 deletions src/tests/rust_guests/Cargo.lock

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

2 changes: 1 addition & 1 deletion src/tests/rust_guests/dummyguest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"


[dependencies]
hyperlight-guest-bin = { path = "../../../hyperlight_guest_bin" }
hyperlight-guest-bin = { path = "../../../hyperlight_guest_bin", default-features = false }
hyperlight-common = { path = "../../../hyperlight_common", default-features = false }

[features]
Expand Down
2 changes: 1 addition & 1 deletion src/tests/rust_guests/simpleguest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
hyperlight-guest = { path = "../../../hyperlight_guest" }
hyperlight-guest-bin = { path = "../../../hyperlight_guest_bin" }
hyperlight-guest-bin = { path = "../../../hyperlight_guest_bin", default-features = false, features = ["macros"] }
hyperlight-common = { path = "../../../hyperlight_common", default-features = false }
hyperlight-guest-tracing = { path = "../../../hyperlight_guest_tracing" }
log = {version = "0.4", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion src/tests/rust_guests/witguest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
hyperlight-guest = { path = "../../../hyperlight_guest" }
hyperlight-guest-bin = { path = "../../../hyperlight_guest_bin" }
hyperlight-guest-bin = { path = "../../../hyperlight_guest_bin", default-features = false }
hyperlight-common = { path = "../../../hyperlight_common", default-features = false }
hyperlight-component-macro = { path = "../../../hyperlight_component_macro" }
spin = "0.10.0"
Expand Down
Loading