Skip to content

Commit a946c71

Browse files
yamahatabonzini
authored andcommitted
KVM: TDX: Add methods to ignore VMX preemption timer
TDX doesn't support VMX preemption timer. Implement access methods for VMM to ignore VMX preemption timer. Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com> Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com> Message-ID: <20250227012021.1778144-15-binbin.wu@linux.intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent e6bb397 commit a946c71

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

arch/x86/kvm/vmx/main.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,27 @@ static int vt_set_identity_map_addr(struct kvm *kvm, u64 ident_addr)
786786
return vmx_set_identity_map_addr(kvm, ident_addr);
787787
}
788788

789+
#ifdef CONFIG_X86_64
790+
static int vt_set_hv_timer(struct kvm_vcpu *vcpu, u64 guest_deadline_tsc,
791+
bool *expired)
792+
{
793+
/* VMX-preemption timer isn't available for TDX. */
794+
if (is_td_vcpu(vcpu))
795+
return -EINVAL;
796+
797+
return vmx_set_hv_timer(vcpu, guest_deadline_tsc, expired);
798+
}
799+
800+
static void vt_cancel_hv_timer(struct kvm_vcpu *vcpu)
801+
{
802+
/* VMX-preemption timer can't be set. See vt_set_hv_timer(). */
803+
if (is_td_vcpu(vcpu))
804+
return;
805+
806+
vmx_cancel_hv_timer(vcpu);
807+
}
808+
#endif
809+
789810
static int vt_mem_enc_ioctl(struct kvm *kvm, void __user *argp)
790811
{
791812
if (!is_td(kvm))
@@ -941,8 +962,8 @@ struct kvm_x86_ops vt_x86_ops __initdata = {
941962
.pi_start_assignment = vmx_pi_start_assignment,
942963

943964
#ifdef CONFIG_X86_64
944-
.set_hv_timer = vmx_set_hv_timer,
945-
.cancel_hv_timer = vmx_cancel_hv_timer,
965+
.set_hv_timer = vt_set_hv_timer,
966+
.cancel_hv_timer = vt_cancel_hv_timer,
946967
#endif
947968

948969
.setup_mce = vmx_setup_mce,

0 commit comments

Comments
 (0)