From patchwork Thu Apr 21 17:10:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamas K Lengyel X-Patchwork-Id: 8902841 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BEB599F457 for ; Thu, 21 Apr 2016 17:13:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CF0EF20320 for ; Thu, 21 Apr 2016 17:13:09 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A2783201F5 for ; Thu, 21 Apr 2016 17:13:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atI7l-0002xy-8R; Thu, 21 Apr 2016 17:10:41 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atI7k-0002xs-Nj for xen-devel@lists.xenproject.org; Thu, 21 Apr 2016 17:10:40 +0000 Received: from [193.109.254.147] by server-13.bemta-14.messagelabs.com id 69/35-02833-09909175; Thu, 21 Apr 2016 17:10:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkkeJIrShJLcpLzFFi42K5GHp/s24/p2S 4wYGjQhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8byV/dZC55KVGz/O5O9gXGDcBcjF4eQwExG iU/bZ7OAOBIC71gkdtzbzN7FyAnkxEjsP/ibDcKuljh3ZTITiC0koCFx+2YjO0T3DCaJN5dPM IIk2AS0Jdpe72IFsUUElCTurQJp4OJgFuhjkmiY/AwowcEhLGAu0bJLD6SGRUBVYtrWRmYQm1 fASWLO59PMEMvkJM4f/8k8gZF3ASPDKkb14tSistQiXUO9pKLM9IyS3MTMHF1DQxO93NTi4sT 01JzEpGK95PzcTYzAgGAAgh2MRzudDzFKcjApifKysUiGC/El5adUZiQWZ8QXleakFh9ilOHg UJLgXcsBlBMsSk1PrUjLzAGGJkxagoNHSYR3Lkiat7ggMbc4Mx0idYrRmGPL72trmTi2Tb23l kmIJS8/L1VKnDcfpFQApDSjNA9uECxmLjHKSgnzMgKdJsRTkFqUm1mCKv+KUZyDUUmY9wjIFJ 7MvBK4fa+ATmECOoX/rijIKSWJCCmpBsaMo+cldv+ZuGvBVll3VWOeqe+YVhyYfyM7j8vwWIR sQ3Neo7j6weCVO8qLvCMTdmv2/bsakeZh0WO9euNsJmCwXlbtElWW51nwLC33+V3Hxf5zp2xt jH2zo1HBQe8fy/f4NZce/oy7yFF44+3rwJsKbz3rXiU+sBRcpb7m1v2H0T/vvNg5iVOJpTgj0 VCLuag4EQAvAwHXlAIAAA== X-Env-Sender: tamas.k.lengyel@gmail.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1461258638!35076242!1 X-Originating-IP: [209.85.223.179] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 51265 invoked from network); 21 Apr 2016 17:10:38 -0000 Received: from mail-io0-f179.google.com (HELO mail-io0-f179.google.com) (209.85.223.179) by server-2.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 21 Apr 2016 17:10:38 -0000 Received: by mail-io0-f179.google.com with SMTP id f89so72931482ioi.0 for ; Thu, 21 Apr 2016 10:10:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Brs5Q00i1+C4X2GSD7Rxt/6HJZf0ew29MlF4mEo7U7M=; b=HGbmRsovLgoipnKyVdLPV8y2+biP9tQoxiE5tb3SDXB4HB7cKb4I1UTBG7IH5UO8NM f0RpP0WRPAqki/nm2XJbeHNtJZuMRigLjY9j4sdE2WxddYtuG1IGxy2DkgGLvbnhFGiF qaYJ0qmDSe6cNutOPtrvvoOeab1Qh0W9/vZEi5qEenhkBJ8s24U2sgYp4/ohxy+Snp9J 3dId5cXSjAQfSnb/EVSJ4T5eW7moY0/bME5zvuSAjoImtr/PysGjJcFpRSOpJDc/4RHC eSXUYyJhBN12CiLCV0e8DoMqZ5JVZ//8k9enL4rQnQMN0Lp0RK5rKZ1BlerP+mn8EAqB fPKw== X-Gm-Message-State: AOPr4FWxXuSNx5s05Tcra1eF4+q9ZrXjUpyd5Ygeq9fpe2vnwXl+3Y67YX7IA4MwTXrSsA== X-Received: by 10.107.161.68 with SMTP id k65mr20598552ioe.110.1461258637850; Thu, 21 Apr 2016 10:10:37 -0700 (PDT) Received: from localhost.localdomain (c-73-14-35-59.hsd1.co.comcast.net. [73.14.35.59]) by smtp.gmail.com with ESMTPSA id be7sm1633161igb.1.2016.04.21.10.10.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Apr 2016 10:10:36 -0700 (PDT) From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Date: Thu, 21 Apr 2016 11:10:32 -0600 Message-Id: <1461258632-3330-1-git-send-email-tamas@tklengyel.com> X-Mailer: git-send-email 2.1.4 Cc: Kevin Tian , Tamas K Lengyel , Keir Fraser , Jan Beulich , George Dunlap , Andrew Cooper , Jun Nakajima Subject: [Xen-devel] [PATCH] altp2m: Allow the hostp2m to be shared X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Don't propagate altp2m changes from ept_set_entry for memshare as memshare already has the lock. We call altp2m propagate changes once memshare successfully finishes. Also, allow the hostp2m entries to be of type p2m_ram_shared. Signed-off-by: Tamas K Lengyel --- Cc: George Dunlap Cc: Keir Fraser Cc: Jan Beulich Cc: Andrew Cooper Cc: Jun Nakajima Cc: Kevin Tian --- xen/arch/x86/mm/mem_sharing.c | 11 +++++++++++ xen/arch/x86/mm/p2m-ept.c | 2 +- xen/arch/x86/mm/p2m.c | 7 +++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index a522423..d5b4b2d 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include "mm-locks.h" @@ -1026,6 +1027,16 @@ int mem_sharing_share_pages(struct domain *sd, unsigned long sgfn, shr_handle_t /* We managed to free a domain page. */ atomic_dec(&nr_shared_mfns); atomic_inc(&nr_saved_mfns); + + if( altp2m_active(cd) ) + { + p2m_access_t a; + struct p2m_domain *p2m = p2m_get_hostp2m(cd); + p2m->get_entry(p2m, cgfn, NULL, &a, 0, NULL, NULL); + p2m_altp2m_propagate_change(cd, _gfn(cgfn), smfn, PAGE_ORDER_4K, + p2m_ram_shared, a); + } + ret = 0; err_out: diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 3cb6868..1ac3018 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -846,7 +846,7 @@ out: if ( is_epte_present(&old_entry) ) ept_free_entry(p2m, &old_entry, target); - if ( rc == 0 && p2m_is_hostp2m(p2m) ) + if ( rc == 0 && p2m_is_hostp2m(p2m) && p2mt != p2m_ram_shared ) p2m_altp2m_propagate_change(d, _gfn(gfn), mfn, order, p2mt, p2ma); return rc; diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index b3fce1b..d2aebf7 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -1739,11 +1739,10 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m, /* Check host p2m if no valid entry in alternate */ if ( !mfn_valid(mfn) ) { - mfn = hp2m->get_entry(hp2m, gfn_l, &t, &old_a, - P2M_ALLOC | P2M_UNSHARE, &page_order, NULL); + mfn = hp2m->get_entry(hp2m, gfn_l, &t, &old_a, 0, &page_order, NULL); rc = -ESRCH; - if ( !mfn_valid(mfn) || t != p2m_ram_rw ) + if ( !mfn_valid(mfn) || (t != p2m_ram_rw && t != p2m_ram_shared) ) return rc; /* If this is a superpage, copy that first */ @@ -1760,7 +1759,7 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m, } return ap2m->set_entry(ap2m, gfn_l, mfn, PAGE_ORDER_4K, t, a, - (current->domain != d)); + (current->domain != d)); } /*