All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "George Dunlap" <George.Dunlap@eu.citrix.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH 3/4] x86/mm: avoid IOMMU operations in more cases in _get_page_type()
Date: Fri, 20 Dec 2019 15:19:56 +0100	[thread overview]
Message-ID: <c93259a3-5f68-bcca-aeee-f264234cadf4@suse.com> (raw)
In-Reply-To: <aa264d92-2545-f2e7-5225-4f870e3ec8f9@suse.com>

All that really matters is whether writability of a page changes; in
paticular e.g. page table -> page table (but different levels)
transitions do not require unmapping the page from the IOMMU again.

Note that the XSA-288 fix did arrange for PGT_none pages not needing
special consideration here.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -2968,17 +2968,19 @@ static int _get_page_type(struct page_in
             return -EINTR;
     }
 
-    if ( unlikely((x & PGT_type_mask) != type) )
+    if ( unlikely(((x & PGT_type_mask) == PGT_writable_page) !=
+                  (type == PGT_writable_page)) )
     {
         /* Special pages should not be accessible from devices. */
         struct domain *d = page_get_owner(page);
+
         if ( d && is_pv_domain(d) && unlikely(need_iommu_pt_sync(d)) )
         {
             mfn_t mfn = page_to_mfn(page);
 
             if ( (x & PGT_type_mask) == PGT_writable_page )
                 rc = iommu_legacy_unmap(d, _dfn(mfn_x(mfn)), PAGE_ORDER_4K);
-            else if ( type == PGT_writable_page )
+            else
                 rc = iommu_legacy_map(d, _dfn(mfn_x(mfn)), mfn, PAGE_ORDER_4K,
                                       IOMMUF_readable | IOMMUF_writable);
 


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-12-20 14:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-20 14:16 [Xen-devel] [PATCH 0/4] x86/mm: XSA-299 / 309 / 310 follow-up Jan Beulich
2019-12-20 14:19 ` [Xen-devel] [PATCH 1/4] x86/mm: mod_l<N>_entry() have no need to use __copy_from_user() Jan Beulich
2019-12-20 14:42   ` Andrew Cooper
2019-12-20 14:47     ` George Dunlap
2019-12-20 14:52       ` Jan Beulich
2019-12-20 14:54         ` George Dunlap
2019-12-20 15:00           ` Jan Beulich
2019-12-20 14:48     ` Jan Beulich
2019-12-20 14:19 ` [Xen-devel] [PATCH 2/4] x86/mm: rename and tidy create_pae_xen_mappings() Jan Beulich
2019-12-20 15:33   ` Andrew Cooper
2020-01-06 14:23     ` Jan Beulich
2019-12-20 14:19 ` Jan Beulich [this message]
2019-12-20 14:47   ` [Xen-devel] [PATCH 3/4] x86/mm: avoid IOMMU operations in more cases in _get_page_type() Andrew Cooper
2019-12-20 14:20 ` [Xen-devel] [PATCH 4/4] x86/mm: drop redundant smp_wmb() from _put_final_page_type() Jan Beulich
2019-12-20 14:51   ` Andrew Cooper
2019-12-20 14:55     ` Jan Beulich
2019-12-20 14:59       ` Andrew Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c93259a3-5f68-bcca-aeee-f264234cadf4@suse.com \
    --to=jbeulich@suse.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.