qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jes Sorensen <jes@sgi.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Kevin O'Connor <kevin@koconnor.net>, qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] FW_CFG_EMULATOR
Date: Mon, 03 Aug 2009 17:05:41 +0200	[thread overview]
Message-ID: <4A76FCC5.2020803@sgi.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 393 bytes --]

Hi,

Here's a patch for QEMU which tells the BIOS it is running on
QEMU/KQEMU/KVM.

I have a set if patches for Seabios using this to runtime select KVM
and QEMU settings, eliminating the need for a specially compiled BIOS
binary.

If we can agree on the interface, I would look into doing something
similar for BOCHS as well.

I will be posting the Seabios patches in a minute.

Cheers,
Jes


[-- Attachment #2: 0003-qemu-cfg-emu-runtime.patch --]
[-- Type: text/x-patch, Size: 3603 bytes --]

Provide FW_CFG_EMULATOR info to the BIOS

This option provides info to the BIOS informing it which emulator it
is running on top of.

The emulator version is designed as a master rev, for the upper 8
bits, and a minor version for the lower 8 bits. This allows one to
specify QEMU_KVM vs QEMU_KQEMU for example. It should leave space for
other emulators to register themselves too.

If the BIOS' probe for FW_CFG fails, it is expected it sets it's
emulator version to the same as CFG_EMU_NONE.

I have a set of patches for Seabios using this to determine it is
running on top of QEMU and KVM. This allows setting certain KVM
specific bits, and also determining at runtime that Seabios is running
on top of QEMU, eliminating the #define CONFIG_KVM.

Signed-off-by: Jes Sorensen

---
 hw/fw_cfg.c |    3 +++
 hw/fw_cfg.h |   11 ++++++++++-
 vl.c        |    6 ++++++
 3 files changed, 19 insertions(+), 1 deletion(-)

Index: qemu/hw/fw_cfg.c
===================================================================
--- qemu.orig/hw/fw_cfg.c
+++ qemu/hw/fw_cfg.c
@@ -38,6 +38,8 @@
 
 #define FW_CFG_SIZE 2
 
+extern uint16_t emu_type;
+
 typedef struct _FWCfgEntry {
     uint16_t len;
     uint8_t *data;
@@ -281,6 +283,7 @@ void *fw_cfg_init(uint32_t ctl_port, uin
     fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus);
     fw_cfg_add_i16(s, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
     fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu);
+    fw_cfg_add_i16(s, FW_CFG_EMULATOR, emu_type);
 
     register_savevm("fw_cfg", -1, 1, fw_cfg_save, fw_cfg_load, s);
     qemu_register_reset(fw_cfg_reset, s);
Index: qemu/hw/fw_cfg.h
===================================================================
--- qemu.orig/hw/fw_cfg.h
+++ qemu/hw/fw_cfg.h
@@ -17,7 +17,8 @@
 #define FW_CFG_NUMA             0x0d
 #define FW_CFG_BOOT_MENU        0x0e
 #define FW_CFG_MAX_CPUS         0x0f
-#define FW_CFG_MAX_ENTRY        0x10
+#define FW_CFG_EMULATOR         0x10
+#define FW_CFG_MAX_ENTRY        0x11
 
 #define FW_CFG_WRITE_CHANNEL    0x4000
 #define FW_CFG_ARCH_LOCAL       0x8000
@@ -25,6 +26,14 @@
 
 #define FW_CFG_INVALID          0xffff
 
+/*
+ * Values for FW_CFG_EMULATOR
+ */
+#define CFG_EMU_NONE            0x0000
+#define CFG_EMU_QEMU            0x0100
+#define CFG_EMU_QEMU_KVM        0x0101
+#define CFG_EMU_QEMU_KQEMU      0x0102
+
 #ifndef NO_QEMU_PROTOS
 typedef void (*FWCfgCallback)(void *opaque, uint8_t *data);
 
Index: qemu/vl.c
===================================================================
--- qemu.orig/vl.c
+++ qemu/vl.c
@@ -142,6 +142,7 @@ int main(int argc, char **argv)
 #include "hw/smbios.h"
 #include "hw/xen.h"
 #include "hw/qdev.h"
+#include "hw/fw_cfg.h"
 #include "bt-host.h"
 #include "net.h"
 #include "monitor.h"
@@ -270,6 +271,8 @@ uint8_t qemu_uuid[16];
 static QEMUBootSetHandler *boot_set_handler;
 static void *boot_set_opaque;
 
+uint16_t emu_type = CFG_EMU_QEMU;
+
 /***********************************************************/
 /* x86 ISA bus support */
 
@@ -5426,14 +5429,17 @@ int main(int argc, char **argv, char **e
 #ifdef CONFIG_KQEMU
             case QEMU_OPTION_enable_kqemu:
                 kqemu_allowed = 1;
+                emu_type = CFG_EMU_QEMU_KQEMU;
                 break;
             case QEMU_OPTION_kernel_kqemu:
                 kqemu_allowed = 2;
+                emu_type = CFG_EMU_QEMU_KQEMU;
                 break;
 #endif
 #ifdef CONFIG_KVM
             case QEMU_OPTION_enable_kvm:
                 kvm_allowed = 1;
+                emu_type = CFG_EMU_QEMU_KVM;
 #ifdef CONFIG_KQEMU
                 kqemu_allowed = 0;
 #endif

             reply	other threads:[~2009-08-03 15:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-03 15:05 Jes Sorensen [this message]
2009-08-05 10:59 ` [Qemu-devel] [PATCH] FW_CFG_EMULATOR Avi Kivity
2009-08-05 12:26   ` Jes Sorensen

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=4A76FCC5.2020803@sgi.com \
    --to=jes@sgi.com \
    --cc=aliguori@us.ibm.com \
    --cc=kevin@koconnor.net \
    --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).