guest_emulation_transport/
api.rs1pub use get_protocol::CreateRamGpaRangeFlags;
9pub use get_protocol::EventLogId;
10pub use get_protocol::GSP_CIPHERTEXT_MAX;
11pub use get_protocol::GspCiphertextContent;
12pub use get_protocol::GspCleartextContent;
13pub use get_protocol::GspExtendedStatusFlags;
14pub use get_protocol::IGVM_ATTEST_MSG_REQ_AGENT_DATA_MAX_SIZE;
15pub use get_protocol::MAX_TRANSFER_SIZE;
16pub use get_protocol::NUMBER_GSP;
17pub use get_protocol::ProtocolVersion;
18pub use get_protocol::SaveGuestVtl2StateFlags;
19pub use get_protocol::VmgsIoStatus;
20
21use guid::Guid;
22use mesh::MeshPayload;
23use std::time::Duration;
24use zerocopy::FromZeros;
25
26#[expect(missing_docs)]
28pub mod platform_settings {
29 pub use get_protocol::dps_json::PcatBootDevice;
30
31 use get_protocol::dps_json::EfiDiagnosticsLogLevelType;
32 use get_protocol::dps_json::GuestStateEncryptionPolicy;
33 use get_protocol::dps_json::GuestStateLifetime;
34 use get_protocol::dps_json::HardwareSealingPolicy;
35 use get_protocol::dps_json::ManagementVtlFeatures;
36 use guid::Guid;
37 use inspect::Inspect;
38
39 #[derive(Debug, Inspect)]
41 pub struct DevicePlatformSettings {
42 pub smbios: Smbios,
43 pub general: General,
44 #[inspect(with = "inspect::iter_by_index")]
45 pub acpi_tables: Vec<Vec<u8>>,
46 }
47
48 #[derive(Debug, Inspect)]
50 pub struct Smbios {
51 pub serial_number: String,
52 pub base_board_serial_number: String,
53 pub chassis_serial_number: String,
54 pub chassis_asset_tag: String,
55
56 pub system_manufacturer: String,
57 pub system_product_name: String,
58 pub system_version: String,
59 pub system_sku_number: String,
60 pub system_family: String,
61 pub bios_lock_string: String,
62 pub memory_device_serial_number: String,
63
64 pub processor_manufacturer: Vec<u8>,
67 pub processor_version: Vec<u8>,
68 pub processor_id: u64,
69 pub external_clock: u16,
70 pub max_speed: u16,
71 pub current_speed: u16,
72 pub processor_characteristics: u16,
73 pub processor_family2: u16,
74 pub processor_type: u8,
75 pub voltage: u8,
76 pub status: u8,
77 pub processor_upgrade: u8,
78 }
79
80 #[derive(Debug, Inspect)]
84 pub struct General {
85 pub secure_boot_enabled: bool,
86 pub secure_boot_template: SecureBootTemplateType,
87 pub bios_guid: Guid,
88 pub console_mode: UefiConsoleMode,
89 pub battery_enabled: bool,
90 pub processor_idle_enabled: bool,
91 pub tpm_enabled: bool,
92 pub ipmi_enabled: bool,
93
94 pub com1_enabled: bool,
95 pub com1_debugger_mode: bool,
96 pub com1_vmbus_redirector: bool,
97 pub com2_enabled: bool,
98 pub com2_debugger_mode: bool,
99 pub com2_vmbus_redirector: bool,
100
101 pub firmware_debugging_enabled: bool,
102 pub hibernation_enabled: bool,
103
104 pub suppress_attestation: Option<bool>,
105 pub generation_id: Option<[u8; 16]>,
106
107 pub legacy_memory_map: bool,
108 pub pause_after_boot_failure: bool,
109 pub pxe_ip_v6: bool,
110 pub measure_additional_pcrs: bool,
111 pub disable_frontpage: bool,
112 pub disable_sha384_pcr: bool,
113 pub media_present_enabled_by_default: bool,
114 pub vpci_boot_enabled: bool,
115 pub memory_protection_mode: MemoryProtectionMode,
116 pub default_boot_always_attempt: bool,
117 pub num_lock_enabled: bool,
118 #[inspect(with = "|x| inspect::iter_by_index(x).map_value(inspect::AsDebug)")]
119 pub pcat_boot_device_order: [PcatBootDevice; 4],
120
121 pub vpci_instance_filter: Option<Guid>,
122 pub nvdimm_count: u16,
123 pub psp_enabled: bool,
124
125 pub vmbus_redirection_enabled: bool,
126 pub always_relay_host_mmio: bool,
127 pub vtl2_settings: Option<underhill_config::Vtl2Settings>,
128
129 pub is_servicing_scenario: bool,
130 pub watchdog_enabled: bool,
131 pub firmware_mode_is_pcat: bool,
132 pub imc_enabled: bool,
133 pub cxl_memory_enabled: bool,
134 #[inspect(debug)]
135 pub efi_diagnostics_log_level: EfiDiagnosticsLogLevelType,
136 #[inspect(debug)]
137 pub guest_state_lifetime: GuestStateLifetime,
138 #[inspect(debug)]
139 pub guest_state_encryption_policy: GuestStateEncryptionPolicy,
140 #[inspect(debug)]
141 pub management_vtl_features: ManagementVtlFeatures,
142 pub force_dma_bounce_enabled: bool,
143 #[inspect(debug)]
144 pub hardware_sealing_policy: HardwareSealingPolicy,
145 }
146
147 #[derive(Copy, Clone, Debug, Inspect)]
148 pub enum MemoryProtectionMode {
149 Disabled = 0,
150 Default = 1,
151 Strict = 2,
152 Relaxed = 3,
153 }
154
155 #[derive(Debug, Inspect)]
156 pub enum UefiConsoleMode {
157 Default = 0,
159 COM1 = 1,
161 COM2 = 2,
163 None = 3,
165 }
166
167 #[derive(Debug, Inspect)]
168 pub enum SecureBootTemplateType {
169 None,
171 MicrosoftWindows,
173 MicrosoftUefiCertificateAuthority,
175 }
176}
177
178pub struct GuestStateProtection {
180 pub encrypted_gsp: GspCiphertextContent,
182 pub decrypted_gsp: [GspCleartextContent; NUMBER_GSP as usize],
184 pub extended_status_flags: GspExtendedStatusFlags,
186 pub new_gsp: GspCleartextContent,
189}
190
191impl GuestStateProtection {
192 pub fn new_zeroed() -> GuestStateProtection {
194 GuestStateProtection {
195 encrypted_gsp: GspCiphertextContent::new_zeroed(),
196 decrypted_gsp: [GspCleartextContent::new_zeroed(); NUMBER_GSP as usize],
197 extended_status_flags: GspExtendedStatusFlags::new_zeroed(),
198 new_gsp: GspCleartextContent::new_zeroed(),
199 }
200 }
201}
202
203#[derive(Copy, Clone)]
205pub struct GuestStateProtectionById {
206 pub seed: GspCleartextContent,
208 pub extended_status_flags: GspExtendedStatusFlags,
210}
211
212impl GuestStateProtectionById {
213 pub fn new_zeroed() -> GuestStateProtectionById {
215 GuestStateProtectionById {
216 seed: GspCleartextContent::new_zeroed(),
217 extended_status_flags: GspExtendedStatusFlags::new_zeroed(),
218 }
219 }
220}
221
222#[derive(Clone)]
224pub struct IgvmAttest {
225 pub response: Vec<u8>,
227}
228
229pub struct VmgsGetDeviceInfo {
231 pub status: VmgsIoStatus,
233 pub capacity: u64,
235 pub bytes_per_logical_sector: u16,
237 pub bytes_per_physical_sector: u16,
239 pub maximum_transfer_size_bytes: u32,
241}
242
243#[derive(Debug, Copy, Clone)]
245pub struct Time {
246 pub utc: i64,
250 pub time_zone: i16,
252}
253
254impl Time {
255 pub fn to_jiff(self) -> jiff::Zoned {
257 const NANOS_IN_SECOND: i64 = 1_000_000_000;
258 const NANOS_100_IN_SECOND: i64 = NANOS_IN_SECOND / 100;
259
260 let windows_epoch_unix_seconds = jiff::civil::date(1601, 1, 1)
261 .at(0, 0, 0, 0)
262 .to_zoned(jiff::tz::TimeZone::UTC)
263 .unwrap()
264 .timestamp();
265
266 let host_time_secs = self.utc / NANOS_100_IN_SECOND;
267 let host_time_nanos = (self.utc % NANOS_100_IN_SECOND) * 100;
268
269 let host_time_utc = jiff::Timestamp::new(
270 windows_epoch_unix_seconds.as_second() + host_time_secs,
271 host_time_nanos as i32,
272 )
273 .unwrap();
274
275 let offset_seconds = -self.time_zone as i32 * 60;
276 let tz = jiff::tz::TimeZone::fixed(jiff::tz::Offset::from_seconds(offset_seconds).unwrap());
277 host_time_utc.to_zoned(tz)
278 }
279}
280
281#[derive(Debug)]
284pub struct RemoteRamGpaRangeHandle(u32);
285
286impl RemoteRamGpaRangeHandle {
287 pub fn as_raw(&self) -> u32 {
289 self.0
290 }
291
292 pub fn from_raw(handle: u32) -> Self {
295 RemoteRamGpaRangeHandle(handle)
296 }
297}
298
299#[derive(MeshPayload)]
301pub struct GuestSaveRequest {
302 pub correlation_id: Guid,
304 pub timeout_hint: Duration,
306 #[mesh(encoding = "mesh::payload::encoding::ZeroCopyEncoding")]
308 pub capabilities_flags: SaveGuestVtl2StateFlags,
309}