Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3122589imu; Sun, 27 Jan 2019 22:18:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN79pAviN39NlZuDdKybUsiOPakPpaZ79oTCg8ag5wYgSltRDd0kb9HYHpba08dsC6BQ2+jm X-Received: by 2002:a17:902:541:: with SMTP id 59mr20954826plf.88.1548656302670; Sun, 27 Jan 2019 22:18:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548656302; cv=none; d=google.com; s=arc-20160816; b=Yy81/QabghkXOnzsULLNzkWRFas9bsQHeTosx05T1M7WlPSPi9BJH9FXAnUl/FMuXb gYaN5gZO+cuDbUUeLOAnkXKD5csISziYur4T8xHxjHJTAf29rweMMJ1d/jHfR1z5WNdL f6KrYC+pJ2a3E89Ee1tv42m+yAiN/N6h6zXakxuv6FDOHiylCYwuHP4mlpcgy+ICkj/a ZVApQxw+vFB0pJp9PBE1AJeZGSvy/+/nfUjPwg/epBDx9doUViU5pThRGaYMr6pi/qko FQ1nhLrhAHkmK8uF8FsjHocfFbBUYZQu38ZmWJ565/RT0o6hf9sOvznqd9lzP4gZFs47 krQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=OYB47a8ZBQrn7vD3L/AdCGcUpnIZwcbD0ZN2z+WHWnM=; b=zLWRGup61sFO88SBCQeCOhrK0qrm8qtNdWq5N+21lwq8mrEzOd6KvW6q7ITzqu54hC f1wu8Be4GEXrUiMpk5a8hMpd9zpBkMP2tqQOqaZU4RZ9lAgu3VszM2mVKnz2okBbgL8X elgzG5ipEWJWq4+weYRtY6bd+u0X7NHx9rgaz+kAWLZTUzqYqtfONZn8gVX6Ue2j/2EF eAm9iKr+etJZhHDWv24cQyKUrDHcbeWDIdltuGpzuogl+vpHVDTVi6vBl1LTwD3SaNty hbecYutDc4kEAXezYYU65r/uIe3B2Ad0K0juQRI+Vq0UDODfaqcFepoN/nFqt3xlvMdf aHGw== 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 w190si32166170pgd.338.2019.01.27.22.18.04; Sun, 27 Jan 2019 22:18:22 -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 S1726648AbfA1GSA convert rfc822-to-8bit (ORCPT + 99 others); Mon, 28 Jan 2019 01:18:00 -0500 Received: from mga12.intel.com ([192.55.52.136]:56253 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726149AbfA1GR7 (ORCPT ); Mon, 28 Jan 2019 01:17:59 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jan 2019 22:17:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,533,1539673200"; d="scan'208";a="314052464" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga006.fm.intel.com with ESMTP; 27 Jan 2019 22:17:59 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 27 Jan 2019 22:17:58 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.102]) with mapi id 14.03.0415.000; Mon, 28 Jan 2019 14:17:57 +0800 From: "Kang, Luwei" To: Konrad Rzeszutek Wilk CC: "kvm@vger.kernel.org" , "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" Subject: RE: [PATCH] KVM: x86: Sync the pending Posted-Interrupts Thread-Topic: [PATCH] KVM: x86: Sync the pending Posted-Interrupts Thread-Index: AQHUrvgng1TGbq88YUCMNKU8aNpvOaW/s2MAgASOSYA= Date: Mon, 28 Jan 2019 06:17:56 +0000 Message-ID: <82D7661F83C1A047AF7DC287873BF1E172CD2616@SHSMSX101.ccr.corp.intel.com> References: <1547793240-9157-1-git-send-email-luwei.kang@intel.com> <20190125163329.GA41385@Konrads-MacBook-Pro.local> In-Reply-To: <20190125163329.GA41385@Konrads-MacBook-Pro.local> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDViYzZlMTctZjE0Yi00YTQ5LWJiOTgtZDEzYTk4Y2QzMGMwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoibWtxSThNcjlENnB5dllnY2Y1ZTh3SkYwSnJPeVZRaWx4MHZcL2NEVzErbEVPYVhFVmk1ajVWZXUzK0V5bmllQmYifQ== dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 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). > > s/but ON/and ON is set too/? Sorry. If the interrupt remapping facility received a interrupt from device but the current SN bit is 1, the remapping facility will not set ON and not send notification event to CPU, just set the corresponding bit of PIR. Thanks, Luwei Kang > > 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.