From patchwork Fri Aug 4 02:20:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sky Liu X-Patchwork-Id: 9880293 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 040E260311 for ; Fri, 4 Aug 2017 02:22:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2C67289A1 for ; Fri, 4 Aug 2017 02:22:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E79F4289A5; Fri, 4 Aug 2017 02:22:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 29E97289A1 for ; Fri, 4 Aug 2017 02:22:53 +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 1ddSEK-0000cm-Mo; Fri, 04 Aug 2017 02:20:48 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ddSEI-0000bp-Lz for xen-devel@lists.xen.org; Fri, 04 Aug 2017 02:20:46 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id A0/6F-01732-DF9D3895; Fri, 04 Aug 2017 02:20:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBIsWRWlGSWpSXmKPExsVyMfTAQd2/N5s jDbackLFY8nExiwOjx9Hdv5kCGKNYM/OS8isSWDM+P1nGVrBesGLF9yfMDYw3eLsYuTiEBCYw Sqy/v46xi5GTg0XgJYvE9yv1IAkJgX5WiUdPJrCBJCQEkiSevV7JCmGXSfy/tZcJxBYSUJaYv vIHO8SkRiaJOecWgRWxCWhIrJ1yEKxZREBa4trny2AbmAW+MUq8nOAFYgsLpEgsPHeEBWKzqs TE3dfBbF4BS4nPH5cwQiyTl5jYOw3M5hSwkmi69oYdYrGlxJ//z1kmMAosYGRYxahRnFpUllq ka2ihl1SUmZ5RkpuYmaNraGCql5taXJyYnpqTmFSsl5yfu4kRGFoMQLCDsWm75yFGSQ4mJVHe 6mNNkUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeDfdaI4UEixKTU+tSMvMAQY5TFqCg0dJhPcmS Jq3uCAxtzgzHSJ1itGV48qVdV+YODasXg8kpxzYDiRfTfj/jYmj6fvH70xCLHn5ealS4rzLQZ oFQJozSvPgRsMi9BKjrJQwLyPQsUI8BalFuZklqPKvGMU5GJWEeR+ATOHJzCuBu+AV0HFMQMf 9qWsEOa4kESEl1cCoMLt7/odXoj0xbCqyXybvjxdrtGuYXnxRcsamK/O37ysR3rHUuF/kQMKl stWbUzzvV4i+SNXf+GtewowV3/ocD00MjGVM17x96/KjtZOnJ6+9X/D27rp5X1JfzFbm138qE fQlc5n5ee49/E+mfuc2D1ZY8jZl21EWFUltTeN5r57VrFhZGB99XYmlOCPRUIu5qDgRAJNcks vLAgAA X-Env-Sender: blackskygg@gmail.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1501813244!89915523!1 X-Originating-IP: [209.85.192.193] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 20267 invoked from network); 4 Aug 2017 02:20:45 -0000 Received: from mail-pf0-f193.google.com (HELO mail-pf0-f193.google.com) (209.85.192.193) by server-16.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 4 Aug 2017 02:20:45 -0000 Received: by mail-pf0-f193.google.com with SMTP id j68so455601pfc.2 for ; Thu, 03 Aug 2017 19:20:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RluPPZa/kTHE+ILNnR/DHPZ10JHDjHtNxCmbkyrlZZc=; b=Bq9XDF1lc9uofDwbu5DwROwmkM0U8X4s0VJ4HbV2jSM+DFDw3npDafjDB9Us0TGCQX lSeBJ7Y6UN0a3qGE9jUnBFN7U98eHxC6T3qnGulaxc1cQjBo9Qi1O026e+W7dgCmw0rr E8mWKpBwn7IuSXb0Bd6XspCOX0A1bScMv/ai7gFfTSLdaN4q6cPWRoEcin8POZTdwZ79 vqWO0Bcg+CHd/54TwyEYYhzPRMEdFm9RlspW+HCbRnvhIF3ANQIY7eI5AVV6y+CRrnuO sC6fieJHYBX4hxy226HOAacbwddxXbdSThHoGqSU31t/3Gmi+oKuEydSHBo+WcFOjbZM ju8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RluPPZa/kTHE+ILNnR/DHPZ10JHDjHtNxCmbkyrlZZc=; b=JDcKgPWFoAg3/1fJtN4doSb/pKkhhSuseZBm241t5CCMe7TXpncTz4cWCEAMJel46r zT5S0E/I2R4siP1YftuWq9ilXgKVd6CPcMSM4Dvr6JrE4GYn4y61mRMblvpmPH5KhcC1 T8Aq7jXzSzUd3c6e9ZpYy+uD5GUBcyws6L5rL0fCAHuogFqxbBjZEONCxrw5fu8T3uri o1N8Z/QkOupyLCWyNXIe8+TxwTIVYznGyEFj6f/IoG917r0YCtUdDjRnGCZfJMf4JciC g2u/osLE4D5yKhzFmPtsCHBQnfFmSqebsij9Ii/SLLpyboSFChN60gAvhDplC0QR7/py vxew== X-Gm-Message-State: AIVw112YRqqC40ZLHEhFDZc2nJn6u6i38mM8nsCZAuHKUDMpkV6wz4dt ibvnai4IdKVeBOE/Zxw= X-Received: by 10.84.195.3 with SMTP id i3mr931770pld.380.1501813243400; Thu, 03 Aug 2017 19:20:43 -0700 (PDT) Received: from localhost.localdomain ([118.189.148.187]) by smtp.gmail.com with ESMTPSA id v62sm403738pfb.170.2017.08.03.19.20.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 19:20:42 -0700 (PDT) From: Zhongze Liu To: xen-devel@lists.xen.org Date: Fri, 4 Aug 2017 10:20:24 +0800 Message-Id: <20170804022025.25293-4-blackskygg@gmail.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170804022025.25293-1-blackskygg@gmail.com> References: <20170804022025.25293-1-blackskygg@gmail.com> Cc: Stefano Stabellini , Zhongze Liu , George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [RFC PATCH 3/4] x86/p2m : remove checks that forbid adding foreign pages between HVM guests 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-Virus-Scanned: ClamAV using ClamSMTP Two checks in the p2m code forbids sharing physical pages among DomU's by using xc_add_to_physmap_batch with XENMAPSPACE_gmfn_foreign. Just simply remove them in this RFC patch to ask for suggestions on how to properly handle this. This is for the proposal "Allow setting up shared memory areas between VMs from xl config file" (see [1]). [1] https://lists.xenproject.org/archives/html/xen-devel/2017-07/msg03047.html Signed-off-by: Zhongze Liu --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Cc: Stefano Stabellini Cc: Julien Grall Cc: xen-devel@lists.xen.org --- xen/arch/x86/mm/p2m.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index e8a57d118c..3ee4c14ed4 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -2531,8 +2531,13 @@ int p2m_add_foreign(struct domain *tdom, unsigned long fgfn, * hvm fixme: until support is added to p2m teardown code to cleanup any * foreign entries, limit this to hardware domain only. */ - if ( !is_hardware_domain(tdom) ) - return -EPERM; + /* The following check prevents us from doing a XENMEM_add_to_physmap + * between two domU's. Asking for suggestions on how to remove or + * work around it. + * + * if ( !is_hardware_domain(tdom) ) + * return -EPERM; + */ if ( foreigndom == DOMID_XEN ) fdom = rcu_lock_domain(dom_xen); @@ -2545,9 +2550,14 @@ int p2m_add_foreign(struct domain *tdom, unsigned long fgfn, if ( tdom == fdom ) goto out; - rc = xsm_map_gmfn_foreign(XSM_TARGET, tdom, fdom); - if ( rc ) - goto out; + /* The following check prevents us from doing a XENMEM_add_to_physmap + * between two domU's. Asking for suggestions on how to remove or + * work around it. + * + * rc = xsm_map_gmfn_foreign(XSM_TARGET, tdom, fdom); + * if ( rc ) + * goto out; + */ /* * Take a refcnt on the mfn. NB: following supported for foreign mapping: