Skip to content
Closed
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a868f66
Closes #274: Adding FFI function for types bool, float, String, vecbytes
vshailesh Sep 22, 2025
4034bab
import fixes for #274
vshailesh Sep 23, 2025
78cca4b
change of function name
vshailesh Sep 23, 2025
8a16031
format fixes
vshailesh Sep 23, 2025
6713bfd
Bump libc from 0.2.175 to 0.2.176 (#910)
dependabot[bot] Sep 24, 2025
42d5196
Bump tempfile from 3.22.0 to 3.23.0 (#909)
dependabot[bot] Sep 24, 2025
0336c2c
Bump windows from 0.62.0 to 0.62.1 (#916)
dependabot[bot] Sep 26, 2025
8729967
Bump windows-sys from 0.61.0 to 0.61.1 (#914)
dependabot[bot] Sep 26, 2025
2d24b1f
Bump flatbuffers from 25.2.10 to 25.9.23 (#911)
dependabot[bot] Sep 26, 2025
ceb86ca
Bump opentelemetry-semantic-conventions from 0.30.0 to 0.31.0 (#915)
dependabot[bot] Sep 26, 2025
3534df1
Bump crate-ci/typos from 1.36.2 to 1.36.3 (#912)
dependabot[bot] Sep 26, 2025
b5f1c60
Bump windows-version from 0.1.5 to 0.1.6 (#918)
dependabot[bot] Sep 26, 2025
7d89c8a
Bump serde from 1.0.226 to 1.0.227 (#917)
dependabot[bot] Sep 26, 2025
39f706a
Added Test for issue #274
vshailesh Sep 28, 2025
95fad0a
Bump serde from 1.0.227 to 1.0.228 (#920)
dependabot[bot] Sep 29, 2025
8c8cf0f
Bump cc from 1.2.38 to 1.2.39 (#919)
dependabot[bot] Sep 29, 2025
3c755f3
Bump thiserror from 2.0.16 to 2.0.17 (#922)
dependabot[bot] Sep 29, 2025
a8eb625
Bump quote from 1.0.40 to 1.0.41 (#921)
dependabot[bot] Sep 29, 2025
0def6c6
Refactor evolve code to be simpler (#895)
ludfjig Sep 29, 2025
5e0458a
Read the xmm registers while debugging
jsturtevant Aug 22, 2025
f109f17
Read the mxcsr registers
jsturtevant Aug 22, 2025
2288743
Add test for additional registers
jsturtevant Sep 12, 2025
8101f97
Set register xmm and mxcsr values
jsturtevant Sep 13, 2025
0ff0a45
Add some helper files
jsturtevant Sep 13, 2025
1859521
Clippy updates
jsturtevant Sep 13, 2025
7aa84bd
Use box now that the enum contains xmm registers which are large
jsturtevant Sep 18, 2025
1276f50
Enable gdb tests on Windows
jsturtevant Sep 19, 2025
a9e639c
Add target triple support to justfile
jsturtevant Aug 29, 2025
d78201f
Disable seccomp for musl target
jsturtevant Aug 29, 2025
6a1921b
Fix a race condition in this test
jsturtevant Aug 29, 2025
c21de21
Refactor dep_rust so it is re-usable in new nightly job
jsturtevant Sep 11, 2025
2076d94
Refactor CI failure and add to nightly job
jsturtevant Sep 10, 2025
5412afc
Filter the location to a local path relative to the project
jsturtevant Sep 10, 2025
f4739f7
Update devcontainer with tools for musl
jsturtevant Sep 12, 2025
d3762fd
Add Release blocker label
jsturtevant Sep 29, 2025
2e9db51
Pin to Debian 12 (bookworm) for Dev image and fix for Nightly (#923)
jsturtevant Sep 30, 2025
7c4158f
Fix dev container and labels for periodic failures (#925)
jsturtevant Oct 1, 2025
69920f2
Bump crate-ci/typos from 1.36.3 to 1.37.0 (#927)
dependabot[bot] Oct 1, 2025
4b7a919
Install the latest gdb in cross (#929)
jsturtevant Oct 1, 2025
0cdd885
Bump crate-ci/typos from 1.37.0 to 1.37.1 (#930)
dependabot[bot] Oct 2, 2025
fe30b78
Bump v0.10.0 in preparation for release (#932)
ludfjig Oct 3, 2025
a835c83
Closes #274: Adding FFI function for types bool, float, String, vecbytes
vshailesh Sep 22, 2025
58086e6
Tests for hl_get_host_return_value_as_Bool()
vshailesh Oct 5, 2025
7eb6792
Added Test for issue #274
vshailesh Sep 28, 2025
fe938dc
Add Release blocker label
jsturtevant Sep 29, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/ValidatePullRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
steps:
- uses: actions/checkout@v5
- name: Spell Check Repo
uses: crate-ci/[email protected].2
uses: crate-ci/[email protected].3

license-headers:
name: check license headers
Expand Down
81 changes: 40 additions & 41 deletions 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/hyperlight_common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Hyperlight's components common to host and guest.
workspace = true

[dependencies]
flatbuffers = { version = "25.2.10", default-features = false }
flatbuffers = { version = "25.9.23", default-features = false }
anyhow = { version = "1.0.100", default-features = false }
log = "0.4.28"
tracing = { version = "0.1.41", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion src/hyperlight_guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ anyhow = { version = "1.0.100", default-features = false }
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
hyperlight-common = { workspace = true }
hyperlight-guest-tracing = { workspace = true, default-features = false }
flatbuffers = { version= "25.2.10", default-features = false }
flatbuffers = { version= "25.9.23", default-features = false }

[features]
default = []
Expand Down
35 changes: 34 additions & 1 deletion src/hyperlight_guest_capi/src/flatbuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ limitations under the License.
*/

use alloc::boxed::Box;
use alloc::ffi::CString;
use alloc::string::String;
use alloc::vec::Vec;
use core::ffi::{CStr, c_char};

use hyperlight_common::flatbuffer_wrappers::util::get_flatbuffer_result;
Expand Down Expand Up @@ -115,4 +118,34 @@ pub extern "C" fn hl_get_host_return_value_as_ULong() -> u64 {
get_host_return_value().expect("Unable to get host return value as ulong")
}

// TODO add bool, float, double, string, vecbytes
#[unsafe(no_mangle)]
pub extern "C" fn hl_get_host_return_value_as_Bool() -> bool {
get_host_return_value().expect("Unable to get host return value as bool")
}

#[unsafe(no_mangle)]
pub extern "C" fn hl_get_host_return_value_as_float() -> f32 {
get_host_return_value().expect("Unable to get host return value as f32")
}

#[unsafe(no_mangle)]
pub extern "C" fn hl_get_host_return_value_as_double() -> f64 {
get_host_return_value().expect("Unable to get host return value as f32")
}

#[unsafe(no_mangle)]
pub extern "C" fn hl_get_host_return_value_as_String() -> *const c_char {
let string_value: String =
get_host_return_value().expect("Unable to get host return value as string");

let c_string = CString::new(string_value).expect("Failed to create CString");
c_string.into_raw()
}

#[unsafe(no_mangle)]
pub extern "C" fn hl_get_host_return_value_as_VecBytes() -> Box<FfiVec> {
let vec_value: Vec<u8> =
get_host_return_value().expect("Unable to get host return value as vec bytes");

Box::new(unsafe { FfiVec::from_vec(vec_value) })
}
8 changes: 4 additions & 4 deletions src/hyperlight_host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ gdbstub_arch = { version = "0.3.2", optional = true }
goblin = { version = "0.10", default-features = false, features = ["std", "elf32", "elf64", "endian_fd"] }
rand = { version = "0.9" }
cfg-if = { version = "1.0.3" }
libc = { version = "0.2.175" }
flatbuffers = "25.2.10"
libc = { version = "0.2.176" }
flatbuffers = "25.9.23"
framehop = { version = "0.15.0", optional = true }
fallible-iterator = { version = "0.3.0", optional = true }
blake3 = "1.8.2"
Expand Down Expand Up @@ -87,7 +87,7 @@ signal-hook-registry = "1.4.6"
envy = { version = "0.4.2" }
serde = "1.0"
proptest = "1.8.0"
tempfile = "3.22.0"
tempfile = "3.23.0"
crossbeam-queue = "0.3.12"
tracing-serde = "0.2.0"
hyperlight-testing = { workspace = true }
Expand All @@ -98,7 +98,7 @@ tracing-subscriber = {version = "0.3.20", features = ["std", "env-filter"]}
tracing-opentelemetry = "0.31.0"
opentelemetry = "0.30.0"
opentelemetry-otlp = { version = "0.30.0", default-features = false, features = ["http-proto", "reqwest-blocking-client"] }
opentelemetry-semantic-conventions = "0.30"
opentelemetry-semantic-conventions = "0.31"
opentelemetry_sdk = { version = "0.30.0", features = ["rt-tokio"] }
tokio = { version = "1.47.1", features = ["full"] }
criterion = "0.7.0"
Expand Down
11 changes: 11 additions & 0 deletions src/hyperlight_host/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,3 +765,14 @@ fn log_test_messages(levelfilter: Option<log::LevelFilter>) {
.unwrap();
}
}

// cargo test --test integration_test log_message -- --ignored
#[test]
fn test_if_guest_is_able_to_get_return_values_from_host() {
let mut sbox1 = new_uninit().unwrap().evolve().unwrap();


let res = sbox1.call::<()>("HostReturnsBoolValue", iterations).unwrap_err();
println!("{:?}", res);
assert!(matches!(res, HyperlightError::StackOverflow()));
}
22 changes: 22 additions & 0 deletions src/tests/c_guests/c_simpleguest/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,24 @@ int guest_function(const char *from_host) {
return 0;
}


bool host_returns_bool_value(const char *from_host) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not taking a string as parameter might make this simpler to test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you I will look at doing it without string input.

char guest_message[256] = "Hello from host_returns_bool_value, ";
int len = strlen(from_host);
strncat(guest_message, from_host, len);

hl_Parameter params = {.tag = hl_ParameterType_Bool,
.value = {.Bool = true}};
const hl_FunctionCall host_call = {.function_name = "HostMethod1",
.parameters = &params,
.parameters_len = 1,
.return_type = hl_ReturnType_Bool
};
hl_call_host_function(&host_call);
return hl_get_host_return_value_as_Bool();
}

HYPERLIGHT_WRAP_FUNCTION(host_returns_bool_value, Bool, 1, String)
HYPERLIGHT_WRAP_FUNCTION(echo, String, 1, String)
// HYPERLIGHT_WRAP_FUNCTION(set_byte_array_to_zero, 1, VecBytes) is not valid for functions that return VecBytes
HYPERLIGHT_WRAP_FUNCTION(guest_function, Int, 1, String)
Expand Down Expand Up @@ -289,6 +307,7 @@ HYPERLIGHT_WRAP_FUNCTION(log_message, Int, 2, String, Long)

void hyperlight_main(void)
{
HYPERLIGHT_REGISTER_FUNCTION("HostReturnsBoolValue", host_returns_bool_value);
HYPERLIGHT_REGISTER_FUNCTION("Echo", echo);
// HYPERLIGHT_REGISTER_FUNCTION macro does not work for functions that return VecBytes,
// so we use hl_register_function_definition directly
Expand Down Expand Up @@ -325,6 +344,9 @@ void hyperlight_main(void)
// HYPERLIGHT_REGISTER_FUNCTION macro does not work for functions that return VecBytes,
// so we use hl_register_function_definition directly
hl_register_function_definition("24K_in_8K_out", twenty_four_k_in_eight_k_out, 1, (hl_ParameterType[]){hl_ParameterType_VecBytes}, hl_ReturnType_VecBytes);
// HYPERLIGHT_REGISTER_FUNCTION macro does not work for functions that return VecBytes,
// so we use hl_register_function_definition directly
hl_register_function_definition("24K_in_8K_out", twenty_four_k_in_eight_k_out, 1, (hl_ParameterType[]){hl_ParameterType_VecBytes}, hl_ReturnType_VecBytes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a copy paste of the function above?

Copy link
Contributor Author

@vshailesh vshailesh Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still working on it, apologies, I was testing something for myself.
this is not final PR. I will tag someone when I have a final version

}

// This dispatch function is only used when the host dispatches a guest function
Expand Down
Loading
Loading