From nobody Mon Feb 9 06:49:24 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=1576698132; cv=none; d=zohomail.com; s=zohoarc; b=KRooJ3WK7KAfv5pWk/hJw7dlTH0gpmKACl1oPkR3BdeG14xaXWmFgLxKkmeWAH96TPChdRpsfS708lFZO9wTRJVnS+txuxhEK2ZsFl+mQMfGC6L2D3bVNt+t7iCWIM5/NqgCN1ZcsaMh7UYBizvjuwX0GaFp3FN9/SLaf/hf328= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576698132; 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=YtY8YWmi/kabZfj/f4NIQp9qeZ6w95HWIVQHJB1P3lw=; b=Y1qI6u75OyrCJavrl872LFASOqUizjH0fjxLlQOsREeQ5BMh7z2oJWm58SBFcmr0aX/8TrTm9l2qsV6/NfWEqNY3yRJca4uJNungXxfJQbCRMH4kk05h1RbJTmF8IWbxzVSFgKS2MEgCCvldcZXePjYw7d/abahoLmff82/LciY= 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 15766981322372.545607084086896; Wed, 18 Dec 2019 11:42:12 -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 1ihfCV-0007kA-LS; Wed, 18 Dec 2019 19:41:39 +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 1ihfCU-0007jL-7W for xen-devel@lists.xenproject.org; Wed, 18 Dec 2019 19:41:38 +0000 Received: from mga03.intel.com (unknown [134.134.136.65]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 592a0795-21ce-11ea-90f3-12813bfff9fa; Wed, 18 Dec 2019 19:41:15 +0000 (UTC) Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Dec 2019 11:41:13 -0800 Received: from tlengyel-mobl2.amr.corp.intel.com (HELO localhost.localdomain) ([10.254.103.7]) by orsmga008.jf.intel.com with ESMTP; 18 Dec 2019 11:41:12 -0800 X-Inumbo-ID: 592a0795-21ce-11ea-90f3-12813bfff9fa X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,330,1571727600"; d="scan'208";a="210196297" From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Date: Wed, 18 Dec 2019 11:40:42 -0800 Message-Id: <136e2a2aab7d7e9b40d83429dba1cf7d70650111.1576697796.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 v2 05/20] x86/mem_sharing: make get_two_gfns take locks conditionally 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" During VM forking the client lock will already be taken. Signed-off-by: Tamas K Lengyel Acked-by: Andrew Cooper --- xen/arch/x86/mm/mem_sharing.c | 11 ++++++----- xen/include/asm-x86/p2m.h | 10 +++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index 319aaf3074..c0e305ad71 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -954,7 +954,7 @@ static int share_pages(struct domain *sd, gfn_t sgfn, s= hr_handle_t sh, unsigned long put_count =3D 0; =20 get_two_gfns(sd, sgfn, &smfn_type, NULL, &smfn, - cd, cgfn, &cmfn_type, NULL, &cmfn, 0, &tg); + cd, cgfn, &cmfn_type, NULL, &cmfn, 0, &tg, true); =20 /* * This tricky business is to avoid two callers deadlocking if @@ -1068,7 +1068,7 @@ err_out: } =20 int mem_sharing_add_to_physmap(struct domain *sd, unsigned long sgfn, shr_= handle_t sh, - struct domain *cd, unsigned long cgfn) + struct domain *cd, unsigned long cgfn, bool= lock) { struct page_info *spage; int ret =3D -EINVAL; @@ -1080,7 +1080,7 @@ int mem_sharing_add_to_physmap(struct domain *sd, uns= igned long sgfn, shr_handle struct two_gfns tg; =20 get_two_gfns(sd, _gfn(sgfn), &smfn_type, NULL, &smfn, - cd, _gfn(cgfn), &cmfn_type, &a, &cmfn, 0, &tg); + cd, _gfn(cgfn), &cmfn_type, &a, &cmfn, 0, &tg, lock); =20 /* Get the source shared page, check and lock */ ret =3D XENMEM_SHARING_OP_S_HANDLE_INVALID; @@ -1155,7 +1155,8 @@ int mem_sharing_add_to_physmap(struct domain *sd, uns= igned long sgfn, shr_handle err_unlock: mem_sharing_page_unlock(spage); err_out: - put_two_gfns(&tg); + if ( lock ) + put_two_gfns(&tg); return ret; } =20 @@ -1574,7 +1575,7 @@ int mem_sharing_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_= sharing_op_t) arg) sh =3D mso.u.share.source_handle; cgfn =3D mso.u.share.client_gfn; =20 - rc =3D mem_sharing_add_to_physmap(d, sgfn, sh, cd, cgfn); + rc =3D mem_sharing_add_to_physmap(d, sgfn, sh, cd, cgfn, true); =20 rcu_unlock_domain(cd); } diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 94285db1b4..7399c4a897 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -539,7 +539,7 @@ struct two_gfns { static inline void get_two_gfns(struct domain *rd, gfn_t rgfn, p2m_type_t *rt, p2m_access_t *ra, mfn_t *rmfn, struct domain *ld, gfn_t lgfn, p2m_type_t *lt, p2m_access_t *la, mfn_t *lmfn, - p2m_query_t q, struct two_gfns *rval) + p2m_query_t q, struct two_gfns *rval, bool lock) { mfn_t *first_mfn, *second_mfn, scratch_mfn; p2m_access_t *first_a, *second_a, scratch_a; @@ -569,10 +569,10 @@ do { = \ #undef assign_pointers =20 /* Now do the gets */ - *first_mfn =3D get_gfn_type_access(p2m_get_hostp2m(rval->first_domain= ), - gfn_x(rval->first_gfn), first_t, fir= st_a, q, NULL); - *second_mfn =3D get_gfn_type_access(p2m_get_hostp2m(rval->second_domai= n), - gfn_x(rval->second_gfn), second_t, s= econd_a, q, NULL); + *first_mfn =3D __get_gfn_type_access(p2m_get_hostp2m(rval->first_doma= in), + gfn_x(rval->first_gfn), first_t, f= irst_a, q, NULL, lock); + *second_mfn =3D __get_gfn_type_access(p2m_get_hostp2m(rval->second_dom= ain), + gfn_x(rval->second_gfn), second_t,= second_a, q, NULL, lock); } =20 static inline void put_two_gfns(struct two_gfns *arg) --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel