ia64/xen-unstable
changeset 438:f852e2cc6f5c
bitkeeper revision 1.220 (3eba7140Xm9JLEfxz1hmvq2pg7H5UA)
sched.h, domain.c, dom0_ops.c:
Robustify domain creation and building.
sched.h, domain.c, dom0_ops.c:
Robustify domain creation and building.
author | kaf24@scramble.cl.cam.ac.uk |
---|---|
date | Thu May 08 15:01:20 2003 +0000 (2003-05-08) |
parents | 49cf8ae8cecc |
children | 76eba4e532dd |
files | xen/common/dom0_ops.c xen/common/domain.c xen/include/xeno/sched.h |
line diff
1.1 --- a/xen/common/dom0_ops.c Thu May 08 10:40:26 2003 +0000 1.2 +++ b/xen/common/dom0_ops.c Thu May 08 15:01:20 2003 +0000 1.3 @@ -20,7 +20,9 @@ extern unsigned int alloc_new_dom_mem(st 1.4 static unsigned int get_domnr(void) 1.5 { 1.6 static unsigned int domnr = 0; 1.7 - return ++domnr; 1.8 + do { domnr = (domnr+1) & ((1<<20)-1); } 1.9 + while ( find_domain_by_id(domnr) != NULL ); 1.10 + return domnr; 1.11 } 1.12 1.13 static void build_page_list(struct task_struct *p) 1.14 @@ -75,6 +77,9 @@ long do_dom0_op(dom0_op_t *u_dom0_op) 1.15 case DOM0_STARTDOMAIN: 1.16 { 1.17 struct task_struct * p = find_domain_by_id(op.u.meminfo.domain); 1.18 + ret = -EINVAL; 1.19 + if ( (p == NULL) || !(p->flags & PF_CONSTRUCTED) ) 1.20 + break; 1.21 wake_up(p); 1.22 reschedule(p); 1.23 ret = p->domain;
2.1 --- a/xen/common/domain.c Thu May 08 10:40:26 2003 +0000 2.2 +++ b/xen/common/domain.c Thu May 08 15:01:20 2003 +0000 2.3 @@ -48,7 +48,7 @@ struct task_struct *do_newdomain(unsigne 2.4 p->domain = dom_id; 2.5 p->processor = cpu; 2.6 2.7 - sprintf (p->name, "Domain-%d", dom_id); 2.8 + sprintf(p->name, "Domain-%d", dom_id); 2.9 2.10 spin_lock_init(&p->blk_ring_lock); 2.11 spin_lock_init(&p->page_lock); 2.12 @@ -331,6 +331,9 @@ int final_setup_guestos(struct task_stru 2.13 net_vif_t *net_vif; 2.14 int i; 2.15 2.16 + if ( (p->flags & PF_CONSTRUCTED) ) 2.17 + return -EINVAL; 2.18 + 2.19 /* High entries in page table must contain hypervisor 2.20 * mem mappings - set them up. 2.21 */ 2.22 @@ -386,11 +389,6 @@ int final_setup_guestos(struct task_stru 2.23 virt_startinfo_addr->dom_id = p->domain; 2.24 virt_startinfo_addr->flags = IS_PRIV(p) ? SIF_PRIVILEGED : 0; 2.25 2.26 - if( virt_startinfo_addr->mod_len ) 2.27 - printk("Initrd module present %08lx (%08lx)\n", 2.28 - virt_startinfo_addr->mod_start, 2.29 - virt_startinfo_addr->mod_len); 2.30 - 2.31 /* Add virtual network interfaces and point to them in startinfo. */ 2.32 while (meminfo->num_vifs-- > 0) { 2.33 net_vif = create_net_vif(p->domain); 2.34 @@ -417,6 +415,8 @@ int final_setup_guestos(struct task_stru 2.35 __asm__ __volatile__ ( 2.36 "mov %%eax,%%cr3" : : "a" (pagetable_val(current->mm.pagetable))); 2.37 __sti(); 2.38 + 2.39 + p->flags |= PF_CONSTRUCTED; 2.40 2.41 new_thread(p, 2.42 (unsigned long)meminfo->virt_load_addr, 2.43 @@ -461,6 +461,7 @@ int setup_guestos(struct task_struct *p, 2.44 2.45 /* Sanity! */ 2.46 if ( p->domain != 0 ) BUG(); 2.47 + if ( (p->flags & PF_CONSTRUCTED) ) BUG(); 2.48 2.49 /* 2.50 * This is all a bit grim. We've moved the modules to the "safe" physical 2.51 @@ -700,6 +701,8 @@ int setup_guestos(struct task_struct *p, 2.52 __write_cr3_counted(pagetable_val(current->mm.pagetable)); 2.53 __sti(); 2.54 2.55 + p->flags |= PF_CONSTRUCTED; 2.56 + 2.57 new_thread(p, 2.58 (unsigned long)virt_load_address, 2.59 (unsigned long)virt_stack_address,
3.1 --- a/xen/include/xeno/sched.h Thu May 08 10:40:26 2003 +0000 3.2 +++ b/xen/include/xeno/sched.h Thu May 08 15:01:20 2003 +0000 3.3 @@ -58,6 +58,7 @@ extern struct mm_struct init_mm; 3.4 #define PF_DONEFPUINIT 0x1 /* Has the FPU been initialised for this task? */ 3.5 #define PF_USEDFPU 0x2 /* Has this task used the FPU since last save? */ 3.6 #define PF_GUEST_STTS 0x4 /* Has the guest OS requested 'stts'? */ 3.7 +#define PF_CONSTRUCTED 0x8 /* Has the guest OS been fully built yet? */ 3.8 3.9 #include <xeno/vif.h> 3.10 #include <xeno/block.h>