Skip to content

Commit 5b2389d

Browse files
committed
Merge remote-tracking branch 'upstream/main' into copilot/fix-502
2 parents bbaf29e + a68ff5e commit 5b2389d

File tree

684 files changed

+911
-839
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

684 files changed

+911
-839
lines changed

.github/copilot-instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ This repository requires commits to be signed you should ensure that any commits
7676
- `fuzz` - contains the fuzzing tests for the project
7777
- `src/hyperlight_common/` - contains the common code shared between the host and guest
7878
- `src/hyperlight_guest/` - contains the hyperlight-guest library code
79+
- `src/hyperlight_guest_bin/` - contains the hyperlight-guest-bin library code
7980
- `src/hyperlight_host/` - contains the hyperlight-host library code
8081
- `src/hyperlight_guest_capi/` - contains the hyperlight-guest C library code
8182
- `src/hyperlight_testing/` - contains the shared code for tests

.github/workflows/CargoPublish.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
VERSION="${{ github.ref }}"
4646
VERSION="${VERSION#refs/heads/release/v}"
4747
fi
48-
./dev/verify-version.sh "$VERSION" hyperlight-common hyperlight-guest hyperlight-host
48+
./dev/verify-version.sh "$VERSION" hyperlight-common hyperlight-guest hyperlight-guest-bin hyperlight-host
4949
5050
- name: Publish hyperlight-common
5151
continue-on-error: ${{ inputs.dry_run }}
@@ -59,6 +59,12 @@ jobs:
5959
env:
6060
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }}
6161

62+
- name: Publish hyperlight-guest-bin
63+
continue-on-error: ${{ inputs.dry_run }}
64+
run: cargo publish --manifest-path ./src/hyperlight_guest_bin/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
65+
env:
66+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }}
67+
6268
- name: Publish hyperlight-host
6369
continue-on-error: ${{ inputs.dry_run }}
6470
run: cargo publish --manifest-path ./src/hyperlight_host/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}

.github/workflows/dep_rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
run: just build ${{ matrix.config }}
9494

9595
- name: Verify MSRV
96-
run: ./dev/verify-msrv.sh hyperlight-host hyperlight-guest hyperlight-common
96+
run: ./dev/verify-msrv.sh hyperlight-host hyperlight-guest hyperlight-guest-bin hyperlight-common
9797

9898
- name: Run Rust tests
9999
env:

