Skip to content

Commit 8ca2dda

Browse files
authored
Merge branch 'main' into guest-call-host-function-improvements
2 parents e06d40a + 43bcf6e commit 8ca2dda

File tree

27 files changed

+147
-366
lines changed

27 files changed

+147
-366
lines changed

.devcontainer/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
5959
&& rustup default ${RUST_TOOLCHAIN} \
6060
&& rustup target add x86_64-unknown-linux-gnu \
6161
&& rustup target add x86_64-unknown-none \
62-
&& rustup target add x86_64-pc-windows-msvc \
6362
&& rustup toolchain add nightly-x86_64-unknown-linux-gnu \
6463
&& cargo install just
6564

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,10 @@ After having an environment with a hypervisor setup, running the example has the
177177
Azure Linux, run `sudo dnf install build-essential`.
178178
2. [Rust](https://www.rust-lang.org/tools/install). Install toolchain v1.81 or later.
179179

180-
Also, install the `x86_64-pc-windows-msvc` and `x86_64-unknown-none` targets, these are needed to build the test
181-
guest binaries. (Note: install both targets on either Linux or Windows: Hyperlight can load ELF or PE files on either
182-
OS, and the tests/examples are built for both):
183-
180+
Also, install the `x86_64-unknown-none` target, it is needed to build the test
181+
guest binaries.
184182
```sh
185183
rustup target add x86_64-unknown-none
186-
rustup target add x86_64-pc-windows-msvc
187184
```
188185

189186
3. [just](https://github.com/casey/just). `cargo install just` On Windows you also need [pwsh](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.4).

dev/verify-msrv.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,21 @@ 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 cargo +$VERSION check --quiet -p $CRATE; then
10-
echo -e " \u001b[1;32m✓\u001b[0m Crate \u001b[1m$CRATE\u001b[0m builds with rust \u001b[1m$VERSION\u001b[0m"
9+
if [[ "$CRATE" == "hyperlight-guest" ]]; then
10+
TARGET="x86_64-unknown-none"
11+
rustup target add "$TARGET" --toolchain "$VERSION" >/dev/null
12+
if cargo +"$VERSION" check --quiet -p "$CRATE" --target "$TARGET"; then
13+
echo -e " \u001b[1;32m✓\u001b[0m Crate \u001b[1m$CRATE\u001b[0m builds with rust \u001b[1m$VERSION\u001b[0m and target \u001b[1m$TARGET\u001b[0m"
14+
else
15+
echo -e " \u001b[1;31m✗\u001b[0m Crate \u001b[1m$CRATE\u001b[0m fails with rust \u001b[1m$VERSION\u001b[0m and target \u001b[1m$TARGET\u001b[0m"
16+
exit 1
17+
fi
1118
else
12-
echo -e " \u001b[1;31m✗\u001b[0m Crate \u001b[1m$CRATE\u001b[0m fails with rust \u001b[1m$VERSION\u001b[0m"
13-
exit 1
19+
if cargo +"$VERSION" check --quiet -p "$CRATE"; then
20+
echo -e " \u001b[1;32m✓\u001b[0m Crate \u001b[1m$CRATE\u001b[0m builds with rust \u001b[1m$VERSION\u001b[0m"
21+
else
22+
echo -e " \u001b[1;31m✗\u001b[0m Crate \u001b[1m$CRATE\u001b[0m fails with rust \u001b[1m$VERSION\u001b[0m"
23+
exit 1
24+
fi
1425
fi
1526
done

src/hyperlight_guest/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ fn cargo_main() {
121121
copy_includes(&include_dir, "third_party/printf/");
122122
}
123123
if cfg!(feature = "libc") {
124-
copy_includes(&include_dir, "include");
125124
copy_includes(&include_dir, "third_party/musl/include");
126125
copy_includes(&include_dir, "third_party/musl/arch/generic");
127126
copy_includes(&include_dir, "third_party/musl/arch/x86_64");

src/hyperlight_guest/include/setjmp.h

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/hyperlight_guest/src/chkstk.rs

Lines changed: 0 additions & 64 deletions
This file was deleted.

src/hyperlight_guest/src/entrypoint.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ use hyperlight_common::outb::OutBAction;
2222
use log::LevelFilter;
2323
use spin::Once;
2424

25-
use crate::gdt::load_gdt;
25+
#[cfg(target_arch = "x86_64")]
26+
use crate::exceptions::{gdt::load_gdt, idtr::load_idt};
2627
use crate::guest_function_call::dispatch_function;
2728
use crate::guest_logger::init_logger;
2829
use crate::host_function_call::outb;
29-
use crate::idtr::load_idt;
30-
use crate::{__security_cookie, HEAP_ALLOCATOR, MIN_STACK_ADDRESS, OS_PAGE_SIZE, P_PEB};
30+
use crate::{HEAP_ALLOCATOR, MIN_STACK_ADDRESS, OS_PAGE_SIZE, P_PEB};
3131

3232
#[inline(never)]
3333
pub fn halt() {
@@ -73,10 +73,8 @@ extern "C" {
7373

7474
static INIT: Once = Once::new();
7575

76-
// Note: entrypoint cannot currently have a stackframe >4KB, as that will invoke __chkstk on msvc
77-
// target without first having setup global `RUNNING_MODE` variable, which __chkstk relies on.
7876
#[no_mangle]
79-
pub extern "win64" fn entrypoint(peb_address: u64, seed: u64, ops: u64, max_log_level: u64) {
77+
pub extern "C" fn entrypoint(peb_address: u64, seed: u64, ops: u64, max_log_level: u64) {
8078
if peb_address == 0 {
8179
panic!("PEB address is null");
8280
}
@@ -85,7 +83,6 @@ pub extern "win64" fn entrypoint(peb_address: u64, seed: u64, ops: u64, max_log_
8583
unsafe {
8684
P_PEB = Some(peb_address as *mut HyperlightPEB);
8785
let peb_ptr = P_PEB.unwrap();
88-
__security_cookie = peb_address ^ seed;
8986

9087
let srand_seed = ((peb_address << 8 ^ seed >> 4) >> 32) as u32;
9188

@@ -103,9 +100,12 @@ pub extern "win64" fn entrypoint(peb_address: u64, seed: u64, ops: u64, max_log_
103100
// don't have to change the assembly code.
104101
MIN_STACK_ADDRESS = (*peb_ptr).gueststackData.minUserStackAddress;
105102

106-
// Setup GDT and IDT
107-
load_gdt();
108-
load_idt();
103+
#[cfg(target_arch = "x86_64")]
104+
{
105+
// Setup GDT and IDT
106+
load_gdt();
107+
load_idt();
108+
}
109109

110110
let heap_start = (*peb_ptr).guestheapData.guestHeapBuffer as usize;
111111
let heap_size = (*peb_ptr).guestheapData.guestHeapSize as usize;
File renamed without changes.

src/hyperlight_guest/src/interrupt_handlers.rs renamed to src/hyperlight_guest/src/exceptions/handlers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::entrypoint::abort_with_code_and_message;
2424

2525
/// Exception handler
2626
#[no_mangle]
27-
pub extern "sysv64" fn hl_exception_handler(
27+
pub extern "C" fn hl_exception_handler(
2828
stack_pointer: u64,
2929
exception_number: u64,
3030
page_fault_address: u64,

src/hyperlight_guest/src/idt.rs renamed to src/hyperlight_guest/src/exceptions/idt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
use hyperlight_common::outb::Exception;
1818

19-
use crate::interrupt_entry::{
19+
use crate::exceptions::interrupt_entry::{
2020
_do_excp0, _do_excp1, _do_excp10, _do_excp11, _do_excp12, _do_excp13, _do_excp14, _do_excp15,
2121
_do_excp16, _do_excp17, _do_excp18, _do_excp19, _do_excp2, _do_excp20, _do_excp3, _do_excp30,
2222
_do_excp4, _do_excp5, _do_excp6, _do_excp7, _do_excp8, _do_excp9,
@@ -96,7 +96,7 @@ pub(crate) fn init_idt() {
9696
set_idt_entry(Exception::SecurityException as usize, _do_excp30); // Security Exception
9797
}
9898

99-
fn set_idt_entry(index: usize, handler: unsafe extern "sysv64" fn()) {
99+
fn set_idt_entry(index: usize, handler: unsafe extern "C" fn()) {
100100
let handler_addr = handler as *const () as u64;
101101
unsafe {
102102
IDT[index] = IdtEntry::new(handler_addr);

0 commit comments

Comments
 (0)