-
Notifications
You must be signed in to change notification settings - Fork 195
Add initial single-sandbox-executing-at-a-time support for Hypervisor.framework #1674
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
Open
+2,506
−851
Open
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
9b775b8
nix: Support developing on macOS
syntactically a027292
Reduce duplication of interrupt handle state machines
syntactically a8d5f97
Abstract out interrupt handle retry logic
syntactically 6b29452
Be more careful about cfg(target_os = "linux") vs cfg(unix)
syntactically f590547
hvf: add cfg items and detection stub
syntactically 8aba46e
hvf: add Rust bindings
syntactically 715ac72
hvf: add interrupt handle using `hv_vcpus_exit`
syntactically 11f85e7
Disentangle host and guest page sizes
syntactically 554f478
Change guest layout to support 16k host pages
syntactically 96f2655
Make VirtualMachine::set_{regs,sregs,fpu} take &mut
syntactically 819c50d
fixup! Reduce duplication of interrupt handle state machines
syntactically 6f72496
[tests] hvf: support identifiers and reduce thread counts
syntactically 9bd34ee
Restrict usage of MIDR_EL1 to Linux
syntactically a798cfc
Initial single-address-space support for Hypervisor.framework
syntactically 41bdec0
cargo: Add codesigning runner script for MacOS
syntactically 9fd6c64
fixup! Initial single-address-space support for Hypervisor.framework
syntactically c9c1e33
aarch64: Move machinery for decoding ESR_ELx to hyperlight-common
syntactically 443068e
fixup! Initial single-address-space support for Hypervisor.framework
syntactically f483541
fixup! Initial single-address-space support for Hypervisor.framework
syntactically c8eee02
fixup! Abstract out interrupt handle retry logic
syntactically a8658a3
fixup! Reduce duplication of interrupt handle state machines
syntactically 51088c4
fixup! Disentangle host and guest page sizes
syntactically f9768dd
fixup! hvf: add Rust bindings
syntactically 20f7a68
ci: enable running on MacOS/HVF
syntactically b369657
fixup! hvf: add Rust bindings
syntactically 3451a0b
fixup! Initial single-address-space support for Hypervisor.framework
syntactically e700eda
fixup! Disentangle host and guest page sizes
syntactically 444045c
amend! [tests] hvf: support identifiers and reduce thread counts
syntactically fb504b4
fixup! Initial single-address-space support for Hypervisor.framework
syntactically 8401d42
fixup! Initial single-address-space support for Hypervisor.framework
syntactically 9e14452
fixup! ci: enable running on MacOS/HVF
syntactically 62d3478
fixup! Change guest layout to support 16k host pages
syntactically 83b696a
Convert mem::shared_mem module to use thiserror structured errors
syntactically c8d2e47
fixup! hvf: add interrupt handle using `hv_vcpus_exit`
syntactically 41a5382
fixup! Initial single-address-space support for Hypervisor.framework
syntactically 27d523d
fixup! aarch64: Move machinery for decoding ESR_ELx to hyperlight-common
syntactically ea31954
fixup! Abstract out interrupt handle retry logic
syntactically eaf228c
fixup! Be more careful about cfg(target_os = "linux") vs cfg(unix)
syntactically 9546a16
fixup! ci: enable running on MacOS/HVF
syntactically 544291f
fixup! Initial single-address-space support for Hypervisor.framework
syntactically 85f33b9
fixup! Convert mem::shared_mem module to use thiserror structured errors
syntactically 813a8c3
fixup! Initial single-address-space support for Hypervisor.framework
syntactically File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [target.'cfg(target_os = "macos")'] | ||
| runner = "dev/macos-sign-and-run.sh" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>com.apple.security.hypervisor</key> | ||
| <true/> | ||
| </dict> | ||
| </plist> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/usr/bin/env bash | ||
| set -Eeuo pipefail | ||
|
|
||
|
|
||
| codesign -f -s - --entitlements "$(dirname "$0")/macos-entitlements.plist" "$1" | ||
| exec "$@" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| /* | ||
| Copyright 2026 The Hyperlight Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| use crate::vmem::bits; | ||
|
|
||
| const ESR_EC_DATA_ABORT_LOWER_EL: u64 = 0b100100; | ||
| const ESR_EC_DATA_ABORT_SAME_EL: u64 = 0b100101; | ||
|
|
||
| // some of the data in these is not used presently, but is logically | ||
| // part of the code being decoded & should be accounted for | ||
| #[allow(dead_code)] | ||
| #[derive(Debug, Copy, Clone)] | ||
| pub enum DataFaultKind { | ||
| TranslationFault(i64), | ||
| PermissionFault(i64), | ||
| Other(u64), | ||
| } | ||
| fn decode_data_fault_status_code(dfsc: u64) -> DataFaultKind { | ||
| if bits::<5, 2>(dfsc) == 0b0011 { | ||
| DataFaultKind::PermissionFault(bits::<1, 0>(dfsc) as i64) | ||
| } else if bits::<5, 2>(dfsc) == 0b0001 { | ||
| DataFaultKind::TranslationFault(bits::<1, 0>(dfsc) as i64) | ||
| } else if bits::<5, 2>(dfsc) == 0b1010 { | ||
| if bits::<1, 0>(dfsc) >= 2 { | ||
| DataFaultKind::TranslationFault(bits::<1, 0>(dfsc) as i64 - 4) | ||
| } else { | ||
| DataFaultKind::Other(dfsc) | ||
| } | ||
| } else { | ||
| DataFaultKind::Other(dfsc) | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Copy, Clone)] | ||
| pub struct DataFaultInstructionSyndrome { | ||
| pub srt: u8, | ||
| // ... | ||
| } | ||
| fn decode_data_fault_instruction_syndrome(iss: u64) -> Option<DataFaultInstructionSyndrome> { | ||
| let isv = bits::<24, 24>(iss); | ||
| if isv != 0b1 { | ||
| return None; | ||
| } | ||
| Some(DataFaultInstructionSyndrome { | ||
| srt: bits::<20, 16>(iss) as u8, | ||
| }) | ||
| } | ||
|
|
||
| #[derive(Debug, Copy, Clone)] | ||
| pub struct DataFault { | ||
| pub from_lower_el: bool, | ||
| pub is_s1ptw: bool, | ||
| pub is_write: bool, | ||
| pub kind: DataFaultKind, | ||
| pub insn: Option<DataFaultInstructionSyndrome>, | ||
| } | ||
|
|
||
| fn decode_data_fault(from_lower_el: bool, iss: u64) -> DataFault { | ||
| DataFault { | ||
| from_lower_el, | ||
| is_s1ptw: bits::<7, 7>(iss) == 0b1, | ||
| is_write: bits::<6, 6>(iss) == 0b1, | ||
| kind: decode_data_fault_status_code(bits::<5, 0>(iss)), | ||
| insn: decode_data_fault_instruction_syndrome(iss), | ||
| } | ||
| } | ||
|
|
||
| // some of the data in these is not used presently, but is logically | ||
| // part of the code being decoded & should be accounted for | ||
| #[allow(dead_code)] | ||
| #[derive(Debug, Copy, Clone)] | ||
| pub enum Exception { | ||
| /// lower el?, faulting address, status code | ||
| DataFault(DataFault), | ||
| Other(u64), | ||
| } | ||
| /// Decode the value of ESR_ELx into a nice enum. Also takes FAR_ELx, | ||
| /// which will be embedded in the structure if relevant. | ||
| pub fn decode_syndrome(esr: u64) -> Exception { | ||
| let ec = bits::<31, 26>(esr); | ||
| match ec { | ||
| ESR_EC_DATA_ABORT_LOWER_EL | ESR_EC_DATA_ABORT_SAME_EL => Exception::DataFault( | ||
| decode_data_fault(ec == ESR_EC_DATA_ABORT_LOWER_EL, bits::<24, 0>(esr)), | ||
| ), | ||
| _ => Exception::Other(esr), | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it sounds like only old aarch64 snapshot are no longer loadable which might be a bit confusing. Also should we make this a bullet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The aarch64 ones are the only ones that actually changed in layout, so I think this is more accurate. (I bumped the global version because it seems difficult with the current infrastructure to make the change arch-specific, and as far as I know nobody is depending on snapshot compatibility yet (since we don't really have any guest ABI compatibility guarantees pre-1.0))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah ok