Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
6d32033
feat: opentmk init
mayank-microsoft Mar 10, 2025
351199b
feat: added docs
mayank-microsoft Apr 21, 2025
3e1673e
refactor(opentmk): interrupt handler doesn't need to save state for a…
mayank-microsoft Apr 21, 2025
056bf7d
reafctor(opentmk): remove dead code
mayank-microsoft Apr 21, 2025
6d37a84
chore: resolve PR feedback
mayank-microsoft May 11, 2025
53e0da2
chore: resolve PR feedback
mayank-microsoft May 12, 2025
7eb38ff
refactor: resolve PR feedback
mayank-microsoft May 12, 2025
2d2aec4
reafactor: errors for hyper-v error handling
mayank-microsoft May 21, 2025
4cd03a5
feat: add test for a negitive case where parition has not enabled VTL1
mayank-microsoft May 21, 2025
bb22270
docs: add documentation for structs
mayank-microsoft May 22, 2025
e9fef3a
rtc+broken misc test
mayank-microsoft Jul 3, 2025
9a0ef26
clippy fixup
mayank-microsoft Jul 3, 2025
e02ee17
broken
mayank-microsoft Jul 17, 2025
48d300a
chore: add tpm working
mayank-microsoft Jul 29, 2025
7bdf91f
feat: add new cvm tests
mayank-microsoft Aug 12, 2025
1104901
lint: add lints for imports
mayank-microsoft Aug 12, 2025
c0f3e0a
chore: resolve PR comments
mayank-microsoft Aug 26, 2025
7f33bbd
chore: resolve PR comments
mayank-microsoft Aug 27, 2025
a49da94
feat: compiles on Arm64
mayank-microsoft Aug 27, 2025
9bdf302
chore: resolve copilot comments
mayank-microsoft Aug 27, 2025
fc0b866
chore: remove default impl for channel
mayank-microsoft Aug 27, 2025
7019671
cleanup
mayank-microsoft Aug 27, 2025
7d70c67
fix: compiler error
mayank-microsoft Aug 28, 2025
43e04f0
chore: add back features
mayank-microsoft Aug 28, 2025
4560aa6
feat: add register intercept test
mayank-microsoft Sep 2, 2025
d28f9c3
lint: ran cargo fmt
mayank-microsoft Sep 2, 2025
1b31943
fix: changes to make register intercepts CVM ready
mayank-microsoft Sep 2, 2025
a20e5cb
refactor: reduce number of cfgs
mayank-microsoft Sep 5, 2025
84297d4
chore: resolve PR comments
mayank-microsoft Sep 8, 2025
c22989a
chore: pr comments resolve
mayank-microsoft Sep 8, 2025
151ae4f
chore: resolve PR comment
mayank-microsoft Sep 8, 2025
7f241aa
chore: resolve PR comments
mayank-microsoft Sep 8, 2025
f961d8a
chore: resolve PR comments
mayank-microsoft Sep 8, 2025
63becb0
chore: adding reason for inline(never)
mayank-microsoft Sep 8, 2025
2be9b2d
chore: update error description
mayank-microsoft Sep 8, 2025
cc9205d
chore: resolve PR comments
mayank-microsoft Sep 8, 2025
93845da
chore: updates for clippy pass
mayank-microsoft Sep 8, 2025
8c436ec
chore: unimplemented functions should not have irrelavant docs
mayank-microsoft Sep 8, 2025
909f2b0
chore: depende on minimal_rt for aarch64 serial port communication
mayank-microsoft Sep 8, 2025
66ee0b7
chore: resolve PR comments
mayank-microsoft Sep 8, 2025
1d687da
chore: resolve PR comments
mayank-microsoft Oct 7, 2025
119afb5
Merge branch 'main' into target-opentmk
mattkur Oct 7, 2025
c32ecbf
Merge branch 'main' into target-opentmk
mayank-microsoft Oct 7, 2025
77e7129
Cargo.lock merge fix
mattkur Oct 7, 2025
4105362
cleanup: remove files not required with the PR merged
mayank-microsoft Oct 7, 2025
ff51df4
chore: refactor for PR comments
mayank-microsoft Oct 7, 2025
a0d6037
chore: [WIP] flowey fixups
mayank-microsoft Oct 8, 2025
e67c794
chore: resolve lint errors
mayank-microsoft Oct 13, 2025
96603fe
chore: resolve lint error
mayank-microsoft Oct 13, 2025
3ca6418
build: fix failure fixes
mayank-microsoft Oct 13, 2025
c0f8aca
fix: build errors
mayank-microsoft Oct 13, 2025
b95eaf6
fix: nightly feature ci failures
mayank-microsoft Oct 13, 2025
b725ef5
fix: ci failures
mayank-microsoft Oct 13, 2025
0952aec
fix: build failures
mayank-microsoft Oct 13, 2025
19a7312
chore: resolve copilot comments
mayank-microsoft Oct 14, 2025
1af6f82
Merge branch 'main' into target-opentmk
mayank-microsoft Oct 15, 2025
a61d548
chore: resolve copilot comments
mayank-microsoft Oct 16, 2025
083a52f
fix: no_mangle should be unsafe
mayank-microsoft Oct 16, 2025
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
69 changes: 69 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3769,6 +3769,15 @@ dependencies = [
"escape8259",
]

[[package]]
name = "linked_list_allocator"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286"
dependencies = [
"spinning_top",
]

[[package]]
name = "linkme"
version = "0.3.33"
Expand Down Expand Up @@ -4622,6 +4631,14 @@ dependencies = [
"libc",
]

