From: Tim Deegan Subject: [PATCH] Re: Re: paging_domctl() missing break statements? Date: Fri, 25 Jun 2010 14:50:52 +0100 Message-ID: <20100625135052.GE31695@whitby.uk.xensource.com> References: <4B7BC96F020000780002FC9A@vpn.id2.novell.com> <20100217095806.GK368@whitby.uk.xensource.com> <4C21FDB3.8000402@redhat.com> <20100623125146.GB31695@whitby.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="ZGiS0Q5IWpPtfppv" Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Patrick Colp Cc: Jan, Paolo Bonzini , "xen-devel@lists.xensource.com" , Keir Fraser , Beulich List-Id: xen-devel@lists.xenproject.org --ZGiS0Q5IWpPtfppv Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline At 17:27 +0100 on 23 Jun (1277314052), Patrick Colp wrote: > The problem with the patch is that with the break statements in the > "else" cases of XEN_DOMCTL_SHADOW_OP_ENABLE and > XEN_DOMCTL_SHADOW_OP_OFF it currently falls through. Simply sticking > break in at the bottom changes these control flow paths. Yep - and that would be the right thing to do; the problem is that it unmasked a different bug that had crept into the shadow-disable code. Since this bug was harmless, the other bug was a hypervisor crash, and the release was imminent, we just reverted to the old code. The attached patch reinstates the breaks in the flow control (and folds two identical cases together) and fixes the memory leak that was causing the crash. Signed-off-by: Tim Deegan Tim. -- Tim Deegan Principal Software Engineer, XenServer Engineering Citrix Systems UK Ltd. (Company #02937203, SL9 0BG) --ZGiS0Q5IWpPtfppv Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: attachment; filename="shadow-disable" diff -r 4001ab0d5785 xen/arch/x86/mm/paging.c --- a/xen/arch/x86/mm/paging.c Fri Jun 25 13:23:49 2010 +0100 +++ b/xen/arch/x86/mm/paging.c Fri Jun 25 14:35:19 2010 +0100 @@ -700,23 +700,21 @@ */ switch ( sc->op ) { + + case XEN_DOMCTL_SHADOW_OP_ENABLE: + if ( !(sc->mode & XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY) ) + break; + /* Else fall through... */ case XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY: if ( hap_enabled(d) ) hap_logdirty_init(d); return paging_log_dirty_enable(d); - case XEN_DOMCTL_SHADOW_OP_ENABLE: - if ( sc->mode & XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY ) - { - if ( hap_enabled(d) ) - hap_logdirty_init(d); - return paging_log_dirty_enable(d); - } - case XEN_DOMCTL_SHADOW_OP_OFF: if ( paging_mode_log_dirty(d) ) if ( (rc = paging_log_dirty_disable(d)) != 0 ) return rc; + break; case XEN_DOMCTL_SHADOW_OP_CLEAN: case XEN_DOMCTL_SHADOW_OP_PEEK: diff -r 4001ab0d5785 xen/arch/x86/mm/shadow/common.c --- a/xen/arch/x86/mm/shadow/common.c Fri Jun 25 13:23:49 2010 +0100 +++ b/xen/arch/x86/mm/shadow/common.c Fri Jun 25 14:35:19 2010 +0100 @@ -3241,9 +3241,12 @@ { int i; mfn_t *oos_snapshot = v->arch.paging.shadow.oos_snapshot; - for(i = 0; i < SHADOW_OOS_PAGES; i++) + for ( i = 0; i < SHADOW_OOS_PAGES; i++ ) if ( mfn_valid(oos_snapshot[i]) ) + { shadow_free(d, oos_snapshot[i]); + oos_snapshot[i] = _mfn(INVALID_MFN); + } } #endif /* OOS */ } @@ -3395,17 +3398,23 @@ #endif make_cr3(v, pagetable_get_pfn(v->arch.guest_table)); +#if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC) + { + int i; + mfn_t *oos_snapshot = v->arch.paging.shadow.oos_snapshot; + for ( i = 0; i < SHADOW_OOS_PAGES; i++ ) + if ( mfn_valid(oos_snapshot[i]) ) + { + shadow_free(d, oos_snapshot[i]); + oos_snapshot[i] = _mfn(INVALID_MFN); + } + } +#endif /* OOS */ } /* Pull down the memory allocation */ if ( sh_set_allocation(d, 0, NULL) != 0 ) - { - // XXX - How can this occur? - // Seems like a bug to return an error now that we've - // disabled the relevant shadow mode. - // - return -ENOMEM; - } + BUG(); /* In fact, we will have BUG()ed already */ shadow_hash_teardown(d); SHADOW_PRINTK("un-shadowing of domain %u done." " Shadow pages total = %u, free = %u, p2m=%u\n", --ZGiS0Q5IWpPtfppv Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --ZGiS0Q5IWpPtfppv--