qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: Stefan Hajnoczi <stefanha@gmail.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	Michal Suchanek <hramrach@centrum.cz>,
	Kevin O'Connor <kevin@koconnor.net>, Avi Kivity <avi@redhat.com>,
	Jordan Justen <jljusten@gmail.com>
Subject: [Qemu-devel] Re: RFC: emulation of system flash
Date: Thu, 10 Mar 2011 13:27:07 +0100	[thread overview]
Message-ID: <4D78C39B.1060404@siemens.com> (raw)
In-Reply-To: <20110310121741.GD14805@redhat.com>

On 2011-03-10 13:17, Gleb Natapov wrote:
> On Thu, Mar 10, 2011 at 01:06:14PM +0100, Jan Kiszka wrote:
>> On 2011-03-10 12:48, Gleb Natapov wrote:
>>> On Thu, Mar 10, 2011 at 12:27:55PM +0100, Jan Kiszka wrote:
>>>> On 2011-03-10 10:47, Gleb Natapov wrote:
>>>>> On Wed, Mar 09, 2011 at 08:51:23PM -0800, Jordan Justen wrote:
>>>>>> Hi all,
>>>>>>
>>>>>> I have documented a simple flash-like device which I think could be
>>>>>> useful for qemu/kvm in some cases.  (Particularly for allowing
>>>>>> persistent UEFI non-volatile variables.)
>>>>>>
>>>>>> http://wiki.qemu.org/Features/System_Flash
>>>>>>
>>>>>> Let me know if you have any suggestions or concerns.
>>>>>>
>>>>>
>>>>> Two things. First You suggest to replace -bios with -flash. This will
>>>>> make firmware upgrade painful process that will have to be performed
>>>>> from inside the guest since the same flash image will contain both
>>>>> firmware and whatever data was stored on a flash which presumably you
>>>>> want to reuse after upgrading a firmware. My suggestion is to extend
>>>>> -bios option like this:
>>>>>
>>>>> -bios bios.bin,flash=flash.bin,flash_base=addr
>>>>>
>>>>> flash.bin will be mapped at address flash_base, or, if flash_base is not
>>>>> present, just below bios.bin.
>>>>
>>>> ...or define -flash in a way that allows mapping the bios image as an
>>>> overlay to the otherwise guest-managed flash image.
>>>>
>>> It is not much different from what I proposed. The result will be the
>>> same. Even option syntax will probably be the same :)
>>
>> -bios is PC-centric, the new command should be generic.
>>
> Well, I tried to reuse the option we already have instead of introducing
> another one. -bios can be extended beyond PC and represent general
> firmware specification. But I like the option you proposed in other
> email too, so I am not going to defend this one.
> 
> 
>>>
>>>>>
>>>>> Second. I asked how flash is programmed because interfaces like CFI
>>>>> where you write into flash memory address range to issue commands cannot
>>>>> be emulated efficiently in KVM. KVM supports either regular memory slots
>>>>> or IO memory, but in your proposal the same memory behaves as IO on
>>>>> write and regular memory on read. Better idea would be to present
>>>>> non-volatile flash as ISA virtio device. Should be simple to implement.
>>>>
>>>> Why not enhancing KVM memory slots to support direct read access while
>>>> writes are trapped and forwarded to a user space device model?
>>> Yes we can make memory slot that will be treated as memory on read and
>>> IO on write, but first relying on that will prevent using flash interface
>>> on older kernels and second it is not enough to implement the proposal.
>>> When magic value is written into an address, the address become IO for
>>> reading too, but KVM slot granularity is page, not byte, so KVM will
>>> have to remove the slot to make it IO, but KVM can't execute code from
>>> IO region (yet), so we will not be able to run firmware from flash and
>>> simultaneously write into the flash. 
>>
>> Yeah, right. I remember that this was also hairy over TCG if you tried
>> to optimize flash emulation so that writing doesn't take orders of
>> magnitude longer than on real HW.
>>
>> BTW, the programming granularity is not bytes but chips with common CFI.
>> But that's still tricky if you want to run code from the same chip while
>> updating parts of it. The easiest workaround would be handling the
>> overlay regions as ROM all the time. Not accurate but realizable without
>> kernel changes.
>>
> So flash will be always IO and overlay will be always ROM. This will

