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

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



commit c674c77f69684bfa57e3c61d6dbf404c13953f34
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Mon Jul 22 09:41:03 2024 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Jul 22 09:41:03 2024 +0200

    x86: don't open-code [gm]fn_to_[gm]addr()
    
    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@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/arch/x86/guest/xen/xen.c        | 2 +-
 xen/arch/x86/include/asm/guest_pt.h | 2 +-
 xen/arch/x86/mm/hap/nested_hap.c    | 2 +-
 xen/arch/x86/mm/p2m-ept.c           | 7 +++----
 4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c
index 7484b3f73a..c17f5c447a 100644
--- 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++ )
diff --git a/xen/arch/x86/include/asm/guest_pt.h 
b/xen/arch/x86/include/asm/guest_pt.h
index e01db4a671..21473f9bbc 100644
--- a/xen/arch/x86/include/asm/guest_pt.h
+++ b/xen/arch/x86/include/asm/guest_pt.h
@@ -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
diff --git a/xen/arch/x86/mm/hap/nested_hap.c b/xen/arch/x86/mm/hap/nested_hap.c
index ee78a797d1..080b60adf0 100644
--- 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;
diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index 469e27ee93..9925c560c1 100644
--- 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, 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;
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

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