ia64/xen-unstable
changeset 2531:991cb10336b9
bitkeeper revision 1.1159.83.6 (4153ed456y_MMR7jU-EZHilZihBC2w)
fix handling of out of memory condition when enabling shadow mode.
fix handling of out of memory condition when enabling shadow mode.
author | iap10@labyrinth.cl.cam.ac.uk |
---|---|
date | Fri Sep 24 09:47:49 2004 +0000 (2004-09-24) |
parents | 6dde6c567e14 |
children | 4d222bf4d125 f96aba5772bd f097c7aa7420 |
files | xen/arch/x86/shadow.c |
line diff
1.1 --- a/xen/arch/x86/shadow.c Fri Sep 24 09:33:23 2004 +0000 1.2 +++ b/xen/arch/x86/shadow.c Fri Sep 24 09:47:49 2004 +0000 1.3 @@ -200,8 +200,6 @@ int shadow_mode_enable( struct domain *p 1.4 struct shadow_status **fptr; 1.5 int i; 1.6 1.7 - m->shadow_mode = mode; 1.8 - 1.9 // allocate hashtable 1.10 m->shadow_ht = xmalloc(shadow_ht_buckets * 1.11 sizeof(struct shadow_status)); 1.12 @@ -241,16 +239,25 @@ int shadow_mode_enable( struct domain *p 1.13 if( m->shadow_dirty_bitmap == NULL ) 1.14 { 1.15 m->shadow_dirty_bitmap_size = 0; 1.16 + BUG(); 1.17 goto nomem; 1.18 } 1.19 memset(m->shadow_dirty_bitmap,0,m->shadow_dirty_bitmap_size/8); 1.20 } 1.21 1.22 + m->shadow_mode = mode; 1.23 + 1.24 // call shadow_mk_pagetable 1.25 __shadow_mk_pagetable( m ); 1.26 return 0; 1.27 1.28 nomem: 1.29 + if( m->shadow_ht ) { 1.30 + xfree( m->shadow_ht ); m->shadow_ht = NULL; }; 1.31 + 1.32 + if( m->shadow_ht_extras ) { 1.33 + xfree( m->shadow_ht_extras ); m->shadow_ht_extras = NULL; }; 1.34 + 1.35 return -ENOMEM; 1.36 } 1.37 1.38 @@ -285,7 +292,10 @@ void __shadow_mode_disable(struct domain 1.39 } 1.40 1.41 // free the hashtable itself 1.42 - xfree( &m->shadow_ht[0] ); 1.43 + xfree( m->shadow_ht ); 1.44 + 1.45 + m->shadow_ht = NULL; 1.46 + m->shadow_ht_extras = NULL; 1.47 } 1.48 1.49 static int shadow_mode_table_op(struct domain *d, 1.50 @@ -314,8 +324,6 @@ static int shadow_mode_table_op(struct d 1.51 switch(op) 1.52 { 1.53 case DOM0_SHADOW_CONTROL_OP_FLUSH: 1.54 - // XXX THIS IS VERY DANGEROUS : MUST ENSURE THE PTs ARE NOT IN USE ON 1.55 - // OTHER CPU -- fix when we get sched sync pause. 1.56 __free_shadow_table( m ); 1.57 break; 1.58 1.59 @@ -452,12 +460,12 @@ int shadow_mode_control(struct domain *d 1.60 else if ( cmd == DOM0_SHADOW_CONTROL_OP_ENABLE_TEST ) 1.61 { 1.62 shadow_mode_disable(d); 1.63 - shadow_mode_enable(d, SHM_test); 1.64 + rc = shadow_mode_enable(d, SHM_test); 1.65 } 1.66 else if ( cmd == DOM0_SHADOW_CONTROL_OP_ENABLE_LOGDIRTY ) 1.67 { 1.68 shadow_mode_disable(d); 1.69 - shadow_mode_enable(d, SHM_logdirty); 1.70 + rc = shadow_mode_enable(d, SHM_logdirty); 1.71 } 1.72 else if ( shadow_mode(d) && 1.73 (cmd >= DOM0_SHADOW_CONTROL_OP_FLUSH) &&