ia64/xen-unstable

changeset 11043:45cd04201495

[IA64] resolve VTI address wrap issue

This patch resolves the address wrap issue in vtlb_purge and vhpt_purge

Signed-off-by: Anthony Xu <anthony.xu@intel.com>
author awilliam@xenbuild.aw
date Wed Aug 16 10:21:13 2006 -0600 (2006-08-16)
parents e6eede7648ee
children 5becaaabd335
files xen/arch/ia64/vmx/vtlb.c
line diff
     1.1 --- a/xen/arch/ia64/vmx/vtlb.c	Wed Aug 16 09:18:16 2006 -0600
     1.2 +++ b/xen/arch/ia64/vmx/vtlb.c	Wed Aug 16 10:21:13 2006 -0600
     1.3 @@ -245,7 +245,6 @@ u64 guest_vhpt_lookup(u64 iha, u64 *pte)
     1.4      return ret;
     1.5  }
     1.6  
     1.7 -
     1.8  /*
     1.9   *  purge software guest tlb
    1.10   */
    1.11 @@ -253,29 +252,29 @@ u64 guest_vhpt_lookup(u64 iha, u64 *pte)
    1.12  void vtlb_purge(VCPU *v, u64 va, u64 ps)
    1.13  {
    1.14      thash_data_t *cur;
    1.15 -    u64 start, end, curadr, size, psbits, tag, def_size;
    1.16 +    u64 start, curadr, size, psbits, tag, rr_ps, num;
    1.17      ia64_rr vrr;
    1.18      thash_cb_t *hcb = &v->arch.vtlb;
    1.19 +
    1.20      vcpu_get_rr(v, va, &vrr.rrval);
    1.21      psbits = VMX(v, psbits[(va >> 61)]);
    1.22 -    size = PSIZE(ps);
    1.23 -    start = va & (-size);
    1.24 -    end = start + size;
    1.25 +    start = va & ~((1UL << ps) - 1);
    1.26      while (psbits) {
    1.27          curadr = start;
    1.28 -        ps = __ffs(psbits);
    1.29 -        psbits &= ~(1UL << ps);
    1.30 -        def_size = PSIZE(ps);
    1.31 -        vrr.ps = ps;
    1.32 -        /* Be careful about overflow.  */
    1.33 -        while (curadr < end && curadr >= start) {
    1.34 +        rr_ps = __ffs(psbits);
    1.35 +        psbits &= ~(1UL << rr_ps);
    1.36 +        num = 1UL << ((ps < rr_ps) ? 0 : (ps - rr_ps));
    1.37 +        size = PSIZE(rr_ps);
    1.38 +        vrr.ps = rr_ps;
    1.39 +        while (num) {
    1.40              cur = vsa_thash(hcb->pta, curadr, vrr.rrval, &tag);
    1.41              while (cur) {
    1.42 -                if (cur->etag == tag && cur->ps == ps)
    1.43 +                if (cur->etag == tag && cur->ps == rr_ps)
    1.44                      cur->etag = 1UL << 63;
    1.45                  cur = cur->next;
    1.46              }
    1.47 -            curadr += def_size;
    1.48 +            curadr += size;
    1.49 +            num--;
    1.50          }
    1.51      }
    1.52  }
    1.53 @@ -288,14 +287,14 @@ static void vhpt_purge(VCPU *v, u64 va, 
    1.54  {
    1.55      //thash_cb_t *hcb = &v->arch.vhpt;
    1.56      thash_data_t *cur;
    1.57 -    u64 start, end, size, tag;
    1.58 +    u64 start, size, tag, num;
    1.59      ia64_rr rr;
    1.60 -    size = PSIZE(ps);
    1.61 -    start = va & (-size);
    1.62 -    end = start + size;
    1.63 -    rr.rrval = ia64_get_rr(va);
    1.64 -    size = PSIZE(rr.ps);    
    1.65 -    while(start < end){
    1.66 +    
    1.67 +    start = va & ~((1UL << ps) - 1);
    1.68 +    rr.rrval = ia64_get_rr(va);  
    1.69 +    size = PSIZE(rr.ps);
    1.70 +    num = 1UL << ((ps < rr.ps) ? 0 : (ps - rr.ps));
    1.71 +    while (num) {
    1.72          cur = (thash_data_t *)ia64_thash(start);
    1.73          tag = ia64_ttag(start);
    1.74          while (cur) {
    1.75 @@ -304,6 +303,7 @@ static void vhpt_purge(VCPU *v, u64 va, 
    1.76              cur = cur->next;
    1.77          }
    1.78          start += size;
    1.79 +        num--;
    1.80      }
    1.81      machine_tlb_purge(va, ps);
    1.82  }