From nobody Mon Feb 9 19:08:54 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=1576698159; cv=none; d=zohomail.com; s=zohoarc; b=WdU84rC3Pb0kGp043a5Vz/gf3J5SvACtektA5AnyCNwXW51MUBzi5BMnfMoP3kdyPKeg6PrbY2QFHLfFX1C4KLg2nfqACDhVDP9Bl1dYm/4gAzsFknjhuYwbDRdatxI5yN9OkVh7HeufRHaz7s0xHUlc5HtUFlxegYR4rh/msvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576698159; 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=qhW5BamtF2O43fN5YkdpQIIjjOW4tLZPms8tiSABy64=; b=NZij/eA3ggrfslid97sdT3++tbiP0Cndt5IGEU5oDMSDDFeLP+sv5rajU8PGaE2Bi1GN+YEiibDz1uIIE6AvjJ2MfPIEx6NIsgnKUnrtAiVBWjxCTK+n5wKQSbstyl7h0anslxMZ9d5Hk5upEpgJj6Wo4ja8h2jrwsK1Z+Zu4CE= 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 1576698159893455.2239247797986; Wed, 18 Dec 2019 11:42:39 -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 1ihfD9-0008NX-NK; Wed, 18 Dec 2019 19:42:19 +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 1ihfD8-0008MH-8a for xen-devel@lists.xenproject.org; Wed, 18 Dec 2019 19:42:18 +0000 Received: from mga03.intel.com (unknown [134.134.136.65]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5dec2f46-21ce-11ea-90f3-12813bfff9fa; Wed, 18 Dec 2019 19:41:21 +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:21 -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:20 -0800 X-Inumbo-ID: 5dec2f46-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="210196369" From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Date: Wed, 18 Dec 2019 11:40:51 -0800 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 14/20] x86/mem_sharing: Enable mem_sharing on first memop 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" It is wasteful to require separate hypercalls to enable sharing on both the parent and the client domain during VM forking. To speed things up we enable sharing on the first memop in case it wasn't already enabled. Signed-off-by: Tamas K Lengyel --- xen/arch/x86/mm/mem_sharing.c | 39 +++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index e5c1424f9b..48809a5349 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -1402,6 +1402,24 @@ static int range_share(struct domain *d, struct doma= in *cd, return rc; } =20 +static inline int mem_sharing_control(struct domain *d, bool enable) +{ + if ( enable ) + { + if ( unlikely(!is_hvm_domain(d)) ) + return -ENOSYS; + + if ( unlikely(!hap_enabled(d)) ) + return -ENODEV; + + if ( unlikely(is_iommu_enabled(d)) ) + return -EXDEV; + } + + d->arch.hvm.mem_sharing.enabled =3D enable; + return 0; +} + int mem_sharing_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_sharing_op_t) arg) { int rc; @@ -1423,10 +1441,8 @@ int mem_sharing_memop(XEN_GUEST_HANDLE_PARAM(xen_mem= _sharing_op_t) arg) if ( rc ) goto out; =20 - /* Only HAP is supported */ - rc =3D -ENODEV; - if ( !mem_sharing_enabled(d) ) - goto out; + if ( !mem_sharing_enabled(d) && (rc =3D mem_sharing_control(d, true)) ) + return rc; =20 switch ( mso.op ) { @@ -1675,24 +1691,15 @@ int mem_sharing_domctl(struct domain *d, struct xen= _domctl_mem_sharing_op *mec) { int rc; =20 - /* Only HAP is supported */ - if ( !hap_enabled(d) ) - return -ENODEV; - switch(mec->op) { case XEN_DOMCTL_MEM_SHARING_CONTROL: - { - rc =3D 0; - if ( unlikely(is_iommu_enabled(d) && mec->u.enable) ) - rc =3D -EXDEV; - else - d->arch.hvm.mem_sharing.enabled =3D mec->u.enable; - } - break; + rc =3D mem_sharing_control(d, mec->u.enable); + break; =20 default: rc =3D -ENOSYS; + break; } =20 return rc; --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel