Skip to content

Removed host error region #457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 5, 2025
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
20 changes: 0 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions src/hyperlight_common/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ pub struct HostFunctionDefinitions {
pub fbHostFunctionDetails: *mut c_void,
}

#[repr(C)]
pub struct HostException {
pub hostExceptionSize: u64,
}

#[repr(C)]
pub struct GuestErrorData {
pub guestErrorSize: u64,
Expand Down Expand Up @@ -89,7 +84,6 @@ pub struct GuestPanicContextData {
pub struct HyperlightPEB {
pub security_cookie_seed: u64,
pub guest_function_dispatch_ptr: u64,
pub hostException: HostException,
pub guestErrorData: GuestErrorData,
pub pCode: *mut c_char,
pub pOutb: *mut c_void,
Expand Down
43 changes: 0 additions & 43 deletions src/hyperlight_guest/src/host_error.rs

This file was deleted.

3 changes: 0 additions & 3 deletions src/hyperlight_guest/src/host_function_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use hyperlight_common::flatbuffer_wrappers::util::get_flatbuffer_result;
use hyperlight_common::mem::RunMode;

use crate::error::{HyperlightGuestError, Result};
use crate::host_error::check_for_host_error;
use crate::shared_input_data::try_pop_shared_input_data_into;
use crate::shared_output_data::push_shared_output_data;
use crate::{OUTB_PTR, OUTB_PTR_WITH_CONTEXT, P_PEB, RUNNING_MODE};
Expand Down Expand Up @@ -102,8 +101,6 @@ pub fn outb(port: u16, value: u8) {
panic!("Tried to call outb in invalid runmode");
}
}

check_for_host_error();
}
}

Expand Down
1 change: 0 additions & 1 deletion src/hyperlight_guest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ pub mod guest_function_call;
pub mod guest_function_definition;
pub mod guest_function_register;

pub mod host_error;
pub mod host_function_call;

pub(crate) mod guest_logger;
Expand Down
6 changes: 2 additions & 4 deletions src/hyperlight_host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ flatbuffers = "25.2.10"
page_size = "0.6.0"
termcolor = "1.2.0"
bitflags = "2.9.0"
lazy_static = "1.4.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
log = "0.4.27"
tracing = { version = "0.1.41", features = ["log"] }
tracing-log = "0.2.0"
Expand All @@ -43,7 +40,6 @@ crossbeam = "0.8.0"
crossbeam-channel = "0.5.15"
thiserror = "2.0.12"
tempfile = { version = "3.19", optional = true }
serde_yaml = "0.9"
anyhow = "1.0"
metrics = "0.24.2"

Expand All @@ -67,6 +63,7 @@ windows-result = "0.3"
rust-embed = { version = "8.7.0", features = ["debug-embed", "include-exclude", "interpolate-folder-path"] }
sha256 = "1.6.0"
windows-version = "0.1"
lazy_static = "1.4.0"

[target.'cfg(unix)'.dependencies]
gdbstub = { version = "0.7.5", optional = true }
Expand Down Expand Up @@ -104,6 +101,7 @@ tracing-chrome = "0.7.2"
metrics-util = "0.19.1"
metrics-exporter-prometheus = "0.17.0"
tracing-tracy = "0.11.4"
serde_json = "1.0"

