direct-io.hg

changeset 1685:37c17d6bda09

bitkeeper revision 1.1041.1.12 (40eae094p4Hi_HGiXIC_gBESK2nm0g)

Move most of DOM0_GETDOMAININFO back to common, leaving just
getting the context in machdep code.
author djm@kirby.fc.hp.com
date Tue Jul 06 17:25:40 2004 +0000 (2004-07-06)
parents 55d2aa0544ae
children d7fd2dca5e0a
files xen/arch/x86/dom0_ops.c xen/common/dom0_ops.c
line diff
     1.1 --- a/xen/arch/x86/dom0_ops.c	Thu Jul 01 23:45:24 2004 +0000
     1.2 +++ b/xen/arch/x86/dom0_ops.c	Tue Jul 06 17:25:40 2004 +0000
     1.3 @@ -79,127 +79,6 @@ long arch_do_dom0_op(dom0_op_t *op, dom0
     1.4      }
     1.5      break;
     1.6  
     1.7 -    case DOM0_GETDOMAININFO:
     1.8 -    { 
     1.9 -        full_execution_context_t *c;
    1.10 -        struct domain            *d;
    1.11 -        unsigned long             flags;
    1.12 -        int                       i;
    1.13 -
    1.14 -        read_lock_irqsave(&tasklist_lock, flags);
    1.15 -
    1.16 -        for_each_domain ( d )
    1.17 -        {
    1.18 -            if ( d->domain >= op->u.getdomaininfo.domain )
    1.19 -                break;
    1.20 -        }
    1.21 -
    1.22 -        if ( (d == NULL) || !get_domain(d) )
    1.23 -        {
    1.24 -            read_unlock_irqrestore(&tasklist_lock, flags);
    1.25 -            ret = -ESRCH;
    1.26 -            break;
    1.27 -        }
    1.28 -
    1.29 -        read_unlock_irqrestore(&tasklist_lock, flags);
    1.30 -
    1.31 -        op->u.getdomaininfo.domain = d->domain;
    1.32 -        strcpy(op->u.getdomaininfo.name, d->name);
    1.33 -        
    1.34 -        op->u.getdomaininfo.flags =
    1.35 -            (test_bit(DF_DYING,     &d->flags) ? DOMFLAGS_DYING    : 0) |
    1.36 -            (test_bit(DF_CRASHED,   &d->flags) ? DOMFLAGS_CRASHED  : 0) |
    1.37 -            (test_bit(DF_SHUTDOWN,  &d->flags) ? DOMFLAGS_SHUTDOWN : 0) |
    1.38 -            (test_bit(DF_CTRLPAUSE, &d->flags) ? DOMFLAGS_PAUSED   : 0) |
    1.39 -            (test_bit(DF_BLOCKED,   &d->flags) ? DOMFLAGS_BLOCKED  : 0) |
    1.40 -            (test_bit(DF_RUNNING,   &d->flags) ? DOMFLAGS_RUNNING  : 0);
    1.41 -
    1.42 -        op->u.getdomaininfo.flags |= d->processor << DOMFLAGS_CPUSHIFT;
    1.43 -        op->u.getdomaininfo.flags |= 
    1.44 -            d->shutdown_code << DOMFLAGS_SHUTDOWNSHIFT;
    1.45 -
    1.46 -        op->u.getdomaininfo.tot_pages   = d->tot_pages;
    1.47 -        op->u.getdomaininfo.max_pages   = d->max_pages;
    1.48 -        op->u.getdomaininfo.cpu_time    = d->cpu_time;
    1.49 -        op->u.getdomaininfo.shared_info_frame = 
    1.50 -            __pa(d->shared_info) >> PAGE_SHIFT;
    1.51 -
    1.52 -        if ( op->u.getdomaininfo.ctxt != NULL )
    1.53 -        {
    1.54 -            if ( (c = kmalloc(sizeof(*c))) == NULL )
    1.55 -            {
    1.56 -                ret = -ENOMEM;
    1.57 -                put_domain(d);
    1.58 -                break;
    1.59 -            }
    1.60 -
    1.61 -            if ( d != current )
    1.62 -                domain_pause(d);
    1.63 -
    1.64 -            c->flags = 0;
    1.65 -            memcpy(&c->cpu_ctxt, 
    1.66 -                   &d->shared_info->execution_context,
    1.67 -                   sizeof(d->shared_info->execution_context));
    1.68 -            if ( test_bit(DF_DONEFPUINIT, &d->flags) )
    1.69 -                c->flags |= ECF_I387_VALID;
    1.70 -            memcpy(&c->fpu_ctxt,
    1.71 -                   &d->thread.i387,
    1.72 -                   sizeof(d->thread.i387));
    1.73 -            memcpy(&c->trap_ctxt,
    1.74 -                   d->thread.traps,
    1.75 -                   sizeof(d->thread.traps));
    1.76 -#ifdef ARCH_HAS_FAST_TRAP
    1.77 -            if ( (d->thread.fast_trap_desc.a == 0) &&
    1.78 -                 (d->thread.fast_trap_desc.b == 0) )
    1.79 -                c->fast_trap_idx = 0;
    1.80 -            else
    1.81 -                c->fast_trap_idx = 
    1.82 -                    d->thread.fast_trap_idx;
    1.83 -#endif
    1.84 -            c->ldt_base = d->mm.ldt_base;
    1.85 -            c->ldt_ents = d->mm.ldt_ents;
    1.86 -            c->gdt_ents = 0;
    1.87 -            if ( GET_GDT_ADDRESS(d) == GDT_VIRT_START )
    1.88 -            {
    1.89 -                for ( i = 0; i < 16; i++ )
    1.90 -                    c->gdt_frames[i] = 
    1.91 -                        l1_pgentry_to_pagenr(d->mm.perdomain_pt[i]);
    1.92 -                c->gdt_ents = 
    1.93 -                    (GET_GDT_ENTRIES(d) + 1) >> 3;
    1.94 -            }
    1.95 -            c->guestos_ss  = d->thread.guestos_ss;
    1.96 -            c->guestos_esp = d->thread.guestos_sp;
    1.97 -            c->pt_base   = 
    1.98 -                pagetable_val(d->mm.pagetable);
    1.99 -            memcpy(c->debugreg, 
   1.100 -                   d->thread.debugreg, 
   1.101 -                   sizeof(d->thread.debugreg));
   1.102 -            c->event_callback_cs  =
   1.103 -                d->event_selector;
   1.104 -            c->event_callback_eip =
   1.105 -                d->event_address;
   1.106 -            c->failsafe_callback_cs  = 
   1.107 -                d->failsafe_selector;
   1.108 -            c->failsafe_callback_eip = 
   1.109 -                d->failsafe_address;
   1.110 -
   1.111 -            if ( d != current )
   1.112 -                domain_unpause(d);
   1.113 -
   1.114 -            if ( copy_to_user(op->u.getdomaininfo.ctxt, c, sizeof(*c)) )
   1.115 -                ret = -EINVAL;
   1.116 -
   1.117 -            if ( c != NULL )
   1.118 -                kfree(c);
   1.119 -        }
   1.120 -
   1.121 -        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )     
   1.122 -            ret = -EINVAL;
   1.123 -
   1.124 -        put_domain(d);
   1.125 -    }
   1.126 -    break;
   1.127 -
   1.128      case DOM0_SHADOW_CONTROL:
   1.129      {
   1.130          struct domain *d; 
   1.131 @@ -221,3 +100,55 @@ long arch_do_dom0_op(dom0_op_t *op, dom0
   1.132  
   1.133      return ret;
   1.134  }
   1.135 +
   1.136 +void arch_getdomaininfo_ctxt(struct domain *d, full_execution_context_t *c)
   1.137 +{ 
   1.138 +    int i;
   1.139 +
   1.140 +    c->flags = 0;
   1.141 +    memcpy(&c->cpu_ctxt, 
   1.142 +           &d->shared_info->execution_context,
   1.143 +           sizeof(d->shared_info->execution_context));
   1.144 +    if ( test_bit(DF_DONEFPUINIT, &d->flags) )
   1.145 +        c->flags |= ECF_I387_VALID;
   1.146 +    memcpy(&c->fpu_ctxt,
   1.147 +           &d->thread.i387,
   1.148 +           sizeof(d->thread.i387));
   1.149 +    memcpy(&c->trap_ctxt,
   1.150 +           d->thread.traps,
   1.151 +           sizeof(d->thread.traps));
   1.152 +#ifdef ARCH_HAS_FAST_TRAP
   1.153 +    if ( (d->thread.fast_trap_desc.a == 0) &&
   1.154 +         (d->thread.fast_trap_desc.b == 0) )
   1.155 +        c->fast_trap_idx = 0;
   1.156 +    else
   1.157 +        c->fast_trap_idx = 
   1.158 +            d->thread.fast_trap_idx;
   1.159 +#endif
   1.160 +    c->ldt_base = d->mm.ldt_base;
   1.161 +    c->ldt_ents = d->mm.ldt_ents;
   1.162 +    c->gdt_ents = 0;
   1.163 +    if ( GET_GDT_ADDRESS(d) == GDT_VIRT_START )
   1.164 +    {
   1.165 +        for ( i = 0; i < 16; i++ )
   1.166 +            c->gdt_frames[i] = 
   1.167 +                l1_pgentry_to_pagenr(d->mm.perdomain_pt[i]);
   1.168 +        c->gdt_ents = 
   1.169 +            (GET_GDT_ENTRIES(d) + 1) >> 3;
   1.170 +    }
   1.171 +    c->guestos_ss  = d->thread.guestos_ss;
   1.172 +    c->guestos_esp = d->thread.guestos_sp;
   1.173 +    c->pt_base   = 
   1.174 +        pagetable_val(d->mm.pagetable);
   1.175 +    memcpy(c->debugreg, 
   1.176 +           d->thread.debugreg, 
   1.177 +           sizeof(d->thread.debugreg));
   1.178 +    c->event_callback_cs  =
   1.179 +        d->event_selector;
   1.180 +    c->event_callback_eip =
   1.181 +        d->event_address;
   1.182 +    c->failsafe_callback_cs  = 
   1.183 +        d->failsafe_selector;
   1.184 +    c->failsafe_callback_eip = 
   1.185 +        d->failsafe_address;
   1.186 +}
     2.1 --- a/xen/common/dom0_ops.c	Thu Jul 01 23:45:24 2004 +0000
     2.2 +++ b/xen/common/dom0_ops.c	Tue Jul 06 17:25:40 2004 +0000
     2.3 @@ -25,6 +25,7 @@
     2.4  
     2.5  extern unsigned int alloc_new_dom_mem(struct domain *, unsigned int);
     2.6  extern long arch_do_dom0_op(dom0_op_t *op, dom0_op_t *u_dom0_op);
     2.7 +extern void arch_getdomaininfo_ctxt(struct domain *, full_execution_context_t *);
     2.8  
     2.9  long do_dom0_op(dom0_op_t *u_dom0_op)
    2.10  {
    2.11 @@ -254,6 +255,81 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    2.12      }
    2.13      break;
    2.14  
    2.15 +    case DOM0_GETDOMAININFO:
    2.16 +    { 
    2.17 +        full_execution_context_t *c;
    2.18 +        struct domain            *d;
    2.19 +        unsigned long             flags;
    2.20 +
    2.21 +        read_lock_irqsave(&tasklist_lock, flags);
    2.22 +
    2.23 +        for_each_domain ( d )
    2.24 +        {
    2.25 +            if ( d->domain >= op->u.getdomaininfo.domain )
    2.26 +                break;
    2.27 +        }
    2.28 +
    2.29 +        if ( (d == NULL) || !get_domain(d) )
    2.30 +        {
    2.31 +            read_unlock_irqrestore(&tasklist_lock, flags);
    2.32 +            ret = -ESRCH;
    2.33 +            break;
    2.34 +        }
    2.35 +
    2.36 +        read_unlock_irqrestore(&tasklist_lock, flags);
    2.37 +
    2.38 +        op->u.getdomaininfo.domain = d->domain;
    2.39 +        strcpy(op->u.getdomaininfo.name, d->name);
    2.40 +        
    2.41 +        op->u.getdomaininfo.flags =
    2.42 +            (test_bit(DF_DYING,     &d->flags) ? DOMFLAGS_DYING    : 0) |
    2.43 +            (test_bit(DF_CRASHED,   &d->flags) ? DOMFLAGS_CRASHED  : 0) |
    2.44 +            (test_bit(DF_SHUTDOWN,  &d->flags) ? DOMFLAGS_SHUTDOWN : 0) |
    2.45 +            (test_bit(DF_CTRLPAUSE, &d->flags) ? DOMFLAGS_PAUSED   : 0) |
    2.46 +            (test_bit(DF_BLOCKED,   &d->flags) ? DOMFLAGS_BLOCKED  : 0) |
    2.47 +            (test_bit(DF_RUNNING,   &d->flags) ? DOMFLAGS_RUNNING  : 0);
    2.48 +
    2.49 +        op->u.getdomaininfo.flags |= d->processor << DOMFLAGS_CPUSHIFT;
    2.50 +        op->u.getdomaininfo.flags |= 
    2.51 +            d->shutdown_code << DOMFLAGS_SHUTDOWNSHIFT;
    2.52 +
    2.53 +        op->u.getdomaininfo.tot_pages   = d->tot_pages;
    2.54 +        op->u.getdomaininfo.max_pages   = d->max_pages;
    2.55 +        op->u.getdomaininfo.cpu_time    = d->cpu_time;
    2.56 +        op->u.getdomaininfo.shared_info_frame = 
    2.57 +            __pa(d->shared_info) >> PAGE_SHIFT;
    2.58 +
    2.59 +        if ( op->u.getdomaininfo.ctxt != NULL )
    2.60 +        {
    2.61 +            if ( (c = kmalloc(sizeof(*c))) == NULL )
    2.62 +            {
    2.63 +                ret = -ENOMEM;
    2.64 +                put_domain(d);
    2.65 +                break;
    2.66 +            }
    2.67 +
    2.68 +            if ( d != current )
    2.69 +                domain_pause(d);
    2.70 +
    2.71 +            arch_getdomaininfo_ctxt(d,c);
    2.72 +
    2.73 +            if ( d != current )
    2.74 +                domain_unpause(d);
    2.75 +
    2.76 +            if ( copy_to_user(op->u.getdomaininfo.ctxt, c, sizeof(*c)) )
    2.77 +                ret = -EINVAL;
    2.78 +
    2.79 +            if ( c != NULL )
    2.80 +                kfree(c);
    2.81 +        }
    2.82 +
    2.83 +        if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )     
    2.84 +            ret = -EINVAL;
    2.85 +
    2.86 +        put_domain(d);
    2.87 +    }
    2.88 +    break;
    2.89 +
    2.90      case DOM0_GETPAGEFRAMEINFO:
    2.91      {
    2.92          struct pfn_info *page;