Skip to content

Commit 34d2d1c

Browse files
yamahatabonzini
authored andcommitted
KVM: TDX: Disable PI wakeup for IPIv
Disable PI wakeup for IPI virtualization (IPIv) case for TDX. When a vCPU is being scheduled out, notification vector is switched and pi_wakeup_handler() is enabled when the vCPU has interrupt enabled and posted interrupt is used to wake up the vCPU. For VMX, a blocked vCPU can be the target of posted interrupts when using IPIv or VT-d PI. TDX doesn't support IPIv, disable PI wakeup for IPIv. Also, since the guest status of TD vCPU is protected, assume interrupt is always enabled for TD. (PV HLT hypercall is not support yet, TDX guest tells VMM whether HLT is called with interrupt disabled or not.) Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com> [binbin: split into new patch] Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com> Message-ID: <20250222014757.897978-3-binbin.wu@linux.intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 90cfe14 commit 34d2d1c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

arch/x86/kvm/vmx/posted_intr.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "posted_intr.h"
1212
#include "trace.h"
1313
#include "vmx.h"
14+
#include "tdx.h"
1415

1516
/*
1617
* Maintain a per-CPU list of vCPUs that need to be awakened by wakeup_handler()
@@ -190,7 +191,8 @@ static bool vmx_needs_pi_wakeup(struct kvm_vcpu *vcpu)
190191
* notification vector is switched to the one that calls
191192
* back to the pi_wakeup_handler() function.
192193
*/
193-
return vmx_can_use_ipiv(vcpu) || vmx_can_use_vtd_pi(vcpu->kvm);
194+
return (vmx_can_use_ipiv(vcpu) && !is_td_vcpu(vcpu)) ||
195+
vmx_can_use_vtd_pi(vcpu->kvm);
194196
}
195197

196198
void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu)
@@ -200,7 +202,8 @@ void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu)
200202
if (!vmx_needs_pi_wakeup(vcpu))
201203
return;
202204

203-
if (kvm_vcpu_is_blocking(vcpu) && !vmx_interrupt_blocked(vcpu))
205+
if (kvm_vcpu_is_blocking(vcpu) &&
206+
(is_td_vcpu(vcpu) || !vmx_interrupt_blocked(vcpu)))
204207
pi_enable_wakeup_handler(vcpu);
205208

206209
/*

arch/x86/kvm/vmx/tdx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ int tdx_vcpu_create(struct kvm_vcpu *vcpu)
650650

651651
fpstate_set_confidential(&vcpu->arch.guest_fpu);
652652
vcpu->arch.apic->guest_apic_protected = true;
653+
INIT_LIST_HEAD(&tdx->vt.pi_wakeup_list);
653654

654655
vcpu->arch.efer = EFER_SCE | EFER_LME | EFER_LMA | EFER_NX;
655656

0 commit comments

Comments
 (0)