From: "Marc Marí" <markmb@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Marc Marí" <markmb@redhat.com>,
"'Kevin O'Connor'" <kevin@koconnor.net>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Stefan Hajnoczi" <stefanha@gmail.com>
Subject: [Qemu-devel] [RFC 7/7] fw_cfg DMA for x86
Date: Tue, 21 Jul 2015 18:03:46 +0200 [thread overview]
Message-ID: <1437494626-3773-8-git-send-email-markmb@redhat.com> (raw)
In-Reply-To: <1437494626-3773-1-git-send-email-markmb@redhat.com>
Enable fw_cfg for x86 machines. Create new machine to avoid
incompatibilites.
Signed-off-by: Marc Marí <markmb@redhat.com>
---
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)
}
#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;
}
-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 = pc_apic_id_limit(max_cpus);
- fw_cfg = fw_cfg_init_io(BIOS_CFG_IOPORT);
+ if (as && fw_cfg_addr) {
+ fw_cfg = fw_cfg_init_mem_wide(fw_cfg_addr + 8, fw_cfg_addr, 8,
+ fw_cfg_addr + 10, as);
+ } else {
+ fw_cfg = 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 hotplug
@@ -1302,6 +1309,7 @@ FWCfgState *pc_memory_init(MachineState *machine,
MemoryRegion *ram_below_4g, *ram_above_4g;
FWCfgState *fw_cfg;
PCMachineState *pcms = PC_MACHINE(machine);
+ AddressSpace *as;
assert(machine->ram_size == below_4g_mem_size + above_4g_mem_size);
@@ -1391,7 +1399,14 @@ FWCfgState *pc_memory_init(MachineState *machine,
option_rom_mr,
1);
- fw_cfg = bochs_bios_init();
+ if (guest_info->fw_cfg_dma) {
+ as = g_malloc(sizeof(*as));
+ address_space_init(as, ram_below_4g, "pc.as");
+ fw_cfg = bochs_bios_init(as, BIOS_CFG_DMA_ADDR);
+ } else {
+ fw_cfg = bochs_bios_init(NULL, 0);
+ }
+
rom_set_fw(fw_cfg);
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 = true;
static bool gigabyte_align = true;
static bool has_reserved_memory = true;
static bool kvmclock_enabled = true;
+static bool fw_cfg_dma = true;
/* PC hardware initialisation */
static void pc_init1(MachineState *machine)
@@ -168,6 +169,7 @@ static void pc_init1(MachineState *machine)
guest_info->isapc_ram_fw = !pci_enabled;
guest_info->has_reserved_memory = has_reserved_memory;
guest_info->rsdp_in_ram = rsdp_in_ram;
+ guest_info->fw_cfg_dma = fw_cfg_dma;
if (smbios_defaults) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
@@ -304,9 +306,16 @@ static void pc_init1(MachineState *machine)
}
}
+static void pc_compat_2_4(MachineState *machine)
+{
+ fw_cfg_dma = false;
+}
+
static void pc_compat_2_3(MachineState *machine)
{
PCMachineState *pcms = PC_MACHINE(machine);
+
+ pc_compat_2_4(machine);
savevm_skip_section_footers();
if (kvm_enabled()) {
pcms->smm = ON_OFF_AUTO_OFF;
@@ -477,7 +486,7 @@ static void pc_i440fx_machine_options(MachineClass *m)
m->hot_add_cpu = pc_hot_add_cpu;
}
-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 = "firmware=bios-256k.bin";
@@ -486,7 +495,19 @@ static void pc_i440fx_2_4_machine_options(MachineClass *m)
m->is_default = 1;
}
-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 = "firmware=bios-256k.bin";
+ m->default_display = "std";
+ m->alias = NULL;
+ m->is_default = 0;
+}
+
+DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", pc_compat_2_4,
pc_i440fx_2_4_machine_options)
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 = true;
*/
static bool gigabyte_align = true;
static bool has_reserved_memory = true;
+static bool fw_cfg_dma = true;
/* 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 = has_acpi_build;
guest_info->has_reserved_memory = has_reserved_memory;
guest_info->rsdp_in_ram = rsdp_in_ram;
+ guest_info->fw_cfg_dma = fw_cfg_dma;
/* 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)
}
}
+static void pc_compat_2_4(MachineState *machine)
+{
+ fw_cfg_dma = false;
+}
+
static void pc_compat_2_3(MachineState *machine)
{
PCMachineState *pcms = PC_MACHINE(machine);
+
+ pc_compat_2_4(machine);
savevm_skip_section_footers();
if (kvm_enabled()) {
pcms->smm = ON_OFF_AUTO_OFF;
@@ -392,7 +401,7 @@ static void pc_q35_machine_options(MachineClass *m)
m->units_per_default_bus = 1;
}
-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 = "firmware=bios-256k.bin";
@@ -402,7 +411,20 @@ static void pc_q35_2_4_machine_options(MachineClass *m)
m->alias = "q35";
}
-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 = "firmware=bios-256k.bin";
+ m->default_display = "std";
+ m->no_floppy = 1;
+ m->no_tco = 0;
+ m->alias = NULL;
+}
+
+DEFINE_Q35_MACHINE(v2_4, "pc-q35-2.4", pc_compat_2_4,
pc_q35_2_4_machine_options);
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;
};
/* parallel.c */
--
2.4.3
next prev parent reply other threads:[~2015-07-21 16:04 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-21 16:03 [Qemu-devel] [RFC 0/7] fw_cfg dma interface Marc Marí
2015-07-21 16:03 ` [Qemu-devel] [RFC 1/7] fw_cfg: document fw_cfg_modify_iXX() update functions Marc Marí
2015-07-21 19:28 ` Laszlo Ersek
2015-07-21 16:03 ` [Qemu-devel] [RFC 2/7] fw_cfg dma interface Marc Marí
2015-07-21 19:44 ` Laszlo Ersek
2015-07-22 8:19 ` Marc Marí
2015-07-22 10:01 ` Laszlo Ersek
2015-07-22 11:30 ` Andrew Jones
2015-07-22 11:40 ` Laszlo Ersek
2015-07-22 4:24 ` Kevin O'Connor
2015-07-22 8:31 ` Marc Marí
2015-07-22 17:18 ` Kevin O'Connor
2015-07-23 13:13 ` Laszlo Ersek
2015-07-23 13:35 ` Peter Maydell
2015-07-23 13:45 ` Laszlo Ersek
2015-07-23 13:48 ` Marc Marí
2015-07-23 14:14 ` Kevin O'Connor
2015-07-22 9:31 ` Stefan Hajnoczi
2015-07-21 16:03 ` [Qemu-devel] [RFC 3/7] fw_cfg dma: adapt to vmstate changes Marc Marí
2015-07-21 16:16 ` Stefan Hajnoczi
2015-07-21 16:03 ` [Qemu-devel] [RFC 4/7] enable fw_cfg dma for arm virt Marc Marí
2015-07-21 17:04 ` Peter Maydell
2015-07-21 19:48 ` Laszlo Ersek
2015-07-22 8:44 ` Marc Marí
2015-07-21 16:03 ` [Qemu-devel] [RFC 5/7] fw_cfg file sort Marc Marí
2015-07-21 16:18 ` Stefan Hajnoczi
2015-07-21 19:53 ` Laszlo Ersek
2015-07-22 8:46 ` Marc Marí
2015-07-21 16:03 ` [Qemu-devel] [RFC 6/7] Add offset register to fw_cfg DMA interface Marc Marí
2015-07-21 16:26 ` Stefan Hajnoczi
2015-07-21 20:06 ` Laszlo Ersek
2015-07-21 20:16 ` Kevin O'Connor
2015-07-21 20:36 ` Laszlo Ersek
2015-07-22 4:11 ` Kevin O'Connor
2015-07-22 9:03 ` Marc Marí
2015-07-21 16:34 ` Stefan Hajnoczi
2015-07-21 16:03 ` Marc Marí [this message]
2015-07-21 17:14 ` [Qemu-devel] [RFC 7/7] fw_cfg DMA for x86 Peter Maydell
2015-07-22 9:06 ` Marc Marí
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=1437494626-3773-8-git-send-email-markmb@redhat.com \
--to=markmb@redhat.com \
--cc=kevin@koconnor.net \
--cc=kraxel@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/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).