Yes, and once we have KVM support for read-RAM/write-IO slots, flash
will be able to switch between ROM and IO mode just like it already does
under TCG.

> work, except BIOS upgrade from inside the guest will not be possible,
> but since we do not support this today too it doesn't bother me to much.
> 
>>>
>>>>                                                                 Virtio
>>>> means that you have to patch the guest (which might be something else
>>>> than flexible Linux...).
>>>>
>>> This intended to be used by firmware only and we control that.
>>
>> I'm thinking beyond this use case, beyond firmware flashes, beyond x86.
>>
> OK, but since both interfaces (virtio and one proposed in the wiki) are PV
> I fail to see the difference between them for any use case. If we
> implement CFI then it will be another story.

I'm proposing CFI (which already exists) with BIOS exception to avoid PV
as far as possible.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

  reply	other threads:[~2011-03-10 12:29 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-10  4:51 [Qemu-devel] RFC: emulation of system flash Jordan Justen
2011-03-10  9:10 ` [Qemu-devel] " Avi Kivity
2011-03-10 18:43   ` Jordan Justen
2011-03-10 21:52     ` Carl-Daniel Hailfinger
2011-03-10 22:14       ` Jordan Justen
2011-03-10 22:31         ` Carl-Daniel Hailfinger
2011-03-10 22:58           ` Jordan Justen
2011-03-10 23:41             ` Carl-Daniel Hailfinger
2011-03-11  2:12               ` Jordan Justen
2011-03-10  9:47 ` Gleb Natapov
2011-03-10 11:27   ` Jan Kiszka
2011-03-10 11:46     ` Jan Kiszka
2011-03-10 11:53       ` Paolo Bonzini
2011-03-10 12:07         ` Jan Kiszka
2011-03-10 19:03       ` Jordan Justen
2011-03-10 19:23         ` Anthony Liguori
2011-03-10 20:05           ` Jordan Justen
2011-03-10 11:48     ` Gleb Natapov
2011-03-10 12:06       ` Jan Kiszka
2011-03-10 12:17         ` Gleb Natapov
2011-03-10 12:27           ` Jan Kiszka [this message]
2011-03-10 19:08             ` Jordan Justen
2011-03-10 19:13               ` Gleb Natapov
2011-03-10 21:46         ` Carl-Daniel Hailfinger
2011-03-10 22:11           ` Scott Wood
2011-03-10 21:41       ` Carl-Daniel Hailfinger
2011-03-10 22:05         ` Jordan Justen
2011-03-10 18:59   ` Jordan Justen
2011-03-10 19:12     ` Gleb Natapov
2011-03-10 19:50       ` Jordan Justen
2011-03-10 20:08         ` Антон Кочков
2011-03-10 20:21         ` Gleb Natapov
2011-03-11 21:41           ` Jordan Justen
2011-03-14 14:29             ` Gleb Natapov
2011-03-10 21:37 ` [Qemu-devel] " Carl-Daniel Hailfinger
2011-03-10 21:55   ` Jordan Justen
2011-03-10 22:10     ` Carl-Daniel Hailfinger
2011-03-10 22:29       ` Jordan Justen
2011-03-10 23:53         ` Carl-Daniel Hailfinger
2011-03-11  0:19       ` [Qemu-devel] " Jan Kiszka
2011-03-11  0:27         ` Carl-Daniel Hailfinger
2011-03-11 19:09           ` Jordan Justen
2011-03-11 23:10             ` Michal Suchanek
2011-03-12  9:24             ` Jan Kiszka

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=4D78C39B.1060404@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=avi@redhat.com \
    --cc=gleb@redhat.com \
    --cc=hramrach@centrum.cz \
    --cc=jljusten@gmail.com \
    --cc=kevin@koconnor.net \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /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).