]> xenbits.xensource.com Git - xen.git/commitdiff
x86: don't open-code [gm]fn_to_[gm]addr()
authorJan Beulich <jbeulich@suse.com>
Mon, 22 Jul 2024 07:41:03 +0000 (09:41 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 22 Jul 2024 07:41:03 +0000 (09:41 +0200)
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>
xen/arch/x86/guest/xen/xen.c
xen/arch/x86/include/asm/guest_pt.h
xen/arch/x86/mm/hap/nested_hap.c
xen/arch/x86/mm/p2m-ept.c

index 7484b3f73ad3e20b914ba48a309bda97b58cff51..c17f5c447ab6405f3ab981efc1b8dce5544082e7 100644 (file)
@@ -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++ )
index e01db4a6716e8ff66429bf7d89c6e39f2fad768b..21473f9bbc74c44b6e0eff6cfa9a190e67237388 100644 (file)
@@ -371,7 +371,7 @@ static inline paddr_t guest_walk_to_gpa(const walk_t *gw)
     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
index ee78a797d1a46a17b51d7d12b90ff78ca3787d1b..080b60adf0e6f62eaca898319aa3774b79705c97 100644 (file)
@@ -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;
index 469e27ee9312faac6eba9bacbeea16d56440226a..9925c560c1f455ab746bd7df4b60c3d96a2e6e0e 100644 (file)
@@ -565,11 +565,10 @@ int epte_get_entry_emt(struct domain *d, gfn_t gfn, mfn_t mfn,
     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;