Skip to content

Commit c9ae69f

Browse files
committed
feat(tdx): finalize TDX virtual machine creation
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
1 parent f1e2f5c commit c9ae69f

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

alioth/src/board/board_x86_64/board_x86_64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ where
352352
match coco {
353353
Coco::AmdSev { policy } => self.sev_finalize(*policy),
354354
Coco::AmdSnp { .. } => self.snp_finalize(),
355-
Coco::IntelTdx { attr } => todo!("Intel TDX {attr:?}"),
355+
Coco::IntelTdx { .. } => self.tdx_finalize(),
356356
}
357357
}
358358

alioth/src/board/board_x86_64/tdx.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,9 @@ where
104104
vcpu.tdx_init_vcpu(hob)?;
105105
Ok(())
106106
}
107+
108+
pub(crate) fn tdx_finalize(&self) -> Result<()> {
109+
self.vm.tdx_finalize_vm()?;
110+
Ok(())
111+
}
107112
}

alioth/src/hv/hv.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ pub trait Vm {
396396
#[cfg(target_arch = "x86_64")]
397397
fn tdx_init_vm(&self, attr: TdAttr, cpuids: &HashMap<CpuidIn, CpuidResult>) -> Result<()>;
398398

399+
#[cfg(target_arch = "x86_64")]
400+
fn tdx_finalize_vm(&self) -> Result<()>;
401+
399402
#[cfg(target_arch = "aarch64")]
400403
type GicV2: GicV2;
401404
#[cfg(target_arch = "aarch64")]

alioth/src/hv/kvm/vm/vm.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,11 @@ impl Vm for KvmVm {
766766
KvmVm::tdx_init_vm(self, attr, cpuids)
767767
}
768768

769+
#[cfg(target_arch = "x86_64")]
770+
fn tdx_finalize_vm(&self) -> Result<()> {
771+
KvmVm::tdx_finalize_vm(self)
772+
}
773+
769774
#[cfg(target_arch = "aarch64")]
770775
fn create_gic_v2(&self, distributor_base: u64, cpu_interface_base: u64) -> Result<Self::GicV2> {
771776
aarch64::KvmGicV2::new(self, distributor_base, cpu_interface_base)

alioth/src/hv/kvm/vm/vm_x86_64/tdx.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,8 @@ impl KvmVm {
8282
tdx_op(&self.vm.fd, KvmTdxCmdId::INIT_VM, 0, Some(&mut *init))?;
8383
Ok(())
8484
}
85+
86+
pub fn tdx_finalize_vm(&self) -> Result<()> {
87+
tdx_op::<()>(&self.vm.fd, KvmTdxCmdId::FINALIZE_VM, 0, None)
88+
}
8589
}

0 commit comments

Comments
 (0)