Skip to content

Commit 7d390a9

Browse files
committed
KVM: TDX: Use kvm_arch_vcpu.host_debugctl to restore the host's DEBUGCTL
Use the kvm_arch_vcpu.host_debugctl snapshot to restore DEBUGCTL after running a TD vCPU. The final TDX series rebase was mishandled, likely due to commit fb71c79 ("KVM: x86: Snapshot the host's DEBUGCTL in common x86") deleting the same line of code from vmx.h, i.e. creating a semantic conflict of sorts, but no syntactic conflict. Using the version in kvm_vcpu_arch picks up the ulong => u64 fix (which isn't relevant to TDX) as well as the IRQ fix from commit 189ecdb ("KVM: x86: Snapshot the host's DEBUGCTL after disabling IRQs"). Link: https://lore.kernel.org/all/20250307212053.2948340-10-pbonzini@redhat.com Cc: Adrian Hunter <adrian.hunter@intel.com> Fixes: 8af0990 ("KVM: TDX: Save and restore IA32_DEBUGCTL") Reviewed-by: Adrian Hunter <adrian.hunter@intel.com> Link: https://lore.kernel.org/r/20250610232010.162191-2-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 28224ef commit 7d390a9

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

arch/x86/kvm/vmx/common.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ struct vcpu_vt {
5353
#ifdef CONFIG_X86_64
5454
u64 msr_host_kernel_gs_base;
5555
#endif
56-
57-
unsigned long host_debugctlmsr;
5856
};
5957

6058
#ifdef CONFIG_KVM_INTEL_TDX

arch/x86/kvm/vmx/tdx.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -785,8 +785,6 @@ void tdx_prepare_switch_to_guest(struct kvm_vcpu *vcpu)
785785
else
786786
vt->msr_host_kernel_gs_base = read_msr(MSR_KERNEL_GS_BASE);
787787

788-
vt->host_debugctlmsr = get_debugctlmsr();
789-
790788
vt->guest_state_loaded = true;
791789
}
792790

@@ -1062,8 +1060,8 @@ fastpath_t tdx_vcpu_run(struct kvm_vcpu *vcpu, bool force_immediate_exit)
10621060

10631061
tdx_vcpu_enter_exit(vcpu);
10641062

1065-
if (vt->host_debugctlmsr & ~TDX_DEBUGCTL_PRESERVED)
1066-
update_debugctlmsr(vt->host_debugctlmsr);
1063+
if (vcpu->arch.host_debugctl & ~TDX_DEBUGCTL_PRESERVED)
1064+
update_debugctlmsr(vcpu->arch.host_debugctl);
10671065

10681066
tdx_load_host_xsave_state(vcpu);
10691067
tdx->guest_entered = true;

0 commit comments

Comments
 (0)