[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [IA64] cleanup



# HG changeset patch
# User awilliam@xxxxxxxxxxx
# Node ID 741fd616f5dc6a2ce1ec97074899785414d7c707
# Parent  fa584e5d17b65f39ef46b15952c650c0226e59cf
[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@xxxxxxxx>
---
 xen/arch/ia64/asm-offsets.c                    |    1 
 xen/arch/ia64/linux-xen/irq_ia64.c             |    6 -
 xen/arch/ia64/linux-xen/smp.c                  |    3 
 xen/arch/ia64/xen/faults.c                     |    3 
 xen/arch/ia64/xen/hypercall.c                  |   82 +++++++++++--------------
 xen/arch/ia64/xen/irq.c                        |    3 
 xen/arch/ia64/xen/privop.c                     |    2 
 xen/arch/ia64/xen/xensetup.c                   |    8 --
 xen/include/asm-ia64/dom_fw.h                  |    5 -
 xen/include/asm-ia64/linux-xen/asm/processor.h |    8 ++
 xen/include/asm-ia64/multicall.h               |    7 +-
 11 files changed, 64 insertions(+), 64 deletions(-)

diff -r fa584e5d17b6 -r 741fd616f5dc xen/arch/ia64/asm-offsets.c
--- a/xen/arch/ia64/asm-offsets.c       Mon Aug 14 13:30:17 2006 -0600
+++ b/xen/arch/ia64/asm-offsets.c       Mon Aug 14 13:42:00 2006 -0600
@@ -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 fa584e5d17b6 -r 741fd616f5dc xen/arch/ia64/linux-xen/irq_ia64.c
--- a/xen/arch/ia64/linux-xen/irq_ia64.c        Mon Aug 14 13:30:17 2006 -0600
+++ b/xen/arch/ia64/linux-xen/irq_ia64.c        Mon Aug 14 13:42:00 2006 -0600
@@ -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 fa584e5d17b6 -r 741fd616f5dc xen/arch/ia64/linux-xen/smp.c
--- a/xen/arch/ia64/linux-xen/smp.c     Mon Aug 14 13:30:17 2006 -0600
+++ b/xen/arch/ia64/linux-xen/smp.c     Mon Aug 14 13:42:00 2006 -0600
@@ -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 fa584e5d17b6 -r 741fd616f5dc xen/arch/ia64/xen/faults.c
--- a/xen/arch/ia64/xen/faults.c        Mon Aug 14 13:30:17 2006 -0600
+++ b/xen/arch/ia64/xen/faults.c        Mon Aug 14 13:42:00 2006 -0600
@@ -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 fa584e5d17b6 -r 741fd616f5dc xen/arch/ia64/xen/hypercall.c
--- a/xen/arch/ia64/xen/hypercall.c     Mon Aug 14 13:30:17 2006 -0600
+++ b/xen/arch/ia64/xen/hypercall.c     Mon Aug 14 13:42:00 2006 -0600
@@ -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 fa584e5d17b6 -r 741fd616f5dc xen/arch/ia64/xen/irq.c
--- a/xen/arch/ia64/xen/irq.c   Mon Aug 14 13:30:17 2006 -0600
+++ b/xen/arch/ia64/xen/irq.c   Mon Aug 14 13:42:00 2006 -0600
@@ -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 fa584e5d17b6 -r 741fd616f5dc xen/arch/ia64/xen/privop.c
--- a/xen/arch/ia64/xen/privop.c        Mon Aug 14 13:30:17 2006 -0600
+++ b/xen/arch/ia64/xen/privop.c        Mon Aug 14 13:42:00 2006 -0600
@@ -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 fa584e5d17b6 -r 741fd616f5dc xen/arch/ia64/xen/xensetup.c
--- a/xen/arch/ia64/xen/xensetup.c      Mon Aug 14 13:30:17 2006 -0600
+++ b/xen/arch/ia64/xen/xensetup.c      Mon Aug 14 13:42:00 2006 -0600
@@ -26,11 +26,6 @@
 #include <linux/efi.h>
 #include <asm/iosapic.h>
 
-/* 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 fa584e5d17b6 -r 741fd616f5dc xen/include/asm-ia64/dom_fw.h
--- a/xen/include/asm-ia64/dom_fw.h     Mon Aug 14 13:30:17 2006 -0600
+++ b/xen/include/asm-ia64/dom_fw.h     Mon Aug 14 13:42:00 2006 -0600
@@ -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 fa584e5d17b6 -r 741fd616f5dc 
xen/include/asm-ia64/linux-xen/asm/processor.h
--- a/xen/include/asm-ia64/linux-xen/asm/processor.h    Mon Aug 14 13:30:17 
2006 -0600
+++ b/xen/include/asm-ia64/linux-xen/asm/processor.h    Mon Aug 14 13:42:00 
2006 -0600
@@ -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 fa584e5d17b6 -r 741fd616f5dc xen/include/asm-ia64/multicall.h
--- a/xen/include/asm-ia64/multicall.h  Mon Aug 14 13:30:17 2006 -0600
+++ b/xen/include/asm-ia64/multicall.h  Mon Aug 14 13:42:00 2006 -0600
@@ -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__ */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.