From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aurelien Jarno Subject: Re: Out of sync shadow core breaks Hurd Date: Tue, 25 Nov 2008 10:57:17 +0100 Message-ID: <20081125095717.GB23072@volta.aurel32.net> References: <20081112190037.GA4009@volta.aurel32.net> <20081120094821.GA990@dmt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from hall.aurel32.net ([88.191.82.174]:57842 "EHLO hall.aurel32.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752092AbYKYJ5U (ORCPT ); Tue, 25 Nov 2008 04:57:20 -0500 Content-Disposition: inline In-Reply-To: <20081120094821.GA990@dmt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Nov 20, 2008 at 10:48:21AM +0100, Marcelo Tosatti wrote: > Hi Aurelien, Hi, > On Wed, Nov 12, 2008 at 08:00:37PM +0100, Aurelien Jarno wrote: > > Hi, > >=20 > > Starting with kvm-76 (and including kvm-79), Hurd does not boot any= more > > under KVM. The ext2fs translator issues a strange error message: > >=20 > > |=A0Hurd server bootstrap: ext2fs.static[device:hd0s3] execext2fs.s= tatic: /build/bui > > |=A0ldd/hurd-20080607/build-tree/hurd/ext2fs/dir.c:494: dirscanbloc= k: Assertion `dp- > > |=A0>dn->dirents[idx] =3D=3D -1 || dp->dn->dirents[idx] =3D=3D nent= ries' failed. - > > |=A0>dn->dirents[idx] =3D=3D -1 || dp->dn->dirents[idx] =3D=3D nent= ries' failed. > >=20 > > Bisecting the problem, I have found that it comes from this patch: > >=20 > > |=A0641fb03992b20aa640781a245f6b7136f0b845e4 is first bad commit > > | commit 641fb03992b20aa640781a245f6b7136f0b845e4 > > |=A0Author: Marcelo Tosatti > > |=A0Date: Tue Sep 23 13:18:39 2008 -0300 > > |=A0 > > |=A0 KVM: MMU: out of sync shadow core v2 > > |=A0 > > |=A0 Allow guest pagetables to go out of sync. > > |=A0 > > |=A0 Signed-off-by: Marcelo Tosatti > > | Signed-off-by: Avi Kivity > >=20 > > The problem can be workarounded loading the kvm module with=20 > > oos_shadow=3D0. > >=20 > > The easiest way to reproduce the problem is to download a ready to = use > > Hurd image=A0[1]. The error message from the ext2fs translator is n= ot > > exactly the same, but it still fails. >=20 > It seems Hurd does not always explicitly flush the TLB via cr0/cr3/cr= 4 > writes or invlpg after updating pagetables. Debugging shows that OOS = is > properly syncing the sptes wrt the guest pagetables, and that all pag= es > are synced before guest re-entry on TLB flush exits. Thanks for your investigation. > The Intel TLB doc says (5.1 "Invalidation Instructions"): >=20 > (Other instructions and operations may invalidate entries in the TLBs > and the paging structure caches, but the instructions identified abov= e > are recommended.) >=20 > As a test, syncing on every exit makes it happy: >=20 > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 7a2aeba..47e2550 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -3052,6 +3052,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vc= pu, struct kvm_run *kvm_run) > =20 > kvm_lapic_sync_from_vapic(vcpu); > =20 > + kvm_mmu_sync_roots(vcpu); > + > r =3D kvm_x86_ops->handle_exit(kvm_run, vcpu); > out: > return r; >=20 > It would be necessary to confirm this by hacking Hurd to flush on eve= ry > pagetable update. Perhaps something like >=20 > RCS file: /sources/hurd/gnumach/i386/intel/pmap.c,v > retrieving revision 1.4.2.22 > diff -u -r1.4.2.22 pmap.c > --- pmap.c 11 Nov 2008 02:24:18 -0000 1.4.2.22 > +++ pmap.c 20 Nov 2008 12:47:01 -0000 > @@ -82,7 +82,7 @@ > #include > #include > =20 > -#define WRITE_PTE(pte_p, pte_entry) *(pte_p) =3D (pte_entry); > +#define WRITE_PTE(pte_p, pte_entry) *(pte_p) =3D (pte_entry); > flush_tlb(); > =20 > /* > * Private data structures. >=20 >=20 I have tried this patch, but it doesn't change anything. I'll try to se= e if there are more place when the PTE is written. --=20 .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' aurel32@debian.org | aurelien@aurel32.net `- people.debian.org/~aurel32 | www.aurel32.net