ia64/xen-unstable

changeset 10140:d8659e39ff3c

[IA64] Add do_callback_ops

Signed-off-by Kevin Tian <kevin.tian@intel.com>
author awilliam@xenbuild.aw
date Tue May 23 08:24:09 2006 -0600 (2006-05-23)
parents 23fe235cb6d3
children 2f2f500c26da
files linux-2.6-xen-sparse/include/asm-ia64/hypercall.h xen/arch/ia64/xen/hypercall.c xen/include/asm-ia64/domain.h xen/include/public/arch-ia64.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h	Tue May 23 08:18:48 2006 -0600
     1.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypercall.h	Tue May 23 08:24:09 2006 -0600
     1.3 @@ -313,9 +313,20 @@ HYPERVISOR_suspend(
     1.4  	return rc;
     1.5  }
     1.6  
     1.7 +static inline int
     1.8 +HYPERVISOR_callback_op(
     1.9 +	int cmd, void *arg)
    1.10 +{
    1.11 +	return _hypercall2(int, callback_op, cmd, arg);
    1.12 +}
    1.13 +
    1.14  extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
    1.15  static inline void exit_idle(void) {}
    1.16 -#define do_IRQ(irq, regs) __do_IRQ((irq), (regs))
    1.17 +#define do_IRQ(irq, regs) ({			\
    1.18 +	irq_enter();				\
    1.19 +	__do_IRQ((irq), (regs));		\
    1.20 +	irq_exit();				\
    1.21 +})
    1.22  
    1.23  #ifdef CONFIG_XEN_IA64_DOM0_VP
    1.24  #include <linux/err.h>
     2.1 --- a/xen/arch/ia64/xen/hypercall.c	Tue May 23 08:18:48 2006 -0600
     2.2 +++ b/xen/arch/ia64/xen/hypercall.c	Tue May 23 08:24:09 2006 -0600
     2.3 @@ -25,9 +25,12 @@
     2.4  #include <asm/hw_irq.h>
     2.5  #include <public/physdev.h>
     2.6  #include <xen/domain.h>
     2.7 +#include <public/callback.h>
     2.8 +#include <xen/event.h>
     2.9  
    2.10  static long do_physdev_op_compat(XEN_GUEST_HANDLE(physdev_op_t) uop);
    2.11  static long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg);
    2.12 +static long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg);
    2.13  /* FIXME: where these declarations should be there ? */
    2.14  extern int dump_privop_counts_to_user(char *, int);
    2.15  extern int zero_privop_counts_to_user(char *, int);
    2.16 @@ -67,7 +70,7 @@ hypercall_t ia64_hypercall_table[] =
    2.17  	(hypercall_t)do_ni_hypercall,		/* do_acm_op */
    2.18  	(hypercall_t)do_ni_hypercall,		/* do_nmi_op */
    2.19  	(hypercall_t)do_sched_op,
    2.20 -	(hypercall_t)do_ni_hypercall,		/*  */				/* 30 */
    2.21 +	(hypercall_t)do_callback_op,		/*  */			/* 30 */
    2.22  	(hypercall_t)do_ni_hypercall,		/*  */
    2.23  	(hypercall_t)do_event_channel_op,
    2.24  	(hypercall_t)do_physdev_op,
    2.25 @@ -200,11 +203,8 @@ fw_hypercall (struct pt_regs *regs)
    2.26  		VCPU(v,pending_interruption) = 1;
    2.27  #endif
    2.28  		if (regs->r28 == PAL_HALT_LIGHT) {
    2.29 -			int pi;
    2.30 -#define SPURIOUS_VECTOR 15
    2.31 -			pi = vcpu_check_pending_interrupts(v);
    2.32 -			if (pi != SPURIOUS_VECTOR) {
    2.33 -				if (!VCPU(v,pending_interruption))
    2.34 +			if (vcpu_deliverable_interrupts(v) ||
    2.35 +				event_pending(v)) {
    2.36  					idle_when_pending++;
    2.37  				vcpu_pend_unspecified_interrupt(v);
    2.38  //printf("idle w/int#%d pending!\n",pi);
    2.39 @@ -435,3 +435,75 @@ long do_event_channel_op_compat(XEN_GUES
    2.40  
    2.41      return do_event_channel_op(op.cmd, guest_handle_from_ptr(&uop.p->u, void));
    2.42  }
    2.43 +
    2.44 +static long register_guest_callback(struct callback_register *reg)
    2.45 +{
    2.46 +    long ret = 0;
    2.47 +    struct vcpu *v = current;
    2.48 +
    2.49 +    if (IS_VMM_ADDRESS(reg->address))
    2.50 +        return -EINVAL;
    2.51 +
    2.52 +    switch ( reg->type )
    2.53 +    {
    2.54 +    case CALLBACKTYPE_event:
    2.55 +        v->arch.event_callback_ip    = reg->address;
    2.56 +        break;
    2.57 +
    2.58 +    case CALLBACKTYPE_failsafe:
    2.59 +        v->arch.failsafe_callback_ip = reg->address;
    2.60 +        break;
    2.61 +
    2.62 +    default:
    2.63 +        ret = -EINVAL;
    2.64 +        break;
    2.65 +    }
    2.66 +
    2.67 +    return ret;
    2.68 +}
    2.69 +
    2.70 +static long unregister_guest_callback(struct callback_unregister *unreg)
    2.71 +{
    2.72 +    return -EINVAL ;
    2.73 +}
    2.74 +
    2.75 +/* First time to add callback to xen/ia64, so let's just stick to
    2.76 + * the newer callback interface.
    2.77 + */
    2.78 +static long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg)
    2.79 +{
    2.80 +    long ret;
    2.81 +
    2.82 +    switch ( cmd )
    2.83 +    {
    2.84 +    case CALLBACKOP_register:
    2.85 +    {
    2.86 +        struct callback_register reg;
    2.87 +
    2.88 +        ret = -EFAULT;
    2.89 +        if ( copy_from_guest(&reg, arg, 1) )
    2.90 +            break;
    2.91 +
    2.92 +        ret = register_guest_callback(&reg);
    2.93 +    }
    2.94 +    break;
    2.95 +
    2.96 +    case CALLBACKOP_unregister:
    2.97 +    {
    2.98 +        struct callback_unregister unreg;
    2.99 +
   2.100 +        ret = -EFAULT;
   2.101 +        if ( copy_from_guest(&unreg, arg, 1) )
   2.102 +            break;
   2.103 +
   2.104 +        ret = unregister_guest_callback(&unreg);
   2.105 +    }
   2.106 +    break;
   2.107 +
   2.108 +    default:
   2.109 +        ret = -EINVAL;
   2.110 +        break;
   2.111 +    }
   2.112 +
   2.113 +    return ret;
   2.114 +}
     3.1 --- a/xen/include/asm-ia64/domain.h	Tue May 23 08:18:48 2006 -0600
     3.2 +++ b/xen/include/asm-ia64/domain.h	Tue May 23 08:24:09 2006 -0600
     3.3 @@ -86,6 +86,8 @@ struct arch_vcpu {
     3.4  	unsigned long xen_itm;
     3.5  
     3.6      mapped_regs_t *privregs; /* save the state of vcpu */
     3.7 +    unsigned long event_callback_ip;		// event callback handler
     3.8 +    unsigned long failsafe_callback_ip; 	// Do we need it?
     3.9  
    3.10      /* These fields are copied from arch_domain to make access easier/faster
    3.11         in assembly code.  */
     4.1 --- a/xen/include/public/arch-ia64.h	Tue May 23 08:18:48 2006 -0600
     4.2 +++ b/xen/include/public/arch-ia64.h	Tue May 23 08:24:09 2006 -0600
     4.3 @@ -320,6 +320,8 @@ struct arch_initrd_info {
     4.4  };
     4.5  typedef struct arch_initrd_info arch_initrd_info_t;
     4.6  
     4.7 +typedef unsigned long xen_callback_t;
     4.8 +
     4.9  #define IA64_COMMAND_LINE_SIZE 512
    4.10  struct vcpu_guest_context {
    4.11  #define VGCF_FPU_VALID (1<<0)