[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86/p2m: make p2m_get_page_from_gfn() handle grant case correctly



commit cbbca7be4aaadbe0a65cd6a7d6a1f7c412d339f4
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Tue Feb 13 09:27:47 2024 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Feb 13 09:27:47 2024 +0100

    x86/p2m: make p2m_get_page_from_gfn() handle grant case correctly
    
    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@xxxxxxxx>
    Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxx>
    Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxx>
---
 xen/arch/x86/mm/p2m.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 6eb446e437..d118d27ab9 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -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;
             }
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.