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 17:52:06 +0100 Message-ID: <20081125165206.GA9267@hall.aurel32.net> References: <20081112190037.GA4009@volta.aurel32.net> <20081120094821.GA990@dmt.cnet> <20081125095717.GB23072@volta.aurel32.net> 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]:51998 "EHLO hall.aurel32.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751668AbYKYQwI (ORCPT ); Tue, 25 Nov 2008 11:52:08 -0500 Content-Disposition: inline In-Reply-To: <20081125095717.GB23072@volta.aurel32.net> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Nov 25, 2008 at 10:57:17AM +0100, Aurelien Jarno wrote: > On Thu, Nov 20, 2008 at 10:48:21AM +0100, Marcelo Tosatti wrote: > > Hi Aurelien, > Hi, >=20 > > 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 a= nymore > > > under KVM. The ext2fs translator issues a strange error message: > > >=20 > > > |=A0Hurd server bootstrap: ext2fs.static[device:hd0s3] execext2fs= =2Estatic: /build/bui > > > |=A0ldd/hurd-20080607/build-tree/hurd/ext2fs/dir.c:494: dirscanbl= ock: Assertion `dp- > > > |=A0>dn->dirents[idx] =3D=3D -1 || dp->dn->dirents[idx] =3D=3D ne= ntries' failed. - > > > |=A0>dn->dirents[idx] =3D=3D -1 || dp->dn->dirents[idx] =3D=3D ne= ntries' 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 t= o use > > > Hurd image=A0[1]. The error message from the ext2fs translator is= not > > > exactly the same, but it still fails. > >=20 > > It seems Hurd does not always explicitly flush the TLB via cr0/cr3/= cr4 > > writes or invlpg after updating pagetables. Debugging shows that OO= S is > > properly syncing the sptes wrt the guest pagetables, and that all p= ages > > are synced before guest re-entry on TLB flush exits. >=20 Looking more precisely at the code, Hurd (actually GNU Mach) flushes th= e TLB via cr3, but just *before* updating the pagetables. I have no idea why it is done that way, but it seems to be correct given the way the Intel MMU works. However, it fails to comply with the recommendations from Intel ("5.2 Recommended Invalidation"), which if I understand=20 correctly, have been taken as a basis for implementing out of sync=20 shadow. I have confirmed that by patching the GNU Mach code so that TLB are flushed before and after modifying pagetables. --=20 .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' aurel32@debian.org | aurelien@aurel32.net `- people.debian.org/~aurel32 | www.aurel32.net