direct-io.hg

changeset 11304:741fd616f5dc

[IA64] cleanup

Cleanup of the week:
Perf counters added.
Use BUILD_BUG_ON instead of #error+macros.
CPL is checked before calling ia64_hypercall().
Reformatting in hypercall.c
multicall now check hypercall number.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Mon Aug 14 13:42:00 2006 -0600 (2006-08-14)
parents fa584e5d17b6
children 6fec75ff8acf
files xen/arch/ia64/asm-offsets.c xen/arch/ia64/linux-xen/irq_ia64.c xen/arch/ia64/linux-xen/smp.c xen/arch/ia64/xen/faults.c xen/arch/ia64/xen/hypercall.c xen/arch/ia64/xen/irq.c xen/arch/ia64/xen/privop.c xen/arch/ia64/xen/xensetup.c xen/include/asm-ia64/dom_fw.h xen/include/asm-ia64/linux-xen/asm/processor.h xen/include/asm-ia64/multicall.h
line diff
     1.1 --- a/xen/arch/ia64/asm-offsets.c	Mon Aug 14 13:30:17 2006 -0600
     1.2 +++ b/xen/arch/ia64/asm-offsets.c	Mon Aug 14 13:42:00 2006 -0600
     1.3 @@ -31,7 +31,6 @@ void foo(void)
     1.4  	DEFINE(IA64_SWITCH_STACK_SIZE, sizeof (struct switch_stack));
     1.5  	DEFINE(IA64_CPU_SIZE, sizeof (struct cpuinfo_ia64));
     1.6  	DEFINE(UNW_FRAME_INFO_SIZE, sizeof (struct unw_frame_info));
     1.7 -	DEFINE(SHARED_INFO_SIZE, sizeof (struct shared_info));
     1.8  	DEFINE(MAPPED_REGS_T_SIZE, sizeof (mapped_regs_t));
     1.9  
    1.10  	BLANK();
     2.1 --- a/xen/arch/ia64/linux-xen/irq_ia64.c	Mon Aug 14 13:30:17 2006 -0600
     2.2 +++ b/xen/arch/ia64/linux-xen/irq_ia64.c	Mon Aug 14 13:42:00 2006 -0600
     2.3 @@ -108,6 +108,9 @@ ia64_handle_irq (ia64_vector vector, str
     2.4  {
     2.5  	unsigned long saved_tpr;
     2.6  
     2.7 +#ifdef XEN
     2.8 +	perfc_incrc(irqs);
     2.9 +#endif
    2.10  #if IRQ_DEBUG
    2.11  #ifdef XEN
    2.12  	xen_debug_irq(vector, regs);
    2.13 @@ -290,8 +293,5 @@ ia64_send_ipi (int cpu, int vector, int 
    2.14  	ipi_data = (delivery_mode << 8) | (vector & 0xff);
    2.15  	ipi_addr = ipi_base_addr + ((phys_cpu_id << 4) | ((redirect & 1) << 3));
    2.16  
    2.17 -#ifdef XEN
    2.18 -	//printf ("send_ipi to %d (%x)\n", cpu, phys_cpu_id);
    2.19 -#endif
    2.20  	writeq(ipi_data, ipi_addr);
    2.21  }
     3.1 --- a/xen/arch/ia64/linux-xen/smp.c	Mon Aug 14 13:30:17 2006 -0600
     3.2 +++ b/xen/arch/ia64/linux-xen/smp.c	Mon Aug 14 13:42:00 2006 -0600
     3.3 @@ -146,6 +146,9 @@ handle_IPI (int irq, void *dev_id, struc
     3.4  	unsigned long *pending_ipis = &__ia64_per_cpu_var(ipi_operation);
     3.5  	unsigned long ops;
     3.6  
     3.7 +#ifdef XEN
     3.8 +	perfc_incrc(ipis);
     3.9 +#endif
    3.10  	mb();	/* Order interrupt and bit testing. */
    3.11  	while ((ops = xchg(pending_ipis, 0)) != 0) {
    3.12  		mb();	/* Order bit clearing and data access. */
     4.1 --- a/xen/arch/ia64/xen/faults.c	Mon Aug 14 13:30:17 2006 -0600
     4.2 +++ b/xen/arch/ia64/xen/faults.c	Mon Aug 14 13:42:00 2006 -0600
     4.3 @@ -515,7 +515,8 @@ ia64_handle_break (unsigned long ifa, st
     4.4  		debugger_trap_fatal(0 /* don't care */, regs);
     4.5  	} 
     4.6  #endif
     4.7 -	else if (iim == d->arch.breakimm) {
     4.8 +	else if (iim == d->arch.breakimm &&
     4.9 +	         ia64_get_cpl(regs->cr_ipsr) == 2) {
    4.10  		/* by default, do not continue */
    4.11  		v->arch.hypercall_continuation = 0;
    4.12  
     5.1 --- a/xen/arch/ia64/xen/hypercall.c	Mon Aug 14 13:30:17 2006 -0600
     5.2 +++ b/xen/arch/ia64/xen/hypercall.c	Mon Aug 14 13:42:00 2006 -0600
     5.3 @@ -33,75 +33,81 @@ static long do_physdev_op_compat(XEN_GUE
     5.4  static long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg);
     5.5  static long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg);
     5.6  
     5.7 -hypercall_t ia64_hypercall_table[] =
     5.8 -	{
     5.9 -	(hypercall_t)do_ni_hypercall,		/* do_set_trap_table */		/*  0 */
    5.10 +const hypercall_t ia64_hypercall_table[NR_hypercalls] =
    5.11 +{
    5.12 +	(hypercall_t)do_ni_hypercall,		/* do_set_trap_table *//*  0 */
    5.13  	(hypercall_t)do_ni_hypercall,		/* do_mmu_update */
    5.14  	(hypercall_t)do_ni_hypercall,		/* do_set_gdt */
    5.15  	(hypercall_t)do_ni_hypercall,		/* do_stack_switch */
    5.16  	(hypercall_t)do_ni_hypercall,		/* do_set_callbacks */
    5.17 -	(hypercall_t)do_ni_hypercall,		/* do_fpu_taskswitch */		/*  5 */
    5.18 +	(hypercall_t)do_ni_hypercall,		/* do_fpu_taskswitch *//*  5 */
    5.19  	(hypercall_t)do_sched_op_compat,
    5.20  	(hypercall_t)do_dom0_op,
    5.21  	(hypercall_t)do_ni_hypercall,		/* do_set_debugreg */
    5.22  	(hypercall_t)do_ni_hypercall,		/* do_get_debugreg */
    5.23 -	(hypercall_t)do_ni_hypercall,		/* do_update_descriptor */	/* 10 */
    5.24 +	(hypercall_t)do_ni_hypercall,		/* do_update_descriptor * 10 */
    5.25  	(hypercall_t)do_ni_hypercall,		/* do_ni_hypercall */
    5.26  	(hypercall_t)do_memory_op,
    5.27  	(hypercall_t)do_multicall,
    5.28  	(hypercall_t)do_ni_hypercall,		/* do_update_va_mapping */
    5.29 -	(hypercall_t)do_ni_hypercall,		/* do_set_timer_op */		/* 15 */
    5.30 +	(hypercall_t)do_ni_hypercall,		/* do_set_timer_op */  /* 15 */
    5.31  	(hypercall_t)do_event_channel_op_compat,
    5.32  	(hypercall_t)do_xen_version,
    5.33  	(hypercall_t)do_console_io,
    5.34  	(hypercall_t)do_physdev_op_compat,
    5.35 -	(hypercall_t)do_grant_table_op,						/* 20 */
    5.36 +	(hypercall_t)do_grant_table_op,				       /* 20 */
    5.37  	(hypercall_t)do_ni_hypercall,		/* do_vm_assist */
    5.38 -	(hypercall_t)do_ni_hypercall,		/* do_update_va_mapping_otherdomain */
    5.39 +	(hypercall_t)do_ni_hypercall,		/* do_update_va_mapping_othe */
    5.40  	(hypercall_t)do_ni_hypercall,		/* (x86 only) */
    5.41  	(hypercall_t)do_ni_hypercall,		/* do_vcpu_op */
    5.42 -	(hypercall_t)do_ni_hypercall,		/* (x86_64 only) */		/* 25 */
    5.43 +	(hypercall_t)do_ni_hypercall,		/* (x86_64 only) */    /* 25 */
    5.44  	(hypercall_t)do_ni_hypercall,		/* do_mmuext_op */
    5.45  	(hypercall_t)do_ni_hypercall,		/* do_acm_op */
    5.46  	(hypercall_t)do_ni_hypercall,		/* do_nmi_op */
    5.47  	(hypercall_t)do_sched_op,
    5.48 -	(hypercall_t)do_callback_op,		/*  */			/* 30 */
    5.49 +	(hypercall_t)do_callback_op,		/*  */                 /* 30 */
    5.50  	(hypercall_t)do_ni_hypercall,		/*  */
    5.51  	(hypercall_t)do_event_channel_op,
    5.52  	(hypercall_t)do_physdev_op,
    5.53  	(hypercall_t)do_hvm_op,			/*  */
    5.54 -	(hypercall_t)do_ni_hypercall,		/*  */                  /* 35 */
    5.55 +	(hypercall_t)do_ni_hypercall,		/*  */                 /* 35 */
    5.56  	(hypercall_t)do_ni_hypercall,		/*  */
    5.57  	(hypercall_t)do_ni_hypercall,		/*  */
    5.58  	(hypercall_t)do_ni_hypercall,		/*  */
    5.59  	(hypercall_t)do_ni_hypercall,		/*  */
    5.60 -	(hypercall_t)do_ni_hypercall,		/*  */                  /* 40 */
    5.61 +	(hypercall_t)do_ni_hypercall,		/*  */                 /* 40 */
    5.62  	(hypercall_t)do_ni_hypercall,		/*  */
    5.63  	(hypercall_t)do_ni_hypercall,		/*  */
    5.64  	(hypercall_t)do_ni_hypercall,		/*  */
    5.65  	(hypercall_t)do_ni_hypercall,		/*  */
    5.66 -	(hypercall_t)do_ni_hypercall,		/*  */                  /* 45 */
    5.67 +	(hypercall_t)do_ni_hypercall,		/*  */                 /* 45 */
    5.68  	(hypercall_t)do_ni_hypercall,		/*  */
    5.69  	(hypercall_t)do_ni_hypercall,		/*  */
    5.70 -	(hypercall_t)do_dom0vp_op,			/* dom0vp_op */
    5.71 +	(hypercall_t)do_dom0vp_op,              /* dom0vp_op */
    5.72  	(hypercall_t)do_ni_hypercall,		/* arch_1 */
    5.73 -	(hypercall_t)do_ni_hypercall,		/* arch_2 */            /* 50 */
    5.74 +	(hypercall_t)do_ni_hypercall,		/* arch_2 */           /* 50 */
    5.75  	(hypercall_t)do_ni_hypercall,		/* arch_3 */
    5.76  	(hypercall_t)do_ni_hypercall,		/* arch_4 */
    5.77  	(hypercall_t)do_ni_hypercall,		/* arch_5 */
    5.78  	(hypercall_t)do_ni_hypercall,		/* arch_6 */
    5.79 -	(hypercall_t)do_ni_hypercall		/* arch_7 */            /* 55 */
    5.80 -	};
    5.81 -
    5.82 -uint32_t nr_hypercalls =
    5.83 -	sizeof(ia64_hypercall_table) / sizeof(hypercall_t);
    5.84 +	(hypercall_t)do_ni_hypercall,		/* arch_7 */           /* 55 */
    5.85 +	(hypercall_t)do_ni_hypercall,
    5.86 +	(hypercall_t)do_ni_hypercall,
    5.87 +	(hypercall_t)do_ni_hypercall,
    5.88 +	(hypercall_t)do_ni_hypercall,
    5.89 +	(hypercall_t)do_ni_hypercall,                                  /* 60 */
    5.90 +	(hypercall_t)do_ni_hypercall,
    5.91 +	(hypercall_t)do_ni_hypercall,
    5.92 +	(hypercall_t)do_ni_hypercall
    5.93 +};
    5.94  
    5.95  static IA64FAULT
    5.96  xen_hypercall (struct pt_regs *regs)
    5.97  {
    5.98  	uint32_t cmd = (uint32_t)regs->r2;
    5.99  
   5.100 -	if (cmd < nr_hypercalls)
   5.101 +	if (cmd < NR_hypercalls) {
   5.102 +		perfc_incra(hypercalls, cmd);
   5.103  		regs->r8 = (*ia64_hypercall_table[cmd])(
   5.104  			regs->r14,
   5.105  			regs->r15,
   5.106 @@ -109,13 +115,12 @@ xen_hypercall (struct pt_regs *regs)
   5.107  			regs->r17,
   5.108  			regs->r18,
   5.109  			regs->r19);
   5.110 -	else
   5.111 +	} else
   5.112  		regs->r8 = -ENOSYS;
   5.113  
   5.114  	return IA64_NO_FAULT;
   5.115  }
   5.116  
   5.117 -
   5.118  static void
   5.119  fw_hypercall_ipi (struct pt_regs *regs)
   5.120  {
   5.121 @@ -277,18 +282,7 @@ fw_hypercall (struct pt_regs *regs)
   5.122  IA64FAULT
   5.123  ia64_hypercall (struct pt_regs *regs)
   5.124  {
   5.125 -	struct vcpu *v = current;
   5.126  	unsigned long index = regs->r2;
   5.127 -	int privlvl = (regs->cr_ipsr & IA64_PSR_CPL) >> IA64_PSR_CPL0_BIT;
   5.128 -
   5.129 -	/* Hypercalls are only allowed by kernel.
   5.130 -	   Kernel checks memory accesses.  */
   5.131 -	if (VMX_DOMAIN(v) ? (privlvl != 0) : (privlvl != 2)) {
   5.132 -	    /* FIXME: Return a better error value ?
   5.133 -	       Reflection ? Illegal operation ?  */
   5.134 -	    regs->r8 = -1;
   5.135 -	    return IA64_NO_FAULT;
   5.136 -	}
   5.137  
   5.138  	if (index >= FW_HYPERCALL_FIRST_ARCH)
   5.139  	    return fw_hypercall (regs);
     6.1 --- a/xen/arch/ia64/xen/irq.c	Mon Aug 14 13:30:17 2006 -0600
     6.2 +++ b/xen/arch/ia64/xen/irq.c	Mon Aug 14 13:42:00 2006 -0600
     6.3 @@ -236,9 +236,6 @@ int setup_vector(unsigned int irq, struc
     6.4  	struct irqaction *old, **p;
     6.5  	irq_desc_t *desc = irq_descp(irq);
     6.6  
     6.7 -	printf ("setup_vector(%d): handler=%p, flags=%x\n",
     6.8 -		irq, desc->handler, desc->status);
     6.9 -
    6.10  	/*
    6.11  	 * The following block of code has to be executed atomically
    6.12  	 */
     7.1 --- a/xen/arch/ia64/xen/privop.c	Mon Aug 14 13:30:17 2006 -0600
     7.2 +++ b/xen/arch/ia64/xen/privop.c	Mon Aug 14 13:42:00 2006 -0600
     7.3 @@ -681,7 +681,7 @@ priv_emulate(VCPU *vcpu, REGS *regs, UIN
     7.4  		return IA64_ILLOP_FAULT;
     7.5  	}
     7.6  	//if (isrcode != 1 && isrcode != 2) return 0;
     7.7 -	privlvl = (ipsr & IA64_PSR_CPL) >> IA64_PSR_CPL0_BIT;
     7.8 +	privlvl = ia64_get_cpl(ipsr);
     7.9  	// its OK for a privified-cover to be executed in user-land
    7.10  	fault = priv_handle_op(vcpu,regs,privlvl);
    7.11  	if ((fault == IA64_NO_FAULT) || (fault == IA64_EXTINT_VECTOR)) { // success!!
     8.1 --- a/xen/arch/ia64/xen/xensetup.c	Mon Aug 14 13:30:17 2006 -0600
     8.2 +++ b/xen/arch/ia64/xen/xensetup.c	Mon Aug 14 13:42:00 2006 -0600
     8.3 @@ -26,11 +26,6 @@
     8.4  #include <linux/efi.h>
     8.5  #include <asm/iosapic.h>
     8.6  
     8.7 -/* Be sure the struct shared_info size is <= XSI_SIZE.  */
     8.8 -#if SHARED_INFO_SIZE > XSI_SIZE
     8.9 -#error "struct shared_info bigger than XSI_SIZE"
    8.10 -#endif
    8.11 -
    8.12  unsigned long xenheap_phys_end, total_pages;
    8.13  
    8.14  char saved_command_line[COMMAND_LINE_SIZE];
    8.15 @@ -258,6 +253,9 @@ void start_kernel(void)
    8.16      int i;
    8.17  #endif
    8.18  
    8.19 +    /* Be sure the struct shared_info size is <= XSI_SIZE.  */
    8.20 +    BUILD_BUG_ON(sizeof(struct shared_info) > XSI_SIZE);
    8.21 +
    8.22      running_on_sim = is_platform_hp_ski();
    8.23      /* Kernel may be relocated by EFI loader */
    8.24      xen_pstart = ia64_tpa(KERNEL_START);
     9.1 --- a/xen/include/asm-ia64/dom_fw.h	Mon Aug 14 13:30:17 2006 -0600
     9.2 +++ b/xen/include/asm-ia64/dom_fw.h	Mon Aug 14 13:42:00 2006 -0600
     9.3 @@ -150,14 +150,11 @@
     9.4  
     9.5  /* Hypercalls index bellow _FIRST_ARCH are reserved by Xen, while those above
     9.6     are for the architecture.
     9.7 -   Note: this limit was defined by Xen/ia64 (and not by Xen).²
     9.8 +   Note: this limit was defined by Xen/ia64 (and not by Xen).
     9.9       This can be renumbered safely.
    9.10  */
    9.11  #define FW_HYPERCALL_FIRST_ARCH		0x300UL
    9.12  
    9.13 -/* Xen/ia64 user hypercalls.  Only used for debugging.  */
    9.14 -#define FW_HYPERCALL_FIRST_USER		0xff00UL
    9.15 -
    9.16  /* Interrupt vector used for os boot rendez vous.  */
    9.17  #define XEN_SAL_BOOT_RENDEZ_VEC	0xF3
    9.18  
    10.1 --- a/xen/include/asm-ia64/linux-xen/asm/processor.h	Mon Aug 14 13:30:17 2006 -0600
    10.2 +++ b/xen/include/asm-ia64/linux-xen/asm/processor.h	Mon Aug 14 13:42:00 2006 -0600
    10.3 @@ -717,6 +717,14 @@ prefetchw (const void *x)
    10.4  
    10.5  extern unsigned long boot_option_idle_override;
    10.6  
    10.7 +#ifdef XEN
    10.8 +static inline unsigned int
    10.9 +ia64_get_cpl(unsigned long psr)
   10.10 +{
   10.11 +  return (psr & IA64_PSR_CPL) >> IA64_PSR_CPL0_BIT;
   10.12 +}
   10.13 +#endif
   10.14 +
   10.15  #endif /* !__ASSEMBLY__ */
   10.16  
   10.17  #endif /* _ASM_IA64_PROCESSOR_H */
    11.1 --- a/xen/include/asm-ia64/multicall.h	Mon Aug 14 13:30:17 2006 -0600
    11.2 +++ b/xen/include/asm-ia64/multicall.h	Mon Aug 14 13:42:00 2006 -0600
    11.3 @@ -11,17 +11,20 @@ typedef unsigned long (*hypercall_t)(
    11.4  			unsigned long arg4,
    11.5  			unsigned long arg5);
    11.6  
    11.7 -extern hypercall_t ia64_hypercall_table[];
    11.8 +extern const hypercall_t ia64_hypercall_table[];
    11.9  
   11.10  static inline void do_multicall_call(multicall_entry_t *call)
   11.11  {
   11.12 -	call->result = (*ia64_hypercall_table[call->op])(
   11.13 +	if (call->op < NR_hypercalls)
   11.14 +		call->result = (*ia64_hypercall_table[call->op])(
   11.15  			call->args[0],
   11.16  			call->args[1],
   11.17  			call->args[2],
   11.18  			call->args[3],
   11.19  			call->args[4],
   11.20  			call->args[5]);
   11.21 +	else
   11.22 +		call->result = -ENOSYS;
   11.23  }
   11.24  
   11.25  #endif /* __ASM_IA64_MULTICALL_H__ */