From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org, Anthony Liguori <anthony@codemonkey.ws>,
lersek@redhat.com, seabios@seabios.org
Subject: [Qemu-devel] [PATCH RFC 13/13] pc: reuse guest info for legacy fw cfg
Date: Mon, 13 May 2013 23:01:20 +0300 [thread overview]
Message-ID: <5a4fcc1346b9b0e0b3ea6d10dd3a9d5c4da28282.1368474222.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1368474222.git.mst@redhat.com>
Reduce code duplication by getting legacy
fw cfg data from guest info structure.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/i386/pc.c | 34 ++++++++++++++--------------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index af414a4..41bfb5b 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -594,14 +594,13 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)
return x86_cpu_apic_id_from_index(max_cpus - 1) + 1;
}
-static FWCfgState *bochs_bios_init(void)
+static FWCfgState *bochs_bios_init(PcGuestInfo *guest_info)
{
FWCfgState *fw_cfg;
uint8_t *smbios_table;
size_t smbios_len;
uint64_t *numa_fw_cfg;
- int i, j;
- unsigned int apic_id_limit = pc_apic_id_limit(max_cpus);
+ int i;
fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0);
/* FW_CFG_MAX_CPUS is a bit confusing/problematic on x86:
@@ -618,7 +617,7 @@ static FWCfgState *bochs_bios_init(void)
* [1] The only kind of "CPU identifier" used between SeaBIOS and QEMU is
* the APIC ID, not the "CPU index"
*/
- fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)apic_id_limit);
+ fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)guest_info->apic_id_limit);
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES,
@@ -637,24 +636,19 @@ static FWCfgState *bochs_bios_init(void)
* of nodes, one word for each VCPU->node and one word for each node to
* hold the amount of memory.
*/
- numa_fw_cfg = g_new0(uint64_t, 1 + apic_id_limit + nb_numa_nodes);
- numa_fw_cfg[0] = cpu_to_le64(nb_numa_nodes);
- for (i = 0; i < max_cpus; i++) {
- unsigned int apic_id = x86_cpu_apic_id_from_index(i);
- assert(apic_id < apic_id_limit);
- for (j = 0; j < nb_numa_nodes; j++) {
- if (test_bit(i, node_cpumask[j])) {
- numa_fw_cfg[apic_id + 1] = cpu_to_le64(j);
- break;
- }
- }
+ numa_fw_cfg = g_new0(uint64_t, 1 + guest_info->apic_id_limit +
+ guest_info->numa_nodes);
+ numa_fw_cfg[0] = cpu_to_le64(guest_info->numa_nodes);
+ for (i = 0; i < guest_info->apic_id_limit; i++) {
+ numa_fw_cfg[i + 1] = cpu_to_le64(guest_info->node_cpu[i]);
}
- for (i = 0; i < nb_numa_nodes; i++) {
- numa_fw_cfg[apic_id_limit + 1 + i] = cpu_to_le64(node_mem[i]);
+ for (i = 0; i < guest_info->numa_nodes; i++) {
+ numa_fw_cfg[guest_info->apic_id_limit + 1 + i] =
+ cpu_to_le64(guest_info->node_mem[i]);
}
fw_cfg_add_bytes(fw_cfg, FW_CFG_NUMA, numa_fw_cfg,
- (1 + apic_id_limit + nb_numa_nodes) *
- sizeof(*numa_fw_cfg));
+ (1 + guest_info->apic_id_limit +
+ guest_info->numa_nodes) * sizeof(*numa_fw_cfg));
return fw_cfg;
}
@@ -1151,7 +1145,7 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,
option_rom_mr,
1);
- fw_cfg = bochs_bios_init();
+ fw_cfg = bochs_bios_init(guest_info);
rom_set_fw(fw_cfg);
if (linux_boot) {
--
MST
next prev parent reply other threads:[~2013-05-13 20:01 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-13 20:00 [Qemu-devel] [PATCH RFC 00/13] qemu: generate acpi tables for the guest Michael S. Tsirkin
2013-05-13 20:00 ` [Qemu-devel] [PATCH RFC 03/13] refer to FWCfgState explicitly Michael S. Tsirkin
2013-05-13 20:00 ` [Qemu-devel] [PATCH RFC 02/13] hw/i386/pc.c: move IO_APIC_DEFAULT_ADDRESS to include/hw/i386/apic.h Michael S. Tsirkin
2013-05-13 20:08 ` Eric Blake
2013-05-13 20:00 ` [Qemu-devel] [PATCH RFC 01/13] apic: rename apic specific bitopts Michael S. Tsirkin
2013-05-13 20:22 ` Peter Maydell
2013-05-13 20:29 ` Michael S. Tsirkin
2013-05-13 20:00 ` [Qemu-devel] [PATCH RFC 04/13] fw_cfg: move typedef to qemu/typedefs.h Michael S. Tsirkin
2013-05-13 20:00 ` [Qemu-devel] [PATCH RFC 05/13] i386: add ACPI table files from seabios Michael S. Tsirkin
2013-05-13 20:01 ` [Qemu-devel] [PATCH RFC 06/13] acpi: add rules to compile ASL source Michael S. Tsirkin
2013-05-13 20:01 ` [Qemu-devel] [PATCH RFC 07/13] acpi: pre-compiled ASL files Michael S. Tsirkin
2013-05-13 20:01 ` [Qemu-devel] [PATCH RFC 08/13] range: add Range structure Michael S. Tsirkin
2013-05-13 20:20 ` Peter Maydell
2013-05-14 7:55 ` Michael S. Tsirkin
2013-05-13 20:01 ` [Qemu-devel] [PATCH RFC 09/13] i386: add bios linker/loader Michael S. Tsirkin
2013-05-13 20:01 ` Michael S. Tsirkin [this message]
2013-05-13 20:01 ` [Qemu-devel] [PATCH RFC 10/13] i386: generate pc guest info Michael S. Tsirkin
2013-05-13 20:23 ` Peter Maydell
2013-05-14 8:06 ` Michael S. Tsirkin
2013-05-14 9:32 ` Peter Maydell
2013-05-13 20:01 ` [Qemu-devel] [PATCH RFC 12/13] i386: ACPI table generation code from seabios Michael S. Tsirkin
2013-05-13 20:27 ` Peter Maydell
2013-05-13 20:01 ` [Qemu-devel] [PATCH RFC 11/13] pc: pass PCI hole ranges to Guests Michael S. Tsirkin
2013-05-13 20:38 ` [Qemu-devel] [PATCH RFC 00/13] qemu: generate acpi tables for the guest Anthony Liguori
2013-05-14 1:54 ` [Qemu-devel] [SeaBIOS] " Kevin O'Connor
2013-05-14 9:29 ` [Qemu-devel] " Gerd Hoffmann
2013-05-14 9:38 ` Peter Maydell
2013-05-14 14:29 ` [Qemu-devel] [SeaBIOS] " David Woodhouse
2013-05-14 15:13 ` Peter Maydell
2013-05-14 13:26 ` [Qemu-devel] " Anthony Liguori
2013-05-14 13:53 ` Gerd Hoffmann
2013-05-14 14:40 ` Anthony Liguori
2013-05-14 11:58 ` Michael S. Tsirkin
2013-05-14 13:34 ` Anthony Liguori
2013-05-14 14:14 ` Michael S. Tsirkin
2013-05-15 6:38 ` [Qemu-devel] [SeaBIOS] " Gerd Hoffmann
2013-06-03 22:19 ` [Qemu-devel] " Jordan Justen
2013-06-03 23:12 ` Anthony Liguori
2013-06-04 4:14 ` Jordan Justen
2013-05-16 11:27 ` 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=5a4fcc1346b9b0e0b3ea6d10dd3a9d5c4da28282.1368474222.git.mst@redhat.com \
--to=mst@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=lersek@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=seabios@seabios.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).