Cargo.lock

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ members = [
1111
"src/hyperlight_host",
1212
"src/hyperlight_guest_capi",
1313
"src/hyperlight_testing",
14-
"fuzz",
14+
"fuzz",
15+
"src/hyperlight_guest_bin",
1516
]
1617
# Guests have custom linker flags, so we need to exclude them from the workspace
1718
exclude = [
@@ -33,6 +34,7 @@ readme = "README.md"
3334
hyperlight-common = { path = "src/hyperlight_common", version = "0.5.0", default-features = false }
3435
hyperlight-host = { path = "src/hyperlight_host", version = "0.5.0", default-features = false }
3536
hyperlight-guest = { path = "src/hyperlight_guest", version = "0.5.0", default-features = false }
37+
hyperlight-guest-bin = { path = "src/hyperlight_guest_bin", version = "0.5.0", default-features = false }
3638
hyperlight-testing = { path = "src/hyperlight_testing", default-features = false }
3739

3840
[workspace.lints.rust]

Justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ clippy-apply-fix-windows:
156156

157157
# Verify Minimum Supported Rust Version
158158
verify-msrv:
159-
./dev/verify-msrv.sh hyperlight-host hyperlight-guest hyperlight-common
159+
./dev/verify-msrv.sh hyperlight-host hyperlight-guest hyperlight-guest-lib hyperlight-common
160160

161161
#####################
162162
### RUST EXAMPLES ###
@@ -178,7 +178,7 @@ run-rust-examples-linux target=default-target features="": (run-rust-examples ta
178178
#########################
179179

180180
tar-headers: (build-rust-capi) # build-rust-capi is a dependency because we need the hyperlight_guest.h to be built
181-
tar -zcvf include.tar.gz -C {{root}}/src/hyperlight_guest/third_party/ musl/include musl/arch/x86_64 printf/printf.h -C {{root}}/src/hyperlight_guest_capi include
181+
tar -zcvf include.tar.gz -C {{root}}/src/hyperlight_guest_bin/third_party/ musl/include musl/arch/x86_64 printf/printf.h -C {{root}}/src/hyperlight_guest_capi include
182182

183183
tar-static-lib: (build-rust-capi "release") (build-rust-capi "debug")
184184
tar -zcvf hyperlight-guest-c-api-linux.tar.gz -C {{root}}/target/x86_64-unknown-none/ release/libhyperlight_guest_capi.a -C {{root}}/target/x86_64-unknown-none/ debug/libhyperlight_guest_capi.a

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,9 @@ use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode;
8787
use hyperlight_common::flatbuffer_wrappers::util::get_flatbuffer_result_from_int;
8888

8989
use hyperlight_guest::error::{HyperlightGuestError, Result};
90-
use hyperlight_guest::guest_function_definition::GuestFunctionDefinition;
91-
use hyperlight_guest::guest_function_register::register_function;
92-
use hyperlight_guest::host_function_call::{
93-
call_host_function, get_host_value_return_as_int,
94-
};
90+
use hyperlight_guest_bin::guest_function::definition::GuestFunctionDefinition;
91+
use hyperlight_guest_bin::guest_function::register::register_function;
92+
use hyperlight_guest_bin::host_comm::{call_host_function, call_host_function_without_returning_result};
9593

9694
fn print_output(function_call: &FunctionCall) -> Result<Vec<u8>> {
9795
if let ParameterValue::String(message) = function_call.parameters.clone().unwrap()[0].clone() {
@@ -145,9 +143,9 @@ the [./src/tests/rust_guests](./src/tests/rust_guests) directory for Rust guests
145143
- [src/hyperlight_host](./src/hyperlight_host) - This is the Rust Hyperlight host library.
146144

147145
- Hyperlight Guest Libraries (i.e., the ones to make it easier to create guests that run inside the VMs)
148-
- [src/hyperlight_guest](./src/hyperlight_guest) - This is the Rust Hyperlight guest library.
149-
- [src/hyperlight_guest_capi](./src/hyperlight_guest_capi) - This is the C compatible wrapper for the Hyperlight
150-
guest library.
146+
- [src/hyperlight_guest](./src/hyperlight_guest) - The core Rust library for Hyperlight guests. It provides only the essential building blocks for interacting with the host environment, including the VM exit mechanism (`outb`), abstractions for calling host functions and receiving return values, and the input/output stacks used for guest-host communication.
147+
- [src/hyperlight_guest_bin](./src/hyperlight_guest_bin/) - An extension to the core Rust library for Hyperlight guests. It contains more opinionated components (e.g., panic handler, heap initialization, musl-specific imports, logging, and exception handling).
148+
- [src/hyperlight_guest_capi](./src/hyperlight_guest_capi) - A C-compatible wrapper around `hyperlight_guest_bin`, exposing its core functionality for use in C programs and other languages via FFI.
151149

152150
- Hyperlight Common (functionality used by both the host and the guest)
153151
- [src/hyperlight_common](./src/hyperlight_common)

c.just

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ mkdir := if os() == "windows" { "mkdir -f -p" } else { "mkdir -p"}
33
# Elf options
44
# We don't support stack protectors at the moment, but Arch Linux clang auto-enables them for -linux platforms, so explicitly disable them.
55
c-compile-options-elf := '-nobuiltininc -H --target=x86_64-unknown-linux-none -fno-stack-protector -fstack-clash-protection -mstack-probe-size=4096 -fPIC'
6-
c-include-flags-elf := "-I " + root / "src/hyperlight_guest_capi/include/" + " -I " + root / "src/hyperlight_guest/third_party/musl/include/" + " -I " + root / "src/hyperlight_guest/third_party/musl/arch/x86_64" + " -I " + root / "src/hyperlight_guest/third_party/printf"
6+
c-include-flags-elf := "-I " + root / "src/hyperlight_guest_capi/include/" + " -I " + root / "src/hyperlight_guest_bin/third_party/musl/include/" + " -I " + root / "src/hyperlight_guest_bin/third_party/musl/arch/x86_64" + " -I " + root / "src/hyperlight_guest_bin/third_party/printf"
77
c-linker-options-elf := '--entry "entrypoint" --nostdlib -pie'
88
c-flags-debug-elf := '-O0'
99
c-flags-release-elf := '-O3'

dev/verify-msrv.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ for CRATE in "$@"; do
66
if ! rustup toolchain list | grep -q "$VERSION"; then
77
rustup --quiet toolchain install "$VERSION" --no-self-update --profile minimal
88
fi
9-
if [[ "$CRATE" == "hyperlight-guest" ]]; then
9+
if [[ "$CRATE" == "hyperlight-guest" || "$CRATE" == "hyperlight-guest-bin" ]]; then
1010
TARGET="x86_64-unknown-none"
1111
rustup target add "$TARGET" --toolchain "$VERSION" >/dev/null
1212
if cargo +"$VERSION" check --quiet -p "$CRATE" --target "$TARGET"; then

docs/how-to-build-a-hyperlight-guest-binary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ binary can be used with Hyperlight:
1818
## Rust guest binary
1919

2020
In the case of a binary that is written in Rust, one needs to make use of the
21-
Hyperlight crate, `hyperlight_guest` that contains the types and APIs that enable
21+
Hyperlight crate, `hyperlight_guest` and `hyperlight_guest_bin` that contains the types and APIs that enable
2222
the guest to:
2323
- register functions that can be called by the host application
2424
- call host functions that have been registered by the host.

0 commit comments

Comments
 (0)