|
| 1 | +// Copyright (c) 2024 Microsoft Corporation |
| 2 | +// Copyright (c) 2024 Alibaba Cloud |
| 3 | +// |
| 4 | +// SPDX-License-Identifier: Apache-2.0 |
| 5 | +// |
| 6 | + |
| 7 | +use scroll::Pread; |
| 8 | + |
| 9 | +#[repr(C)] |
| 10 | +#[derive(Pread)] |
| 11 | +/// Type header of TDREPORT_STRUCT. |
| 12 | +pub struct TdTransportType { |
| 13 | + /// Type of the TDREPORT (0 - SGX, 81 - TDX, rest are reserved). |
| 14 | + pub type_: u8, |
| 15 | + |
| 16 | + /// Subtype of the TDREPORT (Default value is 0). |
| 17 | + pub sub_type: u8, |
| 18 | + |
| 19 | + /// TDREPORT version (Default value is 0). |
| 20 | + pub version: u8, |
| 21 | + |
| 22 | + /// Added for future extension. |
| 23 | + pub reserved: u8, |
| 24 | +} |
| 25 | + |
| 26 | +#[repr(C)] |
| 27 | +#[derive(Pread)] |
| 28 | +/// TDX guest report data, MAC and TEE hashes. |
| 29 | +pub struct ReportMac { |
| 30 | + /// TDREPORT type header. |
| 31 | + pub type_: TdTransportType, |
| 32 | + |
| 33 | + /// Reserved for future extension. |
| 34 | + pub reserved1: [u8; 12], |
| 35 | + |
| 36 | + /// CPU security version. |
| 37 | + pub cpu_svn: [u8; 16], |
| 38 | + |
| 39 | + /// SHA384 hash of TEE TCB INFO. |
| 40 | + pub tee_tcb_info_hash: [u8; 48], |
| 41 | + |
| 42 | + /// SHA384 hash of TDINFO_STRUCT. |
| 43 | + pub tee_td_info_hash: [u8; 48], |
| 44 | + |
| 45 | + /// User defined unique data passed in TDG.MR.REPORT request. |
| 46 | + pub reportdata: [u8; 64], |
| 47 | + |
| 48 | + /// Reserved for future extension. |
| 49 | + pub reserved2: [u8; 32], |
| 50 | + |
| 51 | + /// CPU MAC ID. |
| 52 | + pub mac: [u8; 32], |
| 53 | +} |
| 54 | + |
| 55 | +#[repr(C)] |
| 56 | +#[derive(Pread)] |
| 57 | +/// TDX guest measurements and configuration. |
| 58 | +pub struct TdInfo { |
| 59 | + /// TDX Guest attributes (like debug, spet_disable, etc). |
| 60 | + pub attr: [u8; 8], |
| 61 | + |
| 62 | + /// Extended features allowed mask. |
| 63 | + pub xfam: u64, |
| 64 | + |
| 65 | + /// Build time measurement register. |
| 66 | + pub mrtd: [u64; 6], |
| 67 | + |
| 68 | + /// Software-defined ID for non-owner-defined configuration of the guest - e.g., run-time or OS configuration. |
| 69 | + pub mrconfigid: [u8; 48], |
| 70 | + |
| 71 | + /// Software-defined ID for the guest owner. |
| 72 | + pub mrowner: [u64; 6], |
| 73 | + |
| 74 | + /// Software-defined ID for owner-defined configuration of the guest - e.g., specific to the workload. |
| 75 | + pub mrownerconfig: [u64; 6], |
| 76 | + |
| 77 | + /// Run time measurement registers. |
| 78 | + pub rtmr: [u64; 24], |
| 79 | + |
| 80 | + /// For future extension. |
| 81 | + pub reserved: [u64; 14], |
| 82 | +} |
| 83 | + |
| 84 | +#[repr(C)] |
| 85 | +#[derive(Pread)] |
| 86 | +/// Output of TDCALL[TDG.MR.REPORT]. |
| 87 | +pub struct TdReport { |
| 88 | + /// Mac protected header of size 256 bytes. |
| 89 | + pub report_mac: ReportMac, |
| 90 | + |
| 91 | + /// Additional attestable elements in the TCB are not reflected in the report_mac. |
| 92 | + pub tee_tcb_info: [u8; 239], |
| 93 | + |
| 94 | + /// Added for future extension. |
| 95 | + pub reserved: [u8; 17], |
| 96 | + |
| 97 | + /// Measurements and configuration data of size 512 bytes. |
| 98 | + pub tdinfo: TdInfo, |
| 99 | +} |
0 commit comments