From nobody Sun May 5 01:36:45 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1556601422; cv=none; d=zoho.com; s=zohoarc; b=a4MdL/7nJfZFvXjhXHNtghIpXC/3xUVDEkmFYxyXP+hwbXYORsur7Nkp2O255CB0cuIa62Ftjmp3I+SI8W0VFK4N/dxET+uzllTzAfXyaRY02M5/HzlBUMy+1OvG1rF5bJyBfPz8cASZlASdzHXrYIRdW1p32VUOcGURrS5uxgA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556601422; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=3qLcSjAVOLqb2ZbwRYlIr9nSVzB94C42lj+ehdXdn3M=; b=cSKzy41HEG759rOzVpzXKcplmgAxgwmpQRzLsIsgd20VNVHa1dYxf5F6kAZag99gjIwZoykRy4cdCFrh0JntNjUfBCd80e7pn52NQ+S/Cwd9s8rO+OnHwPhjS6fSAUKnAUuay5k1wH/4lkJW2Sr8dw9Z36wqLauIeBRSlZBK1t8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1556601422367136.66556456428407; Mon, 29 Apr 2019 22:17:02 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLL6s-0000tz-Uu; Tue, 30 Apr 2019 05:15:18 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLL6r-0000tu-2Z for xen-devel@lists.xenproject.org; Tue, 30 Apr 2019 05:15:17 +0000 Received: from mga09.intel.com (unknown [134.134.136.24]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id ef1feb0d-6b06-11e9-843c-bc764e045a96; Tue, 30 Apr 2019 05:15:14 +0000 (UTC) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Apr 2019 22:15:13 -0700 Received: from gao-cwp.sh.intel.com ([10.239.159.26]) by orsmga004.jf.intel.com with ESMTP; 29 Apr 2019 22:15:12 -0700 X-Inumbo-ID: ef1feb0d-6b06-11e9-843c-bc764e045a96 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,412,1549958400"; d="scan'208";a="295684988" From: Chao Gao To: xen-devel@lists.xenproject.org Date: Tue, 30 Apr 2019 13:19:19 +0800 Message-Id: <1556601559-30921-1-git-send-email-chao.gao@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [Xen-devel] [PATCH] x86/pt: skip setup of posted format IRTE when gvec is 0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Jan Beulich , Chao Gao MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" When testing with an UP guest with a pass-thru device with vt-d pi enabled in host, we observed that guest couldn't receive interrupts from that pass-thru device. Dumping IRTE, we found the corresponding IRTE is set to posted format with "vector" field as 0. We would fall into this issue when guest used the pirq format of MSI (see the comment xen_msi_compose_msg() in linux kernel). As 'dest_id' is repurposed, skip migration which is based on 'dest_id'. Signed-off-by: Chao Gao --- xen/drivers/passthrough/io.c | 68 ++++++++++++++++++++++++++++------------= ---- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/xen/drivers/passthrough/io.c b/xen/drivers/passthrough/io.c index 4290c7c..362d4bd 100644 --- a/xen/drivers/passthrough/io.c +++ b/xen/drivers/passthrough/io.c @@ -413,34 +413,52 @@ int pt_irq_create_bind( pirq_dpci->gmsi.gflags =3D gflags; } } - /* Calculate dest_vcpu_id for MSI-type pirq migration. */ - dest =3D MASK_EXTR(pirq_dpci->gmsi.gflags, - XEN_DOMCTL_VMSI_X86_DEST_ID_MASK); - dest_mode =3D pirq_dpci->gmsi.gflags & XEN_DOMCTL_VMSI_X86_DM_MASK; - delivery_mode =3D MASK_EXTR(pirq_dpci->gmsi.gflags, - XEN_DOMCTL_VMSI_X86_DELIV_MASK); - - dest_vcpu_id =3D hvm_girq_dest_2_vcpu_id(d, dest, dest_mode); - pirq_dpci->gmsi.dest_vcpu_id =3D dest_vcpu_id; - spin_unlock(&d->event_lock); - - pirq_dpci->gmsi.posted =3D false; - vcpu =3D (dest_vcpu_id >=3D 0) ? d->vcpu[dest_vcpu_id] : NULL; - if ( iommu_intpost ) + /* + * Migrate pirq and create posted format IRTE only if we know the = gmsi's + * dest_id and vector. + */ + if ( pirq_dpci->gmsi.gvec ) { - if ( delivery_mode =3D=3D dest_LowestPrio ) - vcpu =3D vector_hashing_dest(d, dest, dest_mode, - pirq_dpci->gmsi.gvec); - if ( vcpu ) - pirq_dpci->gmsi.posted =3D true; + /* Calculate dest_vcpu_id for MSI-type pirq migration. */ + dest =3D MASK_EXTR(pirq_dpci->gmsi.gflags, + XEN_DOMCTL_VMSI_X86_DEST_ID_MASK); + dest_mode =3D pirq_dpci->gmsi.gflags & XEN_DOMCTL_VMSI_X86_DM_= MASK; + delivery_mode =3D MASK_EXTR(pirq_dpci->gmsi.gflags, + XEN_DOMCTL_VMSI_X86_DELIV_MASK); + + dest_vcpu_id =3D hvm_girq_dest_2_vcpu_id(d, dest, dest_mode); + pirq_dpci->gmsi.dest_vcpu_id =3D dest_vcpu_id; + spin_unlock(&d->event_lock); + + pirq_dpci->gmsi.posted =3D false; + vcpu =3D (dest_vcpu_id >=3D 0) ? d->vcpu[dest_vcpu_id] : NULL; + if ( iommu_intpost ) + { + if ( delivery_mode =3D=3D dest_LowestPrio ) + vcpu =3D vector_hashing_dest(d, dest, dest_mode, + pirq_dpci->gmsi.gvec); + if ( vcpu ) + pirq_dpci->gmsi.posted =3D true; + } + if ( vcpu && iommu_enabled ) + hvm_migrate_pirq(pirq_dpci, vcpu); + + /* Use interrupt posting if it is supported. */ + if ( iommu_intpost ) + pi_update_irte(vcpu ? &vcpu->arch.hvm.vmx.pi_desc : NULL, + info, pirq_dpci->gmsi.gvec); } - if ( vcpu && iommu_enabled ) - hvm_migrate_pirq(pirq_dpci, vcpu); + else /* pirq_dpci->gmsi.gvec =3D=3D 0 */ + { + pirq_dpci->gmsi.dest_vcpu_id =3D -1; + spin_unlock(&d->event_lock); =20 - /* Use interrupt posting if it is supported. */ - if ( iommu_intpost ) - pi_update_irte(vcpu ? &vcpu->arch.hvm.vmx.pi_desc : NULL, - info, pirq_dpci->gmsi.gvec); + if ( unlikely(pirq_dpci->gmsi.posted) ) + { + pi_update_irte(NULL, info, 0); + pirq_dpci->gmsi.posted =3D false; + } + } =20 if ( pt_irq_bind->u.msi.gflags & XEN_DOMCTL_VMSI_X86_UNMASKED ) { --=20 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel