Skip to content

Update hyperlight dependencies to 0.18.0 - #561

Open
syntactically wants to merge 6 commits into
mainfrom
lm/hl-0.18.0
Open

syntactically wants to merge 6 commits into
mainfrom
lm/hl-0.18.0

Conversation

@syntactically

Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
It turns out that these mostly do not need to be replaced with
new-style h2g queue changes because all the tests end up using mmap
regions instead of copying the buffer around.

Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>
Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com>

@ludfjig ludfjig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks mostly good!

#[instrument(skip_all, level = "Info")]
fn init_wasm_runtime(_function_call: FunctionCall) -> Result<Vec<u8>> {
Ok(get_flatbuffer_result::<i32>(0))
fn init_wasm_runtime(_function_call: FunctionCall) -> Result<ReturnValue> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

guest_dispatch_function at the bottom of this file still returns Result<Vec<u8>>. hyperlight-guest-bin 0.18 calls it through extern "Rust" fn guest_dispatch_function(FunctionCall) -> Result<ReturnValue>.

// TODO: check that the next parameter is the correct length
}
ReturnValue::VecBytes(b) => to_val_bytes(ctx, get_export, core::iter::once(b.as_ref())),
ReturnValue::ByteChunks(bs) => to_val_bytes(ctx, get_export, bs.iter().map(|x| x.as_ref())),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hostfunc_type declares an i64 result for ByteChunks (packed ptr and len), but this returns Val::I32(addr). Wasmtime fails the call after the host callback has run. VecBytes has the same bug (see the TODO in hostfuncs.rs).


/// Set the maximum number of guest pages used for Host2Guest buffers
pub fn with_h2g_pool_pages(mut self, pages: usize) -> Self {
if pages > (MIN_INPUT_DATA_SIZE / hyperlight_common::vmem::PAGE_SIZE + 1) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

new() sets 48 pages, but this ignores anything <= 49. with_h2g_pool_pages(49) is a silent no-op. Use >= against the value new() sets, or document the floor.

let result: Vec<Bytes> = loaded_wasm_sandbox
.call_guest_function(
"ReceiveByteArray",
(vec![Bytes::from_owner(vec![0x01, 0x02, 0x03])], 3i32),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test sends one chunk and only prints the result. The chunk offset step in to_val_bytes (a + b.len()) only matters with two or more chunks.

(vec![Bytes::from_static(&[0x01]), Bytes::from_static(&[0x02, 0x03])], 3i32)
// ...
let flat: Vec<u8> = result.iter().flatten().copied().collect();
assert_eq!(flat, [0x01, 0x02, 0x03]);

builder
.with_h2g_pool_pages(128)
.with_h2g_queue_size(128)
.with_guest_scratch_size(0x3000)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0x3000 is below MIN_SCRATCH_SIZE (2 MiB), so with_guest_scratch_size ignores it. Drop it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants