From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: Finding EPT entries for nested guest in L0 Date: Wed, 9 Nov 2016 00:34:25 +0100 Message-ID: <940752a6-b92e-00a4-cc83-8d0c61bb8362@redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit To: Rohith Kugve Raghavendra , kvm@vger.kernel.org Return-path: Received: from mail-wm0-f50.google.com ([74.125.82.50]:38084 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752119AbcKHXe3 (ORCPT ); Tue, 8 Nov 2016 18:34:29 -0500 Received: by mail-wm0-f50.google.com with SMTP id f82so211225312wmf.1 for ; Tue, 08 Nov 2016 15:34:28 -0800 (PST) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On 08/11/2016 21:27, Rohith Kugve Raghavendra wrote: > I have 2 questions. > > 1. In nested VMs that use multi-dimensional page tables( EPT on EPT) > where exactly in the code are EPT ( 0 -> 2) entries constructed? I can > know from the Turtles paper that these entries are created by > combining EPT 1->2 and EPT 0->1. But I can find that in KVM code. It's in mmu.c, same as for shadow pages. vcpu->arch.nested_mmu contains the MMU for L0->L2, while vcpu->arch.mmu contains the MMU for L0->L1. vcpu->arch.walk_mmu points to one of the two, depending on who was running at the time of the last vmexit. In particular, prepare_vmcs02 (through nested_ept_init_mmu_context) sets vcpu->arch.walk_mmu to &vcpu->arch.nested_mmu. > 2. Are there rmap entries for EPT 0->2 pages maintained? I am trying > to write protect nested guest GFN's directly in L0 ( without letting > L1 do it) but I don't know how to find the EPT 0->2 entry for a given > L2 guest GFN. Yes, they are. There is only one rmap for both vcpu->arch.mmu and vcpu->arch.nested_mmu, but for EPT02 pages of course vcpu->arch.mmu should be direct mapped and not have any rmap. Thanks, Paolo