-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dm: Add initial device model project
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. As this is a user mode program, not sure what is the preferred way to put this project, just put it as a sub folder in coconut-svsm and in the workspace. If in the workspace is not preferred, this can be changed in the future. Signed-off-by: Chuanxiao Dong <[email protected]>
- Loading branch information
1 parent
31ebd16
commit 7493e6f
Showing
8 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ members = [ | |
"syscall", | ||
# init process | ||
"init", | ||
# device model application | ||
"dm", | ||
] | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "dm" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[[bin]] | ||
name = "dm" | ||
path = "src/main.rs" | ||
test = false | ||
|
||
[dependencies] | ||
syscall = { path = "../syscall" } | ||
|
||
[lints] | ||
workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
fn main() { | ||
println!("cargo:rustc-link-arg-bin=dm=-nostdlib"); | ||
println!("cargo:rustc-link-arg-bin=dm=-no-pie"); | ||
println!("cargo:rustc-link-arg-bin=dm=-Tdm/dm.lds"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
OUTPUT_ARCH(i386:x86-64) | ||
|
||
PHDRS | ||
{ | ||
text PT_LOAD FLAGS(5); /* Read + Execute */ | ||
rodata PT_LOAD FLAGS(4); /* Read-only */ | ||
data PT_LOAD FLAGS(6); /* Read + Write */ | ||
bss PT_LOAD FLAGS(6); /* Read + Write */ | ||
} | ||
|
||
SECTIONS | ||
{ | ||
.text : { | ||
*(.text) | ||
*(.text.*) | ||
} :text | ||
. = ALIGN(4096); | ||
.rodata : { | ||
*(.rodata) | ||
*(.rodata.*) | ||
} :rodata | ||
. = ALIGN(4096); | ||
.data : { | ||
*(.data) | ||
*(.data.*) | ||
} :data | ||
. = ALIGN(4096); | ||
.bss : { | ||
*(.bss) *(.bss.*) | ||
. = ALIGN(4096); | ||
} :bss | ||
. = ALIGN(4096); | ||
} | ||
|
||
ENTRY(dm_start) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
// | ||
// 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 dm_start() -> ! { | ||
dm_exit(); | ||
} | ||
|
||
#[panic_handler] | ||
fn panic(_info: &PanicInfo<'_>) -> ! { | ||
dm_exit(); | ||
} |