Received: from eggs.gnu.org ([208.118.235.92]:50751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4NYO-0002XN-On for qemu-devel@nongnu.org; Wed, 22 Aug 2012 22:53:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4NYL-00051s-Pt for qemu-devel@nongnu.org; Wed, 22 Aug 2012 22:53:52 -0400 Received: from csmailer.cs.nctu.edu.tw ([140.113.235.130]:24082) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4NYL-0004zt-2e for qemu-devel@nongnu.org; Wed, 22 Aug 2012 22:53:49 -0400 Date: Thu, 23 Aug 2012 10:53:37 +0800 From: =?utf-8?B?6Zmz6Z+L5Lu7IChXZWktUmVuIENoZW4p?= Message-ID: <20120823025337.GA27969@cs.nctu.edu.tw> References: <20120821072134.GA81486@cs.nctu.edu.tw> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="SLDf9lqlvOQaIe6s" Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Dump guest page table inside QEMU makes system hang List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Filippov Cc: Blue Swirl , qemu-devel@nongnu.org, =?utf-8?B?6Zmz6Z+L5Lu7IChXZWktUmVuIENoZW4p?= --SLDf9lqlvOQaIe6s Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > >> The system will hang while booting. However, if I comment > >> cpu_physical_memory_read in function dump_guest_pgtable, there > >> is no problem. What I am missing here? Thanks. > > > > cpu_physical_memory_read() can cause faults or other side effects lik= e > > MMIO. Using cpu_get_phys_page_debug() may help. > > >=20 > Maybe you just need to avoid accessing unsuitable physical addresses? > Or maybe 'if (env->cr[0] & CR0_PG_MASK)' is not strong enough, may > (CR0_PG_MASK | CR0_PE_MASK) be better? >=20 > At what stage does it hang? What CR3 value changes are observed before > the hang? It's quite embarrassing. The code I posted before is buggy, and it dump= s all 1024 * 1024 page table entries. It takes a lot of time, so that I think t= he system hangs. Attach is the code snipt what I am using, which works fine = now. Another question is, I would like to know the hva corresponding to gpa (i= .e., the guest page pointed by guest pte). Do you happen to know there is such gpa2hva function in QEMU? Thanks. Regards, chenwj --=20 Wei-Ren Chen (=E9=99=B3=E9=9F=8B=E4=BB=BB) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667 Homepage: http://people.cs.nctu.edu.tw/~chenwj --SLDf9lqlvOQaIe6s Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="qemu.patch" // we only consider x86 w/o pae static void dump_guest_pgtable(CPUX86State *env) { int i, j; target_ulong pde_addr, pte_addr; target_ulong phyaddr, phyaddr2; uint32_t pde, pte; pde_addr = (env->cr[3] & ~0xfff) & env->a20_mask; // first level page directory, iterate pde for (i = 0; i < NUM_ENTRY; ++i) { phyaddr = (pde_addr + i * 4) & env->a20_mask; pde = ldl_phys(phyaddr); pd[i] = pde; if (!(pde & PG_PRESENT_MASK)) continue; pte_addr = (pde & ~0xfff) & env->a20_mask; // second level page table, iterate pte for (j = 0; j < NUM_ENTRY; ++j) { phyaddr2 = (pte_addr + j * 4) & env->a20_mask; pte = ldl_phys(phyaddr2); if (!(pte & PG_PRESENT_MASK)) pt[i][j] = 0; pt[i][j] = pte; } } } --SLDf9lqlvOQaIe6s--