mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-10 13:56:48 +00:00
Support TDX debugging feature
This commit is contained in:
parent
05ff441577
commit
d67976da88
@ -4,12 +4,16 @@ use std::process::exit;
|
||||
|
||||
use vsc::VscLaunchConfig;
|
||||
|
||||
use super::{build::create_base_and_cached_build, util::DEFAULT_TARGET_RELPATH};
|
||||
use super::{
|
||||
build::create_base_and_cached_build,
|
||||
util::{is_tdx_enabled, DEFAULT_TARGET_RELPATH},
|
||||
};
|
||||
use crate::{
|
||||
config::{scheme::ActionChoice, Config},
|
||||
error::Errno,
|
||||
error_msg,
|
||||
util::{get_current_crate_info, get_target_directory},
|
||||
warn_msg,
|
||||
};
|
||||
|
||||
pub fn execute_run_command(config: &Config, gdb_server_args: Option<&str>) {
|
||||
@ -65,6 +69,18 @@ fn adapt_for_gdb_server(config: &mut Config, gdb_server_str: &str) -> Option<Vsc
|
||||
config.run.qemu.args += " -S";
|
||||
}
|
||||
|
||||
if is_tdx_enabled() {
|
||||
let target = "-object tdx-guest,";
|
||||
if let Some(pos) = config.run.qemu.args.find(target) {
|
||||
let insert_pos = pos + target.len();
|
||||
config.run.qemu.args.insert_str(insert_pos, "debug=on,");
|
||||
} else {
|
||||
warn_msg!(
|
||||
"TDX is enabled, but the TDX guest object is not found in the QEMU arguments"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure debug info added when debugging in the release profile.
|
||||
if config.run.build.profile.contains("release") {
|
||||
config
|
||||
|
@ -25,3 +25,7 @@ pub fn profile_name_adapter(profile: &str) -> &str {
|
||||
pub fn bin_file_name() -> String {
|
||||
get_current_crate_info().name + "-osdk-bin"
|
||||
}
|
||||
|
||||
pub(crate) fn is_tdx_enabled() -> bool {
|
||||
std::env::var("INTEL_TDX").is_ok_and(|s| s == "1")
|
||||
}
|
||||
|
@ -43,14 +43,14 @@ pub(crate) fn init_cvm_guest() {
|
||||
match init_tdx() {
|
||||
Ok(td_info) => {
|
||||
early_println!(
|
||||
"Intel TDX initialized\ntd gpaw: {}, td attributes: {:?}",
|
||||
"[kernel] Intel TDX initialized\n[kernel] td gpaw: {}, td attributes: {:?}",
|
||||
td_info.gpaw,
|
||||
td_info.attributes
|
||||
);
|
||||
}
|
||||
Err(InitError::TdxGetVpInfoError(td_call_error)) => {
|
||||
panic!(
|
||||
"Intel TDX not initialized, Failed to get TD info: {:?}",
|
||||
"[kernel] Intel TDX not initialized, Failed to get TD info: {:?}",
|
||||
td_call_error
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user