diff mbox series

x86: don't open-code [gm]fn_to_[gm]addr()

Message ID 3a6575b4-8b03-41ce-93e3-a874f23d6522@suse.com (mailing list archive)
State New
Headers show
Series x86: don't open-code [gm]fn_to_[gm]addr() | expand

Commit Message

Jan Beulich July 18, 2024, 10:11 a.m. UTC
At least in pure address calculation use the intended basic construct
instead of opend-coded left-shifting by PAGE_SHIFT. Leave alone page
table entry calculations for now, as those aren't really calculating
addresses.

No functional change.

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

Comments

Andrew Cooper July 18, 2024, 10:13 a.m. UTC | #1
On 18/07/2024 11:11 am, Jan Beulich wrote:
> At least in pure address calculation use the intended basic construct
> instead of opend-coded left-shifting by PAGE_SHIFT. Leave alone page
> table entry calculations for now, as those aren't really calculating
> addresses.
>
> No functional change.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff mbox series

Patch

--- a/xen/arch/x86/guest/xen/xen.c
+++ b/xen/arch/x86/guest/xen/xen.c
@@ -73,7 +73,7 @@  static void map_shared_info(void)
     if ( rc )
         panic("failed to map shared_info page: %ld\n", rc);
 
-    set_fixmap(FIX_XEN_SHARED_INFO, mfn_x(mfn) << PAGE_SHIFT);
+    set_fixmap(FIX_XEN_SHARED_INFO, mfn_to_maddr(mfn));
 
     /* Mask all upcalls */
     for ( i = 0; i < ARRAY_SIZE(XEN_shared_info->evtchn_mask); i++ )
--- a/xen/arch/x86/include/asm/guest_pt.h
+++ b/xen/arch/x86/include/asm/guest_pt.h
@@ -377,7 +377,7 @@  static inline paddr_t guest_walk_to_gpa(
     if ( gfn_eq(gfn, INVALID_GFN) )
         return INVALID_PADDR;
 
-    return (gfn_x(gfn) << PAGE_SHIFT) | (gw->va & ~PAGE_MASK);
+    return gfn_to_gaddr(gfn) | (gw->va & ~PAGE_MASK);
 }
 
 /* Given a walk_t from a successful walk, return the page-order of the
--- a/xen/arch/x86/mm/hap/nested_hap.c
+++ b/xen/arch/x86/mm/hap/nested_hap.c
@@ -134,7 +134,7 @@  static int nestedhap_walk_L0_p2m(
 
     rc = NESTEDHVM_PAGEFAULT_DONE;
 direct_mmio_out:
-    *L0_gpa = (mfn_x(mfn) << PAGE_SHIFT) + (L1_gpa & ~PAGE_MASK);
+    *L0_gpa = mfn_to_maddr(mfn) + (L1_gpa & ~PAGE_MASK);
 out:
     p2m_put_gfn(p2m, gaddr_to_gfn(L1_gpa));
     return rc;
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -565,11 +565,10 @@  int epte_get_entry_emt(struct domain *d,
     if ( gmtrr_mtype == -EADDRNOTAVAIL )
         return -1;
 
-    gmtrr_mtype = v ? mtrr_get_type(&v->arch.hvm.mtrr,
-                                    gfn_x(gfn) << PAGE_SHIFT, order)
+    gmtrr_mtype = v ? mtrr_get_type(&v->arch.hvm.mtrr, gfn_to_gaddr(gfn),
+                                    order)
                     : X86_MT_WB;
-    hmtrr_mtype = mtrr_get_type(&mtrr_state, mfn_x(mfn) << PAGE_SHIFT,
-                                order);
+    hmtrr_mtype = mtrr_get_type(&mtrr_state, mfn_to_maddr(mfn), order);
     if ( gmtrr_mtype < 0 || hmtrr_mtype < 0 )
         return -1;