# HG changeset patch # User gingold@virtu10 # Node ID 49903e608d07f3bb2fb449a2f74cddc0a64dda0a # Parent 00f21b3c2c7df0251c56c4ffcb891e96f8df9a54 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 diff -r 00f21b3c2c7d -r 49903e608d07 xen/arch/ia64/asm-offsets.c --- a/xen/arch/ia64/asm-offsets.c Fri Aug 11 08:52:36 2006 +0200 +++ b/xen/arch/ia64/asm-offsets.c Fri Aug 11 10:03:32 2006 +0200 @@ -31,7 +31,6 @@ void foo(void) DEFINE(IA64_SWITCH_STACK_SIZE, sizeof (struct switch_stack)); DEFINE(IA64_CPU_SIZE, sizeof (struct cpuinfo_ia64)); DEFINE(UNW_FRAME_INFO_SIZE, sizeof (struct unw_frame_info)); - DEFINE(SHARED_INFO_SIZE, sizeof (struct shared_info)); DEFINE(MAPPED_REGS_T_SIZE, sizeof (mapped_regs_t)); BLANK(); diff -r 00f21b3c2c7d -r 49903e608d07 xen/arch/ia64/linux-xen/irq_ia64.c --- a/xen/arch/ia64/linux-xen/irq_ia64.c Fri Aug 11 08:52:36 2006 +0200 +++ b/xen/arch/ia64/linux-xen/irq_ia64.c Fri Aug 11 10:03:32 2006 +0200 @@ -108,6 +108,9 @@ ia64_handle_irq (ia64_vector vector, str { unsigned long saved_tpr; +#ifdef XEN + perfc_incrc(irqs); +#endif #if IRQ_DEBUG #ifdef XEN xen_debug_irq(vector, regs); @@ -290,8 +293,5 @@ ia64_send_ipi (int cpu, int vector, int ipi_data = (delivery_mode << 8) | (vector & 0xff); ipi_addr = ipi_base_addr + ((phys_cpu_id << 4) | ((redirect & 1) << 3)); -#ifdef XEN - //printf ("send_ipi to %d (%x)\n", cpu, phys_cpu_id); -#endif writeq(ipi_data, ipi_addr); } diff -r 00f21b3c2c7d -r 49903e608d07 xen/arch/ia64/linux-xen/smp.c --- a/xen/arch/ia64/linux-xen/smp.c Fri Aug 11 08:52:36 2006 +0200 +++ b/xen/arch/ia64/linux-xen/smp.c Fri Aug 11 10:03:32 2006 +0200 @@ -146,6 +146,9 @@ handle_IPI (int irq, void *dev_id, struc unsigned long *pending_ipis = &__ia64_per_cpu_var(ipi_operation); unsigned long ops; +#ifdef XEN + perfc_incrc(ipis); +#endif mb(); /* Order interrupt and bit testing. */ while ((ops = xchg(pending_ipis, 0)) != 0) { mb(); /* Order bit clearing and data access. */ diff -r 00f21b3c2c7d -r 49903e608d07 xen/arch/ia64/xen/faults.c --- a/xen/arch/ia64/xen/faults.c Fri Aug 11 08:52:36 2006 +0200 +++ b/xen/arch/ia64/xen/faults.c Fri Aug 11 10:03:32 2006 +0200 @@ -515,7 +515,8 @@ ia64_handle_break (unsigned long ifa, st debugger_trap_fatal(0 /* don't care */, regs); } #endif - else if (iim == d->arch.breakimm) { + else if (iim == d->arch.breakimm + && ia64_get_cpl (regs->cr_ipsr) == 2) { /* by default, do not continue */ v->arch.hypercall_continuation = 0; diff -r 00f21b3c2c7d -r 49903e608d07 xen/arch/ia64/xen/hypercall.c --- a/xen/arch/ia64/xen/hypercall.c Fri Aug 11 08:52:36 2006 +0200 +++ b/xen/arch/ia64/xen/hypercall.c Fri Aug 11 10:03:32 2006 +0200 @@ -33,75 +33,81 @@ static long do_physdev_op(int cmd, XEN_G static long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg); static long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg); -hypercall_t ia64_hypercall_table[] = - { - (hypercall_t)do_ni_hypercall, /* do_set_trap_table */ /* 0 */ +const hypercall_t ia64_hypercall_table[NR_hypercalls] = +{ + (hypercall_t)do_ni_hypercall, /* do_set_trap_table *//* 0 */ (hypercall_t)do_ni_hypercall, /* do_mmu_update */ (hypercall_t)do_ni_hypercall, /* do_set_gdt */ (hypercall_t)do_ni_hypercall, /* do_stack_switch */ (hypercall_t)do_ni_hypercall, /* do_set_callbacks */ - (hypercall_t)do_ni_hypercall, /* do_fpu_taskswitch */ /* 5 */ + (hypercall_t)do_ni_hypercall, /* do_fpu_taskswitch *//* 5 */ (hypercall_t)do_sched_op_compat, (hypercall_t)do_dom0_op, (hypercall_t)do_ni_hypercall, /* do_set_debugreg */ (hypercall_t)do_ni_hypercall, /* do_get_debugreg */ - (hypercall_t)do_ni_hypercall, /* do_update_descriptor */ /* 10 */ + (hypercall_t)do_ni_hypercall, /* do_update_descriptor * 10 */ (hypercall_t)do_ni_hypercall, /* do_ni_hypercall */ (hypercall_t)do_memory_op, (hypercall_t)do_multicall, (hypercall_t)do_ni_hypercall, /* do_update_va_mapping */ - (hypercall_t)do_ni_hypercall, /* do_set_timer_op */ /* 15 */ + (hypercall_t)do_ni_hypercall, /* do_set_timer_op */ /* 15 */ (hypercall_t)do_event_channel_op_compat, (hypercall_t)do_xen_version, (hypercall_t)do_console_io, (hypercall_t)do_physdev_op_compat, - (hypercall_t)do_grant_table_op, /* 20 */ + (hypercall_t)do_grant_table_op, /* 20 */ (hypercall_t)do_ni_hypercall, /* do_vm_assist */ - (hypercall_t)do_ni_hypercall, /* do_update_va_mapping_otherdomain */ + (hypercall_t)do_ni_hypercall, /* do_update_va_mapping_othe */ (hypercall_t)do_ni_hypercall, /* (x86 only) */ (hypercall_t)do_ni_hypercall, /* do_vcpu_op */ - (hypercall_t)do_ni_hypercall, /* (x86_64 only) */ /* 25 */ + (hypercall_t)do_ni_hypercall, /* (x86_64 only) */ /* 25 */ (hypercall_t)do_ni_hypercall, /* do_mmuext_op */ (hypercall_t)do_ni_hypercall, /* do_acm_op */ (hypercall_t)do_ni_hypercall, /* do_nmi_op */ (hypercall_t)do_sched_op, - (hypercall_t)do_callback_op, /* */ /* 30 */ + (hypercall_t)do_callback_op, /* */ /* 30 */ (hypercall_t)do_ni_hypercall, /* */ (hypercall_t)do_event_channel_op, (hypercall_t)do_physdev_op, (hypercall_t)do_hvm_op, /* */ - (hypercall_t)do_ni_hypercall, /* */ /* 35 */ - (hypercall_t)do_ni_hypercall, /* */ - (hypercall_t)do_ni_hypercall, /* */ - (hypercall_t)do_ni_hypercall, /* */ - (hypercall_t)do_ni_hypercall, /* */ - (hypercall_t)do_ni_hypercall, /* */ /* 40 */ - (hypercall_t)do_ni_hypercall, /* */ - (hypercall_t)do_ni_hypercall, /* */ - (hypercall_t)do_ni_hypercall, /* */ - (hypercall_t)do_ni_hypercall, /* */ - (hypercall_t)do_ni_hypercall, /* */ /* 45 */ - (hypercall_t)do_ni_hypercall, /* */ - (hypercall_t)do_ni_hypercall, /* */ - (hypercall_t)do_dom0vp_op, /* dom0vp_op */ + (hypercall_t)do_ni_hypercall, /* */ /* 35 */ + (hypercall_t)do_ni_hypercall, /* */ + (hypercall_t)do_ni_hypercall, /* */ + (hypercall_t)do_ni_hypercall, /* */ + (hypercall_t)do_ni_hypercall, /* */ + (hypercall_t)do_ni_hypercall, /* */ /* 40 */ + (hypercall_t)do_ni_hypercall, /* */ + (hypercall_t)do_ni_hypercall, /* */ + (hypercall_t)do_ni_hypercall, /* */ + (hypercall_t)do_ni_hypercall, /* */ + (hypercall_t)do_ni_hypercall, /* */ /* 45 */ + (hypercall_t)do_ni_hypercall, /* */ + (hypercall_t)do_ni_hypercall, /* */ + (hypercall_t)do_dom0vp_op, /* dom0vp_op */ (hypercall_t)do_ni_hypercall, /* arch_1 */ - (hypercall_t)do_ni_hypercall, /* arch_2 */ /* 50 */ + (hypercall_t)do_ni_hypercall, /* arch_2 */ /* 50 */ (hypercall_t)do_ni_hypercall, /* arch_3 */ (hypercall_t)do_ni_hypercall, /* arch_4 */ (hypercall_t)do_ni_hypercall, /* arch_5 */ (hypercall_t)do_ni_hypercall, /* arch_6 */ - (hypercall_t)do_ni_hypercall /* arch_7 */ /* 55 */ - }; - -uint32_t nr_hypercalls = - sizeof(ia64_hypercall_table) / sizeof(hypercall_t); + (hypercall_t)do_ni_hypercall, /* arch_7 */ /* 55 */ + (hypercall_t)do_ni_hypercall, + (hypercall_t)do_ni_hypercall, + (hypercall_t)do_ni_hypercall, + (hypercall_t)do_ni_hypercall, + (hypercall_t)do_ni_hypercall, /* 60 */ + (hypercall_t)do_ni_hypercall, + (hypercall_t)do_ni_hypercall, + (hypercall_t)do_ni_hypercall +}; static IA64FAULT xen_hypercall (struct pt_regs *regs) { uint32_t cmd = (uint32_t)regs->r2; - if (cmd < nr_hypercalls) + if (cmd < NR_hypercalls) { + perfc_incra(hypercalls, cmd); regs->r8 = (*ia64_hypercall_table[cmd])( regs->r14, regs->r15, @@ -109,12 +115,11 @@ xen_hypercall (struct pt_regs *regs) regs->r17, regs->r18, regs->r19); - else + } else regs->r8 = -ENOSYS; return IA64_NO_FAULT; } - static void fw_hypercall_ipi (struct pt_regs *regs) @@ -277,18 +282,7 @@ IA64FAULT IA64FAULT ia64_hypercall (struct pt_regs *regs) { - struct vcpu *v = current; unsigned long index = regs->r2; - int privlvl = (regs->cr_ipsr & IA64_PSR_CPL) >> IA64_PSR_CPL0_BIT; - - /* Hypercalls are only allowed by kernel. - Kernel checks memory accesses. */ - if (VMX_DOMAIN(v) ? (privlvl != 0) : (privlvl != 2)) { - /* FIXME: Return a better error value ? - Reflection ? Illegal operation ? */ - regs->r8 = -1; - return IA64_NO_FAULT; - } if (index >= FW_HYPERCALL_FIRST_ARCH) return fw_hypercall (regs); diff -r 00f21b3c2c7d -r 49903e608d07 xen/arch/ia64/xen/irq.c --- a/xen/arch/ia64/xen/irq.c Fri Aug 11 08:52:36 2006 +0200 +++ b/xen/arch/ia64/xen/irq.c Fri Aug 11 10:03:32 2006 +0200 @@ -236,9 +236,6 @@ int setup_vector(unsigned int irq, struc struct irqaction *old, **p; irq_desc_t *desc = irq_descp(irq); - printf ("setup_vector(%d): handler=%p, flags=%x\n", - irq, desc->handler, desc->status); - /* * The following block of code has to be executed atomically */ diff -r 00f21b3c2c7d -r 49903e608d07 xen/arch/ia64/xen/privop.c --- a/xen/arch/ia64/xen/privop.c Fri Aug 11 08:52:36 2006 +0200 +++ b/xen/arch/ia64/xen/privop.c Fri Aug 11 10:03:32 2006 +0200 @@ -681,7 +681,7 @@ priv_emulate(VCPU *vcpu, REGS *regs, UIN return IA64_ILLOP_FAULT; } //if (isrcode != 1 && isrcode != 2) return 0; - privlvl = (ipsr & IA64_PSR_CPL) >> IA64_PSR_CPL0_BIT; + privlvl = ia64_get_cpl (ipsr); // its OK for a privified-cover to be executed in user-land fault = priv_handle_op(vcpu,regs,privlvl); if ((fault == IA64_NO_FAULT) || (fault == IA64_EXTINT_VECTOR)) { // success!! diff -r 00f21b3c2c7d -r 49903e608d07 xen/arch/ia64/xen/xensetup.c --- a/xen/arch/ia64/xen/xensetup.c Fri Aug 11 08:52:36 2006 +0200 +++ b/xen/arch/ia64/xen/xensetup.c Fri Aug 11 10:03:32 2006 +0200 @@ -26,11 +26,6 @@ #include #include -/* Be sure the struct shared_info size is <= XSI_SIZE. */ -#if SHARED_INFO_SIZE > XSI_SIZE -#error "struct shared_info bigger than XSI_SIZE" -#endif - unsigned long xenheap_phys_end, total_pages; char saved_command_line[COMMAND_LINE_SIZE]; @@ -257,6 +252,9 @@ void start_kernel(void) #ifdef CONFIG_SMP int i; #endif + + /* Be sure the struct shared_info size is <= XSI_SIZE. */ + BUILD_BUG_ON (sizeof (struct shared_info) > XSI_SIZE); running_on_sim = is_platform_hp_ski(); /* Kernel may be relocated by EFI loader */ diff -r 00f21b3c2c7d -r 49903e608d07 xen/include/asm-ia64/dom_fw.h --- a/xen/include/asm-ia64/dom_fw.h Fri Aug 11 08:52:36 2006 +0200 +++ b/xen/include/asm-ia64/dom_fw.h Fri Aug 11 10:03:32 2006 +0200 @@ -150,13 +150,10 @@ /* Hypercalls index bellow _FIRST_ARCH are reserved by Xen, while those above are for the architecture. - Note: this limit was defined by Xen/ia64 (and not by Xen).² + Note: this limit was defined by Xen/ia64 (and not by Xen). This can be renumbered safely. */ #define FW_HYPERCALL_FIRST_ARCH 0x300UL - -/* Xen/ia64 user hypercalls. Only used for debugging. */ -#define FW_HYPERCALL_FIRST_USER 0xff00UL /* Interrupt vector used for os boot rendez vous. */ #define XEN_SAL_BOOT_RENDEZ_VEC 0xF3 diff -r 00f21b3c2c7d -r 49903e608d07 xen/include/asm-ia64/linux-xen/asm/processor.h --- a/xen/include/asm-ia64/linux-xen/asm/processor.h Fri Aug 11 08:52:36 2006 +0200 +++ b/xen/include/asm-ia64/linux-xen/asm/processor.h Fri Aug 11 10:03:32 2006 +0200 @@ -717,6 +717,14 @@ prefetchw (const void *x) extern unsigned long boot_option_idle_override; +#ifdef XEN +static inline unsigned int +ia64_get_cpl (unsigned long psr) +{ + return (psr & IA64_PSR_CPL) >> IA64_PSR_CPL0_BIT; +} +#endif + #endif /* !__ASSEMBLY__ */ #endif /* _ASM_IA64_PROCESSOR_H */ diff -r 00f21b3c2c7d -r 49903e608d07 xen/include/asm-ia64/multicall.h --- a/xen/include/asm-ia64/multicall.h Fri Aug 11 08:52:36 2006 +0200 +++ b/xen/include/asm-ia64/multicall.h Fri Aug 11 10:03:32 2006 +0200 @@ -11,17 +11,20 @@ typedef unsigned long (*hypercall_t)( unsigned long arg4, unsigned long arg5); -extern hypercall_t ia64_hypercall_table[]; +extern const hypercall_t ia64_hypercall_table[]; static inline void do_multicall_call(multicall_entry_t *call) { - call->result = (*ia64_hypercall_table[call->op])( + if (call->op < NR_hypercalls) + call->result = (*ia64_hypercall_table[call->op])( call->args[0], call->args[1], call->args[2], call->args[3], call->args[4], call->args[5]); + else + call->result = -ENOSYS; } #endif /* __ASM_IA64_MULTICALL_H__ */