From patchwork Thu Sep 14 16:49:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 112580 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp838903edb; Thu, 14 Sep 2017 09:52:14 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAsc+1fz++B8EntVOHqTr9Zzvp8JlsMhuwzxofLJtucPEUCR2yglraaVLrMn2LfE/+AWQfg X-Received: by 10.107.84.3 with SMTP id i3mr3709128iob.52.1505407934371; Thu, 14 Sep 2017 09:52:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505407934; cv=none; d=google.com; s=arc-20160816; b=kWB8/I+WVV6yROUGUtkuQoEmSDdbFLplGoU1VxOj7iB0m+48DYTRbVYDg/d2Qj+TO8 MY5iBBD+9o2QWQ9h7JoiLgkV6DwAHmgnxjVHroiYlcgouwwNMP48MZ84I3Hg3b6BYhhe o17KOwKV0jWsc1EAXVGLKZEp11lBcLVHWk6FYV1fXmslPKVurKjGVxtLGElJQ7L35mJt ERYKpfLD71wbj7PIQXbWBpZOR/qCUkPvriS7SP7BT11f1f4TDvVp7ikgp4uf+IpHDO0T gPnxcYwkUJbuHuMiANrg4KIxIub+zbi2ZuI/Vne1w3h6NMiHvHCq1j3psnxJkEAuPWBu Hh5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:message-id:date:to:from :arc-authentication-results; bh=KOXv9QJGqr67DvRXqcnV6rn3cT+GWc1RPM4HfE3CJUw=; b=ODZDuejppAzovM21YILWmP5FedMkFL52AV+oc5Qx05TZS3K+bAxlWx7/vvf4AeBo9+ PMFSnepLls5jsuEF3ClBkDNUKSS3eAhfxbUpmr0l5lb+lZ43XKKBOAGY42IyfpQsDXF9 J1nc6RQlRmXk6UuBXgD+fdC7Xwv3GFec+88yE1uF1mfSCrgAEdaHEcFt2VXS/Pal0S+l Ng+kah4beKs69r74qzt/qjvjQrP8D69C2i0S0G4fBd02mYLHAYszfQOhtqo1/uNZS+/g tilvPka4a0tmdHNJLMsAiTPH2pAWpWznIdsNA88cqaAyZXzciFlNTh0Za8JCcb6ED3MM 9Jeg== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id m185si466196itd.109.2017.09.14.09.52.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2017 09:52:14 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsXKv-0006LT-Px; Thu, 14 Sep 2017 16:49:57 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsXKu-0006LN-6v for xen-devel@lists.xen.org; Thu, 14 Sep 2017 16:49:56 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id B6/39-02023-333BAB95; Thu, 14 Sep 2017 16:49:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrDLMWRWlGSWpSXmKPExsVysyfVTddo865 Ig58PDSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1owVe1azF8wVq3i17SFzA+N9wS5GLg4hgc2M Ej3TzjBBOKcZJZqmdTN2MXJysAloStz5/IkJxBYRkJa49vkyI0gRs8BzJonP++6CFQkLWEmsP 3GBDcRmEVCVuNu0jBnE5hWwlPjcNIkdxJYQkJfY1XaRdQIj5wJGhlWMGsWpRWWpRbpGpnpJRZ npGSW5iZk5uoYGpnq5qcXFiempOYlJxXrJ+bmbGIE+q2dgYNzBuKvd7xCjJAeTkijvXt2dkUJ 8SfkplRmJxRnxRaU5qcWHGGU4OJQkeJ9v3BUpJFiUmp5akZaZAwwemLQEB4+SCO9ekDRvcUFi bnFmOkTqFKMuR8fNu3+YhFjy8vNSpcR59TcBFQmAFGWU5sGNgAXyJUZZKWFeRgYGBiGegtSi3 MwSVPlXjOIcjErCvEwgU3gy80rgNr0COoIJ6Igzp3eAHFGSiJCSamBcqqNw5djHE7tFXkcldH K8WCO87Ccf01ZznlLP42d338hyUpefriCse/jq7R1zjvOtit+WOHna/Xhx81e6l/ffsI7i67j P9V4q7PVJ7hj5OYFfZD1Cpp2J/+zxLnnyvhdr48QfV6dP1t/d75G8X3qzRvxb2clnp6wJjWae +mBB9ok+B9b1PPN+K7EUZyQaajEXFScCAIqrdQJfAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1505407794!111559991!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22887 invoked from network); 14 Sep 2017 16:49:54 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-206.messagelabs.com with SMTP; 14 Sep 2017 16:49:54 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9503B1435; Thu, 14 Sep 2017 09:49:53 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C40EF3F483; Thu, 14 Sep 2017 09:49:51 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 14 Sep 2017 17:49:45 +0100 Message-Id: <20170914164945.11566-1-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH] xen: grant-table: Simplify get_page_frame 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" The implementation of get_page_frame is currently different whether the architecture support sharing memory or paging memory. Both version are extremely similar so it is possible to consolidate in a single implementation. The check for shared/paged memory are gated with the respective ifdef. Potentially, dummy p2m_is_shared/p2m_is_paging could be implemented for Arm. Signed-off-by: Julien Grall --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu get_page_from_gfn will be able to get reference on foreign page and as per my understanding will allow to grant page on foreign memory. This was not allowed with a simple get_page(...) on the ARM implementation (no sharing nor paging supprot) but is allowed on the x86 implementation due to get_page_from_gfn. On x86, foreign pages are currently only allowed for PVH dom0, so I think it is not a big deal for now. On Arm, foreign pages can be present on any domain. So this patch would permit grant on foreing pages. So I would like to check whether it would be valid to grant a mapping on foreign pages? If not, I could add a check if ( p2m_is_foreign(...) ) return GTNST_bad_page. --- xen/common/grant_table.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index c3895e6201..97d3200313 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -259,7 +259,6 @@ static int get_paged_frame(unsigned long gfn, unsigned long *frame, struct domain *rd) { int rc = GNTST_okay; -#if defined(P2M_PAGED_TYPES) || defined(P2M_SHARED_TYPES) p2m_type_t p2mt; *page = get_page_from_gfn(rd, gfn, &p2mt, @@ -267,26 +266,20 @@ static int get_paged_frame(unsigned long gfn, unsigned long *frame, if ( !(*page) ) { *frame = mfn_x(INVALID_MFN); +#if defined(P2M_SHARED_TYPES) if ( p2m_is_shared(p2mt) ) return GNTST_eagain; +#endif +#if defined(P2M_PAGES_TYPES) if ( p2m_is_paging(p2mt) ) { p2m_mem_paging_populate(rd, gfn); return GNTST_eagain; } +#endif return GNTST_bad_page; } *frame = page_to_mfn(*page); -#else - *frame = mfn_x(gfn_to_mfn(rd, _gfn(gfn))); - *page = mfn_valid(_mfn(*frame)) ? mfn_to_page(*frame) : NULL; - if ( (!(*page)) || (!get_page(*page, rd)) ) - { - *frame = mfn_x(INVALID_MFN); - *page = NULL; - rc = GNTST_bad_page; - } -#endif return rc; }