From patchwork Tue Nov 12 16:33:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 290708 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D33C42C00AD for ; Wed, 13 Nov 2013 03:36:48 +1100 (EST) Received: from localhost ([::1]:43845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgGxK-0008TC-Nn for incoming@patchwork.ozlabs.org; Tue, 12 Nov 2013 11:36:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgGuK-0004iA-6d for qemu-devel@nongnu.org; Tue, 12 Nov 2013 11:33:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VgGu5-0007N9-Lt for qemu-devel@nongnu.org; Tue, 12 Nov 2013 11:33:40 -0500 Received: from mail-oa0-x229.google.com ([2607:f8b0:4003:c02::229]:34289) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgGu5-0007MQ-ID for qemu-devel@nongnu.org; Tue, 12 Nov 2013 11:33:25 -0500 Received: by mail-oa0-f41.google.com with SMTP id g12so5620109oah.0 for ; Tue, 12 Nov 2013 08:33:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ukfVlH0Q8O0+KnOOW6oldNIJpc2ZcgSBM2SSy7xVdXA=; b=B+sGuJrQjDtnwMjAd14MwOqqXKEteaexU55hodRHielImd/Opyz8zisRB5v9sal+PR F6HNsPOZgDp97RM5/SMtlhDC4ZdM3OfjJHDhfQtgpgsrAWEC6qJLSZ37FirsnqHd6Mlx dt+DiWCzfXCWUAyY9PyaesJLlEz1/cOeXO1NT2kYNsxvI5gWp+0W4nOleTaq2ulQVoJn w/ygB1kKx7WG1CtC64Z8SyQ6MLP4dD3M/IHJy7nbPyPj0LTPWLg5150LcCgXvblMxKNC B3lyMtkCtaQg2+rLpaishyDMySJ9zIIPLUQiNisjggBUAtUt8kwT7/kX0TFaQYtLf0yW 9MMg== X-Received: by 10.182.80.196 with SMTP id t4mr31610271obx.1.1384274005044; Tue, 12 Nov 2013 08:33:25 -0800 (PST) Received: from t430.minyard.home (pool-173-57-152-84.dllstx.fios.verizon.net. [173.57.152.84]) by mx.google.com with ESMTPSA id s14sm37363298oeo.1.2013.11.12.08.33.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Nov 2013 08:33:24 -0800 (PST) Received: from t430.minyard.home (t430.minyard.home [127.0.0.1]) by t430.minyard.home (8.14.7/8.14.7) with ESMTP id rACGXMCR016653; Tue, 12 Nov 2013 10:33:22 -0600 Received: (from cminyard@localhost) by t430.minyard.home (8.14.7/8.14.7/Submit) id rACGXMgu016652; Tue, 12 Nov 2013 10:33:22 -0600 From: Corey Minyard To: qemu-devel@nongnu.org Date: Tue, 12 Nov 2013 10:33:13 -0600 Message-Id: <1384273995-16486-15-git-send-email-cminyard@mvista.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1384273995-16486-1-git-send-email-cminyard@mvista.com> References: <1384273995-16486-1-git-send-email-cminyard@mvista.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c02::229 Cc: Bret Ketchum , Corey Minyard , Corey Minyard , =?UTF-8?q?Andreas=20F=C3=A4rber?= , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH 14/16] pc: Postpone adding ACPI and SMBIOS to fw_cfg X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Postpone the addition of the ACPI and SMBIOS tables until after device initialization. This allows devices to add entries to these tables. Signed-off-by: Corey Minyard --- hw/i386/pc.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index dee409d..765c95e 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -607,8 +607,6 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus) static FWCfgState *bochs_bios_init(void) { 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); @@ -631,14 +629,8 @@ static FWCfgState *bochs_bios_init(void) fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)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, - acpi_tables, acpi_tables_len); fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override()); - smbios_table = smbios_get_table(&smbios_len); - if (smbios_table) - fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES, - smbios_table, smbios_len); fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE, &e820_table, sizeof(e820_table)); @@ -1127,6 +1119,31 @@ void pc_acpi_init(const char *default_dsdt) } } +struct pc_bios_post_init { + Notifier post_init; + void *fw_cfg; +}; + +/* Add the ACPI and SMBIOS tables after all the hardware has been initialized. + * This gives devices a chance to add to those tables. + */ +static void pc_bios_post_initfn(Notifier *n, void *opaque) +{ + struct pc_bios_post_init *p = container_of(n, struct pc_bios_post_init, + post_init); + uint8_t *smbios_table; + size_t smbios_len; + + fw_cfg_add_bytes(p->fw_cfg, FW_CFG_ACPI_TABLES, + acpi_tables, acpi_tables_len); + smbios_table = smbios_get_table(&smbios_len); + if (smbios_table) + fw_cfg_add_bytes(p->fw_cfg, FW_CFG_SMBIOS_ENTRIES, + smbios_table, smbios_len); +} + +static struct pc_bios_post_init post_init; + FWCfgState *pc_memory_init(MemoryRegion *system_memory, const char *kernel_filename, const char *kernel_cmdline, @@ -1196,6 +1213,11 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory, rom_add_option(option_rom[i].name, option_rom[i].bootindex); } guest_info->fw_cfg = fw_cfg; + + post_init.fw_cfg = fw_cfg; + post_init.post_init.notify = pc_bios_post_initfn; + qemu_add_machine_init_done_notifier(&post_init.post_init); + return fw_cfg; }