From patchwork Fri May 28 12:44:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 102887 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4SCjQI6019490 for ; Fri, 28 May 2010 12:45:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753471Ab0E1MpX (ORCPT ); Fri, 28 May 2010 08:45:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19111 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753634Ab0E1MpV (ORCPT ); Fri, 28 May 2010 08:45:21 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4SCjL1V012087 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 28 May 2010 08:45:21 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4SCjKhk023007; Fri, 28 May 2010 08:45:20 -0400 Received: from amt.cnet (vpn-9-227.rdu.redhat.com [10.11.9.227]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o4SCjIQD026101; Fri, 28 May 2010 08:45:19 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 85E3B68A8C3; Fri, 28 May 2010 09:45:01 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o4SCixXD004360; Fri, 28 May 2010 09:44:59 -0300 Date: Fri, 28 May 2010 09:44:59 -0300 From: Marcelo Tosatti To: kvm Cc: Avi Kivity , Andrea Arcangeli Subject: KVM: MMU: always invalidate and flush on spte page size change Message-ID: <20100528124459.GA3734@amt.cnet> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 28 May 2010 12:45:27 +0000 (UTC) Index: kvm/arch/x86/kvm/mmu.c =================================================================== --- kvm.orig/arch/x86/kvm/mmu.c +++ kvm/arch/x86/kvm/mmu.c @@ -1952,6 +1952,8 @@ static void mmu_set_spte(struct kvm_vcpu child = page_header(pte & PT64_BASE_ADDR_MASK); mmu_page_remove_parent_pte(child, sptep); + __set_spte(sptep, shadow_trap_nonpresent_pte); + kvm_flush_remote_tlbs(vcpu->kvm); } else if (pfn != spte_to_pfn(*sptep)) { pgprintk("hfn old %lx new %lx\n", spte_to_pfn(*sptep), pfn); @@ -2015,6 +2017,16 @@ static int __direct_map(struct kvm_vcpu break; } + if (is_shadow_present_pte(*iterator.sptep) && + !is_large_pte(*iterator.sptep)) + continue; + + if (is_large_pte(*iterator.sptep)) { + rmap_remove(vcpu->kvm, iterator.sptep); + __set_spte(iterator.sptep, shadow_trap_nonpresent_pte); + kvm_flush_remote_tlbs(vcpu->kvm); + } + if (*iterator.sptep == shadow_trap_nonpresent_pte) { u64 base_addr = iterator.addr;