Skip to content

Commit

Permalink
dm: Add initial device model
Browse files Browse the repository at this point in the history
The device model is a user mode program which manages VM's life cycles
and handles various vmexits events. The initial version just calls exit()
syscall without doing anything else.

Signed-off-by: Vijay Dhanraj <[email protected]>
Signed-off-by: Chuanxiao Dong <[email protected]>
  • Loading branch information
vijaydhanraj committed Dec 10, 2024
1 parent 4a6fef6 commit 0000873
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --exclude packit --exclude user* --all-features --tests --target=x86_64-unknown-linux-gnu -- -D warnings
args: --workspace --exclude packit --exclude user* --exclude dm --all-features --tests --target=x86_64-unknown-linux-gnu -- -D warnings

- name: Check documentation
run: make doc
Expand Down
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ members = [
"user/lib",
# Init user-space module
"user/init",
# device model module
"user/dm",
]


Expand All @@ -38,6 +40,7 @@ syscall = { path = "syscall" }
packit = { path = "packit" }
userlib = { path = "user/lib" }
userinit = { path = "user/init" }
dm = { path = "user/dm" }

# crates.io
aes-gcm = { version = "0.10.3", default-features = false }
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ bin/coconut-test-vanadium.igvm: $(IGVMBUILDER) $(IGVMMEASURE) bin/stage1-trampol
$(IGVMMEASURE) --check-kvm --native-zero $@ measure

test:
cargo test ${CARGO_ARGS} ${SVSM_ARGS_TEST} --workspace --exclude=user* --target=x86_64-unknown-linux-gnu
cargo test ${CARGO_ARGS} ${SVSM_ARGS_TEST} --workspace --exclude=user* --exclude=dm --target=x86_64-unknown-linux-gnu

test-igvm: bin/coconut-test-qemu.igvm bin/coconut-test-hyperv.igvm bin/coconut-test-vanadium.igvm

Expand Down Expand Up @@ -176,9 +176,9 @@ bin/svsm-test.bin: bin/stage1-test

clippy:
cargo clippy --workspace --all-features --exclude packit --exclude svsm-fuzz --exclude igvmbuilder --exclude igvmmeasure -- -D warnings
cargo clippy --workspace --all-features --exclude packit --exclude svsm-fuzz --exclude svsm --exclude 'user*' --target=x86_64-unknown-linux-gnu -- -D warnings
cargo clippy --workspace --all-features --exclude packit --exclude svsm-fuzz --exclude svsm --exclude 'user*' --exclude 'dm' --target=x86_64-unknown-linux-gnu -- -D warnings
RUSTFLAGS="--cfg fuzzing" cargo clippy --package svsm-fuzz --all-features --target=x86_64-unknown-linux-gnu -- -D warnings
cargo clippy --workspace --all-features --exclude packit --exclude 'user*' --tests --target=x86_64-unknown-linux-gnu -- -D warnings
cargo clippy --workspace --all-features --exclude packit --exclude 'user*' --exclude 'dm' --tests --target=x86_64-unknown-linux-gnu -- -D warnings

clean:
cargo clean
Expand Down
3 changes: 3 additions & 0 deletions configs/all-targets.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"modules": {
"userinit": {
"path": "/init"
},
"dm": {
"path": "/dm"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions configs/hyperv-target.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
"modules": {
"userinit": {
"path": "/init"
},
"dm": {
"path": "/dm"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions configs/qemu-target.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
"modules": {
"userinit": {
"path": "/init"
},
"dm": {
"path": "/dm"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions configs/vanadium-target.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"modules": {
"userinit": {
"path": "/init"
},
"dm": {
"path": "/dm"
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions user/dm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "dm"
version = "0.1.0"
edition = "2021"

[dependencies]
userlib.workspace = true
syscall = { path = "../../syscall" }

[lints]
workspace = true
4 changes: 4 additions & 0 deletions user/dm/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() {
println!("cargo:rustc-link-arg=-Tuser/lib/module.lds");
println!("cargo:rustc-link-arg=-no-pie");
}
25 changes: 25 additions & 0 deletions user/dm/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
//
// Copyright (c) 2024 Intel Corporation.
//
// Author: Chuanxiao Dong <[email protected]>

#![no_std]
#![no_main]

use core::panic::PanicInfo;
use syscall::exit;

fn dm_exit() -> ! {
exit(0);
}

#[no_mangle]
pub extern "C" fn _start() -> ! {
dm_exit();
}

#[panic_handler]
fn panic(_info: &PanicInfo<'_>) -> ! {
dm_exit();
}

0 comments on commit 0000873

Please sign in to comment.