From: Jordan Justen <jordan.l.justen@intel.com>
To: qemu-devel@nongnu.org
Cc: Jordan Justen <jordan.l.justen@intel.com>
Subject: [Qemu-devel] [PATCH v3 4/5] pc_sysfw: allow flash (-pflash) memory to be used with KVM
Date: Mon, 6 May 2013 00:23:45 -0700 [thread overview]
Message-ID: <1367825026-3146-5-git-send-email-jordan.l.justen@intel.com> (raw)
In-Reply-To: <1367825026-3146-1-git-send-email-jordan.l.justen@intel.com>
When pc-sysfw.rom_only != 0, flash memory will be
usable with kvm. In order to enable flash memory mode,
a pflash device must be created. (For example, by
using the -pflash command line parameter.)
Usage of a flash memory device with kvm requires the
KVM READONLY memory capability, and kvm will abort if
a flash device is used with an older kvm which does
not support this capability.
If a flash device is not used, then qemu/kvm will
operate in the original rom-mode.
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
---
hw/block/pc_sysfw.c | 50 +++++++++++++++++++++++++++++++-------------------
1 file changed, 31 insertions(+), 19 deletions(-)
diff --git a/hw/block/pc_sysfw.c b/hw/block/pc_sysfw.c
index aad8614..301eb96 100644
--- a/hw/block/pc_sysfw.c
+++ b/hw/block/pc_sysfw.c
@@ -215,28 +215,40 @@ void pc_system_firmware_init(MemoryRegion *rom_memory)
qdev_init_nofail(DEVICE(sysfw_dev));
- if (sysfw_dev->rom_only) {
- old_pc_system_rom_init(rom_memory);
- return;
- }
-
pflash_drv = drive_get(IF_PFLASH, 0, 0);
- /* Currently KVM cannot execute from device memory.
- Use old rom based firmware initialization for KVM. */
- /*
- * This is a Bad Idea, because it makes enabling/disabling KVM
- * guest-visible. Do it only in bug-compatibility mode.
- */
- if (pc_sysfw_flash_vs_rom_bug_compatible && kvm_enabled()) {
- if (pflash_drv != NULL) {
- fprintf(stderr, "qemu: pflash cannot be used with kvm enabled\n");
- exit(1);
- } else {
- sysfw_dev->rom_only = 1;
- old_pc_system_rom_init(rom_memory);
- return;
+ if (pc_sysfw_flash_vs_rom_bug_compatible) {
+ /*
+ * This is a Bad Idea, because it makes enabling/disabling KVM
+ * guest-visible. Do it only in bug-compatibility mode.
+ */
+ if (kvm_enabled()) {
+ if (pflash_drv != NULL) {
+ fprintf(stderr, "qemu: pflash cannot be used with kvm enabled\n");
+ exit(1);
+ } else {
+ /* In old pc_sysfw_flash_vs_rom_bug_compatible mode, we assume
+ * that KVM cannot execute from device memory. In this case, we
+ * use old rom based firmware initialization for KVM. But, since
+ * this is different from non-kvm mode, this behavior is
+ * undesirable */
+ sysfw_dev->rom_only = 1;
+ }
}
+ } else if (pflash_drv == NULL) {
+ /* When a pflash drive is not found, use rom-mode */
+ sysfw_dev->rom_only = 1;
+ } else if (kvm_enabled() && !kvm_readonly_mem_enabled()) {
+ /* Older KVM cannot execute from device memory. So, flash memory
+ * cannot be used unless the readonly memory kvm capability is present. */
+ fprintf(stderr, "qemu: pflash with kvm requires KVM readonly memory support\n");
+ exit(1);
+ }
+
+ /* If rom-mode is active, use the old pc system rom initialization. */
+ if (sysfw_dev->rom_only) {
+ old_pc_system_rom_init(rom_memory);
+ return;
}
/* If a pflash drive is not found, then create one using
--
1.7.10.4
next prev parent reply other threads:[~2013-05-06 7:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-06 7:23 [Qemu-devel] [PATCH v3 0/5] KVM flash memory support Jordan Justen
2013-05-06 7:23 ` [Qemu-devel] [PATCH v3 1/5] kvm: add kvm_readonly_mem_enabled Jordan Justen
2013-05-06 7:23 ` [Qemu-devel] [PATCH v3 2/5] kvm: support using KVM_MEM_READONLY flag for readonly regions Jordan Justen
2013-05-06 7:23 ` [Qemu-devel] [PATCH v3 3/5] pflash_cfi01: memory region should be set to enable readonly mode Jordan Justen
2013-05-06 7:23 ` Jordan Justen [this message]
2013-05-06 7:23 ` [Qemu-devel] [PATCH v3 5/5] pc_sysfw: change rom_only default to 0 Jordan Justen
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=1367825026-3146-5-git-send-email-jordan.l.justen@intel.com \
--to=jordan.l.justen@intel.com \
--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).