diff options
author | kaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk> | 2003-05-08 15:01:20 +0000 |
---|---|---|
committer | kaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk> | 2003-05-08 15:01:20 +0000 |
commit | 5188bc32cd76fad6ca42dd2f7be747b64e05a41a (patch) | |
tree | ae5043c6ca654bf8d0d3599e8c58c355d926342e | |
parent | 9c9974b78fea6c9f2ca8c47d79cc3d14e3b030f7 (diff) | |
download | xen-5188bc32cd76fad6ca42dd2f7be747b64e05a41a.tar.gz xen-5188bc32cd76fad6ca42dd2f7be747b64e05a41a.tar.bz2 xen-5188bc32cd76fad6ca42dd2f7be747b64e05a41a.zip |
bitkeeper revision 1.220 (3eba7140Xm9JLEfxz1hmvq2pg7H5UA)
sched.h, domain.c, dom0_ops.c:
Robustify domain creation and building.
-rw-r--r-- | xen/common/dom0_ops.c | 7 | ||||
-rw-r--r-- | xen/common/domain.c | 15 | ||||
-rw-r--r-- | xen/include/xeno/sched.h | 1 |
3 files changed, 16 insertions, 7 deletions
diff --git a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c index fb8d44429e..7a13d135c5 100644 --- a/xen/common/dom0_ops.c +++ b/xen/common/dom0_ops.c @@ -20,7 +20,9 @@ extern unsigned int alloc_new_dom_mem(struct task_struct *, unsigned int); static unsigned int get_domnr(void) { static unsigned int domnr = 0; - return ++domnr; + do { domnr = (domnr+1) & ((1<<20)-1); } + while ( find_domain_by_id(domnr) != NULL ); + return domnr; } static void build_page_list(struct task_struct *p) @@ -75,6 +77,9 @@ long do_dom0_op(dom0_op_t *u_dom0_op) case DOM0_STARTDOMAIN: { struct task_struct * p = find_domain_by_id(op.u.meminfo.domain); + ret = -EINVAL; + if ( (p == NULL) || !(p->flags & PF_CONSTRUCTED) ) + break; wake_up(p); reschedule(p); ret = p->domain; diff --git a/xen/common/domain.c b/xen/common/domain.c index e2a8306357..3a83aa4d10 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -48,7 +48,7 @@ struct task_struct *do_newdomain(unsigned int dom_id, unsigned int cpu) p->domain = dom_id; p->processor = cpu; - sprintf (p->name, "Domain-%d", dom_id); + sprintf(p->name, "Domain-%d", dom_id); spin_lock_init(&p->blk_ring_lock); spin_lock_init(&p->page_lock); @@ -331,6 +331,9 @@ int final_setup_guestos(struct task_struct * p, dom_meminfo_t * meminfo) net_vif_t *net_vif; int i; + if ( (p->flags & PF_CONSTRUCTED) ) + return -EINVAL; + /* High entries in page table must contain hypervisor * mem mappings - set them up. */ @@ -386,11 +389,6 @@ int final_setup_guestos(struct task_struct * p, dom_meminfo_t * meminfo) virt_startinfo_addr->dom_id = p->domain; virt_startinfo_addr->flags = IS_PRIV(p) ? SIF_PRIVILEGED : 0; - if( virt_startinfo_addr->mod_len ) - printk("Initrd module present %08lx (%08lx)\n", - virt_startinfo_addr->mod_start, - virt_startinfo_addr->mod_len); - /* Add virtual network interfaces and point to them in startinfo. */ while (meminfo->num_vifs-- > 0) { net_vif = create_net_vif(p->domain); @@ -417,6 +415,8 @@ int final_setup_guestos(struct task_struct * p, dom_meminfo_t * meminfo) __asm__ __volatile__ ( "mov %%eax,%%cr3" : : "a" (pagetable_val(current->mm.pagetable))); __sti(); + + p->flags |= PF_CONSTRUCTED; new_thread(p, (unsigned long)meminfo->virt_load_addr, @@ -461,6 +461,7 @@ int setup_guestos(struct task_struct *p, dom0_newdomain_t *params, /* Sanity! */ if ( p->domain != 0 ) BUG(); + if ( (p->flags & PF_CONSTRUCTED) ) BUG(); /* * This is all a bit grim. We've moved the modules to the "safe" physical @@ -700,6 +701,8 @@ int setup_guestos(struct task_struct *p, dom0_newdomain_t *params, __write_cr3_counted(pagetable_val(current->mm.pagetable)); __sti(); + p->flags |= PF_CONSTRUCTED; + new_thread(p, (unsigned long)virt_load_address, (unsigned long)virt_stack_address, diff --git a/xen/include/xeno/sched.h b/xen/include/xeno/sched.h index c5ab334b00..f696b5ab56 100644 --- a/xen/include/xeno/sched.h +++ b/xen/include/xeno/sched.h @@ -58,6 +58,7 @@ extern struct mm_struct init_mm; #define PF_DONEFPUINIT 0x1 /* Has the FPU been initialised for this task? */ #define PF_USEDFPU 0x2 /* Has this task used the FPU since last save? */ #define PF_GUEST_STTS 0x4 /* Has the guest OS requested 'stts'? */ +#define PF_CONSTRUCTED 0x8 /* Has the guest OS been fully built yet? */ #include <xeno/vif.h> #include <xeno/block.h> |