Skip to content

Commit 5753743

Browse files
Haozhong Zhangrkrcmar
authored andcommitted
KVM: VMX: remove WARN_ON_ONCE in kvm_vcpu_trigger_posted_interrupt
WARN_ON_ONCE(pi_test_sn(&vmx->pi_desc)) in kvm_vcpu_trigger_posted_interrupt() intends to detect the violation of invariant that VT-d PI notification event is not suppressed when vcpu is in the guest mode. Because the two checks for the target vcpu mode and the target suppress field cannot be performed atomically, the target vcpu mode may change in between. If that does happen, WARN_ON_ONCE() here may raise false alarms. As the previous patch fixed the real invariant breaker, remove this WARN_ON_ONCE() to avoid false alarms, and document the allowed cases instead. Signed-off-by: Haozhong Zhang <[email protected]> Reported-by: "Ramamurthy, Venkatesh" <[email protected]> Reported-by: Dan Williams <[email protected]> Reviewed-by: Paolo Bonzini <[email protected]> Fixes: 28b835d ("KVM: Update Posted-Interrupts Descriptor when vCPU is preempted") Signed-off-by: Radim Krčmář <[email protected]>
1 parent dc91f2e commit 5753743

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

arch/x86/kvm/vmx.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5077,21 +5077,30 @@ static inline bool kvm_vcpu_trigger_posted_interrupt(struct kvm_vcpu *vcpu,
50775077
int pi_vec = nested ? POSTED_INTR_NESTED_VECTOR : POSTED_INTR_VECTOR;
50785078

50795079
if (vcpu->mode == IN_GUEST_MODE) {
5080-
struct vcpu_vmx *vmx = to_vmx(vcpu);
5081-
50825080
/*
5083-
* Currently, we don't support urgent interrupt,
5084-
* all interrupts are recognized as non-urgent
5085-
* interrupt, so we cannot post interrupts when
5086-
* 'SN' is set.
5081+
* The vector of interrupt to be delivered to vcpu had
5082+
* been set in PIR before this function.
5083+
*
5084+
* Following cases will be reached in this block, and
5085+
* we always send a notification event in all cases as
5086+
* explained below.
5087+
*
5088+
* Case 1: vcpu keeps in non-root mode. Sending a
5089+
* notification event posts the interrupt to vcpu.
5090+
*
5091+
* Case 2: vcpu exits to root mode and is still
5092+
* runnable. PIR will be synced to vIRR before the
5093+
* next vcpu entry. Sending a notification event in
5094+
* this case has no effect, as vcpu is not in root
5095+
* mode.
50875096
*
5088-
* If the vcpu is in guest mode, it means it is
5089-
* running instead of being scheduled out and
5090-
* waiting in the run queue, and that's the only
5091-
* case when 'SN' is set currently, warning if
5092-
* 'SN' is set.
5097+
* Case 3: vcpu exits to root mode and is blocked.
5098+
* vcpu_block() has already synced PIR to vIRR and
5099+
* never blocks vcpu if vIRR is not cleared. Therefore,
5100+
* a blocked vcpu here does not wait for any requested
5101+
* interrupts in PIR, and sending a notification event
5102+
* which has no effect is safe here.
50935103
*/
5094-
WARN_ON_ONCE(pi_test_sn(&vmx->pi_desc));
50955104

50965105
apic->send_IPI_mask(get_cpu_mask(vcpu->cpu), pi_vec);
50975106
return true;

0 commit comments

Comments
 (0)