-
Notifications
You must be signed in to change notification settings - Fork 155
feat(opentmk): opentmk framework with first testcase #1210
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
Changes from all commits
6d32033
351199b
3e1673e
056bf7d
6d37a84
53e0da2
7eb38ff
2d2aec4
4cd03a5
bb22270
e9fef3a
9a0ef26
e02ee17
48d300a
7bdf91f
1104901
c0f3e0a
7f33bbd
a49da94
9bdf302
fc0b866
7019671
7d70c67
43e04f0
4560aa6
d28f9c3
1b31943
a20e5cb
84297d4
c22989a
151ae4f
7f241aa
f961d8a
63becb0
2be9b2d
cc9205d
93845da
8c436ec
909f2b0
66ee0b7
1d687da
119afb5
c32ecbf
77e7129
4105362
ff51df4
a0d6037
e67c794
96603fe
3ca6418
c0f8aca
b95eaf6
b725ef5
0952aec
19a7312
1af6f82
a61d548
083a52f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,8 @@ members = [ | |
"vm/loader/igvmfilegen", | ||
"vm/vmgs/vmgs_lib", | ||
"vm/vmgs/vmgstool", | ||
# opentmk | ||
"opentmk", | ||
] | ||
exclude = [ | ||
"xsync", | ||
|
@@ -126,6 +128,7 @@ mesh_rpc = { path = "support/mesh/mesh_rpc" } | |
mesh_worker = { path = "support/mesh/mesh_worker" } | ||
mesh_tracing = { path = "support/mesh_tracing" } | ||
minircu = { path = "support/minircu" } | ||
nostd_spin_channel = { path = "support/nostd_spin_channel"} | ||
open_enum = { path = "support/open_enum" } | ||
openssl_kdf = { path = "support/openssl_kdf" } | ||
openssl_crypto_only = { path = "support/openssl_crypto_only" } | ||
|
@@ -467,9 +470,11 @@ jiff = "0.2.14" | |
kvm-bindings = "0.14.0" | ||
# Use of these specific REPO will go away when changes are taken upstream. | ||
landlock = "0.4.1" | ||
lazy_static = "1.4.0" | ||
libc = "0.2" | ||
libfuzzer-sys = "0.4" | ||
libtest-mimic = "0.8" | ||
linked_list_allocator = "0.10.5" | ||
linkme = "0.3.9" | ||
log = "0.4" | ||
loom = "0.7.2" | ||
|
@@ -506,8 +511,8 @@ rusqlite = "0.37" | |
rustc-hash = "2.1.1" | ||
rustyline = "17" | ||
seccompiler = "0.5" | ||
serde = "1.0.185" | ||
serde_json = "1.0" | ||
serde = { version = "1.0.185", default-features = false } | ||
serde_json = { version = "1.0", default-features = false } | ||
serde_yaml = "0.9" | ||
sha2 = { version = "0.10.8", default-features = false } | ||
shell-words = "1.1" | ||
|
@@ -517,6 +522,7 @@ smallbox = "0.8" | |
smallvec = "1.8" | ||
smoltcp = { version = "0.8", default-features = false } | ||
socket2 = "0.6" | ||
spin = "0.10.0" | ||
stackfuture = "0.3" | ||
static_assertions = "1.1" | ||
syn = "2" | ||
|
@@ -544,6 +550,7 @@ windows = "0.62" | |
windows-service = "0.8" | ||
windows-sys = "0.61" | ||
windows-version = "0.1.4" | ||
x86_64 = { version = "0.15.2", default-features = false } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what are we getting from this dep that we don't already have in x86defs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we use x86_64 heavily for interrupt management. For the IDT structs, helpers and interrupt abi. |
||
xshell = "=0.2.2" # pin to 0.2.2 to work around https://github.com/matklad/xshell/issues/63 | ||
xshell-macros = "0.2" | ||
# We add the derive feature here since the vast majority of our crates use it. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
[package] | ||
name = "opentmk" | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
|
||
[dependencies] | ||
smalis-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
bitfield-struct.workspace = true | ||
cfg-if.workspace = true | ||
hvdef.workspace = true | ||
lazy_static = { workspace = true, features = ["spin_no_std"] } | ||
linked_list_allocator.workspace = true | ||
log.workspace = true | ||
memory_range.workspace = true | ||
minimal_rt.workspace = true | ||
spin.workspace = true | ||
serde = { workspace = true, features = ["derive"]} | ||
serde_json = { workspace = true, features = ["alloc"] } | ||
thiserror.workspace = true | ||
uefi = { workspace = true, features = ["alloc"] } | ||
x86_64 = { workspace = true, features = ["instructions"] } | ||
zerocopy.workspace = true | ||
nostd_spin_channel.workspace = true | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[build-dependencies] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# OpenTMK | ||
|
||
See the guide for more info on how to build/run the code in this crate. | ||
smalis-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
#![expect(missing_docs)] | ||
|
||
fn main() { | ||
// Allow a cfg of nightly to avoid using a feature, see main.rs. | ||
println!("cargo:rustc-check-cfg=cfg(nightly)"); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
//! Hypercall interface for AArch64 architecture. | ||
|
||
/// Writes a synthetic register to tell the hypervisor the OS ID. | ||
fn report_os_id(guest_os_id: u64) { | ||
// On ARM64, to be able to make hypercalls, one needs first to set the Guest OS ID | ||
// synthetic register using a hypercall. Can't use `Hvcall::set_register` at that will | ||
// lead to the infinite recursion as that function will first try initializing hypercalls | ||
// with setting a register. | ||
// | ||
// Only one very specific HvSetVpRegisters hypercall is allowed to set the Guest OS ID | ||
// (this is TLFS section 17.4.4.1.1 and 5.3), and that must be the fast hypercall. | ||
let _ = minimal_rt::arch::hypercall::set_register_fast( | ||
hvdef::HvArm64RegisterName::GuestOsId.into(), | ||
guest_os_id.into(), | ||
); | ||
} | ||
|
||
pub(crate) fn initialize(guest_os_id: u64) { | ||
// We are assuming we are running under a Microsoft hypervisor. | ||
report_os_id(guest_os_id); | ||
} | ||
|
||
/// Call before jumping to kernel. | ||
pub(crate) fn uninitialize() { | ||
report_os_id(0); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
pub mod hypercall; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
//! Imports and re-exports architecture-specific implementations. | ||
|
||
cfg_if::cfg_if!( | ||
if #[cfg(target_arch = "x86_64")] { // xtask-fmt allow-target-arch sys-crate | ||
mod x86_64; | ||
pub use x86_64::*; | ||
|
||
} else if #[cfg(target_arch = "aarch64")] { // xtask-fmt allow-target-arch sys-crate | ||
mod aarch64; | ||
pub use aarch64::*; | ||
} else { | ||
compile_error!("target_arch is not supported"); | ||
} | ||
); |
Uh oh!
There was an error while loading. Please reload this page.