[target.'cfg(windows)'.dev-dependencies]
windows = { version = "0.61", features = [
Expand Down
33 changes: 0 additions & 33 deletions src/hyperlight_host/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use std::cell::{BorrowError, BorrowMutError};
use std::convert::Infallible;
use std::error::Error;
use std::num::TryFromIntError;
use std::str::Utf8Error;
use std::string::FromUtf8Error;
use std::sync::{MutexGuard, PoisonError};
use std::time::SystemTimeError;
Expand All @@ -35,21 +34,13 @@ use crossbeam_channel::{RecvError, SendError};
use flatbuffers::InvalidFlatbuffer;
use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnValue};
use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode;
use serde::{Deserialize, Serialize};
use serde_yaml;
use thiserror::Error;

#[cfg(target_os = "windows")]
use crate::hypervisor::wrappers::HandleWrapper;
use crate::mem::memory_region::MemoryRegionFlags;
use crate::mem::ptr::RawPtr;

#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
pub(crate) struct HyperlightHostError {
pub(crate) message: String,
pub(crate) source: String,
}

/// The error type for Hyperlight operations
#[derive(Error, Debug)]
pub enum HyperlightError {
Expand Down Expand Up @@ -87,14 +78,6 @@ pub enum HyperlightError {
#[error("{0}")]
Error(String),

/// Exception Data Length is incorrect
#[error("Exception Data Length is incorrect. Expected: {0}, Actual: {1}")]
ExceptionDataLengthIncorrect(i32, usize),

/// Exception Message is too big
#[error("Exception Message is too big. Max Size: {0}, Actual: {1}")]
ExceptionMessageTooBig(usize, usize),

/// Execution violation
#[error("Non-executable address {0:#x} tried to be executed")]
ExecutionAccessViolation(u64),
Expand Down Expand Up @@ -171,10 +154,6 @@ pub enum HyperlightError {
#[error("The flatbuffer is invalid")]
InvalidFlatBuffer(#[from] InvalidFlatbuffer),

/// Conversion of str to Json failed
#[error("Conversion of str data to json failed")]
JsonConversionFailure(#[from] serde_json::Error),

/// Error occurred in KVM Operation
#[error("KVM Error {0:?}")]
#[cfg(kvm)]
Expand Down Expand Up @@ -225,10 +204,6 @@ pub enum HyperlightError {
#[error("Restore_state called with no valid snapshot")]
NoMemorySnapshot,

/// An error occurred handling an outb message
#[error("An error occurred handling an outb message {0:?}: {1}")]
OutBHandlingError(String, String),

/// Failed to get value from parameter value
#[error("Failed To Convert Parameter Value {0:?} to {1:?}")]
ParameterValueConversionFailure(ParameterValue, &'static str),
Expand Down Expand Up @@ -292,10 +267,6 @@ pub enum HyperlightError {
#[error("The return value type is unexpected got {0:?} expected {1:?}")]
UnexpectedReturnValueType(ReturnValue, String),

/// Slice conversion to UTF8 failed
#[error("Slice Conversion of UTF8 data to str failed")]
UTF8SliceConversionFailure(#[from] Utf8Error),

/// Slice conversion to UTF8 failed
#[error("String Conversion of UTF8 data to str failed")]
UTF8StringConversionFailure(#[from] FromUtf8Error),
Expand All @@ -315,10 +286,6 @@ pub enum HyperlightError {
#[cfg(target_os = "windows")]
#[error("Windows API Error Result {0:?}")]
WindowsAPIError(#[from] windows_result::Error),

/// Conversion of str to YAML failed
#[error("Conversion of str data to yaml failed")]
YamlConversionFailure(#[from] serde_yaml::Error),
}

impl From<Infallible> for HyperlightError {
Expand Down
14 changes: 1 addition & 13 deletions src/hyperlight_host/src/func/guest_err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode;

use crate::error::HyperlightError::{GuestError, OutBHandlingError, StackOverflow};
use crate::error::HyperlightError::{GuestError, StackOverflow};
use crate::mem::shared_mem::HostSharedMemory;
use crate::metrics::{METRIC_GUEST_ERROR, METRIC_GUEST_ERROR_LABEL_CODE};
use crate::sandbox::mem_mgr::MemMgrWrapper;
Expand All @@ -27,18 +27,6 @@ pub(crate) fn check_for_guest_error(mgr: &MemMgrWrapper<HostSharedMemory>) -> Re
let guest_err = mgr.as_ref().get_guest_error()?;
match guest_err.code {
ErrorCode::NoError => Ok(()),
ErrorCode::OutbError => match mgr.as_ref().get_host_error()? {
Some(host_err) => {
metrics::counter!(METRIC_GUEST_ERROR, METRIC_GUEST_ERROR_LABEL_CODE => (guest_err.code as u64).to_string()).increment(1);

log_then_return!(OutBHandlingError(
host_err.source.clone(),
guest_err.message.clone()
));
}
// TODO: Not sure this is correct behavior. We should probably return error here
None => Ok(()),
},
ErrorCode::StackOverflow => {
metrics::counter!(METRIC_GUEST_ERROR, METRIC_GUEST_ERROR_LABEL_CODE => (guest_err.code as u64).to_string()).increment(1);
log_then_return!(StackOverflow());
Expand Down
Loading
Loading