Skip to content

Commit 935b978

Browse files
authored
TDX: Fix a VTL 1-only typo, but move logic to only affect VTL 0 (#1859)
Masanamuthu spotted this copy/paste typo in vm/x86/x86defs/src/tdx.rs, fix that up. However I think in the only place we set any TDX controls today we actually only want those controls to apply to VTL 0, so move that logic out of the for loop. This makes this PR a functional no-op, but it fixes the typo for when the day comes that we do want to set a control on VTL 1.
1 parent 5ca4657 commit 935b978

File tree

2 files changed

+11
-13
lines changed
  • openhcl/virt_mshv_vtl/src/processor/tdx
  • vm/x86/x86defs/src

2 files changed

+11
-13
lines changed

openhcl/virt_mshv_vtl/src/processor/tdx/mod.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -856,20 +856,18 @@ impl BackingPrivate for TdxBacked {
856856
.into(),
857857
);
858858

859-
for vtl in [GuestVtl::Vtl0, GuestVtl::Vtl1] {
860-
let controls = TdxL2Ctls::new()
861-
// Configure L2 controls to permit shared memory.
862-
.with_enable_shared_ept(!shared.cvm.hide_isolation)
863-
// If the synic is to be managed by the hypervisor, then enable TDVMCALLs.
864-
.with_enable_tdvmcall(
865-
shared.untrusted_synic.is_none() && !shared.cvm.hide_isolation,
866-
);
859+
let controls = TdxL2Ctls::new()
860+
// Configure L2 controls to permit shared memory.
861+
.with_enable_shared_ept(!shared.cvm.hide_isolation)
862+
// If the synic is to be managed by the hypervisor, then enable TDVMCALLs.
863+
.with_enable_tdvmcall(shared.untrusted_synic.is_none() && !shared.cvm.hide_isolation);
867864

868-
params
869-
.runner
870-
.set_l2_ctls(vtl, controls)
871-
.map_err(crate::Error::FailedToSetL2Ctls)?;
865+
params
866+
.runner
867+
.set_l2_ctls(GuestVtl::Vtl0, controls)
868+
.map_err(crate::Error::FailedToSetL2Ctls)?;
872869

870+
for vtl in [GuestVtl::Vtl0, GuestVtl::Vtl1] {
873871
// Set guest/host masks for CR0 and CR4. These enable shadowing these
874872
// registers since TDX requires certain bits to be set at all times.
875873
let initial_cr0 = params

vm/x86/x86defs/src/tdx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ impl TdxContextCode {
478478
pub const TDX_FIELD_CODE_L2_CTLS_VM1: TdxExtendedFieldCode =
479479
TdxExtendedFieldCode(0xA020000300000051);
480480
pub const TDX_FIELD_CODE_L2_CTLS_VM2: TdxExtendedFieldCode =
481-
TdxExtendedFieldCode(0xA020000300000051);
481+
TdxExtendedFieldCode(0xA020000300000052);
482482

483483
/// Extended field code for TDG.VP.WR and TDG.VP.RD
484484
#[bitfield(u64)]

0 commit comments

Comments
 (0)