From nobody Fri Apr 19 01:42:54 2024 Delivered-To: importer@patchew.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 ARC-Seal: i=1; a=rsa-sha256; t=1561987157; cv=none; d=zoho.com; s=zohoarc; b=n5yAaLgZL2JQcJuF3zm93k30JOMau1Dt0d9t+Pvz2xCz9bW6wGKS0NufIbcFG2YRYWbfFe6aZShaE8iqud66OUvYkLXkgILEo1I4b7eFP/JgflBGLIyHMiRfPAtqYUZD1xxO110kput/fs6GNUzIZEm50n8AXqIQmGB7xtPfWyg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561987157; 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=MD6n+Vm4p0ATe/PTdbwKgtinN4ypaGOLATbDq1Mg+1g=; b=GF6XH0iyAucRkSSYS4eV2ErZ9kPkKqrx29u3RiJXg4DF/mABlwEZi8d915aZyrRg43fyupO3u7enOQgG4tfB6MiFAZMraWFo3Wf+nyrXemOiNMfBfw64Ix9GilYmIGAMXg2+P3rY60OA2vfbpY2WjykCFmsq4vjHKCB35tV5vZQ= 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1561987157422378.0940326587403; Mon, 1 Jul 2019 06:19:17 -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 1hhwBy-0005M6-Cr; Mon, 01 Jul 2019 13:17:58 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hhwBx-0005M1-C5 for xen-devel@lists.xenproject.org; Mon, 01 Jul 2019 13:17:57 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a27e6d56-9c02-11e9-9bd2-a3353d4c32af; Mon, 01 Jul 2019 13:17:54 +0000 (UTC) X-Inumbo-ID: a27e6d56-9c02-11e9-9bd2-a3353d4c32af Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=paul.durrant@citrix.com; spf=Pass smtp.mailfrom=Paul.Durrant@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com 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; Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of paul.durrant@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="paul.durrant@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of Paul.Durrant@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="Paul.Durrant@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: ntUv4B+JvyZc0doTSt9gv4jsFStS0PixuBcTlgyhmFboBCxQn2sAZWvlVrPDOQYG5UpEJMh5zi crDfEZKbrTK0k7CeGs/E2n6CHq9EqCmuTNFI7i5V7pgzYZe/cWAjUFCwLcieQMcsymhOmvkK+g 7efh4jkQTPTSUf0xjjdZIjznnWidBOHM4xL45I3Hc3mkGz9rmxnR9o2ooVg2dOITCO8FIelJ7r /JJEYm5AJt21BzDHmQzTRKtRbzG9se7G6Cm2IUmUxUxspx7Q68wyNpP5xks2ZHGiHXFiUZNn2u o5U= X-SBRS: 2.7 X-MesageID: 2459934 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.63,439,1557201600"; d="scan'208";a="2459934" From: Paul Durrant To: Date: Mon, 1 Jul 2019 14:17:50 +0100 Message-ID: <20190701131750.37855-1-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1.2.gb21ebb671 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] passthrough/pci: properly qualify the mem_sharing_enabled check... 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: Tamas K Lengyel , Wei Liu , George Dunlap , Andrew Cooper , Paul Durrant , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" ...in assign_device(). The check of arch.hvm.mem_sharing_enabled flag at the top of drivers/passthrough/pci.c:assign_device() does not make sure that the domain is actually an HVM domain. This patch fixes the issue by moving the definition of the mem_sharing_enabled() macro from mem_sharing.c into asm-86/hvm/domain.h and then using that instead. Signed-off-by: Paul Durrant --- Cc: Tamas K Lengyel Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monn=C3=A9" --- xen/arch/x86/mm/mem_sharing.c | 3 --- xen/drivers/passthrough/pci.c | 2 +- xen/include/asm-x86/hvm/domain.h | 3 +++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index f16a3f5324..db02f4dfd5 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -149,9 +149,6 @@ static inline shr_handle_t get_next_handle(void) return x + 1; } =20 -#define mem_sharing_enabled(d) \ - (is_hvm_domain(d) && (d)->arch.hvm.mem_sharing_enabled) - static atomic_t nr_saved_mfns =3D ATOMIC_INIT(0);=20 static atomic_t nr_shared_mfns =3D ATOMIC_INIT(0); =20 diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index e88689425d..7697ec440d 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -1450,7 +1450,7 @@ static int assign_device(struct domain *d, u16 seg, u= 8 bus, u8 devfn, u32 flag) =20 /* Prevent device assign if mem paging or mem sharing have been=20 * enabled for this domain */ - if ( unlikely(d->arch.hvm.mem_sharing_enabled || + if ( unlikely(mem_sharing_enabled(d) || vm_event_check_ring(d->vm_event_paging) || p2m_get_hostp2m(d)->global_logdirty) ) return -EXDEV; diff --git a/xen/include/asm-x86/hvm/domain.h b/xen/include/asm-x86/hvm/dom= ain.h index 6c7c4f5aa6..1e6e3ce078 100644 --- a/xen/include/asm-x86/hvm/domain.h +++ b/xen/include/asm-x86/hvm/domain.h @@ -197,8 +197,11 @@ struct hvm_domain { =20 #ifdef CONFIG_HVM #define hap_enabled(d) (is_hvm_domain(d) && (d)->arch.hvm.hap_enabled) +#define mem_sharing_enabled(d) \ + (is_hvm_domain(d) && (d)->arch.hvm.mem_sharing_enabled) #else #define hap_enabled(d) ({(void)(d); false;}) +#define mem_sharing_enabled(d) ({(void)(d); false;}) #endif =20 #endif /* __ASM_X86_HVM_DOMAIN_H__ */ --=20 2.20.1.2.gb21ebb671 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel