ia64/xen-unstable

changeset 12926:4ca8abbd89c8

[XEN][POWERPC] Improve the debugging strategy of these hcalls.
This patch cleans up all the variaus printk()s.
Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Sun Oct 01 08:38:38 2006 -0400 (2006-10-01)
parents 234257c78627
children 2bf4257944f4
files xen/arch/powerpc/papr/xlate.c
line diff
     1.1 --- a/xen/arch/powerpc/papr/xlate.c	Fri Sep 29 14:31:05 2006 -0400
     1.2 +++ b/xen/arch/powerpc/papr/xlate.c	Sun Oct 01 08:38:38 2006 -0400
     1.3 @@ -19,7 +19,7 @@
     1.4   */
     1.5  
     1.6  #undef DEBUG
     1.7 -#undef DEBUG_FAIL
     1.8 +#undef DEBUG_LOW
     1.9  
    1.10  #include <xen/config.h>
    1.11  #include <xen/types.h>
    1.12 @@ -30,6 +30,17 @@
    1.13  #include <asm/papr.h>
    1.14  #include <asm/hcalls.h>
    1.15  
    1.16 +#ifdef DEBUG
    1.17 +#define DBG(fmt...) printk(fmt)
    1.18 +#else
    1.19 +#define DBG(fmt...)
    1.20 +#endif
    1.21 +#ifdef DEBUG_LOW
    1.22 +#define DBG_LOW(fmt...) printk(fmt)
    1.23 +#else
    1.24 +#define DBG_LOW(fmt...)
    1.25 +#endif
    1.26 +
    1.27  #ifdef USE_PTE_INSERT
    1.28  static inline void pte_insert(union pte volatile *pte,
    1.29          ulong vsid, ulong rpn, ulong lrpn)
    1.30 @@ -129,8 +140,8 @@ static void h_enter(struct cpu_user_regs
    1.31  
    1.32      htab = &d->arch.htab;
    1.33      if (ptex > (1UL << htab->log_num_ptes)) {
    1.34 +        DBG("%s: bad ptex: 0x%lx\n", __func__, ptex);
    1.35          regs->gprs[3] = H_Parameter;
    1.36 -        printk("%s: bad ptex: 0x%lx\n", __func__, ptex);
    1.37          return;
    1.38      }
    1.39  
    1.40 @@ -150,8 +161,8 @@ static void h_enter(struct cpu_user_regs
    1.41          }
    1.42  
    1.43          if ( lp_size >= d->arch.large_page_sizes ) {
    1.44 -            printk("%s: attempt to use unsupported lp_size %d\n",
    1.45 -                   __func__, lp_size);
    1.46 +            DBG("%s: attempt to use unsupported lp_size %d\n",
    1.47 +                __func__, lp_size);
    1.48              regs->gprs[3] = H_Parameter;
    1.49              return;
    1.50          }
    1.51 @@ -168,6 +179,7 @@ static void h_enter(struct cpu_user_regs
    1.52  
    1.53      mfn = pfn2mfn(d, pfn, &mtype);
    1.54      if (mfn == INVALID_MFN) {
    1.55 +        DBG("%s: Bad PFN: 0x%lx\n", __func__, pfn);
    1.56          regs->gprs[3] =  H_Parameter;
    1.57          return;
    1.58      }
    1.59 @@ -175,21 +187,19 @@ static void h_enter(struct cpu_user_regs
    1.60      if (mtype == PFN_TYPE_IO) {
    1.61          /* only a privilaged dom can access outside IO space */
    1.62          if ( !d->is_privileged ) {
    1.63 +            DBG("%s: unprivileged access to physical page: 0x%lx\n",
    1.64 +                __func__, pfn);
    1.65              regs->gprs[3] =  H_Privilege;
    1.66 -            printk("%s: unprivileged access to physical page: 0x%lx\n",
    1.67 -                   __func__, pfn);
    1.68              return;
    1.69          }
    1.70  
    1.71          if ( !((pte.bits.w == 0)
    1.72               && (pte.bits.i == 1)
    1.73               && (pte.bits.g == 1)) ) {
    1.74 -#ifdef DEBUG_FAIL
    1.75 -            printk("%s: expecting an IO WIMG "
    1.76 -                   "w=%x i=%d m=%d, g=%d\n word 0x%lx\n", __func__,
    1.77 -                   pte.bits.w, pte.bits.i, pte.bits.m, pte.bits.g,
    1.78 -                   pte.words.rpn);
    1.79 -#endif
    1.80 +            DBG("%s: expecting an IO WIMG "
    1.81 +                "w=%x i=%d m=%d, g=%d\n word 0x%lx\n", __func__,
    1.82 +                pte.bits.w, pte.bits.i, pte.bits.m, pte.bits.g,
    1.83 +                pte.words.rpn);
    1.84              regs->gprs[3] =  H_Parameter;
    1.85              return;
    1.86          }
    1.87 @@ -213,11 +223,13 @@ static void h_enter(struct cpu_user_regs
    1.88          BUG_ON(f == d);
    1.89  
    1.90          if (unlikely(!get_domain(f))) {
    1.91 +            DBG("%s: Rescinded, no domain: 0x%lx\n",  __func__, pfn);
    1.92              regs->gprs[3] = H_Rescinded;
    1.93              return;
    1.94          }
    1.95          if (unlikely(!get_page(pg, f))) {
    1.96              put_domain(f);
    1.97 +            DBG("%s: Rescinded, no page: 0x%lx\n",  __func__, pfn);
    1.98              regs->gprs[3] = H_Rescinded;
    1.99              return;
   1.100          }
   1.101 @@ -283,10 +295,8 @@ static void h_enter(struct cpu_user_regs
   1.102          }
   1.103      }
   1.104  
   1.105 -#ifdef DEBUG
   1.106      /* If the PTEG is full then no additional values are returned. */
   1.107 -    printk("%s: PTEG FULL\n", __func__);
   1.108 -#endif
   1.109 +    DBG("%s: PTEG FULL\n", __func__);
   1.110  
   1.111      if (pg != NULL)
   1.112          put_page(pg);
   1.113 @@ -308,13 +318,11 @@ static void h_protect(struct cpu_user_re
   1.114      union pte volatile *ppte;
   1.115      union pte lpte;
   1.116  
   1.117 -#ifdef DEBUG
   1.118 -    printk("%s: flags: 0x%lx ptex: 0x%lx avpn: 0x%lx\n", __func__,
   1.119 -           flags, ptex, avpn);
   1.120 -#endif
   1.121 +    DBG_LOW("%s: flags: 0x%lx ptex: 0x%lx avpn: 0x%lx\n", __func__,
   1.122 +            flags, ptex, avpn);
   1.123      if ( ptex > (1UL << htab->log_num_ptes) ) {
   1.124 +        DBG("%s: bad ptex: 0x%lx\n", __func__, ptex);
   1.125          regs->gprs[3] = H_Parameter;
   1.126 -        printk("%s: bad ptex: 0x%lx\n", __func__, ptex);
   1.127          return;
   1.128      }
   1.129      ppte = &htab->map[ptex];
   1.130 @@ -324,10 +332,8 @@ static void h_protect(struct cpu_user_re
   1.131  
   1.132      /* the AVPN param occupies the bit-space of the word */
   1.133      if ( (flags & H_AVPN) && lpte.bits.avpn != avpn >> 7 ) {
   1.134 -#ifdef DEBUG_FAIL
   1.135 -        printk("%s: %p: AVPN check failed: 0x%lx, 0x%lx\n", __func__,
   1.136 -                ppte, lpte.words.vsid, lpte.words.rpn);
   1.137 -#endif
   1.138 +        DBG("%s: %p: AVPN check failed: 0x%lx, 0x%lx\n", __func__,
   1.139 +            ppte, lpte.words.vsid, lpte.words.rpn);
   1.140          regs->gprs[3] = H_Not_Found;
   1.141          return;
   1.142      }
   1.143 @@ -337,9 +343,7 @@ static void h_protect(struct cpu_user_re
   1.144           * we invalidate entires where the PAPR says to 0 the whole hi
   1.145           * dword, so the AVPN should catch this first */
   1.146  
   1.147 -#ifdef DEBUG_FAIL
   1.148 -        printk("%s: pte invalid\n", __func__);
   1.149 -#endif
   1.150 +        DBG("%s: pte invalid\n", __func__);
   1.151          regs->gprs[3] =  H_Not_Found;
   1.152          return;
   1.153      }
   1.154 @@ -382,20 +386,20 @@ static void h_clear_ref(struct cpu_user_
   1.155      union pte volatile *pte;
   1.156      union pte lpte;
   1.157  
   1.158 +    DBG_LOW("%s: flags: 0x%lx ptex: 0x%lx\n", __func__,
   1.159 +            flags, ptex);
   1.160 +
   1.161  #ifdef DEBUG
   1.162 -    printk("%s: flags: 0x%lx ptex: 0x%lx\n", __func__,
   1.163 -           flags, ptex);
   1.164 +    if (flags != 0) {
   1.165 +        DBG("WARNING: %s: "
   1.166 +            "flags are undefined and should be 0: 0x%lx\n",
   1.167 +            __func__, flags);
   1.168 +    }
   1.169  #endif
   1.170  
   1.171 -    if (flags != 0) {
   1.172 -        printk("WARNING: %s: "
   1.173 -                "flags are undefined and should be 0: 0x%lx\n",
   1.174 -                __func__, flags);
   1.175 -    }
   1.176 -
   1.177      if (ptex > (1UL << htab->log_num_ptes)) {
   1.178 +        DBG("%s: bad ptex: 0x%lx\n", __func__, ptex);
   1.179          regs->gprs[3] = H_Parameter;
   1.180 -        printk("%s: bad ptex: 0x%lx\n", __func__, ptex);
   1.181          return;
   1.182      }
   1.183      pte = &htab->map[ptex];
   1.184 @@ -425,19 +429,20 @@ static void h_clear_mod(struct cpu_user_
   1.185      union pte volatile *pte;
   1.186      union pte lpte;
   1.187  
   1.188 +    DBG_LOW("%s: flags: 0x%lx ptex: 0x%lx\n", __func__,
   1.189 +           flags, ptex);
   1.190 +
   1.191  #ifdef DEBUG
   1.192 -    printk("%s: flags: 0x%lx ptex: 0x%lx\n", __func__,
   1.193 -           flags, ptex);
   1.194 -#endif
   1.195      if (flags != 0) {
   1.196 -        printk("WARNING: %s: "
   1.197 -                "flags are undefined and should be 0: 0x%lx\n",
   1.198 -                __func__, flags);
   1.199 +        DBG("WARNING: %s: "
   1.200 +            "flags are undefined and should be 0: 0x%lx\n",
   1.201 +            __func__, flags);
   1.202      }
   1.203 -    
   1.204 +#endif
   1.205 +
   1.206      if (ptex > (1UL << htab->log_num_ptes)) {
   1.207 +        DBG("%s: bad ptex: 0x%lx\n", __func__, ptex);
   1.208          regs->gprs[3] = H_Parameter;
   1.209 -        printk("%s: bad ptex: 0x%lx\n", __func__, ptex);
   1.210          return;
   1.211      }
   1.212      pte = &htab->map[ptex];
   1.213 @@ -477,13 +482,12 @@ static void h_remove(struct cpu_user_reg
   1.214      union pte volatile *pte;
   1.215      union pte lpte;
   1.216  
   1.217 -#ifdef DEBUG
   1.218 -    printk("%s: flags: 0x%lx ptex: 0x%lx avpn: 0x%lx\n", __func__,
   1.219 -           flags, ptex, avpn);
   1.220 -#endif
   1.221 +    DBG_LOW("%s: flags: 0x%lx ptex: 0x%lx avpn: 0x%lx\n", __func__,
   1.222 +            flags, ptex, avpn);
   1.223 +
   1.224      if ( ptex > (1UL << htab->log_num_ptes) ) {
   1.225 +        DBG("%s: bad ptex: 0x%lx\n", __func__, ptex);
   1.226          regs->gprs[3] = H_Parameter;
   1.227 -        printk("%s: bad ptex: 0x%lx\n", __func__, ptex);
   1.228          return;
   1.229      }
   1.230      pte = &htab->map[ptex];
   1.231 @@ -491,17 +495,13 @@ static void h_remove(struct cpu_user_reg
   1.232      lpte.words.rpn = pte->words.rpn;
   1.233  
   1.234      if ((flags & H_AVPN) && lpte.bits.avpn != (avpn >> 7)) {
   1.235 -#ifdef DEBUG_FAIL
   1.236 -        printk("%s: avpn doesn not match\n", __func__);
   1.237 -#endif
   1.238 +        DBG("%s: avpn doesn not match\n", __func__);
   1.239          regs->gprs[3] = H_Not_Found;
   1.240          return;
   1.241      }
   1.242  
   1.243      if ((flags & H_ANDCOND) && ((avpn & pte->words.vsid) != 0)) {
   1.244 -#ifdef DEBUG_FAIL
   1.245 -        printk("%s: andcond does not match\n", __func__);
   1.246 -#endif
   1.247 +        DBG("%s: andcond does not match\n", __func__);
   1.248          regs->gprs[3] = H_Not_Found;
   1.249          return;
   1.250      }
   1.251 @@ -511,11 +511,13 @@ static void h_remove(struct cpu_user_reg
   1.252      regs->gprs[4] = lpte.words.vsid;
   1.253      regs->gprs[5] = lpte.words.rpn;
   1.254  
   1.255 +#ifdef DEBUG_LOW
   1.256      /* XXX - I'm very skeptical of doing ANYTHING if not bits.v */
   1.257      /* XXX - I think the spec should be questioned in this case (MFM) */
   1.258      if (lpte.bits.v == 0) {
   1.259 -        printk("%s: removing invalid entry\n", __func__);
   1.260 +        DBG_LOW("%s: removing invalid entry\n", __func__);
   1.261      }
   1.262 +#endif
   1.263  
   1.264      if (lpte.bits.v) {
   1.265          ulong mfn = lpte.bits.rpn;
   1.266 @@ -551,8 +553,8 @@ static void h_read(struct cpu_user_regs 
   1.267          ptex &= ~0x3UL;
   1.268  
   1.269      if (ptex > (1UL << htab->log_num_ptes)) {
   1.270 +        DBG("%s: bad ptex: 0x%lx\n", __func__, ptex);
   1.271          regs->gprs[3] = H_Parameter;
   1.272 -        printk("%s: bad ptex: 0x%lx\n", __func__, ptex);
   1.273          return;
   1.274      }
   1.275      pte = &htab->map[ptex];