From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sylvestre Gallon Subject: Re: How works Xen mmu ? Date: Thu, 3 Jun 2010 17:23:08 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On Thu, Jun 3, 2010 at 3:29 PM, Keir Fraser wro= te: > > > > On 03/06/2010 14:16, "Sylvestre Gallon" wrote: > >> addr =3D get_cr3(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // getting p= age directory >> addr &=3D 0xfffff000; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // remove pdir= flags >> addr =3D ((uint32_t*) addr_[0]; =A0 =A0 // get address of first page dir >> (0xb8000 is in the first pdir) >> addr +=3D 0xb8 * 4; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0// 0xb8000 mu= st be the pte 0xb8 into pdir >> 0 >> >> mmu.ptr =3D pte | MMU_NORMAL_PT_UPDATE; >> mmu.val =3D 0xb8000 | 0x3; =A0 =A0 =A0 =A0// 0x3 for pte present and rw = flags >> >> HYPERVISOR_mmu_update(&mmu, 1, NULL, DOMID_SELF); >> >> while(42); >> >> But when I try this code I get an unhandled page fault :/ >> >> Do I have misunderstood something ? > > This is closer, but page table entries will be 64 bits not 32 bits (hence > use uint64_t). And also the page tables will have three or four levels > (depending on whether your guest is 32-bit PAE or 64-bit). So in the 64-b= it > case for example, you would read cr3 to get pagedir_1, then index into > pagedir_1 to get pagedir_2, then index into pagedir_2 to get pagedir_3, t= hen > index into pagedir_3 to get the pagetable. And mmu.ptr would point at an > entry in that pagetable. > OK , I see. I still have a question, does I need to compile my kernel with -m64 ? If not how can I use 64bits addresses ? Thanks for your help. Cheers, --=20 Sylvestre Gallon