From: Tim Deegan Subject: [PATCH] Fix recursive lock p2m lock acquisition in POD code Date: Thu, 1 Oct 2009 12:04:12 +0100 Message-ID: <20091001110412.GB9914@whitby.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="E39vaYmALEf/7YXx" Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --E39vaYmALEf/7YXx Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline The POD code can take the p2m lock from inside a lookup. This causes a crash if anyone calls gfn_to_mfn* with the p2m lock held, which is quite a few places. Make the POD code understand that it may be called with the lock held, and DTRT about talking or releasing it. Signed-off-by: Tim Deegan --E39vaYmALEf/7YXx Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: attachment; filename="pod-p2m-locking" diff -r 6472342c8ab0 xen/arch/x86/mm/p2m.c --- a/xen/arch/x86/mm/p2m.c Wed Sep 30 08:51:21 2009 +0100 +++ b/xen/arch/x86/mm/p2m.c Thu Oct 01 11:58:25 2009 +0100 @@ -1067,21 +1067,29 @@ l1_pgentry_t *p2m_entry, int order, p2m_query_t q) { + /* Only take the lock if we don't already have it. Otherwise it + * wouldn't be safe to do p2m lookups with the p2m lock held */ + int do_locking = !p2m_locked_by_me(d->arch.p2m); int r; - p2m_lock(d->arch.p2m); + + if ( do_locking ) + p2m_lock(d->arch.p2m); + audit_p2m(d); /* Check to make sure this is still PoD */ if ( p2m_flags_to_type(l1e_get_flags(*p2m_entry)) != p2m_populate_on_demand ) { - p2m_unlock(d->arch.p2m); + if ( do_locking ) + p2m_unlock(d->arch.p2m); return 0; } r = p2m_pod_demand_populate(d, gfn, order, q); audit_p2m(d); - p2m_unlock(d->arch.p2m); + if ( do_locking ) + p2m_unlock(d->arch.p2m); return r; } --E39vaYmALEf/7YXx 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 --E39vaYmALEf/7YXx--