From: Tim Deegan Subject: Re: machine address Date: Thu, 9 Apr 2015 11:11:51 +0100 Message-ID: <20150409101151.GB17031@deinos.phlegethon.org> References: <4c67540fa2376dc7672ec9987bf79aee@inp-toulouse.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: George Dunlap Cc: HANNAS YAYA Issa , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org At 10:26 +0100 on 31 Mar (1427797566), George Dunlap wrote: > On Mon, Mar 30, 2015 at 3:00 PM, HANNAS YAYA Issa > wrote: > > Hi > > When there is a page fault the trapper of the page fault in the hypervisor > > is do_page_fault in xen/arch/x86/traps.c right? > > That's for PV guests. For HVM guests, the page fault causes a VMEXIT, > which will be handled in > xen/arch/x86/hvm/vmx/vmx.c:vmx_vmexit_handler() (on Intel). > > > in this funcion i found a method read_cr2() which return the virtual adrress > > of the page who generate the page fault. > > My question is : is it possible to get the machine address of the page table > > entry for this virtual address? > > In general the way you have to do that is to use the virtual address > to walk the guest's pagetables (exactly the same way the hardware > would do on a TLB miss). > > For HVM guests (or PV guests in shadow mode) there's already code to > do walk for you in xen/arch/x86/mm/guest_walk.c:guest_walk(). You can > see how it's called from the HAP code and the shadow code if you want. > > I don't immediately see a walker for PV guests. There one in __page_fault_type(). You can also use the linear pagetable mappings, if you know what you're doing -- see, e.g., guest_map_l1e() which does something very like this. Cheers, Tim.