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

[PATCH 1/2] x86/p2m: make p2m_get_page_from_gfn() handle grant and shared cases better


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 23 Feb 2022 16:14:55 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=st09De5AhrTxtdqW5QYgoa+DjF7F0kOPM0aXdyBYarM=; b=HSj84r02CbY+xmuKm5mTllNjAIX1oF5YfGBA8oP6/ZSFRSmbT0Qk8NkfIGdYIpgRoa2kiNmNx4e1lAgeBwlJIDrjdnqVEhvM1Y4FIeDd9imkO9ztWpOdYnUvvm2vHf8FDZizdo9BeB5UpgqP3UZy74NNCWSU+sLwlE5lob0WXdNb5kmeQZlGKS4txWZrcUxFUYS6DdckVPAPoeMeAX4+qe0f/93m1DKMVr0lGBpumayoDUsKywY4C73jPCU9KpjsN0MgRRrMo+k8lM85pl/RB/PD7QPxpV4qI5KtIjBgBglJhLOg338xWgnHf+XDQAITROv6KtsxqUWA/PvHChGESQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JIfAxmIMAJeqOtVHyS5LYz9eBwzWXekExKRqJizoEc7CGUnEHjcFrbyBcmLf997yA1OiIQgayPxpAvMtx3fWFdLNge82iWHEL7+mWOa+JWU5tLGAEIxmKU9Y0EXqS5mmSBCjQIMymDhXBofTRUzZUb9dCnSfy6YCOEZFxenpnZpR/9WmtxjE4OhlgzAa9stVd/6qWCzIUqbtqDCbyGk9VreJqwLUB5+2QkpiLszL+j609ziZ1nYx9U2ywLMj6rEqAyGKcMMxdHh6QFb3DYyWbVMn8R0g67H11tN3GB1A80CmIm1xAQq/yV4oBKtlnQPy5x9jrONnBLq0GYzupT0sqQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Tamas K Lengyel <tamas@xxxxxxxxxxxxx>
  • Delivery-date: Wed, 23 Feb 2022 15:15:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Grant P2M entries, which are covered by p2m_is_any_ram(), wouldn't pass
the get_page() unless the grant was a local one. These need to take the
same path as foreign entries. Just the assertion there is not valid for
local grants, and hence it triggering needs to be avoided.

Shared entries, when unshare is requested, would bypass the retrieval of
"page" and thus always take the error path rather than actually trying
to unshare by taking the slow path.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
Using | instead of || helps the compiler fold the two p2m_is_*().

--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -584,11 +584,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) | 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;
             }
@@ -607,6 +607,7 @@ struct page_info *p2m_get_page_from_gfn(
 
         /* Error path: not a suitable GFN at all */
         if ( !p2m_is_ram(*t) && !p2m_is_paging(*t) && !p2m_is_pod(*t) &&
+             (!p2m_is_shared(*t) || !(q & P2M_UNSHARE)) &&
              !mem_sharing_is_fork(p2m->domain) )
             return NULL;
     }




 


Rackspace

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