From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:32793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S46Yc-0007O4-4M for qemu-devel@nongnu.org; Sun, 04 Mar 2012 03:12:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S46Ya-0005QM-Du for qemu-devel@nongnu.org; Sun, 04 Mar 2012 03:12:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52026) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S46Ya-0005QG-3Z for qemu-devel@nongnu.org; Sun, 04 Mar 2012 03:12:40 -0500 Date: Sun, 4 Mar 2012 10:12:34 +0200 From: Gleb Natapov Message-ID: <20120304081234.GL10743@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: Subject: Re: [Qemu-devel] KVM/QEMU: Support executing from flash device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jordan Justen Cc: Jordan Justen , Alexander Graf , Avi Kivity , kvm-devel , qemu-devel@nongnu.org On Sat, Mar 03, 2012 at 10:56:02PM -0800, Jordan Justen wrote: > On Tue, Oct 25, 2011 at 00:47, Avi Kivity wrote: > > The core issue that kvm (the kernel part) supports two styles of memory: > > read/write RAM, and read/write MMIO. =9AROM wants writes to be ignored, > > and rom/device wants reads serviced from memory and writes serviced by > > userspace (as MMIO). > > > > It should not be too hard to patch kvm to support these additional two > > styles. =9AThe entry point is the KVM_SET_USER_MEMORY_REGION ioctl to > > define the new attributes for the region, and kvm_mmu_page_fault() to > > map these pages as read-only and emulate writes (for ROM/device regions= ). >=20 > Additional context for CC'd kvm-devel: I would like to support > executing from an emulated flash memory on kvm. The flash memory > would be a CFI (Firmware Hub-like) device which is programmed via MMIO > at the same addresses in memory where the execution would occur. >=20 > What is needed is: > 1. The ability to set a region to allow read/exec, > but trap to qemu on writes. > 2. qemu should then be able to set the region > to trap on reads/exec/writes. Do you want to execute code from a flash while it traps on read/exec? KVM emulator can't do that. > 3. qemu should be able to then restore the region > to the initial state. >=20 > Here is my plan: > 1. Add KVM_CAP_REGION_WRITE_TRAP > 2. Add kvm_memory_region::flags > KVM_MEMSLOT_TRAP_WRITES > 3. Update page table creation to trap on writes when > KVM_MEMSLOT_TRAP_WRITES is set >=20 > Is this plan heading in the right direction? >=20 > Regarding emulating ROM (as you mentioned above): I think that it can > trap to qemu and QEMU can ignore it. This would be a performance hit, > but I don't think it is expected that lots of writes to a ROM will > occur. Do you agree? >=20 > -Jordan -- Gleb.