From d67976da88f24a2b8eaf2a942db02ebeec5cc2fc Mon Sep 17 00:00:00 2001 From: Hsy-Intel Date: Mon, 25 Nov 2024 02:57:20 -0500 Subject: [PATCH] Support TDX debugging feature --- osdk/src/commands/run.rs | 18 +++++++++++++++++- osdk/src/commands/util.rs | 4 ++++ ostd/src/arch/x86/mod.rs | 4 ++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/osdk/src/commands/run.rs b/osdk/src/commands/run.rs index 223f9ddf6..59c542bcd 100644 --- a/osdk/src/commands/run.rs +++ b/osdk/src/commands/run.rs @@ -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 &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") +} diff --git a/ostd/src/arch/x86/mod.rs b/ostd/src/arch/x86/mod.rs index 336ac0e03..880df1294 100644 --- a/ostd/src/arch/x86/mod.rs +++ b/ostd/src/arch/x86/mod.rs @@ -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 ); }