ia64/xen-unstable

changeset 2465:ed44deec5fb6

bitkeeper revision 1.1159.1.143 (413faaf2dqvBsgM4ABe5flo11aYh1A)

Fix domain-finalizing dom0_op to check its inputs for sanity.
author kaf24@freefall.cl.cam.ac.uk
date Thu Sep 09 00:59:30 2004 +0000 (2004-09-09)
parents eab6988779a6
children db0119e98043
files xen/arch/x86/domain.c xen/common/domain.c xen/include/asm-x86/domain.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Thu Sep 09 00:24:45 2004 +0000
     1.2 +++ b/xen/arch/x86/domain.c	Thu Sep 09 00:59:30 2004 +0000
     1.3 @@ -231,48 +231,66 @@ void arch_do_createdomain(struct domain 
     1.4                             PAGE_SHIFT] = 0x0fffdeadUL;  /* debug */
     1.5  }
     1.6  
     1.7 -void arch_final_setup_guestos(struct domain *p, full_execution_context_t *c)
     1.8 +int arch_final_setup_guestos(struct domain *d, full_execution_context_t *c)
     1.9  {
    1.10      unsigned long phys_basetab;
    1.11 -    int i;
    1.12 +    int i, rc;
    1.13  
    1.14 -    clear_bit(DF_DONEFPUINIT, &p->flags);
    1.15 +    clear_bit(DF_DONEFPUINIT, &d->flags);
    1.16      if ( c->flags & ECF_I387_VALID )
    1.17 -        set_bit(DF_DONEFPUINIT, &p->flags);
    1.18 -    memcpy(&p->shared_info->execution_context,
    1.19 +        set_bit(DF_DONEFPUINIT, &d->flags);
    1.20 +
    1.21 +    memcpy(&d->shared_info->execution_context,
    1.22             &c->cpu_ctxt,
    1.23 -           sizeof(p->shared_info->execution_context));
    1.24 -    memcpy(&p->thread.i387,
    1.25 +           sizeof(d->shared_info->execution_context));
    1.26 +
    1.27 +    memcpy(&d->thread.i387,
    1.28             &c->fpu_ctxt,
    1.29 -           sizeof(p->thread.i387));
    1.30 -    memcpy(p->thread.traps,
    1.31 +           sizeof(d->thread.i387));
    1.32 +
    1.33 +    memcpy(d->thread.traps,
    1.34             &c->trap_ctxt,
    1.35 -           sizeof(p->thread.traps));
    1.36 +           sizeof(d->thread.traps));
    1.37 +
    1.38  #ifdef ARCH_HAS_FAST_TRAP
    1.39 -    SET_DEFAULT_FAST_TRAP(&p->thread);
    1.40 -    (void)set_fast_trap(p, c->fast_trap_idx);
    1.41 +    SET_DEFAULT_FAST_TRAP(&d->thread);
    1.42 +    if ( (rc = (int)set_fast_trap(d, c->fast_trap_idx)) != 0 )
    1.43 +        return rc;
    1.44  #endif
    1.45 -    p->mm.ldt_base = c->ldt_base;
    1.46 -    p->mm.ldt_ents = c->ldt_ents;
    1.47 -    SET_GDT_ENTRIES(p, DEFAULT_GDT_ENTRIES);
    1.48 -    SET_GDT_ADDRESS(p, DEFAULT_GDT_ADDRESS);
    1.49 -    if ( c->gdt_ents != 0 )
    1.50 -        (void)set_gdt(p,
    1.51 -                      c->gdt_frames,
    1.52 -                      c->gdt_ents);
    1.53 -    p->thread.guestos_ss = c->guestos_ss;
    1.54 -    p->thread.guestos_sp = c->guestos_esp;
    1.55 +
    1.56 +    d->mm.ldt_base = c->ldt_base;
    1.57 +    d->mm.ldt_ents = c->ldt_ents;
    1.58 +
    1.59 +    d->thread.guestos_ss = c->guestos_ss;
    1.60 +    d->thread.guestos_sp = c->guestos_esp;
    1.61 +
    1.62      for ( i = 0; i < 8; i++ )
    1.63 -        (void)set_debugreg(p, i, c->debugreg[i]);
    1.64 -    p->event_selector    = c->event_callback_cs;
    1.65 -    p->event_address     = c->event_callback_eip;
    1.66 -    p->failsafe_selector = c->failsafe_callback_cs;
    1.67 -    p->failsafe_address  = c->failsafe_callback_eip;
    1.68 +        (void)set_debugreg(d, i, c->debugreg[i]);
    1.69 +
    1.70 +    d->event_selector    = c->event_callback_cs;
    1.71 +    d->event_address     = c->event_callback_eip;
    1.72 +    d->failsafe_selector = c->failsafe_callback_cs;
    1.73 +    d->failsafe_address  = c->failsafe_callback_eip;
    1.74      
    1.75      phys_basetab = c->pt_base;
    1.76 -    p->mm.pagetable = mk_pagetable(phys_basetab);
    1.77 -    get_page_and_type(&frame_table[phys_basetab>>PAGE_SHIFT], p, 
    1.78 -                      PGT_base_page_table);
    1.79 +    d->mm.pagetable = mk_pagetable(phys_basetab);
    1.80 +    if ( !get_page_and_type(&frame_table[phys_basetab>>PAGE_SHIFT], d, 
    1.81 +                            PGT_base_page_table) )
    1.82 +        return -EINVAL;
    1.83 +
    1.84 +    /* Failure to set GDT is harmless. */
    1.85 +    SET_GDT_ENTRIES(d, DEFAULT_GDT_ENTRIES);
    1.86 +    SET_GDT_ADDRESS(d, DEFAULT_GDT_ADDRESS);
    1.87 +    if ( c->gdt_ents != 0 )
    1.88 +    {
    1.89 +        if ( (rc = (int)set_gdt(d, c->gdt_frames, c->gdt_ents)) != 0 )
    1.90 +        {
    1.91 +            put_page_and_type(&frame_table[phys_basetab>>PAGE_SHIFT]);
    1.92 +            return rc;
    1.93 +        }
    1.94 +    }
    1.95 +
    1.96 +    return 0;
    1.97  }
    1.98  
    1.99  #if defined(__i386__)
     2.1 --- a/xen/common/domain.c	Thu Sep 09 00:24:45 2004 +0000
     2.2 +++ b/xen/common/domain.c	Thu Sep 09 00:59:30 2004 +0000
     2.3 @@ -296,7 +296,8 @@ int final_setup_guestos(struct domain *p
     2.4          goto out;
     2.5      }
     2.6      
     2.7 -    arch_final_setup_guestos(p,c);
     2.8 +    if ( (rc = arch_final_setup_guestos(p,c)) != 0 )
     2.9 +        goto out;
    2.10  
    2.11      /* Set up the shared info structure. */
    2.12      update_dom_time(p->shared_info);
     3.1 --- a/xen/include/asm-x86/domain.h	Thu Sep 09 00:24:45 2004 +0000
     3.2 +++ b/xen/include/asm-x86/domain.h	Thu Sep 09 00:59:30 2004 +0000
     3.3 @@ -4,7 +4,7 @@
     3.4  
     3.5  extern void arch_do_createdomain(struct domain *d);
     3.6  
     3.7 -extern void arch_final_setup_guestos(
     3.8 +extern int  arch_final_setup_guestos(
     3.9      struct domain *d, full_execution_context_t *c);
    3.10  
    3.11  extern void free_perdomain_pt(struct domain *d);