]> xenbits.xensource.com Git - xen.git/commitdiff
x86/p2m: make p2m_get_page_from_gfn() handle grant case correctly
authorJan Beulich <jbeulich@suse.com>
Tue, 13 Feb 2024 08:27:47 +0000 (09:27 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 13 Feb 2024 08:27:47 +0000 (09:27 +0100)
The 'fast' path of p2m_get_page_from_gfn handles three cases: normal ram,
foreign p2m entries, and grant map entries.  For normal ram and grant table
entries, get_page() is called, but for foreign entries,
page_get_owner_and_reference() is called, since the current domain is
expected not to be the owner.

Unfortunately, grant maps are *also* generally expected to be owned by
foreign domains; so this function will fail for any p2m entry containing a
grant map that doesn't happen to be local.

Have grant maps take the same path as foreign entries.  Since grants may
actually be either foreign or local, adjust the assertion to allow for this.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: George Dunlap <george.dunlap@cloud.com>
Reviewed-by: George Dunlap <george.dunlap@cloud.com>
xen/arch/x86/mm/p2m.c

index 6eb446e4371bfc2b4b3c2aaaf928229c62e18c7f..d118d27ab9088e82a6a3c0682f4f5532dde297ad 100644 (file)
@@ -346,11 +346,11 @@ struct page_info *p2m_get_page_from_gfn(
              && !((q & P2M_UNSHARE) && p2m_is_shared(*t)) )
         {
             page = mfn_to_page(mfn);
-            if ( unlikely(p2m_is_foreign(*t)) )
+            if ( unlikely(p2m_is_foreign(*t)) || unlikely(p2m_is_grant(*t)) )
             {
                 struct domain *fdom = page_get_owner_and_reference(page);
 
-                ASSERT(fdom != p2m->domain);
+                ASSERT(!p2m_is_foreign(*t) || fdom != p2m->domain);
                 if ( fdom == NULL )
                     page = NULL;
             }