From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHa1x-0003Gv-Qp for qemu-devel@nongnu.org; Tue, 21 Jul 2015 12:04:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZHa1w-000340-Cw for qemu-devel@nongnu.org; Tue, 21 Jul 2015 12:04:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58619) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHa1w-00033d-3t for qemu-devel@nongnu.org; Tue, 21 Jul 2015 12:04:32 -0400 From: =?UTF-8?q?Marc=20Mar=C3=AD?= Date: Tue, 21 Jul 2015 18:03:46 +0200 Message-Id: <1437494626-3773-8-git-send-email-markmb@redhat.com> In-Reply-To: <1437494626-3773-1-git-send-email-markmb@redhat.com> References: <1437494626-3773-1-git-send-email-markmb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [RFC 7/7] fw_cfg DMA for x86 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Marc=20Mar=C3=AD?= , 'Kevin O'Connor' , Gerd Hoffmann , Stefan Hajnoczi Enable fw_cfg for x86 machines. Create new machine to avoid incompatibilites. Signed-off-by: Marc Mar=C3=AD --- hw/i386/pc.c | 21 ++++++++++++++++++--- hw/i386/pc_piix.c | 25 +++++++++++++++++++++++-- hw/i386/pc_q35.c | 26 ++++++++++++++++++++++++-- include/hw/i386/pc.h | 1 + 4 files changed, 66 insertions(+), 7 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 7661ea9..5b202fa 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -87,6 +87,7 @@ void pc_set_legacy_acpi_data_size(void) } =20 #define BIOS_CFG_IOPORT 0x510 +#define BIOS_CFG_DMA_ADDR 0xfef00000 #define FW_CFG_ACPI_TABLES (FW_CFG_ARCH_LOCAL + 0) #define FW_CFG_SMBIOS_ENTRIES (FW_CFG_ARCH_LOCAL + 1) #define FW_CFG_IRQ0_OVERRIDE (FW_CFG_ARCH_LOCAL + 2) @@ -718,7 +719,7 @@ static unsigned int pc_apic_id_limit(unsigned int max= _cpus) return x86_cpu_apic_id_from_index(max_cpus - 1) + 1; } =20 -static FWCfgState *bochs_bios_init(void) +static FWCfgState *bochs_bios_init(AddressSpace *as, hwaddr fw_cfg_addr) { FWCfgState *fw_cfg; uint8_t *smbios_tables, *smbios_anchor; @@ -727,7 +728,13 @@ static FWCfgState *bochs_bios_init(void) int i, j; unsigned int apic_id_limit =3D pc_apic_id_limit(max_cpus); =20 - fw_cfg =3D fw_cfg_init_io(BIOS_CFG_IOPORT); + if (as && fw_cfg_addr) { + fw_cfg =3D fw_cfg_init_mem_wide(fw_cfg_addr + 8, fw_cfg_addr, 8, + fw_cfg_addr + 10, as= ); + } else { + fw_cfg =3D fw_cfg_init_io(BIOS_CFG_IOPORT); + } + /* FW_CFG_MAX_CPUS is a bit confusing/problematic on x86: * * SeaBIOS needs FW_CFG_MAX_CPUS for CPU hotplug, but the CPU hotplu= g @@ -1302,6 +1309,7 @@ FWCfgState *pc_memory_init(MachineState *machine, MemoryRegion *ram_below_4g, *ram_above_4g; FWCfgState *fw_cfg; PCMachineState *pcms =3D PC_MACHINE(machine); + AddressSpace *as; =20 assert(machine->ram_size =3D=3D below_4g_mem_size + above_4g_mem_siz= e); =20 @@ -1391,7 +1399,14 @@ FWCfgState *pc_memory_init(MachineState *machine, option_rom_mr, 1); =20 - fw_cfg =3D bochs_bios_init(); + if (guest_info->fw_cfg_dma) { + as =3D g_malloc(sizeof(*as)); + address_space_init(as, ram_below_4g, "pc.as"); + fw_cfg =3D bochs_bios_init(as, BIOS_CFG_DMA_ADDR); + } else { + fw_cfg =3D bochs_bios_init(NULL, 0); + } + rom_set_fw(fw_cfg); =20 if (guest_info->has_reserved_memory && pcms->hotplug_memory.base) { diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 8167b12..bb94c87 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -74,6 +74,7 @@ static bool smbios_uuid_encoded =3D true; static bool gigabyte_align =3D true; static bool has_reserved_memory =3D true; static bool kvmclock_enabled =3D true; +static bool fw_cfg_dma =3D true; =20 /* PC hardware initialisation */ static void pc_init1(MachineState *machine) @@ -168,6 +169,7 @@ static void pc_init1(MachineState *machine) guest_info->isapc_ram_fw =3D !pci_enabled; guest_info->has_reserved_memory =3D has_reserved_memory; guest_info->rsdp_in_ram =3D rsdp_in_ram; + guest_info->fw_cfg_dma =3D fw_cfg_dma; =20 if (smbios_defaults) { MachineClass *mc =3D MACHINE_GET_CLASS(machine); @@ -304,9 +306,16 @@ static void pc_init1(MachineState *machine) } } =20 +static void pc_compat_2_4(MachineState *machine) +{ + fw_cfg_dma =3D false; +} + static void pc_compat_2_3(MachineState *machine) { PCMachineState *pcms =3D PC_MACHINE(machine); + + pc_compat_2_4(machine); savevm_skip_section_footers(); if (kvm_enabled()) { pcms->smm =3D ON_OFF_AUTO_OFF; @@ -477,7 +486,7 @@ static void pc_i440fx_machine_options(MachineClass *m= ) m->hot_add_cpu =3D pc_hot_add_cpu; } =20 -static void pc_i440fx_2_4_machine_options(MachineClass *m) +static void pc_i440fx_2_5_machine_options(MachineClass *m) { pc_i440fx_machine_options(m); m->default_machine_opts =3D "firmware=3Dbios-256k.bin"; @@ -486,7 +495,19 @@ static void pc_i440fx_2_4_machine_options(MachineCla= ss *m) m->is_default =3D 1; } =20 -DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL, +DEFINE_I440FX_MACHINE(v2_5, "pc-i440fx-2.5", NULL, + pc_i440fx_2_5_machine_options) + +static void pc_i440fx_2_4_machine_options(MachineClass *m) +{ + pc_i440fx_machine_options(m); + m->default_machine_opts =3D "firmware=3Dbios-256k.bin"; + m->default_display =3D "std"; + m->alias =3D NULL; + m->is_default =3D 0; +} + +DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", pc_compat_2_4, pc_i440fx_2_4_machine_options) =20 =20 diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 974aead..7230da6 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -61,6 +61,7 @@ static bool smbios_uuid_encoded =3D true; */ static bool gigabyte_align =3D true; static bool has_reserved_memory =3D true; +static bool fw_cfg_dma =3D true; =20 /* PC hardware initialisation */ static void pc_q35_init(MachineState *machine) @@ -156,6 +157,7 @@ static void pc_q35_init(MachineState *machine) guest_info->has_acpi_build =3D has_acpi_build; guest_info->has_reserved_memory =3D has_reserved_memory; guest_info->rsdp_in_ram =3D rsdp_in_ram; + guest_info->fw_cfg_dma =3D fw_cfg_dma; =20 /* Migration was not supported in 2.0 for Q35, so do not bother * with this hack (see hw/i386/acpi-build.c). @@ -287,9 +289,16 @@ static void pc_q35_init(MachineState *machine) } } =20 +static void pc_compat_2_4(MachineState *machine) +{ + fw_cfg_dma =3D false; +} + static void pc_compat_2_3(MachineState *machine) { PCMachineState *pcms =3D PC_MACHINE(machine); + + pc_compat_2_4(machine); savevm_skip_section_footers(); if (kvm_enabled()) { pcms->smm =3D ON_OFF_AUTO_OFF; @@ -392,7 +401,7 @@ static void pc_q35_machine_options(MachineClass *m) m->units_per_default_bus =3D 1; } =20 -static void pc_q35_2_4_machine_options(MachineClass *m) +static void pc_q35_2_5_machine_options(MachineClass *m) { pc_q35_machine_options(m); m->default_machine_opts =3D "firmware=3Dbios-256k.bin"; @@ -402,7 +411,20 @@ static void pc_q35_2_4_machine_options(MachineClass = *m) m->alias =3D "q35"; } =20 -DEFINE_Q35_MACHINE(v2_4, "pc-q35-2.4", NULL, +DEFINE_Q35_MACHINE(v2_5, "pc-q35-2.5", NULL, + pc_q35_2_5_machine_options); + +static void pc_q35_2_4_machine_options(MachineClass *m) +{ + pc_q35_machine_options(m); + m->default_machine_opts =3D "firmware=3Dbios-256k.bin"; + m->default_display =3D "std"; + m->no_floppy =3D 1; + m->no_tco =3D 0; + m->alias =3D NULL; +} + +DEFINE_Q35_MACHINE(v2_4, "pc-q35-2.4", pc_compat_2_4, pc_q35_2_4_machine_options); =20 =20 diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 15e3352..6c7eb65 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -103,6 +103,7 @@ struct PcGuestInfo { bool has_acpi_build; bool has_reserved_memory; bool rsdp_in_ram; + bool fw_cfg_dma; }; =20 /* parallel.c */ --=20 2.4.3