Skip to content

Commit 1db294b

Browse files
committed
tmp (x7)
Signed-off-by: danbugs <[email protected]>
1 parent 81ca6a1 commit 1db294b

File tree

32 files changed

+1033
-1081
lines changed

32 files changed

+1033
-1081
lines changed

Cargo.toml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ members = [
1111
"src/hyperlight_host",
1212
"src/hyperlight_guest_capi",
1313
"src/hyperlight_testing",
14-
"src/hyperlight_host/fuzz",
15-
# "src/tests/rust_guests/simpleguest",
14+
"fuzz",
1615
]
1716
# Because hyperlight-guest has custom linker flags,
1817
# we exclude it from the default-members list
@@ -21,13 +20,7 @@ members = [
2120
exclude = [
2221
"src/tests/rust_guests/callbackguest",
2322
"src/tests/rust_guests/dummyguest",
24-
"src/tests/rust_guests/simpleguest",
25-
# TODO(danbugs:297): This is a temporary guest to test
26-
# the new memory layout. Once I'm done w/
27-
# the work, I'll delete it. `simpleguest`
28-
# and `callbackguest` will be demonstrative
29-
# of the work by themselves.
30-
"src/tests/rust_guests/customguest",
23+
"src/tests/rust_guests/simpleguest",
3124
]
3225

3326
[workspace.package]

Justfile

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ default-target := "debug"
1414
simpleguest_source := "src/tests/rust_guests/simpleguest/target/x86_64-unknown-none"
1515
simpleguest_msvc_source := "src/tests/rust_guests/simpleguest/target/x86_64-pc-windows-msvc"
1616
dummyguest_source := "src/tests/rust_guests/dummyguest/target/x86_64-unknown-none"
17-
# TODO(danbugs:297): Delete
18-
customguest_source := "src/tests/rust_guests/customguest/target/x86_64-unknown-none"
1917
callbackguest_source := "src/tests/rust_guests/callbackguest/target/x86_64-unknown-none"
2018
callbackguest_msvc_source := "src/tests/rust_guests/callbackguest/target/x86_64-pc-windows-msvc"
2119
rust_guests_bin_dir := "src/tests/rust_guests/bin"
@@ -37,22 +35,18 @@ tar-static-lib: (build-rust-capi "release") (build-rust-capi "debug")
3735

3836
# BUILDING
3937
build-rust-guests target=default-target:
38+
cd src/tests/rust_guests/callbackguest && cargo build --profile={{ if target == "debug" { "dev" } else { target } }}
39+
cd src/tests/rust_guests/callbackguest && cargo build --profile={{ if target == "debug" { "dev" } else { target } }} --target=x86_64-pc-windows-msvc
4040
cd src/tests/rust_guests/simpleguest && cargo build --profile={{ if target == "debug" { "dev" } else { target } }}
4141
cd src/tests/rust_guests/simpleguest && cargo build --profile={{ if target == "debug" { "dev" } else { target } }} --target=x86_64-pc-windows-msvc
42-
# TODO(danbugs:297): clean up
43-
# cd src/tests/rust_guests/callbackguest && cargo build --profile={{ if target == "debug" { "dev" } else { target } }}
44-
# cd src/tests/rust_guests/callbackguest && cargo build --profile={{ if target == "debug" { "dev" } else { target } }} --target=x86_64-pc-windows-msvc
45-
# cd src/tests/rust_guests/dummyguest && cargo build --profile={{ if target == "debug" { "dev" } else { target } }}
46-
# cd src/tests/rust_guests/customguest && cargo build --profile={{ if target == "debug" { "dev" } else { target } }}
42+
cd src/tests/rust_guests/dummyguest && cargo build --profile={{ if target == "debug" { "dev" } else { target } }}
4743

4844
@move-rust-guests target=default-target:
45+
cp {{ callbackguest_source }}/{{ target }}/callbackguest* {{ rust_guests_bin_dir }}/{{ target }}/
46+
cp {{ callbackguest_msvc_source }}/{{ target }}/callbackguest* {{ rust_guests_bin_dir }}/{{ target }}/
4947
cp {{ simpleguest_source }}/{{ target }}/simpleguest* {{ rust_guests_bin_dir }}/{{ target }}/
5048
cp {{ simpleguest_msvc_source }}/{{ target }}/simpleguest* {{ rust_guests_bin_dir }}/{{ target }}/
51-
# TODO(danbugs:297): Delete
52-
# cp {{ callbackguest_source }}/{{ target }}/callbackguest* {{ rust_guests_bin_dir }}/{{ target }}/
53-
# cp {{ callbackguest_msvc_source }}/{{ target }}/callbackguest* {{ rust_guests_bin_dir }}/{{ target }}/
54-
# cp {{ dummyguest_source }}/{{ target }}/dummyguest* {{ rust_guests_bin_dir }}/{{ target }}/
55-
# cp {{ customguest_source }}/{{ target }}/customguest* {{ rust_guests_bin_dir }}/{{ target }}/
49+
cp {{ dummyguest_source }}/{{ target }}/dummyguest* {{ rust_guests_bin_dir }}/{{ target }}/
5650

5751
build-and-move-rust-guests: (build-rust-guests "debug") (move-rust-guests "debug") (build-rust-guests "release") (move-rust-guests "release")
5852
build-and-move-c-guests: (build-c-guests "debug") (move-c-guests "debug") (build-c-guests "release") (move-c-guests "release")
@@ -75,8 +69,6 @@ clean-rust:
7569
cargo clean
7670
cd src/tests/rust_guests/simpleguest && cargo clean
7771
cd src/tests/rust_guests/dummyguest && cargo clean
78-
# TODO(danbugs:297): Delete
79-
cd src/tests/rust_guests/customguest && cargo clean
8072
cd src/tests/rust_guests/callbackguest && cargo clean
8173
git clean -fdx src/tests/c_guests/bin src/tests/rust_guests/bin
8274

@@ -143,8 +135,6 @@ fmt-apply:
143135
cargo +nightly fmt --manifest-path src/tests/rust_guests/callbackguest/Cargo.toml
144136
cargo +nightly fmt --manifest-path src/tests/rust_guests/simpleguest/Cargo.toml
145137
cargo +nightly fmt --manifest-path src/tests/rust_guests/dummyguest/Cargo.toml
146-
# TODO(danbugs:297): Delete
147-
cargo +nightly fmt --manifest-path src/tests/rust_guests/customguest/Cargo.toml
148138
cargo +nightly fmt --manifest-path src/hyperlight_guest_capi/Cargo.toml
149139

150140
clippy target=default-target:

docs/paging-development-notes.md

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ The following page table structs are set up in memory before running a Hyperligh
2929
### PML4 (Page Map Level 4) Table
3030

3131
The PML4 table is located at physical address specified in CR3. In Hyperlight we set
32-
`CR3=pml4_address` (i.e., i.e., base address (0x0) + aligned guest code size), which
33-
means the PML4 table is located at physical address `0x0`. The PML4 table comprises
34-
512 64-bit entries.
32+
`CR3=pml4_address`. The PML4 table comprises 512 64-bit entries.
3533

3634
In Hyperlight, we only initialize the first entry, with value `0x1_000`, implying that
3735
we only have a single PDPT.
@@ -103,48 +101,3 @@ PML4E, PDPTE, and PD Entries have the present flag set to 1, and the rest of the
103101
flags are not set.
104102

105103
PTE Entries all have the present flag set to 1.
106-
107-
In addition, the following flags are set according to the type of memory being
108-
mapped:
109-
110-
For `Host Function Definitions` and `Host Exception Data` the NX flag is set to 1
111-
meaning that the memory is not executable in the guest and is not accessible to
112-
guest code (ring 3) and is also read only even in ring 0.
113-
114-
For `Input/Output Data`, `Page Table Data`, `PEB`, `PanicContext` and
115-
`GuestErrorData` the NX flag is set to 1 meaning that the memory is not executable
116-
in the guest and the RW flag is set to 1 meaning that the memory is read/write in
117-
ring 0, this means that this data is not accessible to guest code unless accessed
118-
via the Hyperlight Guest API (which will be in ring 0).
119-
120-
For `Code` the NX flag is not set meaning that the memory is executable in the guest
121-
and the RW flag is set to 1 meaning the data is read/write, as the user/supervisor
122-
flag is set then the memory is also read/write accessible to user code. (The code
123-
section contains both code and data, so it is marked as read/write. In a future
124-
update we will parse the layout of the code and set the access flags accordingly).
125-
126-
For `Stack` the NX flag is set to 1 meaning that the memory is not executable in the
127-
guest, the RW flag is set to 1 meaning the data is read/write, as the
128-
user/supervisor flag is set then the memory is also read/write accessible to user
129-
code.
130-
131-
For `Heap` the RW flag is set to 1 meaning the data is read/write, as the
132-
user/supervisor flag is set then the memory is also read/write accessible to user
133-
code. The NX flag is not set if the feature `executable_heap` is enabled, otherwise
134-
the NX flag is set to 1 meaning that the memory is not executable in the guest. The
135-
`executable_heap` feature is disabled by default. It is required to allow data in
136-
the heap to be executable to when guests dynamically load or generate code, e.g.
137-
`hyperlight-wasm` supports loading of AOT compiled WebAssembly modules, these are
138-
loaded dynamically by the Wasm runtime and end up in the heap, therefore for this
139-
scenario the `executable_heap` feature must be enabled. In a future update we will
140-
implement a mechanism to allow the guest to request memory to be executable at
141-
runtime via the Hyperlight Guest API.
142-
143-
For `Guard Pages` the NX flag is set to 1 meaning that the memory is not executable
144-
in the guest. The RW flag is set to 1 meaning the data is read/write, as the
145-
user/supervisor flag is set then the memory is also read/write accessible to user
146-
code. **Note that neither of these flags should really be set as the purpose of the
147-
guard pages is to cause a fault if accessed, however, as we deal with this fault in
148-
the host not in the guest we need to make the memory accessible to the guest, in a
149-
future update we will implement exception and interrupt handling in the guest and
150-
then change these flags.**

src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub struct FunctionCall {
4747
pub function_name: String,
4848
/// The parameters for the function call.
4949
pub parameters: Option<Vec<ParameterValue>>,
50-
pub function_call_type: FunctionCallType,
50+
function_call_type: FunctionCallType,
5151
/// The return type of the function call
5252
pub expected_return_type: ReturnType,
5353
}

src/hyperlight_common/src/flatbuffer_wrappers/hyperlight_peb.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
Copyright 2024 The Hyperlight Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
116
use crate::PAGE_SIZE;
217

318
/// Hyperlight supports 2 primary modes:

src/hyperlight_common/src/flatbuffer_wrappers/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,4 @@ pub mod guest_log_level;
2525
pub mod host_function_definition;
2626
/// cbindgen:ignore
2727
pub mod host_function_details;
28-
pub mod hyperlight_peb;
2928
pub mod util;

0 commit comments

Comments
 (0)