Received: from eggs.gnu.org ([208.118.235.92]:44322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Szjs5-0002EN-Ac for qemu-devel@nongnu.org; Fri, 10 Aug 2012 03:43:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Szjs2-0000Mt-AN for qemu-devel@nongnu.org; Fri, 10 Aug 2012 03:43:01 -0400 Received: from csmailer.cs.nctu.edu.tw ([140.113.235.130]:32911) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Szjs1-0000MP-4w for qemu-devel@nongnu.org; Fri, 10 Aug 2012 03:42:58 -0400 Date: Fri, 10 Aug 2012 15:42:49 +0800 From: =?utf-8?B?6Zmz6Z+L5Lu7IChXZWktUmVuIENoZW4p?= Message-ID: <20120810074249.GA12986@cs.nctu.edu.tw> References: <20120808073856.GA84469@cs.nctu.edu.tw> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] Is it possible to detect guest OS modifying pte inside QEMU? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel@nongnu.org, =?utf-8?B?6Zmz6Z+L5Lu7IChXZWktUmVuIENoZW4p?= Hi Peter, On Wed, Aug 08, 2012 at 09:05:18AM +0100, Peter Maydell wrote: > On 8 August 2012 08:38, =E9=99=B3=E9=9F=8B=E4=BB=BB (Wei-Ren Chen) wrote: > > Just for research, we are studying if we can leave the guest page > > table walk to underlying hardware rather than using software emulatio= n > > (like current approach). So, maybe (if *doable*) we can use x86 hardw= are > > to help us to walk guest (like ARM) page table. The rough idea is we > > have to maintain a x86-format shadow page table for the corresponding > > ARM page table, point host cr3 to the shadow page table, and let x86 > > hardware do its job. The problem is, we have to aware that guest is > > modifying its guest page table entry so that we can sync its corrspon= ding > > shadow page table. But, we still haven't find a good way to know when > > the guest OS is modifying guest page table entry. >=20 > Make it read-only for the guest, and then when you get the exception wh= en > the guest tries to write it, you can (a) do what you need to do and (b) > emulate the failing write insn. Let me try if I understand you correctly, Get cp15:c2 value (guest virtual address), then call something like qemu_get_ram_ptr with cp15:c2 to get its corresponding host virtual address. Then we mprotect(hva, 16k, PROT_READ). Is that a right direction? That's what I thought when you said make it read-only. But after reading Blue's reply [1], it seems he give another approach. =20 Regards, chenwj [1] http://www.mail-archive.com/qemu-devel@nongnu.org/msg125104.html --=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