ia64/xen-unstable

changeset 3968:6fe925d85cd6

bitkeeper revision 1.1236.6.1 (42265e38FOWXHddB1NPxV83mnMxy7Q)

Merge kirby.fc.hp.com:/home/djm/src/xen/xeno-unstable-ia64.bk
into kirby.fc.hp.com:/home/djm/src/xen/useraccess.bk
author djm@kirby.fc.hp.com
date Thu Mar 03 00:45:44 2005 +0000 (2005-03-03)
parents 180fe147132c c17fa9eea8c5
children f6004779d1ee dce709e1e050
files xen/arch/ia64/Makefile xen/arch/ia64/privop.c xen/arch/ia64/process.c xen/arch/ia64/tools/mkbuildtree xen/arch/ia64/xenasm.S xen/arch/ia64/xenmisc.c xen/arch/ia64/xensetup.c xen/include/asm-ia64/config.h
line diff
     1.1 --- a/xen/arch/ia64/Makefile	Wed Mar 02 09:33:11 2005 +0000
     1.2 +++ b/xen/arch/ia64/Makefile	Thu Mar 03 00:45:44 2005 +0000
     1.3 @@ -7,6 +7,7 @@ OBJS = xensetup.o setup.o time.o irq.o i
     1.4  	machvec.o dom0_ops.o domain.o \
     1.5  	idle0_task.o pal.o hpsim.o efi.o efi_stub.o ivt.o mm_contig.o \
     1.6  	mm_bootmem.o sal.o cmdline.o mm_init.o tlb.o page_alloc.o slab.o \
     1.7 +	extable.o linuxextable.o \
     1.8  	regionreg.o entry.o unaligned.o privop.o vcpu.o \
     1.9  	irq_ia64.o irq_lsapic.o hpsim_irq.o vhpt.o xenasm.o dom_fw.o
    1.10  # perfmon.o
     2.1 --- a/xen/arch/ia64/privop.c	Wed Mar 02 09:33:11 2005 +0000
     2.2 +++ b/xen/arch/ia64/privop.c	Thu Mar 03 00:45:44 2005 +0000
     2.3 @@ -538,7 +538,8 @@ unsigned long privop_trace = 0;
     2.4  IA64FAULT
     2.5  priv_handle_op(VCPU *vcpu, REGS *regs, int privlvl)
     2.6  {
     2.7 -	IA64_BUNDLE bundle, __get_domain_bundle(UINT64);
     2.8 +	IA64_BUNDLE bundle;
     2.9 +	IA64_BUNDLE __get_domain_bundle(UINT64);
    2.10  	int slot;
    2.11  	IA64_SLOT_TYPE slot_type;
    2.12  	INST64 inst;
    2.13 @@ -550,19 +551,14 @@ priv_handle_op(VCPU *vcpu, REGS *regs, i
    2.14  	// make a local copy of the bundle containing the privop
    2.15  #if 1
    2.16  	bundle = __get_domain_bundle(iip);
    2.17 -	if (!bundle.i64[0] && !bundle.i64[1]) return IA64_RETRY;
    2.18 -#else
    2.19 -#ifdef AVOIDING_POSSIBLE_DOMAIN_TLB_MISS
    2.20 -	//TODO: this needs to check for faults and behave accordingly
    2.21 -	if (!vcpu_get_iip_bundle(&bundle)) return IA64_DTLB_FAULT;
    2.22 +	if (!bundle.i64[0] && !bundle.i64[1])
    2.23  #else
    2.24 -if (iip < 0x10000) {
    2.25 - printf("priv_handle_op: unlikely iip=%p,b0=%p\n",iip,regs->b0);
    2.26 - dummy();
    2.27 -}
    2.28 -        bundle = *(IA64_BUNDLE *)iip;
    2.29 +	if (__copy_from_user(&bundle,iip,sizeof(bundle)))
    2.30  #endif
    2.31 -#endif
    2.32 +	{
    2.33 +//printf("*** priv_handle_op: privop bundle @%p not mapped, retrying\n",iip);
    2.34 +		return IA64_RETRY;
    2.35 +	}
    2.36  #if 0
    2.37  	if (iip==0xa000000100001820) {
    2.38  		static int firstpagefault = 1;
    2.39 @@ -783,10 +779,12 @@ char *cr_str[128] = {
    2.40    RS,RS,RS,RS,RS,RS,RS,RS
    2.41  };
    2.42  
    2.43 -void dump_privop_counts(void)
    2.44 +// FIXME: should use snprintf to ensure no buffer overflow
    2.45 +int dump_privop_counts(char *buf)
    2.46  {
    2.47  	int i, j;
    2.48  	UINT64 sum = 0;
    2.49 +	char *s = buf;
    2.50  
    2.51  	// this is ugly and should probably produce sorted output
    2.52  	// but it will have to do for now
    2.53 @@ -795,63 +793,64 @@ void dump_privop_counts(void)
    2.54  	sum += privcnt.rfi; sum += privcnt.bsw0;
    2.55  	sum += privcnt.bsw1; sum += privcnt.cover;
    2.56  	for (i=0; i < 64; i++) sum += privcnt.Mpriv_cnt[i];
    2.57 -	printf("Privop statistics: (Total privops: %ld)\r\n",sum);
    2.58 +	s += sprintf(s,"Privop statistics: (Total privops: %ld)\r\n",sum);
    2.59  	if (privcnt.mov_to_ar_imm)
    2.60 -		printf("%10d  %s [%d%%]\r\n", privcnt.mov_to_ar_imm,
    2.61 +		s += sprintf(s,"%10d  %s [%d%%]\r\n", privcnt.mov_to_ar_imm,
    2.62  			"mov_to_ar_imm", (privcnt.mov_to_ar_imm*100L)/sum);
    2.63  	if (privcnt.mov_to_ar_reg)
    2.64 -		printf("%10d  %s [%d%%]\r\n", privcnt.mov_to_ar_reg,
    2.65 +		s += sprintf(s,"%10d  %s [%d%%]\r\n", privcnt.mov_to_ar_reg,
    2.66  			"mov_to_ar_reg", (privcnt.mov_to_ar_reg*100L)/sum);
    2.67  	if (privcnt.ssm)
    2.68 -		printf("%10d  %s [%d%%]\r\n", privcnt.ssm,
    2.69 +		s += sprintf(s,"%10d  %s [%d%%]\r\n", privcnt.ssm,
    2.70  			"ssm", (privcnt.ssm*100L)/sum);
    2.71  	if (privcnt.rsm)
    2.72 -		printf("%10d  %s [%d%%]\r\n", privcnt.rsm,
    2.73 +		s += sprintf(s,"%10d  %s [%d%%]\r\n", privcnt.rsm,
    2.74  			"rsm", (privcnt.rsm*100L)/sum);
    2.75  	if (privcnt.rfi)
    2.76 -		printf("%10d  %s [%d%%]\r\n", privcnt.rfi,
    2.77 +		s += sprintf(s,"%10d  %s [%d%%]\r\n", privcnt.rfi,
    2.78  			"rfi", (privcnt.rfi*100L)/sum);
    2.79  	if (privcnt.bsw0)
    2.80 -		printf("%10d  %s [%d%%]\r\n", privcnt.bsw0,
    2.81 +		s += sprintf(s,"%10d  %s [%d%%]\r\n", privcnt.bsw0,
    2.82  			"bsw0", (privcnt.bsw0*100L)/sum);
    2.83  	if (privcnt.bsw1)
    2.84 -		printf("%10d  %s [%d%%]\r\n", privcnt.bsw1,
    2.85 +		s += sprintf(s,"%10d  %s [%d%%]\r\n", privcnt.bsw1,
    2.86  			"bsw1", (privcnt.bsw1*100L)/sum);
    2.87  	if (privcnt.cover)
    2.88 -		printf("%10d  %s [%d%%]\r\n", privcnt.cover,
    2.89 +		s += sprintf(s,"%10d  %s [%d%%]\r\n", privcnt.cover,
    2.90  			"cover", (privcnt.cover*100L)/sum);
    2.91  	for (i=0; i < 64; i++) if (privcnt.Mpriv_cnt[i]) {
    2.92 -		if (!Mpriv_str[i]) printf("PRIVSTRING NULL!!\r\n");
    2.93 -		else printf("%10d  %s [%d%%]\r\n", privcnt.Mpriv_cnt[i],
    2.94 +		if (!Mpriv_str[i]) s += sprintf(s,"PRIVSTRING NULL!!\r\n");
    2.95 +		else s += sprintf(s,"%10d  %s [%d%%]\r\n", privcnt.Mpriv_cnt[i],
    2.96  			Mpriv_str[i], (privcnt.Mpriv_cnt[i]*100L)/sum);
    2.97  		if (i == 0x24) { // mov from CR
    2.98 -			printf("            [");
    2.99 +			s += sprintf(s,"            [");
   2.100  			for (j=0; j < 128; j++) if (from_cr_cnt[j]) {
   2.101  				if (!cr_str[j])
   2.102 -					printf("PRIVSTRING NULL!!\r\n");
   2.103 -				printf("%s(%d),",cr_str[j],from_cr_cnt[j]);
   2.104 +					s += sprintf(s,"PRIVSTRING NULL!!\r\n");
   2.105 +				s += sprintf(s,"%s(%d),",cr_str[j],from_cr_cnt[j]);
   2.106  			}
   2.107 -			printf("]\r\n");
   2.108 +			s += sprintf(s,"]\r\n");
   2.109  		}
   2.110  		else if (i == 0x2c) { // mov to CR
   2.111 -			printf("            [");
   2.112 +			s += sprintf(s,"            [");
   2.113  			for (j=0; j < 128; j++) if (to_cr_cnt[j]) {
   2.114  				if (!cr_str[j])
   2.115 -					printf("PRIVSTRING NULL!!\r\n");
   2.116 -				printf("%s(%d),",cr_str[j],to_cr_cnt[j]);
   2.117 +					s += sprintf(s,"PRIVSTRING NULL!!\r\n");
   2.118 +				s += sprintf(s,"%s(%d),",cr_str[j],to_cr_cnt[j]);
   2.119  			}
   2.120 -			printf("]\r\n");
   2.121 +			s += sprintf(s,"]\r\n");
   2.122  		}
   2.123  	}
   2.124 +	return s - buf;
   2.125  }
   2.126  
   2.127 -void zero_privop_counts(void)
   2.128 +int zero_privop_counts(char *buf)
   2.129  {
   2.130  	int i, j;
   2.131 +	char *s = buf;
   2.132  
   2.133  	// this is ugly and should probably produce sorted output
   2.134  	// but it will have to do for now
   2.135 -	printf("Zeroing privop statistics\r\n");
   2.136  	privcnt.mov_to_ar_imm = 0; privcnt.mov_to_ar_reg = 0;
   2.137  	privcnt.ssm = 0; privcnt.rsm = 0;
   2.138  	privcnt.rfi = 0; privcnt.bsw0 = 0;
   2.139 @@ -859,4 +858,27 @@ void zero_privop_counts(void)
   2.140  	for (i=0; i < 64; i++) privcnt.Mpriv_cnt[i] = 0;
   2.141  	for (j=0; j < 128; j++) from_cr_cnt[j] = 0;
   2.142  	for (j=0; j < 128; j++) to_cr_cnt[j] = 0;
   2.143 +	s += sprintf(s,"All privop statistics zeroed\r\n");
   2.144 +	return s - buf;
   2.145  }
   2.146 +
   2.147 +#define TMPBUFLEN 8*1024
   2.148 +int dump_privop_counts_to_user(char __user *ubuf, int len)
   2.149 +{
   2.150 +	char buf[TMPBUFLEN];
   2.151 +	int n = dump_privop_counts(buf);
   2.152 +
   2.153 +	if (len < TMPBUFLEN) return -1;
   2.154 +	if (__copy_to_user(ubuf,buf,n)) return -1;
   2.155 +	return n;
   2.156 +}
   2.157 +
   2.158 +int zero_privop_counts_to_user(char __user *ubuf, int len)
   2.159 +{
   2.160 +	char buf[TMPBUFLEN];
   2.161 +	int n = zero_privop_counts(buf);
   2.162 +
   2.163 +	if (len < TMPBUFLEN) return -1;
   2.164 +	if (__copy_to_user(ubuf,buf,n)) return -1;
   2.165 +	return n;
   2.166 +}
     3.1 --- a/xen/arch/ia64/process.c	Wed Mar 02 09:33:11 2005 +0000
     3.2 +++ b/xen/arch/ia64/process.c	Thu Mar 03 00:45:44 2005 +0000
     3.3 @@ -242,7 +242,9 @@ void xen_handle_domain_access(unsigned l
     3.4  	unsigned long pteval, mpaddr;
     3.5  	unsigned long lookup_domain_mpa(struct domain *,unsigned long);
     3.6  	IA64FAULT fault;
     3.7 +#ifndef USER_ACCESS
     3.8  	extern void __get_domain_bundle(void);
     3.9 +#endif
    3.10  
    3.11  // NEED TO HANDLE THREE CASES:
    3.12  // 1) domain is in metaphysical mode
    3.13 @@ -265,20 +267,41 @@ void xen_handle_domain_access(unsigned l
    3.14  		vcpu_itc_no_srlz(ed,2,address,pteval,PAGE_SHIFT);
    3.15  		return;
    3.16  	}
    3.17 -if (address < 0x4000) printf("WARNING: page_fault @%p, iip=%p\n",address,iip);
    3.18 +#ifndef USER_ACCESS
    3.19  	if (*(unsigned long *)__get_domain_bundle != iip) {
    3.20  		printf("Bad user space access @%p ",address);
    3.21  		printf("iip=%p, ipsr=%p, b0=%p\n",iip,psr,regs->b0);
    3.22  		while(1);
    3.23  	}
    3.24 +#endif
    3.25 +if (address < 0x4000) printf("WARNING: page_fault @%p, iip=%p\n",address,iip);
    3.26  		
    3.27  	fault = vcpu_tpa(ed,address,&mpaddr);
    3.28  	if (fault != IA64_NO_FAULT) {
    3.29 +#ifndef USER_ACCESS
    3.30  		// this is hardcoded to handle __get_domain_bundle only
    3.31  		regs->r8 = 0; regs->r9 = 0;
    3.32  		regs->cr_iip += 0x20;
    3.33  		//regs->cr_iip |= (2UL << IA64_PSR_RI_BIT);
    3.34  		return;
    3.35 +#else /* USER_ACCESS */
    3.36 +		static int uacnt = 0;
    3.37 +		// can't translate it, just fail (poor man's exception)
    3.38 +		// which results in retrying execution
    3.39 +//printk("*** xen_handle_domain_access: poor man's exception cnt=%i iip=%p, addr=%p...\n",uacnt++,iip,address);
    3.40 +		if (ia64_done_with_exception(regs)) {
    3.41 +//if (!(uacnt++ & 0x3ff)) printk("*** xen_handle_domain_access: successfully handled cnt=%d iip=%p, addr=%p...\n",uacnt,iip,address);
    3.42 +			return;
    3.43 +		}
    3.44 +		else {
    3.45 +			// should never happen.  If it does, region 0 addr may
    3.46 +			// indicate a bad xen pointer
    3.47 +			printk("*** xen_handle_domain_access: exception table"
    3.48 +                               " lookup failed, iip=%p, addr=%p, spinning...\n",
    3.49 +				iip,address);
    3.50 +			while(1);
    3.51 +		}
    3.52 +#endif /* USER_ACCESS */
    3.53  	}
    3.54  	if (d == dom0) {
    3.55  		if (mpaddr < dom0_start || mpaddr >= dom0_start + dom0_size) {
    3.56 @@ -286,6 +309,7 @@ if (address < 0x4000) printf("WARNING: p
    3.57  			tdpfoo();
    3.58  		}
    3.59  	}
    3.60 +//printk("*** xen_handle_domain_access: tpa resolved miss @%p...\n",address);
    3.61  	pteval = lookup_domain_mpa(d,mpaddr);
    3.62  	// would be nice to have a counter here
    3.63  	//printf("Handling privop data TLB miss\n");
    3.64 @@ -755,6 +779,16 @@ ia64_handle_break (unsigned long ifa, st
    3.65  			// FIXME: need fixes in efi.h from 2.6.9
    3.66  			regs->r8 = EFI_UNSUPPORTED;
    3.67  			break;
    3.68 +		    case 0xffff: // test dummy hypercall
    3.69 +			regs->r8 = dump_privop_counts_to_user(
    3.70 +				vcpu_get_gr(ed,32),
    3.71 +				vcpu_get_gr(ed,33));
    3.72 +			break;
    3.73 +		    case 0xfffe: // test dummy hypercall
    3.74 +			regs->r8 = zero_privop_counts_to_user(
    3.75 +				vcpu_get_gr(ed,32),
    3.76 +				vcpu_get_gr(ed,33));
    3.77 +			break;
    3.78  		}
    3.79  		vcpu_increment_iip(current);
    3.80  	}
     4.1 --- a/xen/arch/ia64/tools/mkbuildtree	Wed Mar 02 09:33:11 2005 +0000
     4.2 +++ b/xen/arch/ia64/tools/mkbuildtree	Thu Mar 03 00:45:44 2005 +0000
     4.3 @@ -98,6 +98,9 @@ cp_patch mm/bootmem.c arch/ia64/mm_bootm
     4.4  cp_patch mm/page_alloc.c arch/ia64/page_alloc.c page_alloc.c
     4.5  cp_patch mm/slab.c arch/ia64/slab.c slab.c
     4.6  
     4.7 +# following renamed to avoid conflict
     4.8 +softlink kernel/extable.c arch/ia64/linuxextable.c
     4.9 +
    4.10  cp_patch arch/ia64/mm/contig.c arch/ia64/mm_contig.c mm_contig.c
    4.11  cp_patch arch/ia64/mm/tlb.c arch/ia64/tlb.c tlb.c
    4.12  
    4.13 @@ -108,6 +111,7 @@ softlink arch/ia64/kernel/entry.h arch/i
    4.14  softlink arch/ia64/kernel/ia64_ksyms.c arch/ia64/ia64_ksyms.c
    4.15  softlink arch/ia64/kernel/irq_lsapic.c arch/ia64/irq_lsapic.c
    4.16  softlink arch/ia64/kernel/machvec.c arch/ia64/machvec.c
    4.17 +softlink arch/ia64/mm/extable.c arch/ia64/extable.c
    4.18  softlink arch/ia64/kernel/pal.S arch/ia64/pal.S
    4.19  softlink arch/ia64/kernel/patch.c arch/ia64/patch.c
    4.20  softlink arch/ia64/kernel/sal.c arch/ia64/sal.c
    4.21 @@ -182,6 +186,7 @@ null include/asm-ia64/domain_page.h
    4.22  null include/asm-ia64/flushtlb.h
    4.23  null include/asm-ia64/io_apic.h
    4.24  null include/asm-ia64/pdb.h
    4.25 +null include/asm-ia64/module.h
    4.26  
    4.27  softlink include/asm-ia64/acpi.h include/asm-ia64/acpi.h
    4.28  softlink include/asm-ia64/asmmacro.h include/asm-ia64/asmmacro.h
     5.1 --- a/xen/arch/ia64/xenasm.S	Wed Mar 02 09:33:11 2005 +0000
     5.2 +++ b/xen/arch/ia64/xenasm.S	Thu Mar 03 00:45:44 2005 +0000
     5.3 @@ -261,6 +261,8 @@ GLOBAL_ENTRY(ia64_prepare_handle_reflect
     5.4  	br.cond.sptk.many rp			// goes to ia64_leave_kernel
     5.5  END(ia64_prepare_handle_reflection)
     5.6  
     5.7 +#ifndef USER_ACCESS
     5.8 +// REMOVE: replaced with get_user
     5.9  // NOTE: instruction spacing must be explicit for recovery on miss
    5.10  GLOBAL_ENTRY(__get_domain_bundle)
    5.11  	ld8 r8=[r32],8
    5.12 @@ -276,6 +278,23 @@ GLOBAL_ENTRY(__get_domain_bundle)
    5.13  	nop 0
    5.14  	;;
    5.15  END(__get_domain_bundle)
    5.16 +#else
    5.17 +GLOBAL_ENTRY(__get_domain_bundle)
    5.18 +	EX(.failure_in_get_bundle,ld8 r8=[r32],8)
    5.19 +	;;
    5.20 +	EX(.failure_in_get_bundle,ld8 r9=[r32])
    5.21 +	;;
    5.22 +	br.ret.sptk.many rp
    5.23 +	;;
    5.24 +.failure_in_get_bundle:
    5.25 +	mov r8=0
    5.26 +	;;
    5.27 +	mov r9=0
    5.28 +	;;
    5.29 +	br.ret.sptk.many rp
    5.30 +	;;
    5.31 +END(__get_domain_bundle)
    5.32 +#endif
    5.33  
    5.34  GLOBAL_ENTRY(dorfirfi)
    5.35  #define SI_CR_IIP_OFFSET 0x10
     6.1 --- a/xen/arch/ia64/xenmisc.c	Wed Mar 02 09:33:11 2005 +0000
     6.2 +++ b/xen/arch/ia64/xenmisc.c	Thu Mar 03 00:45:44 2005 +0000
     6.3 @@ -216,3 +216,15 @@ physdev_pci_access_modify(domid_t id, in
     6.4  {
     6.5  	return -EINVAL;
     6.6  }
     6.7 +
     6.8 +// accomodate linux extable.c
     6.9 +//const struct exception_table_entry *
    6.10 +void *search_module_extables(unsigned long addr)
    6.11 +{
    6.12 +	return NULL;
    6.13 +}
    6.14 +
    6.15 +void *module_text_address(unsigned long addr)
    6.16 +{
    6.17 +	return NULL;
    6.18 +}
     7.1 --- a/xen/arch/ia64/xensetup.c	Wed Mar 02 09:33:11 2005 +0000
     7.2 +++ b/xen/arch/ia64/xensetup.c	Thu Mar 03 00:45:44 2005 +0000
     7.3 @@ -288,6 +288,8 @@ printk("About to call ac_timer_init()\n"
     7.4  // init_xen_time(); ???
     7.5  // schedulers_start(); ???
     7.6  // do_initcalls(); ???
     7.7 +printk("About to call sort_main_extable()\n");
     7.8 +    sort_main_extable();
     7.9  #else
    7.10      start_of_day();
    7.11  
     8.1 --- a/xen/include/asm-ia64/config.h	Wed Mar 02 09:33:11 2005 +0000
     8.2 +++ b/xen/include/asm-ia64/config.h	Thu Mar 03 00:45:44 2005 +0000
     8.3 @@ -1,4 +1,7 @@
     8.4 +// control flags for turning on/off features under test
     8.5  #undef CLONE_DOMAIN0
     8.6 +#define USER_ACCESS
     8.7 +
     8.8  // manufactured from component pieces
     8.9  
    8.10  // defined in linux/arch/ia64/defconfig
    8.11 @@ -160,6 +163,20 @@ struct pci_bus_region {
    8.12  	unsigned long end;
    8.13  };
    8.14  
    8.15 +// from linux/include/linux/module.h
    8.16 +
    8.17 +// warning: unless search_extable is declared, the return value gets
    8.18 +// truncated to 32-bits, causing a very strange error in privop handling
    8.19 +struct exception_table_entry;
    8.20 +
    8.21 +const struct exception_table_entry *
    8.22 +search_extable(const struct exception_table_entry *first,
    8.23 +	       const struct exception_table_entry *last,
    8.24 +	       unsigned long value);
    8.25 +void sort_extable(struct exception_table_entry *start,
    8.26 +		  struct exception_table_entry *finish);
    8.27 +void sort_main_extable(void);
    8.28 +
    8.29  // defined (why?) in include/asm-i386/processor.h
    8.30  // used in common/physdev.c
    8.31  #define IO_BITMAP_SIZE 32