All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Roger Pau Monne <roger.pau@citrix.com>,
	Jan Beulich <jbeulich@suse.com>, Paul Durrant <paul@xen.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>
Subject: [PATCH 3/5] iommu/x86: use full addresses internally for the IVMD/RMRR range checks
Date: Wed, 14 Feb 2024 11:37:39 +0100	[thread overview]
Message-ID: <20240214103741.16189-4-roger.pau@citrix.com> (raw)
In-Reply-To: <20240214103741.16189-1-roger.pau@citrix.com>

Adjust the code in the checker to use full addresses rather than frame numbers,
as it's only page_get_ram_type() that requires an mfn parameter.

Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/passthrough/x86/iommu.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c
index 304a2f5480c7..e713cf803e8a 100644
--- a/xen/drivers/passthrough/x86/iommu.c
+++ b/xen/drivers/passthrough/x86/iommu.c
@@ -794,28 +794,26 @@ __initcall(adjust_irq_affinities);
 
 bool __init iommu_unity_region_ok(const char *prefix, mfn_t start, mfn_t end)
 {
-    mfn_t addr;
+    paddr_t s = mfn_to_maddr(start), e = mfn_to_maddr(end);
 
-    if ( e820_all_mapped(mfn_to_maddr(start), mfn_to_maddr(end) + PAGE_SIZE,
-                         E820_RESERVED) )
+    if ( e820_all_mapped(s, e + PAGE_SIZE, E820_RESERVED) )
         return true;
 
     printk(XENLOG_WARNING
            "%s: [%#lx, %#lx] is not (entirely) in reserved memory\n",
-           prefix, mfn_to_maddr(start), mfn_to_maddr(end));
+           prefix, s, e);
 
-    for ( addr = start; mfn_x(addr) <= mfn_x(end); addr = mfn_add(addr, 1) )
+    for ( paddr_t addr = s; addr <= e; addr += PAGE_SIZE )
     {
-        unsigned int type = page_get_ram_type(addr);
+        unsigned int type = page_get_ram_type(maddr_to_mfn(addr));
 
         if ( type == RAM_TYPE_UNKNOWN )
         {
-            if ( e820_add_range(mfn_to_maddr(addr),
-                                mfn_to_maddr(addr) + PAGE_SIZE, E820_RESERVED) )
+            if ( e820_add_range(addr, addr + PAGE_SIZE, E820_RESERVED) )
                 continue;
             printk(XENLOG_ERR
-                   "%s: page at %#" PRI_mfn " couldn't be reserved\n",
-                   prefix, mfn_x(addr));
+                   "%s: page at %#lx couldn't be reserved\n",
+                   prefix, paddr_to_pfn(addr));
             return false;
         }
 
@@ -829,9 +827,8 @@ bool __init iommu_unity_region_ok(const char *prefix, mfn_t start, mfn_t end)
                      RAM_TYPE_UNUSABLE) )
             continue;
 
-        printk(XENLOG_ERR
-               "%s: page at %#" PRI_mfn " can't be converted\n",
-               prefix, mfn_x(addr));
+        printk(XENLOG_ERR "%s: page at %#lx can't be converted\n",
+               prefix, paddr_to_pfn(addr));
         return false;
     }
 
-- 
2.43.0



  parent reply	other threads:[~2024-02-14 11:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 10:37 [PATCH 0/5] Fix fallout from IVMD/RMRR unification checks Roger Pau Monne
2024-02-14 10:37 ` [PATCH 1/5] iommu/x86: fix IVMD/RMRR range checker loop increment Roger Pau Monne
2024-02-14 11:51   ` Jan Beulich
2024-02-14 12:04     ` Roger Pau Monné
2024-02-14 10:37 ` [PATCH 2/5] iommu/x86: print RMRR/IVMD ranges using full addresses Roger Pau Monne
2024-02-14 13:22   ` Jan Beulich
2024-02-14 14:03     ` Roger Pau Monné
2024-02-14 10:37 ` Roger Pau Monne [this message]
2024-02-14 13:29   ` [PATCH 3/5] iommu/x86: use full addresses internally for the IVMD/RMRR range checks Jan Beulich
2024-02-14 14:05     ` Roger Pau Monné
2024-02-14 14:31       ` Jan Beulich
2024-02-14 10:37 ` [PATCH 4/5] iommu/x86: print page type in IVMD/RMRR check in case of error Roger Pau Monne
2024-02-14 13:30   ` Jan Beulich
2024-02-14 10:37 ` [PATCH 5/5] mm: add the __must_check attribute to {gfn,mfn}_add() Roger Pau Monne
2024-02-14 12:02   ` Julien Grall
2024-02-14 13:42   ` Jan Beulich
2024-02-14 14:00     ` Roger Pau Monné
2024-02-14 14:11   ` [PATCH v2 5/5] mm: add the __must_check attribute to {gfn,mfn,dfn}_add() Roger Pau Monne
2024-02-14 14:32     ` Jan Beulich
2024-02-19  5:07   ` [PATCH 5/5] mm: add the __must_check attribute to {gfn,mfn}_add() George Dunlap
2024-02-19  8:50     ` Jan Beulich

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=20240214103741.16189-4-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=paul@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.