From: Pasi =?iso-8859-1?Q?K=E4rkk=E4inen?= Subject: Re: xen.git branch reorg / success with 2.6.30-rc3 pv_ops dom0 Date: Thu, 11 Jun 2009 22:34:37 +0300 Message-ID: <20090611193437.GX24960@edu.joroinen.fi> References: <20090605154130.GB24960@edu.joroinen.fi> <1244217948.27370.213.camel@zakaz.uk.xensource.com> <1244218353.27370.216.camel@zakaz.uk.xensource.com> <20090605181925.GC24960@edu.joroinen.fi> <1244475935.27370.309.camel@zakaz.uk.xensource.com> <1244476858.27370.325.camel@zakaz.uk.xensource.com> <4A2E9BC3.4060507@goop.org> <1244710938.27370.502.camel@zakaz.uk.xensource.com> <1244711914.27370.511.camel@zakaz.uk.xensource.com> <20090611182709.GV24960@edu.joroinen.fi> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline In-Reply-To: <20090611182709.GV24960@edu.joroinen.fi> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Campbell Cc: Jeremy Fitzhardinge , Xen-devel List-Id: xen-devel@lists.xenproject.org On Thu, Jun 11, 2009 at 09:27:09PM +0300, Pasi K=E4rkk=E4inen wrote: > On Thu, Jun 11, 2009 at 10:18:34AM +0100, Ian Campbell wrote: > > Pasi, to validate the theory that you are seeing races between unpinn= ing > > and kmap_atomic_pte can you give this biguglystick approach to solvin= g > > it a go. > >=20 >=20 > Guess what..=20 >=20 > Now my dom0 didn't crash !! (with only this patch applied). > It survived kernel compilation just fine.. first time so far with pv_op= s dom0. >=20 > I'll try again, just in case. >=20 Yep, I tried again, and it still worked.=20 No crashes anymore with this patch :) Congratulations and thanks! -- Pasi >=20 > > diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c > > index 1729178..beeb8e8 100644 > > --- a/arch/x86/xen/mmu.c > > +++ b/arch/x86/xen/mmu.c > > @@ -1145,9 +1145,12 @@ static int xen_unpin_page(struct mm_struct *mm= , struct page *page, > > return 0; /* never need to flush on unpin */ > > } > > =20 > > +static DEFINE_SPINLOCK(hack_lock); /* Hack to sync unpin against kma= p_atomic_pte */ > > + > > /* Release a pagetables pages back as normal RW */ > > static void __xen_pgd_unpin(struct mm_struct *mm, pgd_t *pgd) > > { > > + spin_lock(&hack_lock); > > xen_mc_batch(); > > =20 > > xen_do_pin(MMUEXT_UNPIN_TABLE, PFN_DOWN(__pa(pgd))); > > @@ -1173,6 +1176,7 @@ static void __xen_pgd_unpin(struct mm_struct *m= m, pgd_t *pgd) > > __xen_pgd_walk(mm, pgd, xen_unpin_page, USER_LIMIT); > > =20 > > xen_mc_issue(0); > > + spin_unlock(&hack_lock); > > } > > =20 > > static void xen_pgd_unpin(struct mm_struct *mm) > > @@ -1521,6 +1525,9 @@ static void xen_pgd_free(struct mm_struct *mm, = pgd_t *pgd) > > static void *xen_kmap_atomic_pte(struct page *page, enum km_type typ= e) > > { > > pgprot_t prot =3D PAGE_KERNEL; > > + void *ret; > > + > > + spin_lock(&hack_lock); > > =20 > > if (PagePinned(page)) > > prot =3D PAGE_KERNEL_RO; > > @@ -1530,7 +1537,11 @@ static void *xen_kmap_atomic_pte(struct page *= page, enum km_type type) > > page_to_pfn(page), type, > > (unsigned long)pgprot_val(prot) & _PAGE_RW ? "WRITE" : "REA= D"); > > =20 > > - return kmap_atomic_prot(page, type, prot); > > + ret =3D kmap_atomic_prot(page, type, prot); > > + > > + spin_unlock(&hack_lock); > > + > > + return ret; > > } > > #endif > > =20 > >=20 > >=20 >=20