From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH] KVM: MMU: Segregate mmu pages created with different cr4.pge settings Date: Wed, 7 Jan 2009 08:43:50 -0200 Message-ID: <20090107104350.GA4170@amt.cnet> References: <20081221184146.8E00B250012@cleopatra.tlv.redhat.com> <49621FA9.5080903@suse.de> <49633564.7070403@redhat.com> <20090106141151.GA3701@amt.cnet> <49636AE7.4090108@redhat.com> <20090106164311.GA4902@amt.cnet> <49645066.4040009@suse.de> <496481AE.1060102@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Alexander Graf , "kvm@vger.kernel.org" , joerg.roedel@amd.com To: Avi Kivity Return-path: Received: from mx2.redhat.com ([66.187.237.31]:44264 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751580AbZAGKoD (ORCPT ); Wed, 7 Jan 2009 05:44:03 -0500 Content-Disposition: inline In-Reply-To: <496481AE.1060102@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Jan 07, 2009 at 12:19:26PM +0200, Avi Kivity wrote: > Alexander Graf wrote: >> Using this patch it works. But if I read it correctly, that doesn't >> actually fix anything but only treats NPT/EPT special, which it >> shouldn't, should it? > > The patch doesn't fix the bug but is nevertheless correct. cr4.pge only > matters to the mmu if using the shadow mmu; with tdp it only wastes > memory (and exposes the bug which you encountered). > > So, wrt to the bug you saw, it's a workaround, but it's also a correct > fix for another bug. > >> Maybe this actually even breaks EPT? >> > > It shouldn't. > >> I remember having seen a lot of CR4 hacks in svm.c when npt is enabled. >> Maybe that is related? >> > > No. cr4 controls the guest mmu, but with npt the guest mmu is > completely virtualized, so we need to ignore those bits. Let me shoot at one direction: a shadow page with PGE bit in either state is created. Later that shadow page is nuked (via mmu notifiers, for example). Then set_cr4 changes base_role.pge to a different value, and a fault creates a new shadow page and instantiates that in the tree. Perhaps a svm_flush_tlb is required in such case, when updating a previously valid pagetable entry? Joerg?