Skip to content
Closed
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
540 changes: 281 additions & 259 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ exclude = [

[workspace.package]
version = "0.2.0"
edition = "2021"
rust-version = "1.80.0"
edition = "2024"
rust-version = "1.85.0"
license = "Apache-2.0"
homepage = "https://github.com/hyperlight-dev/hyperlight"
repository = "https://github.com/hyperlight-dev/hyperlight"
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/host_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ limitations under the License.
use std::sync::{Mutex, OnceLock};

use hyperlight_host::func::{ParameterValue, ReturnType};
use hyperlight_host::sandbox::uninitialized::GuestBinary;
use hyperlight_host::sandbox::SandboxConfiguration;
use hyperlight_host::sandbox::uninitialized::GuestBinary;
use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox;
use hyperlight_host::sandbox_state::transition::Noop;
use hyperlight_host::{HyperlightError, MultiUseSandbox, UninitializedSandbox};
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/host_print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox;
use hyperlight_host::sandbox_state::transition::Noop;
use hyperlight_host::{MultiUseSandbox, UninitializedSandbox};
use hyperlight_testing::simple_guest_for_fuzzing_as_string;
use libfuzzer_sys::{fuzz_target, Corpus};
use libfuzzer_sys::{Corpus, fuzz_target};

static SANDBOX: OnceLock<Mutex<MultiUseSandbox>> = OnceLock::new();

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.81.0"
channel = "1.85.0"
14 changes: 7 additions & 7 deletions src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ limitations under the License.
use alloc::string::{String, ToString};
use alloc::vec::Vec;

use anyhow::{bail, Error, Result};
use flatbuffers::{size_prefixed_root, WIPOffset};
use anyhow::{Error, Result, bail};
use flatbuffers::{WIPOffset, size_prefixed_root};
#[cfg(feature = "tracing")]
use tracing::{instrument, Span};
use tracing::{Span, instrument};

use super::function_types::{ParameterValue, ReturnType};
use crate::flatbuffers::hyperlight::generated::{
hlbool, hlboolArgs, hldouble, hldoubleArgs, hlfloat, hlfloatArgs, hlint, hlintArgs, hllong,
hllongArgs, hlstring, hlstringArgs, hluint, hluintArgs, hlulong, hlulongArgs, hlvecbytes,
hlvecbytesArgs, FunctionCall as FbFunctionCall, FunctionCallArgs as FbFunctionCallArgs,
FunctionCall as FbFunctionCall, FunctionCallArgs as FbFunctionCallArgs,
FunctionCallType as FbFunctionCallType, Parameter, ParameterArgs,
ParameterValue as FbParameterValue,
ParameterValue as FbParameterValue, hlbool, hlboolArgs, hldouble, hldoubleArgs, hlfloat,
hlfloatArgs, hlint, hlintArgs, hllong, hllongArgs, hlstring, hlstringArgs, hluint, hluintArgs,
hlulong, hlulongArgs, hlvecbytes, hlvecbytesArgs,
};

/// The type of function call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ limitations under the License.
use alloc::string::{String, ToString};
use alloc::vec::Vec;

use anyhow::{anyhow, bail, Error, Result};
use anyhow::{Error, Result, anyhow, bail};
use flatbuffers::size_prefixed_root;
#[cfg(feature = "tracing")]
use tracing::{instrument, Span};
use tracing::{Span, instrument};

use crate::flatbuffers::hyperlight::generated::{
hlbool, hlboolArgs, hldouble, hldoubleArgs, hlfloat, hlfloatArgs, hlint, hlintArgs, hllong,
hllongArgs, hlsizeprefixedbuffer, hlsizeprefixedbufferArgs, hlstring, hlstringArgs, hluint,
hluintArgs, hlulong, hlulongArgs, hlvoid, hlvoidArgs,
FunctionCallResult as FbFunctionCallResult, FunctionCallResultArgs as FbFunctionCallResultArgs,
Parameter, ParameterType as FbParameterType, ParameterValue as FbParameterValue,
ReturnType as FbReturnType, ReturnValue as FbReturnValue,
ReturnType as FbReturnType, ReturnValue as FbReturnValue, hlbool, hlboolArgs, hldouble,
hldoubleArgs, hlfloat, hlfloatArgs, hlint, hlintArgs, hllong, hllongArgs, hlsizeprefixedbuffer,
hlsizeprefixedbufferArgs, hlstring, hlstringArgs, hluint, hluintArgs, hlulong, hlulongArgs,
hlvoid, hlvoidArgs,
};

/// Supported parameter types with values for function calling.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use alloc::vec::Vec;
use anyhow::{Error, Result};
use flatbuffers::size_prefixed_root;
#[cfg(feature = "tracing")]
use tracing::{instrument, Span};
use tracing::{Span, instrument};

use crate::flatbuffers::hyperlight::generated::{
ErrorCode as FbErrorCode, GuestError as FbGuestError, GuestErrorArgs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ limitations under the License.
use alloc::string::{String, ToString};
use alloc::vec::Vec;

use anyhow::{anyhow, Error, Result};
use anyhow::{Error, Result, anyhow};
use flatbuffers::size_prefixed_root;
#[cfg(feature = "tracing")]
use tracing::{instrument, Span};
use tracing::{Span, instrument};

use super::guest_log_level::LogLevel;
use crate::flatbuffers::hyperlight::generated::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

use anyhow::{bail, Error, Result};
use anyhow::{Error, Result, bail};
use log::Level;
use strum::EnumIter;
#[cfg(feature = "tracing")]
use tracing::{instrument, Span};
use tracing::{Span, instrument};

use crate::flatbuffers::hyperlight::generated::LogLevel as FbLogLevel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ limitations under the License.
use alloc::string::{String, ToString};
use alloc::vec::Vec;

use anyhow::{anyhow, Error, Result};
use anyhow::{Error, Result, anyhow};
use flatbuffers::{FlatBufferBuilder, WIPOffset};
#[cfg(feature = "tracing")]
use tracing::{instrument, Span};
use tracing::{Span, instrument};

use super::function_types::{ParameterType, ReturnType};
use crate::flatbuffers::hyperlight::generated::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ limitations under the License.
use alloc::vec::Vec;

use anyhow::{Error, Result};
use flatbuffers::{size_prefixed_root, WIPOffset};
use flatbuffers::{WIPOffset, size_prefixed_root};
#[cfg(feature = "tracing")]
use tracing::{instrument, Span};
use tracing::{Span, instrument};

use super::host_function_definition::HostFunctionDefinition;
use crate::flatbuffers::hyperlight::generated::{
Expand Down Expand Up @@ -57,11 +57,8 @@ impl HostFunctionDetails {
/// Sort the host functions by name.
#[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))]
pub fn sort_host_functions_by_name(&mut self) {
match &mut self.host_functions {
Some(host_functions) => {
host_functions.sort_by(|a, b| a.function_name.cmp(&b.function_name))
}
None => {}
if let Some(host_functions) = &mut self.host_functions {
host_functions.sort_by(|a, b| a.function_name.cmp(&b.function_name))
}
}

Expand Down
13 changes: 6 additions & 7 deletions src/hyperlight_common/src/flatbuffer_wrappers/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ use alloc::vec::Vec;
use flatbuffers::FlatBufferBuilder;

use crate::flatbuffers::hyperlight::generated::{
hlbool as Fbhlbool, hlboolArgs as FbhlboolArgs, hldouble as Fbhldouble,
hldoubleArgs as FbhldoubleArgs, hlfloat as Fbhlfloat, hlfloatArgs as FbhlfloatArgs,
hlint as Fbhlint, hlintArgs as FbhlintArgs, hllong as Fbhllong, hllongArgs as FbhllongArgs,
hlsizeprefixedbuffer as Fbhlsizeprefixedbuffer,
FunctionCallResult as FbFunctionCallResult, FunctionCallResultArgs as FbFunctionCallResultArgs,
ReturnValue as FbReturnValue, hlbool as Fbhlbool, hlboolArgs as FbhlboolArgs,
hldouble as Fbhldouble, hldoubleArgs as FbhldoubleArgs, hlfloat as Fbhlfloat,
hlfloatArgs as FbhlfloatArgs, hlint as Fbhlint, hlintArgs as FbhlintArgs, hllong as Fbhllong,
hllongArgs as FbhllongArgs, hlsizeprefixedbuffer as Fbhlsizeprefixedbuffer,
hlsizeprefixedbufferArgs as FbhlsizeprefixedbufferArgs, hlstring as Fbhlstring,
hlstringArgs as FbhlstringArgs, hluint as Fbhluint, hluintArgs as FbhluintArgs,
hlulong as Fbhlulong, hlulongArgs as FbhlulongArgs, hlvoid as Fbhlvoid,
hlvoidArgs as FbhlvoidArgs, FunctionCallResult as FbFunctionCallResult,
FunctionCallResultArgs as FbFunctionCallResultArgs, ReturnValue as FbReturnValue,
hlvoidArgs as FbhlvoidArgs,
};

/// Flatbuffer-encodes the given value
Expand All @@ -46,7 +46,6 @@ pub trait FlatbufferSerializable {
}

/// Implementations for basic types below

impl FlatbufferSerializable for () {
fn serialize(&self, builder: &mut FlatBufferBuilder) -> FbFunctionCallResultArgs {
FbFunctionCallResultArgs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,20 @@ impl<'a> flatbuffers::Follow<'a> for ErrorCode {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = flatbuffers::read_scalar_at::<u64>(buf, loc);
Self(b)
unsafe {
let b = flatbuffers::read_scalar_at::<u64>(buf, loc);
Self(b)
}
}
}

impl flatbuffers::Push for ErrorCode {
type Output = ErrorCode;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
flatbuffers::emplace_scalar::<u64>(dst, self.0);
unsafe {
flatbuffers::emplace_scalar::<u64>(dst, self.0);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for FunctionCall<'a> {
type Inner = FunctionCall<'a>;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
_tab: flatbuffers::Table::new(buf, loc),
unsafe {
Self {
_tab: flatbuffers::Table::new(buf, loc),
}
}
}
}
Expand Down Expand Up @@ -290,14 +292,14 @@ pub fn size_prefixed_root_as_function_call_with_opts<'b, 'o>(
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `FunctionCall`.
pub unsafe fn root_as_function_call_unchecked(buf: &[u8]) -> FunctionCall {
flatbuffers::root_unchecked::<FunctionCall>(buf)
unsafe { flatbuffers::root_unchecked::<FunctionCall>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed FunctionCall and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `FunctionCall`.
pub unsafe fn size_prefixed_root_as_function_call_unchecked(buf: &[u8]) -> FunctionCall {
flatbuffers::size_prefixed_root_unchecked::<FunctionCall>(buf)
unsafe { flatbuffers::size_prefixed_root_unchecked::<FunctionCall>(buf) }
}
#[inline]
pub fn finish_function_call_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for FunctionCallResult<'a> {
type Inner = FunctionCallResult<'a>;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
_tab: flatbuffers::Table::new(buf, loc),
unsafe {
Self {
_tab: flatbuffers::Table::new(buf, loc),
}
}
}
}
Expand Down Expand Up @@ -513,7 +515,7 @@ pub fn size_prefixed_root_as_function_call_result_with_opts<'b, 'o>(
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `FunctionCallResult`.
pub unsafe fn root_as_function_call_result_unchecked(buf: &[u8]) -> FunctionCallResult {
flatbuffers::root_unchecked::<FunctionCallResult>(buf)
unsafe { flatbuffers::root_unchecked::<FunctionCallResult>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed FunctionCallResult and returns it.
Expand All @@ -522,7 +524,7 @@ pub unsafe fn root_as_function_call_result_unchecked(buf: &[u8]) -> FunctionCall
pub unsafe fn size_prefixed_root_as_function_call_result_unchecked(
buf: &[u8],
) -> FunctionCallResult {
flatbuffers::size_prefixed_root_unchecked::<FunctionCallResult>(buf)
unsafe { flatbuffers::size_prefixed_root_unchecked::<FunctionCallResult>(buf) }
}
#[inline]
pub fn finish_function_call_result_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,20 @@ impl<'a> flatbuffers::Follow<'a> for FunctionCallType {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = flatbuffers::read_scalar_at::<u8>(buf, loc);
Self(b)
unsafe {
let b = flatbuffers::read_scalar_at::<u8>(buf, loc);
Self(b)
}
}
}

impl flatbuffers::Push for FunctionCallType {
type Output = FunctionCallType;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
flatbuffers::emplace_scalar::<u8>(dst, self.0);
unsafe {
flatbuffers::emplace_scalar::<u8>(dst, self.0);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for GuestError<'a> {
type Inner = GuestError<'a>;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
_tab: flatbuffers::Table::new(buf, loc),
unsafe {
Self {
_tab: flatbuffers::Table::new(buf, loc),
}
}
}
}
Expand Down Expand Up @@ -192,14 +194,14 @@ pub fn size_prefixed_root_as_guest_error_with_opts<'b, 'o>(
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `GuestError`.
pub unsafe fn root_as_guest_error_unchecked(buf: &[u8]) -> GuestError {
flatbuffers::root_unchecked::<GuestError>(buf)
unsafe { flatbuffers::root_unchecked::<GuestError>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed GuestError and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `GuestError`.
pub unsafe fn size_prefixed_root_as_guest_error_unchecked(buf: &[u8]) -> GuestError {
flatbuffers::size_prefixed_root_unchecked::<GuestError>(buf)
unsafe { flatbuffers::size_prefixed_root_unchecked::<GuestError>(buf) }
}
#[inline]
pub fn finish_guest_error_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for GuestLogData<'a> {
type Inner = GuestLogData<'a>;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
_tab: flatbuffers::Table::new(buf, loc),
unsafe {
Self {
_tab: flatbuffers::Table::new(buf, loc),
}
}
}
}
Expand Down Expand Up @@ -288,14 +290,14 @@ pub fn size_prefixed_root_as_guest_log_data_with_opts<'b, 'o>(
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `GuestLogData`.
pub unsafe fn root_as_guest_log_data_unchecked(buf: &[u8]) -> GuestLogData {
flatbuffers::root_unchecked::<GuestLogData>(buf)
unsafe { flatbuffers::root_unchecked::<GuestLogData>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size prefixed GuestLogData and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `GuestLogData`.
pub unsafe fn size_prefixed_root_as_guest_log_data_unchecked(buf: &[u8]) -> GuestLogData {
flatbuffers::size_prefixed_root_unchecked::<GuestLogData>(buf)
unsafe { flatbuffers::size_prefixed_root_unchecked::<GuestLogData>(buf) }
}
#[inline]
pub fn finish_guest_log_data_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for hlbool<'a> {
type Inner = hlbool<'a>;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
_tab: flatbuffers::Table::new(buf, loc),
unsafe {
Self {
_tab: flatbuffers::Table::new(buf, loc),
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for hldouble<'a> {
type Inner = hldouble<'a>;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
_tab: flatbuffers::Table::new(buf, loc),
unsafe {
Self {
_tab: flatbuffers::Table::new(buf, loc),
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ impl<'a> flatbuffers::Follow<'a> for hlfloat<'a> {
type Inner = hlfloat<'a>;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
_tab: flatbuffers::Table::new(buf, loc),
unsafe {
Self {
_tab: flatbuffers::Table::new(buf, loc),
}
}
}
}
Expand Down
Loading
Loading