ia64/xen-unstable

changeset 5800:9870485d4836

Better pal/sal support
Fix bug with pgd allocation (used pgd_quick)
Add some more debug info for tracking down vcpu_translate bad addr
Signed-off by: Dan Magenheimer <dan.magenheimer@hp.com>
author djm@kirby.fc.hp.com
date Tue Jul 12 08:13:06 2005 -0700 (2005-07-12)
parents 970f74591ffa
children a87242c44417
files xen/arch/ia64/asm-offsets.c xen/arch/ia64/dom_fw.c xen/arch/ia64/hypercall.c xen/arch/ia64/ivt.S xen/arch/ia64/vcpu.c
line diff
     1.1 --- a/xen/arch/ia64/asm-offsets.c	Mon Jul 11 08:20:39 2005 -0700
     1.2 +++ b/xen/arch/ia64/asm-offsets.c	Tue Jul 12 08:13:06 2005 -0700
     1.3 @@ -93,7 +93,7 @@ void foo(void)
     1.4  
     1.5  	BLANK();
     1.6  	DEFINE(IA64_CPUINFO_ITM_NEXT_OFFSET, offsetof (struct cpuinfo_ia64, itm_next));
     1.7 -	DEFINE(IA64_CPUINFO_PGD_QUICK_OFFSET, offsetof (struct cpuinfo_ia64, pgd_quick));
     1.8 +	DEFINE(IA64_CPUINFO_KSOFTIRQD_OFFSET, offsetof (struct cpuinfo_ia64, ksoftirqd));
     1.9  
    1.10  	//DEFINE(IA64_SIGHAND_SIGLOCK_OFFSET,offsetof (struct sighand_struct, siglock));
    1.11  
     2.1 --- a/xen/arch/ia64/dom_fw.c	Mon Jul 11 08:20:39 2005 -0700
     2.2 +++ b/xen/arch/ia64/dom_fw.c	Tue Jul 12 08:13:06 2005 -0700
     2.3 @@ -154,7 +154,7 @@ offtime (unsigned long t, efi_time_t *tp
     2.4  	return 1;
     2.5  }
     2.6  
     2.7 -extern void pal_emulator_static (void);
     2.8 +extern struct ia64_pal_retval pal_emulator_static (unsigned long);
     2.9  
    2.10  /* Macro to emulate SAL call using legacy IN and OUT calls to CF8, CFC etc.. */
    2.11  
    2.12 @@ -220,17 +220,14 @@ sal_emulator (long index, unsigned long 
    2.13  	 */
    2.14  	status = 0;
    2.15  	if (index == SAL_FREQ_BASE) {
    2.16 -		switch (in1) {
    2.17 +		if (!running_on_sim)
    2.18 +			status = ia64_sal_freq_base(in1,&r9,&r10);
    2.19 +		else switch (in1) {
    2.20  		      case SAL_FREQ_BASE_PLATFORM:
    2.21  			r9 = 200000000;
    2.22  			break;
    2.23  
    2.24  		      case SAL_FREQ_BASE_INTERVAL_TIMER:
    2.25 -			/*
    2.26 -			 * Is this supposed to be the cr.itc frequency
    2.27 -			 * or something platform specific?  The SAL
    2.28 -			 * doc ain't exactly clear on this...
    2.29 -			 */
    2.30  			r9 = 700000000;
    2.31  			break;
    2.32  
    2.33 @@ -285,6 +282,96 @@ sal_emulator (long index, unsigned long 
    2.34  	return ((struct sal_ret_values) {status, r9, r10, r11});
    2.35  }
    2.36  
    2.37 +struct ia64_pal_retval
    2.38 +xen_pal_emulator(unsigned long index, unsigned long in1,
    2.39 +	unsigned long in2, unsigned long in3)
    2.40 +{
    2.41 +	long r9  = 0;
    2.42 +	long r10 = 0;
    2.43 +	long r11 = 0;
    2.44 +	long status = -1;
    2.45 +
    2.46 +	if (running_on_sim) return pal_emulator_static(index);
    2.47 +	if (index >= PAL_COPY_PAL) {
    2.48 +		printk("xen_pal_emulator: UNIMPLEMENTED PAL CALL %d!!!!\n",
    2.49 +				index);
    2.50 +	}
    2.51 +	else switch (index) {
    2.52 +	    case PAL_MEM_ATTRIB:
    2.53 +		status = ia64_pal_mem_attrib(&r9);
    2.54 +		break;
    2.55 +	    case PAL_FREQ_BASE:
    2.56 +		status = ia64_pal_freq_base(&r9);
    2.57 +		break;
    2.58 +	    case PAL_PROC_GET_FEATURES:
    2.59 +		status = ia64_pal_proc_get_features(&r9,&r10,&r11);
    2.60 +		break;
    2.61 +	    case PAL_BUS_GET_FEATURES:
    2.62 +		status = ia64_pal_bus_get_features(&r9,&r10,&r11);
    2.63 +		break;
    2.64 +	    case PAL_FREQ_RATIOS:
    2.65 +		status = ia64_pal_freq_ratios(&r9,&r10,&r11);
    2.66 +		break;
    2.67 +	    case PAL_PTCE_INFO:
    2.68 +		status = ia64_get_ptce(&r9);
    2.69 +		break;
    2.70 +	    case PAL_VERSION:
    2.71 +		status = ia64_pal_version(&r9,&r10);
    2.72 +		break;
    2.73 +	    case PAL_VM_PAGE_SIZE:
    2.74 +		status = ia64_pal_vm_page_size(&r9,&r10);
    2.75 +		break;
    2.76 +	    case PAL_DEBUG_INFO:
    2.77 +		status = ia64_pal_debug_info(&r9,&r10);
    2.78 +		break;
    2.79 +	    case PAL_CACHE_SUMMARY:
    2.80 +		status = ia64_pal_cache_summary(&r9,&r10);
    2.81 +		break;
    2.82 +	    case PAL_VM_SUMMARY:
    2.83 +		status = ia64_pal_vm_summary(&r9,&r10);
    2.84 +		break;
    2.85 +	    case PAL_RSE_INFO:
    2.86 +		status = ia64_pal_rse_info(&r9,&r10);
    2.87 +		break;
    2.88 +	    case PAL_VM_INFO:
    2.89 +		status = ia64_pal_vm_info(in1,in2,&r9,&r10);
    2.90 +		break;
    2.91 +	    case PAL_REGISTER_INFO:
    2.92 +		status = ia64_pal_register_info(in1,&r9,&r10);
    2.93 +		break;
    2.94 +	    case PAL_CACHE_FLUSH:
    2.95 +		return pal_emulator_static(index); /* FIXME */
    2.96 +		break;
    2.97 +	    case PAL_PERF_MON_INFO:
    2.98 +		{
    2.99 +			unsigned long pm_buffer[16];
   2.100 +			status = ia64_pal_perf_mon_info(pm_buffer,&r9);
   2.101 +			if (status != 0) break;
   2.102 +			if (copy_to_user((void __user *)in1,pm_buffer,128))
   2.103 +				printk("xen_pal_emulator: PAL_PERF_MON_INFO "
   2.104 +					"can't copy to user!!!!\n");
   2.105 +		}
   2.106 +		break;
   2.107 +	    case PAL_CACHE_INFO:
   2.108 +		{
   2.109 +			pal_cache_config_info_t ci;
   2.110 +			status = ia64_pal_cache_config_info(in1,in2,&ci);
   2.111 +			if (status != 0) break;
   2.112 +			r9 = ci.pcci_info_1.pcci1_data;
   2.113 +			r10 = ci.pcci_info_2.pcci2_data;
   2.114 +		}
   2.115 +		break;
   2.116 +	    case PAL_VM_TR_READ:	/* FIXME: vcpu_get_tr?? */
   2.117 +		break;
   2.118 +	    case PAL_HALT_INFO:		/* inappropriate info for guest? */
   2.119 +		break;
   2.120 +	    default:
   2.121 +		printk("xen_pal_emulator: UNIMPLEMENTED PAL CALL %d!!!!\n",
   2.122 +				index);
   2.123 +		break;
   2.124 +	}
   2.125 +	return ((struct ia64_pal_retval) {status, r9, r10, r11});
   2.126 +}
   2.127  
   2.128  #define NFUNCPTRS 20
   2.129  
     3.1 --- a/xen/arch/ia64/hypercall.c	Mon Jul 11 08:20:39 2005 -0700
     3.2 +++ b/xen/arch/ia64/hypercall.c	Tue Jul 12 08:13:06 2005 -0700
     3.3 @@ -16,7 +16,7 @@
     3.4  #include <asm/dom_fw.h>
     3.5  
     3.6  extern unsigned long translate_domain_mpaddr(unsigned long);
     3.7 -extern struct ia64_sal_retval pal_emulator_static(UINT64);
     3.8 +extern struct ia64_pal_retval xen_pal_emulator(UINT64,UINT64,UINT64,UINT64);
     3.9  extern struct ia64_sal_retval sal_emulator(UINT64,UINT64,UINT64,UINT64,UINT64,UINT64,UINT64,UINT64);
    3.10  
    3.11  unsigned long idle_when_pending = 0;
    3.12 @@ -27,6 +27,7 @@ ia64_hypercall (struct pt_regs *regs)
    3.13  {
    3.14  	struct vcpu *v = (struct domain *) current;
    3.15  	struct ia64_sal_retval x;
    3.16 +	struct ia64_pal_retval y;
    3.17  	unsigned long *tv, *tc;
    3.18  	int pi;
    3.19  
    3.20 @@ -42,7 +43,6 @@ ia64_hypercall (struct pt_regs *regs)
    3.21  		// in the idle loop, this should resolve it
    3.22  		v->vcpu_info->arch.pending_interruption = 1;
    3.23  #endif
    3.24 -		x = pal_emulator_static(regs->r28);
    3.25  		if (regs->r28 == PAL_HALT_LIGHT) {
    3.26  #define SPURIOUS_VECTOR 15
    3.27  			pi = vcpu_check_pending_interrupts(v);
    3.28 @@ -62,8 +62,15 @@ ia64_hypercall (struct pt_regs *regs)
    3.29  			}
    3.30  			//break;
    3.31  		}
    3.32 -		regs->r8 = x.status; regs->r9 = x.v0;
    3.33 -		regs->r10 = x.v1; regs->r11 = x.v2;
    3.34 +		else if (regs->r28 >= PAL_COPY_PAL) {	/* FIXME */
    3.35 +			printf("stacked PAL hypercalls not supported\n");
    3.36 +			regs->r8 = -1;
    3.37 +			break;
    3.38 +		}
    3.39 +		else y = xen_pal_emulator(regs->r28,regs->r29,
    3.40 +						regs->r30,regs->r31);
    3.41 +		regs->r8 = y.status; regs->r9 = y.v0;
    3.42 +		regs->r10 = y.v1; regs->r11 = y.v2;
    3.43  		break;
    3.44  	    case FW_HYPERCALL_SAL_CALL:
    3.45  		x = sal_emulator(vcpu_get_gr(v,32),vcpu_get_gr(v,33),
     4.1 --- a/xen/arch/ia64/ivt.S	Mon Jul 11 08:20:39 2005 -0700
     4.2 +++ b/xen/arch/ia64/ivt.S	Tue Jul 12 08:13:06 2005 -0700
     4.3 @@ -931,10 +931,10 @@ ENTRY(interrupt)
     4.4  	;;
     4.5  #ifdef XEN
     4.6  	mov r30=cr.ivr		// pass cr.ivr as first arg
     4.7 -	// FIXME: this is a hack... use cpuinfo.pgd_quick because its
     4.8 +	// FIXME: this is a hack... use cpuinfo.ksoftirqd because its
     4.9  	// not used anywhere else and we need a place to stash ivr and
    4.10  	// there's no registers available unused by SAVE_MIN/REST
    4.11 -	movl r29=(PERCPU_ADDR)+IA64_CPUINFO_PGD_QUICK_OFFSET;;
    4.12 +	movl r29=(PERCPU_ADDR)+IA64_CPUINFO_KSOFTIRQD_OFFSET;;
    4.13  	st8 [r29]=r30;;
    4.14  	movl r28=slow_interrupt;;
    4.15  	mov r29=rp;;
    4.16 @@ -954,7 +954,7 @@ slow_interrupt:
    4.17  	;;
    4.18  	alloc r14=ar.pfs,0,0,2,0 // must be first in an insn group
    4.19  #ifdef XEN
    4.20 -	movl out0=(PERCPU_ADDR)+IA64_CPUINFO_PGD_QUICK_OFFSET;;
    4.21 +	movl out0=(PERCPU_ADDR)+IA64_CPUINFO_KSOFTIRQD_OFFSET;;
    4.22  	ld8 out0=[out0];;
    4.23  #else
    4.24  	mov out0=cr.ivr		// pass cr.ivr as first arg
     5.1 --- a/xen/arch/ia64/vcpu.c	Mon Jul 11 08:20:39 2005 -0700
     5.2 +++ b/xen/arch/ia64/vcpu.c	Tue Jul 12 08:13:06 2005 -0700
     5.3 @@ -1263,6 +1263,7 @@ IA64FAULT vcpu_ttag(VCPU *vcpu, UINT64 v
     5.4  #define itir_mask(itir) (~((1UL << itir_ps(itir)) - 1))
     5.5  
     5.6  unsigned long vhpt_translate_count = 0;
     5.7 +int in_vcpu_tpa = 0;
     5.8  
     5.9  IA64FAULT vcpu_translate(VCPU *vcpu, UINT64 address, BOOLEAN is_data, UINT64 *pteval, UINT64 *itir)
    5.10  {
    5.11 @@ -1271,8 +1272,20 @@ IA64FAULT vcpu_translate(VCPU *vcpu, UIN
    5.12  	ia64_rr rr;
    5.13  
    5.14  	if (!(address >> 61)) {
    5.15 -		if (!PSCB(vcpu,metaphysical_mode))
    5.16 +		if (!PSCB(vcpu,metaphysical_mode)) {
    5.17 +			REGS *regs = vcpu_regs(vcpu);
    5.18 +			unsigned long viip = PSCB(vcpu,iip);
    5.19 +			unsigned long vipsr = PSCB(vcpu,ipsr);
    5.20 +			unsigned long iip = regs->cr_iip;
    5.21 +			unsigned long ipsr = regs->cr_ipsr;
    5.22 +#if 0
    5.23 +			printk("vcpu_translate: bad address %p, viip=%p, vipsr=%p, iip=%p, ipsr=%p\n", address, viip, vipsr, iip, ipsr);
    5.24 +			if (in_vcpu_tpa) printk("vcpu_translate called from vcpu_tpa\n");
    5.25 +			while(1);
    5.26  			panic_domain(0,"vcpu_translate: bad address %p\n", address);
    5.27 +#endif
    5.28 +			printk("vcpu_translate: bad address %p, viip=%p, vipsr=%p, iip=%p, ipsr=%p continuing\n", address, viip, vipsr, iip, ipsr);
    5.29 +		}
    5.30  
    5.31  		*pteval = (address & _PAGE_PPN_MASK) | __DIRTY_BITS | _PAGE_PL_2 | _PAGE_AR_RWX;
    5.32  		*itir = PAGE_SHIFT << 2;
    5.33 @@ -1291,6 +1304,7 @@ IA64FAULT vcpu_translate(VCPU *vcpu, UIN
    5.34  	/* check 1-entry TLB */
    5.35  	if ((trp = match_dtlb(vcpu,address))) {
    5.36  		dtlb_translate_count++;
    5.37 +if (!in_vcpu_tpa) printf("vcpu_translate: found in vdtlb\n");
    5.38  		*pteval = trp->page_flags;
    5.39  		*itir = trp->itir;
    5.40  		return IA64_NO_FAULT;
    5.41 @@ -1342,7 +1356,9 @@ IA64FAULT vcpu_tpa(VCPU *vcpu, UINT64 va
    5.42  	UINT64 pteval, itir, mask;
    5.43  	IA64FAULT fault;
    5.44  
    5.45 +in_vcpu_tpa=1;
    5.46  	fault = vcpu_translate(vcpu, vadr, 1, &pteval, &itir);
    5.47 +in_vcpu_tpa=0;
    5.48  	if (fault == IA64_NO_FAULT)
    5.49  	{
    5.50  		mask = itir_mask(itir);