[[package]]
name = "nostd_spin_channel"
version = "0.0.0"
dependencies = [
"spin 0.10.0",
"thiserror 2.0.16",
]

[[package]]
name = "ntapi"
version = "0.4.1"
Expand Down Expand Up @@ -5071,6 +5088,28 @@ dependencies = [
"thiserror 2.0.16",
]

[[package]]
name = "opentmk"
version = "0.0.0"
dependencies = [
"bitfield-struct 0.11.0",
"cfg-if",
"hvdef",
"lazy_static",
"linked_list_allocator",
"log",
"memory_range",
"minimal_rt",
"nostd_spin_channel",
"serde",
"serde_json",
"spin 0.10.0",
"thiserror 2.0.16",
"uefi",
"x86_64",
"zerocopy 0.8.25",
]

[[package]]
name = "openvmm"
version = "0.0.0"
Expand Down Expand Up @@ -6842,6 +6881,18 @@ name = "spin"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5fe4ccb98d9c292d56fec89a5e07da7fc4cf0dc11e156b41793132775d3e591"
dependencies = [
"lock_api",
]

[[package]]
name = "spinning_top"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0"
dependencies = [
"lock_api",
]

[[package]]
name = "spki"
Expand Down Expand Up @@ -9441,6 +9492,12 @@ dependencies = [
"vmsocket",
]

[[package]]
name = "volatile"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "442887c63f2c839b346c192d047a7c87e73d0689c9157b00b53dcc27dd5ea793"

[[package]]
name = "vpci"
version = "0.0.0"
Expand Down Expand Up @@ -10174,6 +10231,18 @@ dependencies = [
"tap",
]

[[package]]
name = "x86_64"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f042214de98141e9c8706e8192b73f56494087cc55ebec28ce10f26c5c364ae"
dependencies = [
"bit_field",
"bitflags 2.9.3",
"rustversion",
"volatile",
]

[[package]]
name = "x86defs"
version = "0.0.0"
Expand Down
11 changes: 9 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ members = [
"vm/loader/igvmfilegen",
"vm/vmgs/vmgs_lib",
"vm/vmgs/vmgstool",
# opentmk
"opentmk",
]
exclude = [
"xsync",
Expand Down Expand Up @@ -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" }
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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 }
Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.
Expand Down
4 changes: 2 additions & 2 deletions flowey/flowey_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ fs-err.workspace = true
log.workspace = true
parking_lot.workspace = true
petgraph.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true, features = ["raw_value"] }
serde = { workspace = true, features = ["std", "derive"] }
serde_json = { workspace = true, features = ["std", "raw_value"] }
serde_yaml.workspace = true
toml_edit = { workspace = true, features = ["serde"] }
xshell.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion flowey/flowey_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ anyhow.workspace = true
fs-err.workspace = true
linkme.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
serde_json = { workspace = true, features = ["std"] }
serde_yaml.workspace = true

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion flowey/flowey_hvlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ vmm_test_images = { workspace = true, features = ["serde", "clap"] }
anyhow.workspace = true
clap = { workspace = true, features = ["derive"] }
log.workspace = true
serde.workspace = true
serde = { workspace = true, features = ["std"] }
target-lexicon = { workspace = true, features = ["serde_support"] }

[lints]
Expand Down
4 changes: 2 additions & 2 deletions flowey/flowey_lib_common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ home.workspace = true
log.workspace = true
rlimit.workspace = true
rustc-hash.workspace = true
serde.workspace = true
serde_json.workspace = true
serde = { workspace = true, features = ["std"] }
serde_json = { workspace = true, features = ["std"] }
target-lexicon = { workspace = true, features = ["serde_support"] }
toml_edit.workspace = true
which.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions flowey/flowey_lib_hvlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ igvmfilegen_config.workspace = true
anyhow.workspace = true
fs-err.workspace = true
log.workspace = true
serde.workspace = true
serde_json.workspace = true
serde = { workspace = true, features = ["std"] }
serde_json = { workspace = true, features = ["std"] }
target-lexicon = { workspace = true, features = ["serde_support"] }
which.workspace = true
xshell.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion openhcl/openhcl_attestation_protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ base64.workspace = true
base64-serde.workspace = true
hex.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
serde_json = { workspace = true, features = ["std"] }
zerocopy.workspace = true

[lints]
Expand Down
4 changes: 2 additions & 2 deletions openhcl/underhill_attestation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ base64.workspace = true
base64-serde.workspace = true
getrandom.workspace = true
openssl.workspace = true
serde.workspace = true
serde_json.workspace = true
serde = { workspace = true, features = ["std"] }
serde_json = { workspace = true, features = ["std"] }
static_assertions.workspace = true
thiserror.workspace = true
time = { workspace = true, features = ["macros"] }
Expand Down
2 changes: 1 addition & 1 deletion openhcl/underhill_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ libc.workspace = true
parking_lot.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_helpers.workspace = true
serde_json.workspace = true
serde_json = { workspace = true, features = ["std"] }
socket2.workspace = true
thiserror = { workspace = true, features = ["std"] }
time = { workspace = true, features = ["macros"] }
Expand Down
30 changes: 30 additions & 0 deletions opentmk/Cargo.toml
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]
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]
3 changes: 3 additions & 0 deletions opentmk/README.md
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.
9 changes: 9 additions & 0 deletions opentmk/build.rs
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)");
}
29 changes: 29 additions & 0 deletions opentmk/src/arch/aarch64/hypercall.rs
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);
}
4 changes: 4 additions & 0 deletions opentmk/src/arch/aarch64/mod.rs
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;
17 changes: 17 additions & 0 deletions opentmk/src/arch/mod.rs
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");
}
);
Loading