qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Jordan Justen <jljusten@gmail.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>,
	Alexander Graf <agraf@suse.de>, Avi Kivity <avi@redhat.com>,
	kvm-devel <kvm@vger.kernel.org>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] KVM/QEMU: Support executing from flash device
Date: Sun, 4 Mar 2012 10:12:34 +0200	[thread overview]
Message-ID: <20120304081234.GL10743@redhat.com> (raw)
In-Reply-To: <CAFe8ug837GWOD=Km3y7FWs4ENEWZ-vmeGRHTi3L_9v-2mBUMEw@mail.gmail.com>

On Sat, Mar 03, 2012 at 10:56:02PM -0800, Jordan Justen wrote:
> On Tue, Oct 25, 2011 at 00:47, Avi Kivity <avi@redhat.com> wrote:
> > The core issue that kvm (the kernel part) supports two styles of memory:
> > read/write RAM, and read/write MMIO.  ROM 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.  The 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).
> 
> 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.
> 
> 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.
> 
> 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
> 
> Is this plan heading in the right direction?
> 
> 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?
> 
> -Jordan

--
			Gleb.

  reply	other threads:[~2012-03-04  8:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-04  6:56 [Qemu-devel] KVM/QEMU: Support executing from flash device Jordan Justen
2012-03-04  8:12 ` Gleb Natapov [this message]
2012-03-04 10:36   ` Avi Kivity
2012-03-04 10:38     ` Gleb Natapov
2012-03-04 10:46       ` Avi Kivity
2012-03-04 21:11         ` Jordan Justen
2012-03-04 10:44 ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120304081234.GL10743@redhat.com \
    --to=gleb@redhat.com \
    --cc=agraf@suse.de \
    --cc=avi@redhat.com \
    --cc=jljusten@gmail.com \
    --cc=jordan.l.justen@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).