From nobody Tue Feb 10 04:16:49 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.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 (zohomail.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=1577722385; cv=none; d=zohomail.com; s=zohoarc; b=bFR7zpRhGVvhSurmKC3XbtkYqdEpdW1ehwXSH9ySl6XoTKv3mpOOSAQuXHoXmuQt7MFFCn9JTeayH3LKbtImvK0ulbXvIwxJHul9hIw/ycVfz6DGN3IyRk/6HythX9DFddc55fPXKDEe2Tg4ogRFDFURsJ896FgVOAO10wqoixM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577722385; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/ROZZLS7EPUmpBY5iN662dAMWlqngx2ZIf7Yc5WeDDk=; b=a5OpAdx0ItADQ7qlw6CyoIhA7LblUqFs7Qd0Ow3xBuyuaLy3An0kelwT6Z7GWoU+odEhYT1/qAH3NdR6xMZLmVEcVp49xyZsORnB0bTUOBs94eVrxFFuvC4ZCcjVug+DB43Xa5WSB6gSk+8dWDLs3IbnxPAqBVjxYUbZJ/jtBX0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.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 1577722385644810.3112322567663; Mon, 30 Dec 2019 08:13:05 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ilxeS-0002BS-Lv; Mon, 30 Dec 2019 16:12:16 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ilxeR-0002B7-UV for xen-devel@lists.xenproject.org; Mon, 30 Dec 2019 16:12:15 +0000 Received: from mga14.intel.com (unknown [192.55.52.115]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1b1e7a48-2b1f-11ea-a1e1-bc764e2007e4; Mon, 30 Dec 2019 16:11:59 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Dec 2019 08:11:58 -0800 Received: from tlengyel-mobl2.amr.corp.intel.com (HELO localhost.localdomain) ([10.254.94.206]) by orsmga003.jf.intel.com with ESMTP; 30 Dec 2019 08:11:57 -0800 X-Inumbo-ID: 1b1e7a48-2b1f-11ea-a1e1-bc764e2007e4 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,375,1571727600"; d="scan'208";a="221167345" From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Date: Mon, 30 Dec 2019 08:11:35 -0800 Message-Id: <899d79b4ab49c0aabb7743daf7b842d624bcd5fa.1577721845.git.tamas.lengyel@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 11/18] x86/mem_sharing: ASSERT that p2m_set_entry succeeds 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 , Tamas K Lengyel , Wei Liu , George Dunlap , Andrew Cooper , 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" Signed-off-by: Tamas K Lengyel --- xen/arch/x86/mm/mem_sharing.c | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index 93e7605900..3f36cd6bbc 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -1117,11 +1117,19 @@ int add_to_physmap(struct domain *sd, unsigned long= sgfn, shr_handle_t sh, goto err_unlock; } =20 + /* + * Must succeed, we just read the entry and hold the p2m lock + * via get_two_gfns. + */ ret =3D p2m_set_entry(p2m, _gfn(cgfn), smfn, PAGE_ORDER_4K, p2m_ram_shared, a); + ASSERT(!ret); =20 - /* Tempted to turn this into an assert */ - if ( ret ) + /* + * There is a chance we're plugging a hole where a paged out + * page was. + */ + if ( p2m_is_paging(cmfn_type) && (cmfn_type !=3D p2m_ram_paging_out) ) { mem_sharing_gfn_destroy(spage, cd, gfn_info); put_page_and_type(spage); @@ -1129,29 +1137,21 @@ int add_to_physmap(struct domain *sd, unsigned long= sgfn, shr_handle_t sh, else { /* - * There is a chance we're plugging a hole where a paged out - * page was. + * Further, there is a chance this was a valid page. + * Don't leak it. */ - if ( p2m_is_paging(cmfn_type) && (cmfn_type !=3D p2m_ram_paging_ou= t) ) + if ( mfn_valid(cmfn) ) { - atomic_dec(&cd->paged_pages); - /* - * Further, there is a chance this was a valid page. - * Don't leak it. - */ - if ( mfn_valid(cmfn) ) + struct page_info *cpage =3D mfn_to_page(cmfn); + + if ( !get_page(cpage, cd) ) { - struct page_info *cpage =3D mfn_to_page(cmfn); - - if ( !get_page(cpage, cd) ) - { - domain_crash(cd); - ret =3D -EOVERFLOW; - goto err_unlock; - } - put_page_alloc_ref(cpage); - put_page(cpage); + domain_crash(cd); + ret =3D -EOVERFLOW; + goto err_unlock; } + put_page_alloc_ref(cpage); + put_page(cpage); } } =20 --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel