From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mukesh Rathor Subject: [V10 PATCH 2/4] pvh dom0: Add checks and restrictions for p2m_is_foreign Date: Tue, 29 Apr 2014 18:06:46 -0700 Message-ID: <1398820008-9005-3-git-send-email-mukesh.rathor@oracle.com> References: <1398820008-9005-1-git-send-email-mukesh.rathor@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WfIze-0007fY-19 for xen-devel@lists.xenproject.org; Wed, 30 Apr 2014 01:07:26 +0000 In-Reply-To: <1398820008-9005-1-git-send-email-mukesh.rathor@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: George.Dunlap@eu.citrix.com, keir.xen@gmail.com, tim@xen.org, JBeulich@suse.com List-Id: xen-devel@lists.xenproject.org In this patch, we add some checks and restrictions in the relevant p2m paths for p2m_is_foreign. Signed-off-by: Mukesh Rathor --- xen/arch/x86/mm/p2m-ept.c | 1 + xen/arch/x86/mm/p2m.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 8d3051b..c0bfc50 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -776,6 +776,7 @@ static void ept_change_entry_type_global(struct p2m_domain *p2m, BUG_ON(p2m_is_grant(ot) || p2m_is_grant(nt)); BUG_ON(p2m_is_mmio(ot) || p2m_is_mmio(nt)); + BUG_ON(p2m_is_foreign(ot) || p2m_is_foreign(nt)); ept_change_entry_type_page(_mfn(ept_get_asr(ept)), ept_get_wl(ept), ot, nt); diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 365e37a..6370306 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -559,6 +559,10 @@ guest_physmap_add_entry(struct domain *d, unsigned long gfn, return 0; } + /* foreign pages are added thru p2m_add_foreign */ + if ( p2m_is_foreign(t) ) + return -EINVAL; + p2m_lock(p2m); P2M_DEBUG("adding gfn=%#lx mfn=%#lx\n", gfn, mfn); @@ -593,9 +597,9 @@ guest_physmap_add_entry(struct domain *d, unsigned long gfn, omfn = p2m->get_entry(p2m, gfn + i, &ot, &a, 0, NULL); ASSERT(!p2m_is_shared(ot)); } - if ( p2m_is_grant(ot) ) + if ( p2m_is_grant(ot) || p2m_is_foreign(ot) ) { - /* Really shouldn't be unmapping grant maps this way */ + /* Really shouldn't be unmapping grant/foreign maps this way */ domain_crash(d); p2m_unlock(p2m); @@ -697,6 +701,7 @@ p2m_type_t p2m_change_type(struct domain *d, unsigned long gfn, struct p2m_domain *p2m = p2m_get_hostp2m(d); BUG_ON(p2m_is_grant(ot) || p2m_is_grant(nt)); + BUG_ON(p2m_is_foreign(ot) || p2m_is_foreign(nt)); gfn_lock(p2m, gfn, 0); @@ -721,6 +726,7 @@ void p2m_change_type_range(struct domain *d, struct p2m_domain *p2m = p2m_get_hostp2m(d); BUG_ON(p2m_is_grant(ot) || p2m_is_grant(nt)); + BUG_ON(p2m_is_foreign(ot) || p2m_is_foreign(nt)); p2m_lock(p2m); p2m->defer_nested_flush = 1; @@ -771,7 +777,7 @@ static int set_typed_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn, gfn_lock(p2m, gfn, 0); omfn = p2m->get_entry(p2m, gfn, &ot, &a, 0, NULL); - if ( p2m_is_grant(ot) ) + if ( p2m_is_grant(ot) || p2m_is_foreign(ot) ) { p2m_unlock(p2m); domain_crash(d); -- 1.8.3.1