From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: Trying to switch EPTP for execute-protecting guest pages Date: Tue, 24 Nov 2015 12:44:12 +0100 Message-ID: <56544D8C.10307@redhat.com> References: <565348BA.4020905@illinois.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit To: "Estrada, Zachary J" , kvm@vger.kernel.org Return-path: Received: from mail-wm0-f48.google.com ([74.125.82.48]:35696 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751736AbbKXLoP (ORCPT ); Tue, 24 Nov 2015 06:44:15 -0500 Received: by wmuu63 with SMTP id u63so92561742wmu.0 for ; Tue, 24 Nov 2015 03:44:14 -0800 (PST) In-Reply-To: <565348BA.4020905@illinois.edu> Sender: kvm-owner@vger.kernel.org List-ID: On 23/11/2015 18:11, Estrada, Zachary J wrote: > I'm playing around with EPTs and kvm to track execution in the guest. > I've created a separate set of EPTs (and copied the last level entries > from the real tables, minus execute permissions) but I'm not getting > exits where I expect. I also have code in handle_ept_violation to > preserve those permissions for any non-execute ept violations. > > Here is what I am calling within a VM Exit handler: > --- > kvm_mmu_unload(vcpu); > vcpu->arch.mmu.root_hpa = eptp; > kvm_x86_ops->set_tdp_cr3(vcpu, eptp); > kvm_mmu_load(vcpu); > kvm_flush_remote_tlbs(vcpu->kvm); > --- > > I think some of this is overkill, but am I missing something? I think I > may need to flush the rmaps too, but I'm not exactly sure how. My suggestion is: 1) use tracing and check that kvm_mmu_get_page is being called correctly. 2) there is already code for write protection. Try copying that code instead of doing a complete reimplementation. Paolo