direct-io.hg
changeset 4807:1bc0400523f0
bitkeeper revision 1.1389.9.4 (427ff28cpHTPvFmKde6BQbpMm2W-Qw)
Add itc hyperprivop code and hyperprivop counters
Add itc hyperprivop code and hyperprivop counters
author | djm@kirby.fc.hp.com |
---|---|
date | Mon May 09 23:30:20 2005 +0000 (2005-05-09) |
parents | e24efdd35ac2 |
children | a22acf8b8127 |
files | xen/arch/ia64/privop.c xen/arch/ia64/process.c xen/arch/ia64/vcpu.c xen/include/asm-ia64/vcpu.h |
line diff
1.1 --- a/xen/arch/ia64/privop.c Mon May 09 18:51:24 2005 +0000 1.2 +++ b/xen/arch/ia64/privop.c Mon May 09 23:30:20 2005 +0000 1.3 @@ -205,7 +205,8 @@ IA64FAULT priv_itc_d(VCPU *vcpu, INST64 1.4 return(IA64_ILLOP_FAULT); 1.5 if ((fault = vcpu_get_ifa(vcpu,&ifa)) != IA64_NO_FAULT) 1.6 return(IA64_ILLOP_FAULT); 1.7 - pte = vcpu_get_gr(vcpu,inst.M41.r2); 1.8 + if (!inst.inst) pte = vcpu_get_tmp(vcpu,0); 1.9 + else pte = vcpu_get_gr(vcpu,inst.M41.r2); 1.10 1.11 return (vcpu_itc_d(vcpu,pte,itir,ifa)); 1.12 } 1.13 @@ -219,7 +220,8 @@ IA64FAULT priv_itc_i(VCPU *vcpu, INST64 1.14 return(IA64_ILLOP_FAULT); 1.15 if ((fault = vcpu_get_ifa(vcpu,&ifa)) != IA64_NO_FAULT) 1.16 return(IA64_ILLOP_FAULT); 1.17 - pte = vcpu_get_gr(vcpu,inst.M41.r2); 1.18 + if (!inst.inst) pte = vcpu_get_tmp(vcpu,0); 1.19 + else pte = vcpu_get_gr(vcpu,inst.M41.r2); 1.20 1.21 return (vcpu_itc_i(vcpu,pte,itir,ifa)); 1.22 } 1.23 @@ -695,7 +697,7 @@ priv_handle_op(VCPU *vcpu, REGS *regs, i 1.24 //printf("We who are about do die salute you\n"); 1.25 printf("handle_op: can't handle privop at 0x%lx (op=0x%016lx) slot %d (type=%d)\n", 1.26 iip, (UINT64)inst.inst, slot, slot_type); 1.27 - //printf("vtop(0x%lx)==0x%lx\r\n", iip, tr_vtop(iip)); 1.28 + //printf("vtop(0x%lx)==0x%lx\n", iip, tr_vtop(iip)); 1.29 //thread_mozambique("privop fault\n"); 1.30 return (IA64_ILLOP_FAULT); 1.31 } 1.32 @@ -759,19 +761,37 @@ priv_emulate(VCPU *vcpu, REGS *regs, UIN 1.33 1.34 1.35 // FIXME: Move these to include/public/arch-ia64? 1.36 -#define HYPERPRIVOP_RFI 1 1.37 -#define HYPERPRIVOP_RSM_DT 2 1.38 -#define HYPERPRIVOP_SSM_DT 3 1.39 -#define HYPERPRIVOP_COVER 4 1.40 +#define HYPERPRIVOP_RFI 0x1 1.41 +#define HYPERPRIVOP_RSM_DT 0x2 1.42 +#define HYPERPRIVOP_SSM_DT 0x3 1.43 +#define HYPERPRIVOP_COVER 0x4 1.44 +#define HYPERPRIVOP_ITC_D 0x5 1.45 +#define HYPERPRIVOP_ITC_I 0x6 1.46 +#define HYPERPRIVOP_MAX 0x6 1.47 + 1.48 +char *hyperpriv_str[HYPERPRIVOP_MAX+1] = { 1.49 + 0, "rfi", "rsm.dt", "ssm.dt", "cover", "itc.d", "itc.i", 1.50 + 0 1.51 +}; 1.52 + 1.53 +unsigned long hyperpriv_cnt[HYPERPRIVOP_MAX+1] = { 0 }; 1.54 1.55 /* hyperprivops are generally executed in assembly (with physical psr.ic off) 1.56 * so this code is primarily used for debugging them */ 1.57 int 1.58 -ia64_hyperprivop(unsigned long iim) 1.59 +ia64_hyperprivop(unsigned long iim, REGS *regs) 1.60 { 1.61 struct exec_domain *ed = (struct domain *) current; 1.62 + INST64 inst; 1.63 + UINT64 val; 1.64 1.65 // FIXME: Add instrumentation for these 1.66 +// FIXME: Handle faults appropriately for these 1.67 + if (!iim || iim > HYPERPRIVOP_MAX) { 1.68 + printf("bad hyperprivop; ignored\n"); 1.69 + return 1; 1.70 + } 1.71 + hyperpriv_cnt[iim]++; 1.72 switch(iim) { 1.73 case HYPERPRIVOP_RFI: 1.74 (void)vcpu_rfi(ed); 1.75 @@ -785,6 +805,14 @@ ia64_hyperprivop(unsigned long iim) 1.76 case HYPERPRIVOP_COVER: 1.77 (void)vcpu_cover(ed); 1.78 return 1; 1.79 + case HYPERPRIVOP_ITC_D: 1.80 + inst.inst = 0; 1.81 + (void)priv_itc_d(ed,inst); 1.82 + return 1; 1.83 + case HYPERPRIVOP_ITC_I: 1.84 + inst.inst = 0; 1.85 + (void)priv_itc_i(ed,inst); 1.86 + return 1; 1.87 } 1.88 return 0; 1.89 } 1.90 @@ -843,61 +871,61 @@ int dump_privop_counts(char *buf) 1.91 sum += privcnt.rfi; sum += privcnt.bsw0; 1.92 sum += privcnt.bsw1; sum += privcnt.cover; 1.93 for (i=0; i < 64; i++) sum += privcnt.Mpriv_cnt[i]; 1.94 - s += sprintf(s,"Privop statistics: (Total privops: %ld)\r\n",sum); 1.95 + s += sprintf(s,"Privop statistics: (Total privops: %ld)\n",sum); 1.96 if (privcnt.mov_to_ar_imm) 1.97 - s += sprintf(s,"%10d %s [%d%%]\r\n", privcnt.mov_to_ar_imm, 1.98 + s += sprintf(s,"%10d %s [%d%%]\n", privcnt.mov_to_ar_imm, 1.99 "mov_to_ar_imm", (privcnt.mov_to_ar_imm*100L)/sum); 1.100 if (privcnt.mov_to_ar_reg) 1.101 - s += sprintf(s,"%10d %s [%d%%]\r\n", privcnt.mov_to_ar_reg, 1.102 + s += sprintf(s,"%10d %s [%d%%]\n", privcnt.mov_to_ar_reg, 1.103 "mov_to_ar_reg", (privcnt.mov_to_ar_reg*100L)/sum); 1.104 if (privcnt.mov_from_ar) 1.105 - s += sprintf(s,"%10d %s [%d%%]\r\n", privcnt.mov_from_ar, 1.106 + s += sprintf(s,"%10d %s [%d%%]\n", privcnt.mov_from_ar, 1.107 "privified-mov_from_ar", (privcnt.mov_from_ar*100L)/sum); 1.108 if (privcnt.ssm) 1.109 - s += sprintf(s,"%10d %s [%d%%]\r\n", privcnt.ssm, 1.110 + s += sprintf(s,"%10d %s [%d%%]\n", privcnt.ssm, 1.111 "ssm", (privcnt.ssm*100L)/sum); 1.112 if (privcnt.rsm) 1.113 - s += sprintf(s,"%10d %s [%d%%]\r\n", privcnt.rsm, 1.114 + s += sprintf(s,"%10d %s [%d%%]\n", privcnt.rsm, 1.115 "rsm", (privcnt.rsm*100L)/sum); 1.116 if (privcnt.rfi) 1.117 - s += sprintf(s,"%10d %s [%d%%]\r\n", privcnt.rfi, 1.118 + s += sprintf(s,"%10d %s [%d%%]\n", privcnt.rfi, 1.119 "rfi", (privcnt.rfi*100L)/sum); 1.120 if (privcnt.bsw0) 1.121 - s += sprintf(s,"%10d %s [%d%%]\r\n", privcnt.bsw0, 1.122 + s += sprintf(s,"%10d %s [%d%%]\n", privcnt.bsw0, 1.123 "bsw0", (privcnt.bsw0*100L)/sum); 1.124 if (privcnt.bsw1) 1.125 - s += sprintf(s,"%10d %s [%d%%]\r\n", privcnt.bsw1, 1.126 + s += sprintf(s,"%10d %s [%d%%]\n", privcnt.bsw1, 1.127 "bsw1", (privcnt.bsw1*100L)/sum); 1.128 if (privcnt.cover) 1.129 - s += sprintf(s,"%10d %s [%d%%]\r\n", privcnt.cover, 1.130 + s += sprintf(s,"%10d %s [%d%%]\n", privcnt.cover, 1.131 "cover", (privcnt.cover*100L)/sum); 1.132 if (privcnt.fc) 1.133 - s += sprintf(s,"%10d %s [%d%%]\r\n", privcnt.fc, 1.134 + s += sprintf(s,"%10d %s [%d%%]\n", privcnt.fc, 1.135 "privified-fc", (privcnt.fc*100L)/sum); 1.136 if (privcnt.cpuid) 1.137 - s += sprintf(s,"%10d %s [%d%%]\r\n", privcnt.cpuid, 1.138 + s += sprintf(s,"%10d %s [%d%%]\n", privcnt.cpuid, 1.139 "privified-getcpuid", (privcnt.cpuid*100L)/sum); 1.140 for (i=0; i < 64; i++) if (privcnt.Mpriv_cnt[i]) { 1.141 - if (!Mpriv_str[i]) s += sprintf(s,"PRIVSTRING NULL!!\r\n"); 1.142 - else s += sprintf(s,"%10d %s [%d%%]\r\n", privcnt.Mpriv_cnt[i], 1.143 + if (!Mpriv_str[i]) s += sprintf(s,"PRIVSTRING NULL!!\n"); 1.144 + else s += sprintf(s,"%10d %s [%d%%]\n", privcnt.Mpriv_cnt[i], 1.145 Mpriv_str[i], (privcnt.Mpriv_cnt[i]*100L)/sum); 1.146 if (i == 0x24) { // mov from CR 1.147 s += sprintf(s," ["); 1.148 for (j=0; j < 128; j++) if (from_cr_cnt[j]) { 1.149 if (!cr_str[j]) 1.150 - s += sprintf(s,"PRIVSTRING NULL!!\r\n"); 1.151 + s += sprintf(s,"PRIVSTRING NULL!!\n"); 1.152 s += sprintf(s,"%s(%d),",cr_str[j],from_cr_cnt[j]); 1.153 } 1.154 - s += sprintf(s,"]\r\n"); 1.155 + s += sprintf(s,"]\n"); 1.156 } 1.157 else if (i == 0x2c) { // mov to CR 1.158 s += sprintf(s," ["); 1.159 for (j=0; j < 128; j++) if (to_cr_cnt[j]) { 1.160 if (!cr_str[j]) 1.161 - s += sprintf(s,"PRIVSTRING NULL!!\r\n"); 1.162 + s += sprintf(s,"PRIVSTRING NULL!!\n"); 1.163 s += sprintf(s,"%s(%d),",cr_str[j],to_cr_cnt[j]); 1.164 } 1.165 - s += sprintf(s,"]\r\n"); 1.166 + s += sprintf(s,"]\n"); 1.167 } 1.168 } 1.169 return s - buf; 1.170 @@ -919,7 +947,7 @@ int zero_privop_counts(char *buf) 1.171 for (i=0; i < 64; i++) privcnt.Mpriv_cnt[i] = 0; 1.172 for (j=0; j < 128; j++) from_cr_cnt[j] = 0; 1.173 for (j=0; j < 128; j++) to_cr_cnt[j] = 0; 1.174 - s += sprintf(s,"All privop statistics zeroed\r\n"); 1.175 + s += sprintf(s,"All privop statistics zeroed\n"); 1.176 return s - buf; 1.177 } 1.178 1.179 @@ -943,7 +971,7 @@ int dump_privop_addrs(char *buf) 1.180 { 1.181 int i,j; 1.182 char *s = buf; 1.183 - s += sprintf(s,"Privop addresses:\r\n"); 1.184 + s += sprintf(s,"Privop addresses:\n"); 1.185 for (i = 0; i < PRIVOP_COUNT_NINSTS; i++) { 1.186 struct privop_addr_count *v = &privop_addr_counter[i]; 1.187 s += sprintf(s,"%s:\n",v->instname); 1.188 @@ -969,12 +997,30 @@ void zero_privop_addrs(void) 1.189 } 1.190 #endif 1.191 1.192 +int dump_hyperprivop_counts(char *buf) 1.193 +{ 1.194 + int i; 1.195 + char *s = buf; 1.196 + s += sprintf(s,"Hyperprivops:\n"); 1.197 + for (i = 1; i <= HYPERPRIVOP_MAX; i++) 1.198 + if (hyperpriv_cnt[i]) 1.199 + s += sprintf("%10d %s\n", 1.200 + hyperpriv_cnt[i], hyperpriv_str[i]); 1.201 +} 1.202 + 1.203 +void zero_hyperprivop_counts(void) 1.204 +{ 1.205 + int i; 1.206 + for (i = 0; i <= HYPERPRIVOP_MAX; i++) hyperpriv_cnt[i] = 0; 1.207 +} 1.208 + 1.209 #define TMPBUFLEN 8*1024 1.210 int dump_privop_counts_to_user(char __user *ubuf, int len) 1.211 { 1.212 char buf[TMPBUFLEN]; 1.213 int n = dump_privop_counts(buf); 1.214 1.215 + n += dump_hyperprivop_counts(buf + n); 1.216 #ifdef PRIVOP_ADDR_COUNT 1.217 n += dump_privop_addrs(buf + n); 1.218 #endif 1.219 @@ -988,6 +1034,7 @@ int zero_privop_counts_to_user(char __us 1.220 char buf[TMPBUFLEN]; 1.221 int n = zero_privop_counts(buf); 1.222 1.223 + zero_hyperprivop_counts(); 1.224 #ifdef PRIVOP_ADDR_COUNT 1.225 zero_privop_addrs(); 1.226 #endif
2.1 --- a/xen/arch/ia64/process.c Mon May 09 18:51:24 2005 +0000 2.2 +++ b/xen/arch/ia64/process.c Mon May 09 23:30:20 2005 +0000 2.3 @@ -724,7 +724,7 @@ ia64_handle_break (unsigned long ifa, st 2.4 vcpu_increment_iip(current); 2.5 } 2.6 else if (!PSCB(ed,interrupt_collection_enabled)) { 2.7 - if (ia64_hyperprivop(iim)) 2.8 + if (ia64_hyperprivop(iim,regs)) 2.9 vcpu_increment_iip(current); 2.10 } 2.11 else reflect_interruption(ifa,isr,iim,regs,IA64_BREAK_VECTOR);
3.1 --- a/xen/arch/ia64/vcpu.c Mon May 09 18:51:24 2005 +0000 3.2 +++ b/xen/arch/ia64/vcpu.c Mon May 09 23:30:20 2005 +0000 3.3 @@ -849,6 +849,20 @@ IA64FAULT vcpu_set_cmcv(VCPU *vcpu, UINT 3.4 } 3.5 3.6 /************************************************************************** 3.7 + VCPU temporary register access routines 3.8 +**************************************************************************/ 3.9 +UINT64 vcpu_get_tmp(VCPU *vcpu, UINT64 index) 3.10 +{ 3.11 + if (index > 7) return 0; 3.12 + return PSCB(vcpu,tmp[index]); 3.13 +} 3.14 + 3.15 +void vcpu_set_tmp(VCPU *vcpu, UINT64 index, UINT64 val) 3.16 +{ 3.17 + if (index <= 7) PSCB(vcpu,tmp[index]) = val; 3.18 +} 3.19 + 3.20 +/************************************************************************** 3.21 Interval timer routines 3.22 **************************************************************************/ 3.23
4.1 --- a/xen/include/asm-ia64/vcpu.h Mon May 09 18:51:24 2005 +0000 4.2 +++ b/xen/include/asm-ia64/vcpu.h Mon May 09 23:30:20 2005 +0000 4.3 @@ -147,6 +147,8 @@ extern void vcpu_set_next_timer(VCPU *vc 4.4 extern BOOLEAN vcpu_timer_expired(VCPU *vcpu); 4.5 extern UINT64 vcpu_deliverable_interrupts(VCPU *vcpu); 4.6 extern void vcpu_itc_no_srlz(VCPU *vcpu, UINT64, UINT64, UINT64, UINT64, UINT64); 4.7 +extern UINT64 vcpu_get_tmp(VCPU *, UINT64); 4.8 +extern void vcpu_set_tmp(VCPU *, UINT64, UINT64); 4.9 4.10 4.11 #endif