WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] [PATCH] Cleanup: TLB translation

To: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-ia64-devel] [PATCH] Cleanup: TLB translation
From: Kouya Shimura <kouya@xxxxxxxxxxxxxx>
Date: Wed, 26 Mar 2008 17:40:48 +0900
Delivery-date: Wed, 26 Mar 2008 01:41:09 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
Add a new static inline function for readability.

Signed-off-by: Kouya Shimura <kouya@xxxxxxxxxxxxxx>

diff -r edfb58ca4d96 xen/arch/ia64/vmx/vmmu.c
--- a/xen/arch/ia64/vmx/vmmu.c  Tue Mar 25 12:37:17 2008 -0600
+++ b/xen/arch/ia64/vmx/vmmu.c  Wed Mar 26 17:05:31 2008 +0900
@@ -167,7 +167,7 @@ fetch_code(VCPU *vcpu, u64 gip, IA64_BUN
 //        if( tlb == NULL )
 //             tlb = vtlb_lookup(vcpu, gip, DSIDE_TLB );
         if (tlb)
-            gpip = (tlb->ppn >>(tlb->ps-12)<<tlb->ps) | ( gip & 
(PSIZE(tlb->ps)-1) );
+            gpip = thash_translate(tlb, gip);
     }
     if( gpip){
         mfn = gmfn_to_mfn(vcpu->domain, gpip >>PAGE_SHIFT);
@@ -180,8 +180,7 @@ fetch_code(VCPU *vcpu, u64 gip, IA64_BUN
             ia64_ptcl(gip, ARCH_PAGE_SHIFT << 2);
             return IA64_RETRY;
         }
-        maddr = (tlb->ppn >> (tlb->ps - 12) << tlb->ps) |
-                (gip & (PSIZE(tlb->ps) - 1));
+        maddr = thash_translate(tlb, gip);
         mfn = maddr >> PAGE_SHIFT;
     }
 
@@ -536,8 +535,7 @@ IA64FAULT vmx_vcpu_tpa(VCPU *vcpu, u64 v
             dnat_page_consumption(vcpu, vadr);
             return IA64_FAULT;
         } else {
-            *padr = ((data->ppn >> (data->ps - 12)) << data->ps) |
-                    (vadr & (PSIZE(data->ps) - 1));
+            *padr = thash_translate(data, vadr);
             return IA64_NO_FAULT;
         }
     }
@@ -554,8 +552,7 @@ IA64FAULT vmx_vcpu_tpa(VCPU *vcpu, u64 v
             dnat_page_consumption(vcpu, vadr);
             return IA64_FAULT;
         } else {
-            madr = (data->ppn >> (data->ps - 12) << data->ps) |
-                   (vadr & (PSIZE(data->ps) - 1));
+            madr = thash_translate(data, vadr);
             *padr = __mpa_to_gpa(madr);
             return IA64_NO_FAULT;
         }
diff -r edfb58ca4d96 xen/arch/ia64/vmx/vmx_fault.c
--- a/xen/arch/ia64/vmx/vmx_fault.c     Tue Mar 25 12:37:17 2008 -0600
+++ b/xen/arch/ia64/vmx/vmx_fault.c     Wed Mar 26 17:01:48 2008 +0900
@@ -402,8 +402,7 @@ try_again:
                 if ((data->ma == VA_MATTR_UC) || (data->ma == VA_MATTR_UCE))
                     return vmx_handle_lds(regs);
             }
-            gppa = (vadr & ((1UL << data->ps) - 1)) +
-                   (data->ppn >> (data->ps - 12) << data->ps);
+            gppa = thash_translate(data, vadr);
             pte = lookup_domain_mpa(v->domain, gppa, NULL);
             if (pte & GPFN_IO_MASK) {
                 if (misr.sp)
diff -r edfb58ca4d96 xen/include/asm-ia64/vmmu.h
--- a/xen/include/asm-ia64/vmmu.h       Tue Mar 25 12:37:17 2008 -0600
+++ b/xen/include/asm-ia64/vmmu.h       Wed Mar 26 17:12:58 2008 +0900
@@ -118,6 +118,11 @@ typedef struct thash_data {
 #define INVALID_TR(hdata)      (!(hdata)->p)
 #define INVALID_ENTRY(hcb, hdata)       INVALID_VHPT(hdata)
 
+static inline u64 thash_translate(thash_data_t *hdata, u64 vadr)
+{
+    int ps = hdata->ps;
+    return (hdata->ppn >> (ps - 12) << ps) | (vadr & ((1UL << ps) - 1));
+}
 
 typedef struct thash_cb {
     /* THASH base information */
_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel
<Prev in Thread] Current Thread [Next in Thread>