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
6 changes: 6 additions & 0 deletions .github/workflows/dep_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ jobs:
- name: Verify MSRV
run: ./dev/verify-msrv.sh hyperlight-host hyperlight-guest hyperlight-guest-bin hyperlight-common

- name: Check hyperlight-guest builds for 32-bit (Nanvix compatibility)
if: ${{ runner.os == 'Linux' }}
run: |
rustup target add i686-unknown-linux-gnu
just check-guest-i686 ${{ inputs.config }}

build:
if: ${{ inputs.docs_only == 'false' }}
timeout-minutes: 60
Expand Down
4 changes: 4 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ test-rust-tracing target=default-target features="":
{{ cargo-cmd }} test -p hyperlight-common -F trace_guest --profile={{ if target == "debug" { "dev" } else { target } }} {{ target-triple-flag }}
{{ cargo-cmd }} test -p hyperlight-host --profile={{ if target == "debug" { "dev" } else { target } }} {{ if features =="" {'--features trace_guest'} else { "--features trace_guest," + features } }} {{ target-triple-flag }}

# verify hyperlight-guest builds for 32-bit (for Nanvix compatibility - uses i686 as proxy for Nanvix's custom 32-bit x86 target)
check-guest-i686 target=default-target:
cargo check -p hyperlight-guest --target i686-unknown-linux-gnu --profile={{ if target == "debug" { "dev" } else { target } }}

# Build the tracing guest to ensure it builds with the tracing feature
just build-rust-guests {{ target }} trace_guest
just move-rust-guests {{ target }}
Expand Down
6 changes: 4 additions & 2 deletions src/hyperlight_guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ Provides only the essential building blocks for interacting with the host enviro
anyhow = { version = "1.0.100", default-features = false }
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
hyperlight-common = { workspace = true, default-features = false }
hyperlight-guest-tracing = { workspace = true, default-features = false }
flatbuffers = { version= "25.9.23", default-features = false }
tracing = { version = "0.1.43", default-features = false, features = ["attributes"] }

[target.'cfg(target_arch = "x86_64")'.dependencies]
hyperlight-guest-tracing = { workspace = true, default-features = false, optional = true }

[features]
default = []
trace_guest = ["hyperlight-guest-tracing/trace"]
trace_guest = ["dep:hyperlight-guest-tracing", "hyperlight-guest-tracing?/trace"]
10 changes: 5 additions & 5 deletions src/hyperlight_guest/src/exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use tracing::instrument;
#[inline(never)]
#[instrument(skip_all, level = "Trace")]
pub fn halt() {
#[cfg(feature = "trace_guest")]
#[cfg(all(feature = "trace_guest", target_arch = "x86_64"))]
{
// Send data before halting
// If there is no data, this doesn't do anything
Expand All @@ -49,7 +49,7 @@ pub extern "C" fn abort() -> ! {
/// Exits the VM with an Abort OUT action and a specific code.
pub fn abort_with_code(code: &[u8]) -> ! {
// End any ongoing trace before aborting
#[cfg(feature = "trace_guest")]
#[cfg(all(feature = "trace_guest", target_arch = "x86_64"))]
hyperlight_guest_tracing::end_trace();
outb(OutBAction::Abort as u16, code);
outb(OutBAction::Abort as u16, &[0xFF]); // send abort terminator (if not included in code)
Expand All @@ -62,7 +62,7 @@ pub fn abort_with_code(code: &[u8]) -> ! {
/// This function is unsafe because it dereferences a raw pointer.
pub unsafe fn abort_with_code_and_message(code: &[u8], message_ptr: *const c_char) -> ! {
// End any ongoing trace before aborting
#[cfg(feature = "trace_guest")]
#[cfg(all(feature = "trace_guest", target_arch = "x86_64"))]
hyperlight_guest_tracing::end_trace();
unsafe {
// Step 1: Send abort code (typically 1 byte, but `code` allows flexibility)
Expand Down Expand Up @@ -116,7 +116,7 @@ pub(crate) fn outb(port: u16, data: &[u8]) {
/// in exception contexts. Because if the trace state is already locked, trying to create a span
/// would cause a panic, which is undesirable in exception handling.
pub(crate) unsafe fn out32(port: u16, val: u32) {
#[cfg(feature = "trace_guest")]
#[cfg(all(feature = "trace_guest", target_arch = "x86_64"))]
{
if let Some((ptr, len)) = hyperlight_guest_tracing::serialized_data() {
// If tracing is enabled and there is data to send, send it along with the OUT action
Expand All @@ -142,7 +142,7 @@ pub(crate) unsafe fn out32(port: u16, val: u32) {
};
}
}
#[cfg(not(feature = "trace_guest"))]
#[cfg(not(all(feature = "trace_guest", target_arch = "x86_64")))]
unsafe {
asm!("out dx, eax", in("dx") port, in("eax") val, options(preserves_flags, nomem, nostack));
}
Expand Down
10 changes: 5 additions & 5 deletions src/hyperlight_guest/src/guest_handle/host_comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl GuestHandle {
line: u32,
) {
// Closure to send log message to host
let send_to_host = || {
let _send_to_host = || {
let guest_log_data = GuestLogData::new(
message.to_string(),
source.to_string(),
Expand All @@ -201,7 +201,7 @@ impl GuestHandle {
}
};

#[cfg(feature = "trace_guest")]
#[cfg(all(feature = "trace_guest", target_arch = "x86_64"))]
if hyperlight_guest_tracing::is_trace_enabled() {
// If the "trace_guest" feature is enabled and tracing is initialized, log using tracing
tracing::trace!(
Expand All @@ -213,11 +213,11 @@ impl GuestHandle {
code.lineno = line,
);
} else {
send_to_host();
_send_to_host();
}
#[cfg(not(feature = "trace_guest"))]
#[cfg(not(all(feature = "trace_guest", target_arch = "x86_64")))]
{
send_to_host();
_send_to_host();
}
}
}
3 changes: 2 additions & 1 deletion src/hyperlight_guest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ limitations under the License.
*/

#![no_std]
// Deps
#[cfg(all(feature = "trace_guest", not(target_arch = "x86_64")))]
compile_error!("trace_guest feature is only supported on x86_64 architecture");

extern crate alloc;

Expand Down
Loading