Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2798616imu; Thu, 17 Jan 2019 22:52:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN4O5g8Br4cN+X8r+097Vk0MfT8rOAcqcnZs7WilmMtKq6t8euFBAVN4P4vwkjbQzNYF5Pmd X-Received: by 2002:a17:902:981:: with SMTP id 1mr17640269pln.142.1547794336709; Thu, 17 Jan 2019 22:52:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547794336; cv=none; d=google.com; s=arc-20160816; b=gDy3VlYs3afCZ3Ns/VoTxYXNVa6aDHZYKCmClsqORiOxJb4dekAnlBsr1aYdG4HZP0 4pBVoeNWA8BQgCl9y5CZNn8NEoU3aCSQ0OYr4N4Tvr9FZVgX4aUp7Jhd3e3pvJM6S2iQ Pm+nB3RZRQIncIfAOo7HyaotqEnlWGtUTvkfI2Q6vBU8EpywlLiVExRrR3DKjyUuA+Wm td3S/dJUbuY6rYEOeQSZosEK8iELK+IrELS917n5NpWKgiKX/kPWtizSOvkVhQqkgvTt oX3Tzm6aJyYhWBRbLTLiLaavtJumDKxXALqFeeDvnF7DhMRLpaAWsfi6Wcule3ZEzptG RArA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=erl9bZBHjAsWL4CHOZGC905/gSzht7ziwUs8yH1daGE=; b=z0i0k5AflKAtFHJOA6QJT0TlUsxVIM2EPxm16j86rOH2I+oxyMlTZt64JLB28YGa0V qw8jnwcddANykSTyt8IE/ID0D3yyh0k5ItO3dP/s2VniygMx5deCtutQ5fDyYMWTlrLA FKQETvl6HoyJvWXEQ9MpAlzz9oBJ3Yh4ivbGVyqZtGAVvFwkYwI9J1DyLeuD1zTa+K6H 8TG5nfm22pQxITRpITAxdcHVZwZUnfYOxXRx5u04rs0lQmftBN27zqySxUqJNlkEdI+C Z6NF108kqMnbxUfwlfs2P+7XPPRQSiFU0PlQGKV4kLWdsHSQDKKS2bQgtjfD/ZPRwtlq DuvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 145si3866986pga.396.2019.01.17.22.51.48; Thu, 17 Jan 2019 22:52:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727194AbfARGgV (ORCPT + 99 others); Fri, 18 Jan 2019 01:36:21 -0500 Received: from mga06.intel.com ([134.134.136.31]:27865 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726962AbfARGgV (ORCPT ); Fri, 18 Jan 2019 01:36:21 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jan 2019 22:36:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,489,1539673200"; d="scan'208";a="109201422" Received: from skl-d.bj.intel.com ([10.238.135.173]) by orsmga006.jf.intel.com with ESMTP; 17 Jan 2019 22:36:18 -0800 From: Luwei Kang To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, rkrcmar@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, Luwei Kang Subject: [PATCH] KVM: x86: Sync the pending Posted-Interrupts Date: Fri, 18 Jan 2019 14:34:00 +0800 Message-Id: <1547793240-9157-1-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some Posted-Interrupts from passthrough devices may be lost or overwritten when the vCPU is in runnable state. The SN (Suppress Notification) of PID (Posted Interrupt Descriptor) will be set when the vCPU is preempted (vCPU in KVM_MP_STATE_RUNNABLE state but not running on physical CPU). If a posted interrupt coming at this time, the irq remmaping facility will set the bit of PIR (Posted Interrupt Requests) but ON (Outstanding Notification). So this interrupt can't be sync to APIC virtualization register and will not be handled by Guest because ON is zero. Signed-off-by: Luwei Kang --- arch/x86/kvm/vmx/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index f6915f1..820a03b 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6048,7 +6048,7 @@ static int vmx_sync_pir_to_irr(struct kvm_vcpu *vcpu) bool max_irr_updated; WARN_ON(!vcpu->arch.apicv_active); - if (pi_test_on(&vmx->pi_desc)) { + if (!bitmap_empty((unsigned long *)vmx->pi_desc.pir, NR_VECTORS)) { pi_clear_on(&vmx->pi_desc); /* * IOMMU can write to PIR.ON, so the barrier matters even on UP. -- 1.8.3.1