From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: jsnow@redhat.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH 1/6] pc: initialize fw_cfg earlier
Date: Thu, 18 Sep 2014 18:17:49 +0200 [thread overview]
Message-ID: <1411057074-11157-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1411057074-11157-1-git-send-email-pbonzini@redhat.com>
Notifiers are called in LIFO order. In our case, we want fw_cfg to use
the output of the machine-specific notifier: we will process the -kernel
command-line option there, and this will modify the boot order which
fw_cfg's notifier processes.
Because fw_cfg's notifier has to run last, we have to create the device
early, before pc_guest_info_init registers its own notifier.
It turns out that pc_guest_info_init is itself a good place to create
fw_cfg. This also makes Xen more similar to native machine types.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/i386/pc.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index b6c9b61..b95ac18 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -104,6 +104,8 @@ static struct e820_entry *e820_table;
static unsigned e820_entries;
struct hpet_fw_config hpet_cfg = {.count = UINT8_MAX};
+static FWCfgState *bochs_bios_init(void);
+
void gsi_handler(void *opaque, int n, int level)
{
GSIState *s = opaque;
@@ -1093,6 +1095,9 @@ PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
PcGuestInfo *guest_info = &guest_info_state->info;
int i, j;
+ guest_info->fw_cfg = bochs_bios_init();
+ rom_set_fw(guest_info->fw_cfg);
+
guest_info->ram_size_below_4g = below_4g_mem_size;
guest_info->ram_size = below_4g_mem_size + above_4g_mem_size;
guest_info->apic_id_limit = pc_apic_id_limit(max_cpus);
@@ -1173,22 +1178,17 @@ FWCfgState *xen_load_linux(const char *kernel_filename,
PcGuestInfo *guest_info)
{
int i;
- FWCfgState *fw_cfg;
assert(kernel_filename != NULL);
- fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0);
- rom_set_fw(fw_cfg);
-
- load_linux(fw_cfg, kernel_filename, initrd_filename,
+ load_linux(guest_info->fw_cfg, kernel_filename, initrd_filename,
kernel_cmdline, below_4g_mem_size);
for (i = 0; i < nb_option_roms; i++) {
assert(!strcmp(option_rom[i].name, "linuxboot.bin") ||
!strcmp(option_rom[i].name, "multiboot.bin"));
rom_add_option(option_rom[i].name, option_rom[i].bootindex);
}
- guest_info->fw_cfg = fw_cfg;
- return fw_cfg;
+ return guest_info->fw_cfg;
}
FWCfgState *pc_memory_init(MachineState *machine,
@@ -1202,7 +1202,7 @@ FWCfgState *pc_memory_init(MachineState *machine,
int linux_boot, i;
MemoryRegion *ram, *option_rom_mr;
MemoryRegion *ram_below_4g, *ram_above_4g;
- FWCfgState *fw_cfg;
+ FWCfgState *fw_cfg = guest_info->fw_cfg;
PCMachineState *pcms = PC_MACHINE(machine);
assert(machine->ram_size == below_4g_mem_size + above_4g_mem_size);
@@ -1280,9 +1280,6 @@ FWCfgState *pc_memory_init(MachineState *machine,
option_rom_mr,
1);
- fw_cfg = bochs_bios_init();
- rom_set_fw(fw_cfg);
-
if (guest_info->has_reserved_memory && pcms->hotplug_memory_base) {
uint64_t *val = g_malloc(sizeof(*val));
*val = cpu_to_le64(ROUND_UP(pcms->hotplug_memory_base, 0x1ULL << 30));
@@ -1297,7 +1294,6 @@ FWCfgState *pc_memory_init(MachineState *machine,
for (i = 0; i < nb_option_roms; i++) {
rom_add_option(option_rom[i].name, option_rom[i].bootindex);
}
- guest_info->fw_cfg = fw_cfg;
return fw_cfg;
}
--
2.1.0
next prev parent reply other threads:[~2014-09-18 16:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-18 16:17 [Qemu-devel] [PATCH 0/6] pc: bring ACPI table size below to 2.0 levels, try fixing -initrd for good Paolo Bonzini
2014-09-18 16:17 ` Paolo Bonzini [this message]
2014-09-18 16:17 ` [Qemu-devel] [PATCH 2/6] pc: load the kernel after ACPI tables are built Paolo Bonzini
2014-09-18 16:17 ` [Qemu-devel] [PATCH 3/6] pc: redo sizing of reserved high memory area for -kernel/-initrd Paolo Bonzini
2014-09-18 16:17 ` [Qemu-devel] [PATCH 4/6] pc: introduce new ACPI table sizing algorithm Paolo Bonzini
2014-09-18 16:17 ` [Qemu-devel] [PATCH 5/6] pc: go back to smaller ACPI tables Paolo Bonzini
2014-09-18 16:17 ` [Qemu-devel] [PATCH 6/6] pc: clean up pre-2.1 compatibility code Paolo Bonzini
2014-09-19 7:36 ` [Qemu-devel] [PATCH 0/6] pc: bring ACPI table size below to 2.0 levels, try fixing -initrd for good Gerd Hoffmann
2014-09-19 8:06 ` Paolo Bonzini
2014-09-19 13:09 ` Paolo Bonzini
2014-10-02 12:11 ` Michael S. Tsirkin
2014-10-02 12:44 ` Paolo Bonzini
2014-10-02 13:30 ` Paolo Bonzini
2014-10-02 13:41 ` Michael S. Tsirkin
2014-10-02 13:43 ` Paolo Bonzini
2014-10-02 13:49 ` Michael S. Tsirkin
2014-10-06 13:42 ` Paolo Bonzini
2014-10-06 13:52 ` Michael S. Tsirkin
2014-10-06 13:55 ` Paolo Bonzini
2014-10-06 14:12 ` Michael S. Tsirkin
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=1411057074-11157-2-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=jsnow@redhat.com \
--cc=mst@redhat.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).