Skip to content

Commit 7646260

Browse files
committed
cvm: Better error report for tdx quote error
1 parent 4b756f6 commit 7646260

File tree

4 files changed

+27
-20
lines changed

4 files changed

+27
-20
lines changed

dstack-util/src/main.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,12 @@ impl core::fmt::Debug for ParsedReport {
271271
}
272272

273273
fn cmd_show_mrs() -> Result<()> {
274-
let attestation = ra_tls::attestation::Attestation::local()?;
275-
let app_info = attestation.decode_app_info(false)?;
276-
serde_json::to_writer_pretty(io::stdout(), &app_info)?;
274+
let attestation =
275+
ra_tls::attestation::Attestation::local().context("Failed to get attestation")?;
276+
let app_info = attestation
277+
.decode_app_info(false)
278+
.context("Failed to decode app info")?;
279+
serde_json::to_writer_pretty(io::stdout(), &app_info).context("Failed to write app info")?;
277280
println!();
278281
Ok(())
279282
}

dstack-util/src/system_setup.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,9 @@ impl<'a> Stage0<'a> {
551551

552552
async fn setup_fs(self) -> Result<Stage1<'a>> {
553553
let is_initialized = self.shared.instance_info.is_initialized();
554-
let app_info = self.measure_app_info()?;
554+
let app_info = self
555+
.measure_app_info()
556+
.context("Failed to measure app info")?;
555557
if self.shared.app_compose.key_provider().is_kms() {
556558
cmd_show_mrs()?;
557559
}

ra-tls/src/attestation.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,11 @@ impl<T> Attestation<T> {
234234
impl Attestation {
235235
/// Create an attestation for local machine
236236
pub fn local() -> Result<Self> {
237-
let (_, quote) = tdx_attest::get_quote(&[0u8; 64], None)?;
238-
let event_log = tdx_attest::eventlog::read_event_logs()?;
239-
let raw_event_log = serde_json::to_vec(&event_log)?;
237+
let (_, quote) = tdx_attest::get_quote(&[0u8; 64], None).context("Failed to get quote")?;
238+
let event_log =
239+
tdx_attest::eventlog::read_event_logs().context("Failed to read event logs")?;
240+
let raw_event_log =
241+
serde_json::to_vec(&event_log).context("Failed to serialize event log")?;
240242
Ok(Self {
241243
quote,
242244
raw_event_log,

tdx-attest/src/linux.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,32 @@ use crate::{Result, TdxUuid};
2424
#[repr(u32)]
2525
#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, Error)]
2626
pub enum TdxAttestError {
27-
#[error("unexpected")]
27+
#[error("TDX_ATTEST_ERROR_UNEXPECTED")]
2828
Unexpected = _tdx_attest_error_t::TDX_ATTEST_ERROR_UNEXPECTED,
29-
#[error("invalid parameter")]
29+
#[error("TDX_ATTEST_ERROR_INVALID_PARAMETER")]
3030
InvalidParameter = _tdx_attest_error_t::TDX_ATTEST_ERROR_INVALID_PARAMETER,
31-
#[error("out of memory")]
31+
#[error("TDX_ATTEST_ERROR_OUT_OF_MEMORY")]
3232
OutOfMemory = _tdx_attest_error_t::TDX_ATTEST_ERROR_OUT_OF_MEMORY,
33-
#[error("vsock failure")]
33+
#[error("TDX_ATTEST_ERROR_VSOCK_FAILURE")]
3434
VsockFailure = _tdx_attest_error_t::TDX_ATTEST_ERROR_VSOCK_FAILURE,
35-
#[error("report failure")]
35+
#[error("TDX_ATTEST_ERROR_REPORT_FAILURE")]
3636
ReportFailure = _tdx_attest_error_t::TDX_ATTEST_ERROR_REPORT_FAILURE,
37-
#[error("extend failure")]
37+
#[error("TDX_ATTEST_ERROR_EXTEND_FAILURE")]
3838
ExtendFailure = _tdx_attest_error_t::TDX_ATTEST_ERROR_EXTEND_FAILURE,
39-
#[error("not supported")]
39+
#[error("TDX_ATTEST_ERROR_NOT_SUPPORTED")]
4040
NotSupported = _tdx_attest_error_t::TDX_ATTEST_ERROR_NOT_SUPPORTED,
41-
#[error("quote failure")]
41+
#[error("TDX_ATTEST_ERROR_QUOTE_FAILURE")]
4242
QuoteFailure = _tdx_attest_error_t::TDX_ATTEST_ERROR_QUOTE_FAILURE,
43-
#[error("busy")]
43+
#[error("TDX_ATTEST_ERROR_BUSY")]
4444
Busy = _tdx_attest_error_t::TDX_ATTEST_ERROR_BUSY,
45-
#[error("device failure")]
45+
#[error("TDX_ATTEST_ERROR_DEVICE_FAILURE")]
4646
DeviceFailure = _tdx_attest_error_t::TDX_ATTEST_ERROR_DEVICE_FAILURE,
47-
#[error("invalid rtmr index")]
47+
#[error("TDX_ATTEST_ERROR_INVALID_RTMR_INDEX")]
4848
InvalidRtmrIndex = _tdx_attest_error_t::TDX_ATTEST_ERROR_INVALID_RTMR_INDEX,
49-
#[error("unsupported att key id")]
49+
#[error("TDX_ATTEST_ERROR_UNSUPPORTED_ATT_KEY_ID")]
5050
UnsupportedAttKeyId = _tdx_attest_error_t::TDX_ATTEST_ERROR_UNSUPPORTED_ATT_KEY_ID,
5151
#[num_enum(catch_all)]
52-
#[error("unknown error ({0})")]
52+
#[error("unknown tdx attest error ({0})")]
5353
UnknownError(u32),
5454
}
5555

0 commit comments

Comments
 (0)