Skip to contentSkip to conversation

publish etc/acpi/APIC in fw_cfg

PATCH Superseded Laszlo Ersek 2 participants 12 messages Apr 15, 2013

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover publish etc/acpi/APIC in fw_cfg

v1 blurb:

This series exports the MADT (APIC) ACPI table under the new "etc/acpi/APIC" fw_cfg file. I sought to follow the requirements set forth in [1], the new table is only visible in the patched/patched case. I cross-tested { master, patched } qemu with { master, patched } seabios (the APIC, DSDT and RSDT tables) using guest acpidump and dmesg.

The -acpitable command line option is purposely ignored based on the last paragraph of [2]; the user isn't supposed to pass APIC with that option.

checkpatch.pl complains a little but (as last time) it's a false alarm.

The series is bisectable.

[1] http://thread.gmane.org/gmane.comp.emulators.qemu/202005/focus=202072
[2] http://thread.gmane.org/gmane.comp.bios.coreboot.seabios/5960/focus=6008

v2:
- address (1) in
<http://thread.gmane.org/gmane.comp.emulators.qemu/206146/focus=206195>:

- rebase to Paolo's recent series

    <http://thread.gmane.org/gmane.comp.emulators.qemu/206196/focus=206278>,

- patch 2 is new, fixes style of function parameter references in a comment [mst],

- patch 6 is new, moves a macro definition [mst],

- patch 7 should be structured more logically now, plus the commit message has grown some bits related to licensing [mst]. acpi_table_fill_hdr() is kept distinct from the -acpitable switch's implementation on purpose, similarly to pc_acpi_install() in v1.

- Tested APIC / DSDT / RSDT against contents saved from v1.

Laszlo Ersek (6):
refer to FWCfgState explicitly
acpi_table_install(): fix funcparam formatting in leading comment hw/acpi: extract standard table headers as a standalone structure hw/acpi: export default ACPI headers using the type just introduced hw/acpi: export acpi_checksum()
hw/i386: build ACPI MADT (APIC) for fw_cfg clients

Michael S. Tsirkin (1):
hw/i386/pc.c: move IO_APIC_DEFAULT_ADDRESS to include/hw/i386/apic.h

 hw/i386/acpi.h         |    9 +++
 hw/i386/multiboot.h    |    4 +-
 include/hw/acpi/acpi.h |   15 +++++
 include/hw/i386/apic.h |    2 +
 include/hw/i386/pc.h   |   19 +++---
 include/hw/loader.h    |    3 +-
 hw/acpi/core.c         |   91 ++++++++++++++-------------
 hw/acpi/piix4.c        |    2 +-
 hw/core/loader.c       |    2 +-
 hw/i386/acpi.c         |  159 ++++++++++++++++++++++++++++++++++++++++++++++++
 hw/i386/multiboot.c    |    2 +-
 hw/i386/pc.c           |   42 +++++++++----
 hw/i386/pc_piix.c      |    2 +-
 hw/sparc/sun4m.c       |    6 +-
 hw/sparc64/sun4u.c     |    2 +-
 hw/i386/Makefile.objs  |    1 +
 16 files changed, 284 insertions(+), 77 deletions(-)
 create mode 100644 hw/i386/acpi.h
 create mode 100644 hw/i386/acpi.c
#1 lore raw

PATCH v2 1/7 refer to FWCfgState explicitly

Currently some places use pointer-to-void even though they mean pointer-to-FWCfgState. Clean them up.

---
 hw/i386/multiboot.h  |    4 +++-
 include/hw/i386/pc.h |   19 ++++++++++---------
 include/hw/loader.h  |    3 ++-
 hw/acpi/piix4.c      |    2 +-
 hw/core/loader.c     |    2 +-
 hw/i386/multiboot.c  |    2 +-
 hw/i386/pc.c         |   24 ++++++++++++------------
 hw/i386/pc_piix.c    |    2 +-
 hw/sparc/sun4m.c     |    6 +++---
 hw/sparc64/sun4u.c   |    2 +-
 10 files changed, 35 insertions(+), 31 deletions(-)
hw/i386/multiboot.h +3 -1
index 98fb1b7..60de309 100644
@@ -1,7 +1,9 @@
 #ifndef QEMU_MULTIBOOT_H
 #define QEMU_MULTIBOOT_H
 
-int load_multiboot(void *fw_cfg,
+#include "hw/nvram/fw_cfg.h"
+
+int load_multiboot(FWCfgState *fw_cfg,
                    FILE *f,
                    const char *kernel_filename,
                    const char *initrd_filename,
include/hw/i386/pc.h +10 -9
index 9bcc819..fa4b5ce 100644
@@ -9,6 +9,7 @@
 #include "net/net.h"
 #include "exec/memory.h"
 #include "hw/i386/ioapic.h"
+#include "hw/nvram/fw_cfg.h"
 
 /* PC-style peripherals (also used by other machines).  */
 
@@ -80,14 +81,14 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
 
 void pc_cpus_init(const char *cpu_model);
 void pc_acpi_init(const char *default_dsdt);
-void *pc_memory_init(MemoryRegion *system_memory,
-                    const char *kernel_filename,
-                    const char *kernel_cmdline,
-                    const char *initrd_filename,
-                    ram_addr_t below_4g_mem_size,
-                    ram_addr_t above_4g_mem_size,
-                    MemoryRegion *rom_memory,
-                    MemoryRegion **ram_memory);
+FWCfgState *pc_memory_init(MemoryRegion *system_memory,
+                           const char *kernel_filename,
+                           const char *kernel_cmdline,
+                           const char *initrd_filename,
+                           ram_addr_t below_4g_mem_size,
+                           ram_addr_t above_4g_mem_size,
+                           MemoryRegion *rom_memory,
+                           MemoryRegion **ram_memory);
 qemu_irq *pc_allocate_cpu_irq(void);
 DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
 void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
@@ -111,7 +112,7 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
 
 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                        qemu_irq sci_irq, qemu_irq smi_irq,
-                       int kvm_enabled, void *fw_cfg);
+                       int kvm_enabled, FWCfgState *fw_cfg);
 void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
 
 /* hpet.c */
include/hw/loader.h +2 -1
index 0958f06..15d4cc9 100644
@@ -1,6 +1,7 @@
 #ifndef LOADER_H
 #define LOADER_H
 #include "qapi/qmp/qdict.h"
+#include "hw/nvram/fw_cfg.h"
 
 /* loader.c */
 int get_image_size(const char *filename);
@@ -30,7 +31,7 @@ int rom_add_blob(const char *name, const void *blob, size_t len,
 int rom_add_elf_program(const char *name, void *data, size_t datasize,
                         size_t romsize, hwaddr addr);
 int rom_load_all(void);
-void rom_set_fw(void *f);
+void rom_set_fw(FWCfgState *f);
 int rom_copy(uint8_t *dest, hwaddr addr, size_t size);
 void *rom_ptr(hwaddr addr);
 void do_info_roms(Monitor *mon, const QDict *qdict);
hw/acpi/piix4.c +1 -1
index 88386d7..200c297 100644
@@ -435,7 +435,7 @@ static int piix4_pm_initfn(PCIDevice *dev)
 
 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                        qemu_irq sci_irq, qemu_irq smi_irq,
-                       int kvm_enabled, void *fw_cfg)
+                       int kvm_enabled, FWCfgState *fw_cfg)
 {
     PCIDevice *dev;
     PIIX4PMState *s;
hw/core/loader.c +1 -1
index 7507914..a711145 100644
@@ -733,7 +733,7 @@ int rom_load_all(void)
     return 0;
 }
 
-void rom_set_fw(void *f)
+void rom_set_fw(FWCfgState *f)
 {
     fw_cfg = f;
 }
hw/i386/multiboot.c +1 -1
index d696507..09211e0 100644
@@ -124,7 +124,7 @@ static void mb_add_mod(MultibootState *s,
     s->mb_mods_count++;
 }
 
-int load_multiboot(void *fw_cfg,
+int load_multiboot(FWCfgState *fw_cfg,
                    FILE *f,
                    const char *kernel_filename,
                    const char *initrd_filename,
hw/i386/pc.c +12 -12
index 0d6e72b..3c12b55 100644
@@ -569,9 +569,9 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)
     return x86_cpu_apic_id_from_index(max_cpus - 1) + 1;
 }
 
-static void *bochs_bios_init(void)
+static FWCfgState *bochs_bios_init(void)
 {
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
     uint8_t *smbios_table;
     size_t smbios_len;
     uint64_t *numa_fw_cfg;
@@ -648,7 +648,7 @@ static long get_file_size(FILE *f)
     return size;
 }
 
-static void load_linux(void *fw_cfg,
+static void load_linux(FWCfgState *fw_cfg,
                        const char *kernel_filename,
                        const char *initrd_filename,
                        const char *kernel_cmdline,
@@ -924,19 +924,19 @@ void pc_acpi_init(const char *default_dsdt)
     }
 }
 
-void *pc_memory_init(MemoryRegion *system_memory,
-                    const char *kernel_filename,
-                    const char *kernel_cmdline,
-                    const char *initrd_filename,
-                    ram_addr_t below_4g_mem_size,
-                    ram_addr_t above_4g_mem_size,
-                    MemoryRegion *rom_memory,
-                    MemoryRegion **ram_memory)
+FWCfgState *pc_memory_init(MemoryRegion *system_memory,
+                           const char *kernel_filename,
+                           const char *kernel_cmdline,
+                           const char *initrd_filename,
+                           ram_addr_t below_4g_mem_size,
+                           ram_addr_t above_4g_mem_size,
+                           MemoryRegion *rom_memory,
+                           MemoryRegion **ram_memory)
 {
     int linux_boot, i;
     MemoryRegion *ram, *option_rom_mr;
     MemoryRegion *ram_below_4g, *ram_above_4g;
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
 
     linux_boot = (kernel_filename != NULL);
 
hw/i386/pc_piix.c +1 -1
index 943758a..da10e6d 100644
@@ -85,7 +85,7 @@ static void pc_init1(MemoryRegion *system_memory,
     MemoryRegion *ram_memory;
     MemoryRegion *pci_memory;
     MemoryRegion *rom_memory;
-    void *fw_cfg = NULL;
+    FWCfgState *fw_cfg = NULL;
 
     pc_cpus_init(cpu_model);
     pc_acpi_init("acpi-dsdt.aml");
hw/sparc/sun4m.c +3 -3
index 31beb32..0b1b620 100644
@@ -874,7 +874,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
     qemu_irq *cpu_halt;
     unsigned long kernel_size;
     DriveInfo *fd[MAX_FD];
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
     unsigned int num_vsimms;
 
     /* init CPUs */
@@ -1592,7 +1592,7 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
         espdma_irq, ledma_irq;
     qemu_irq esp_reset, dma_enable;
     unsigned long kernel_size;
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
     DeviceState *dev;
 
     /* init CPUs */
@@ -1793,7 +1793,7 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
     qemu_irq fdc_tc;
     unsigned long kernel_size;
     DriveInfo *fd[MAX_FD];
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
     DeviceState *dev;
     unsigned int i;
 
hw/sparc64/sun4u.c +1 -1
index 0d29620..0138252 100644
@@ -818,7 +818,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
     qemu_irq *ivec_irqs, *pbm_irqs;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
     DriveInfo *fd[MAX_FD];
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
 
     /* init CPUs */
     cpu = cpu_devinit(cpu_model, hwdef);
Signature · 1 line
1.7.1
#2 lore raw

PATCH v2 2/7 acpi_table_install(): fix funcparam formatting in leading comment

In reply to Laszlo Ersek
---
 hw/acpi/core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/acpi/core.c +1 -1
index 64b8718..69cadb0 100644
@@ -86,7 +86,7 @@ static int acpi_checksum(const uint8_t *data, int len)
  * is optionally overwritten from @hdrs.
  *
  * It is valid to call this function with
- * (@blob == NULL && bloblen == 0 && !has_header).
+ * (@blob == NULL && @bloblen == 0 && !@has_header).
  *
  * @hdrs->file and @hdrs->data are ignored.
  *
Signature · 1 line
1.7.1
#3 lore raw

PATCH v2 3/7 hw/acpi: extract standard table headers as a standalone structure

In reply to Laszlo Ersek

This enables reuse when preparing per-table fw_cfg blobs later.

---
 include/hw/acpi/acpi.h |   11 +++++++++++
 hw/acpi/core.c         |   48 +++++++++++++++++++++---------------------------
 2 files changed, 32 insertions(+), 27 deletions(-)
include/hw/acpi/acpi.h +11 -0
index 635be7b..0e26f63 100644
@@ -167,4 +167,15 @@ extern size_t acpi_tables_len;
 
 void acpi_table_add(const QemuOpts *opts, Error **errp);
 
+typedef struct acpi_table_std_header {
+    char sig[4];              /* ACPI signature (4 ASCII characters) */
+    uint32_t length;          /* Length of table, in bytes, including header */
+    uint8_t revision;         /* ACPI Specification minor version # */
+    uint8_t checksum;         /* To make sum of entire table == 0 */
+    char oem_id[6];           /* OEM identification */
+    char oem_table_id[8];     /* OEM table identification */
+    uint32_t oem_revision;    /* OEM revision number */
+    char asl_compiler_id[4];  /* ASL compiler vendor ID */
+    uint32_t asl_compiler_revision; /* ASL compiler revision number */
+} QEMU_PACKED AcpiTableStdHdr;
 #endif /* !QEMU_HW_ACPI_H */
hw/acpi/core.c +21 -27

102 lines not on this page · raw message

Signature · 1 line
1.7.1
#5 lore raw

PATCH v2 5/7 hw/acpi: export acpi_checksum()

In reply to Laszlo Ersek

Again, this enables reuse when preparing per-table fw_cfg blobs later.

---
 include/hw/acpi/acpi.h |    2 ++
 hw/acpi/core.c         |    2 +-
 2 files changed, 3 insertions(+), 1 deletions(-)
include/hw/acpi/acpi.h +2 -0
index bc7e107..7e51110 100644
@@ -180,4 +180,6 @@ typedef struct acpi_table_std_header {
 } QEMU_PACKED AcpiTableStdHdr;
 
 extern const AcpiTableStdHdr acpi_dfl_hdr;
+
+int acpi_checksum(const uint8_t *data, int len);
 #endif /* !QEMU_HW_ACPI_H */
hw/acpi/core.c +1 -1
index 36a4d03..3be7e09 100644
@@ -69,7 +69,7 @@ static void acpi_register_config(void)
 
 machine_init(acpi_register_config);
 
-static int acpi_checksum(const uint8_t *data, int len)
+int acpi_checksum(const uint8_t *data, int len)
 {
     int sum, i;
     sum = 0;
Signature · 1 line
1.7.1
#4 lore raw

PATCH v2 4/7 hw/acpi: export default ACPI headers using the type just introduced

In reply to Laszlo Ersek

This enables reuse when preparing per-table fw_cfg blobs later.

---
 include/hw/acpi/acpi.h |    2 ++
 hw/acpi/core.c         |   39 ++++++++++++++++++++++++---------------
 2 files changed, 26 insertions(+), 15 deletions(-)
include/hw/acpi/acpi.h +2 -0
index 0e26f63..bc7e107 100644
@@ -178,4 +178,6 @@ typedef struct acpi_table_std_header {
     char asl_compiler_id[4];  /* ASL compiler vendor ID */
     uint32_t asl_compiler_revision; /* ASL compiler revision number */
 } QEMU_PACKED AcpiTableStdHdr;
+
+extern const AcpiTableStdHdr acpi_dfl_hdr;
 #endif /* !QEMU_HW_ACPI_H */
hw/acpi/core.c +24 -15
index d348f81..36a4d03 100644
@@ -37,11 +37,20 @@ struct acpi_table_header {
 /* size of the extra prefix */
 #define ACPI_TABLE_PFX_SIZE offsetof(struct acpi_table_header, std)
 
-static const char unsigned dfl_hdr[sizeof(AcpiTableStdHdr)] =
-    "QEMU\0\0\0\0\1\0"       /* sig (4), len(4), revno (1), csum (1) */
-    "QEMUQEQEMUQEMU\1\0\0\0" /* OEM id (6), table (8), revno (4) */
-    "QEMU\1\0\0\0"           /* ASL compiler ID (4), version (4) */
-    ;
+const AcpiTableStdHdr acpi_dfl_hdr = {
+    .sig = "QEMU",
+    .revision = 1,
+    .oem_id = "QEMUQE",
+    .oem_table_id = "QEMUQEMU",
+    .asl_compiler_id = "QEMU",
+#ifdef HOST_WORDS_BIGENDIAN
+    .oem_revision = 0x01000000,
+    .asl_compiler_revision = 0x01000000
+#else
+    .oem_revision = 1,
+    .asl_compiler_revision = 1
+#endif
+};
 
 char unsigned *acpi_tables;
 size_t acpi_tables_len;
@@ -74,8 +83,8 @@ static int acpi_checksum(const uint8_t *data, int len)
 /* Install a copy of the ACPI table specified in @blob.
  *
  * If @has_header is set, @blob starts with the System Description Table Header
- * structure. Otherwise, "dfl_hdr" is prepended. In any case, each header field
- * is optionally overwritten from @hdrs.
+ * structure. Otherwise, "acpi_dfl_hdr" is prepended. In any case, each header
+ * field is optionally overwritten from @hdrs.
  *
  * It is valid to call this function with
  * (@blob == NULL && @bloblen == 0 && !@has_header).
@@ -105,13 +114,13 @@ static void acpi_table_install(const char unsigned *blob, size_t bloblen,
     if (has_header) {
         /*   _length             | ACPI header in blob | blob body
          *   ^^^^^^^^^^^^^^^^^^^   ^^^^^^^^^^^^^^^^^^^   ^^^^^^^^^
-         *   ACPI_TABLE_PFX_SIZE     sizeof dfl_hdr      body_size
+         *   ACPI_TABLE_PFX_SIZE   sizeof acpi_dfl_hdr   body_size
          *                           == body_start
          *
          *                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          *                           acpi_payload_size == bloblen
          */
-        body_start = sizeof dfl_hdr;
+        body_start = sizeof acpi_dfl_hdr;
 
         if (bloblen < body_start) {
             error_setg(errp, "ACPI table claiming to have header is too "
@@ -123,17 +132,17 @@ static void acpi_table_install(const char unsigned *blob, size_t bloblen,
     } else {
         /*   _length             | ACPI header in template | blob body
          *   ^^^^^^^^^^^^^^^^^^^   ^^^^^^^^^^^^^^^^^^^^^^^   ^^^^^^^^^^
-         *   ACPI_TABLE_PFX_SIZE       sizeof dfl_hdr        body_size
+         *   ACPI_TABLE_PFX_SIZE     sizeof acpi_dfl_hdr     body_size
          *                                                   == bloblen
          *
          *                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          *                                  acpi_payload_size
          */
         body_start = 0;
-        hdr_src = dfl_hdr;
+        hdr_src = (const char unsigned *)&acpi_dfl_hdr;
     }
     body_size = bloblen - body_start;
-    acpi_payload_size = sizeof dfl_hdr + body_size;
+    acpi_payload_size = sizeof acpi_dfl_hdr + body_size;
 
     if (acpi_payload_size > UINT16_MAX) {
         error_setg(errp, "ACPI table too big, requested: %zu, max: %u",
@@ -149,13 +158,13 @@ static void acpi_table_install(const char unsigned *blob, size_t bloblen,
 
     acpi_tables = g_realloc(acpi_tables, acpi_tables_len +
                                          ACPI_TABLE_PFX_SIZE +
-                                         sizeof dfl_hdr + body_size);
+                                         sizeof acpi_dfl_hdr + body_size);
 
     ext_hdr = (struct acpi_table_header *)(acpi_tables + acpi_tables_len);
     acpi_tables_len += ACPI_TABLE_PFX_SIZE;
 
-    memcpy(acpi_tables + acpi_tables_len, hdr_src, sizeof dfl_hdr);
-    acpi_tables_len += sizeof dfl_hdr;
+    memcpy(acpi_tables + acpi_tables_len, hdr_src, sizeof acpi_dfl_hdr);
+    acpi_tables_len += sizeof acpi_dfl_hdr;
 
     if (blob != NULL) {
         memcpy(acpi_tables + acpi_tables_len, blob + body_start, body_size);
Signature · 1 line
1.7.1
#6 lore raw

PATCH v2 6/7 hw/i386/pc.c: move IO_APIC_DEFAULT_ADDRESS to include/hw/i386/apic.h

In reply to Laszlo Ersek

From: Michael S. Tsirkin <[email protected]>

---
 include/hw/i386/apic.h |    2 ++
 hw/i386/pc.c           |    2 --
 2 files changed, 2 insertions(+), 2 deletions(-)
include/hw/i386/apic.h +2 -0
index 1d48e02..edbb37f 100644
@@ -26,6 +26,8 @@ void apic_designate_bsp(DeviceState *d);
 /* pc.c */
 DeviceState *cpu_get_current_apic(void);
 
+#define IO_APIC_DEFAULT_ADDRESS 0xfec00000
+
 /* cpu.c */
 bool cpu_is_bsp(X86CPU *cpu);
 
hw/i386/pc.c +0 -2
index 3c12b55..8727489 100644
@@ -73,8 +73,6 @@
 #define FW_CFG_E820_TABLE (FW_CFG_ARCH_LOCAL + 3)
 #define FW_CFG_HPET (FW_CFG_ARCH_LOCAL + 4)
 
-#define IO_APIC_DEFAULT_ADDRESS 0xfec00000
-
 #define E820_NR_ENTRIES		16
 
 struct e820_entry {
Signature · 1 line
1.7.1
#9 lore raw

PATCH v2 7/7 hw/i386: build ACPI MADT (APIC) for fw_cfg clients

In reply to Laszlo Ersek

This patch reuses some code from SeaBIOS, which was originally under LGPLv2 and then relicensed to GPLv3 or LGPLv3, in QEMU under GPLv2+. This relicensing has been acked by all contributors that had contributed to the code since the v2->v3 relicense. ACKs approving the v2+ relicensing are listed below. The list might include ACKs from people not holding copyright on any parts of the reused code, but it's better to err on the side of caution and include them.

Affected SeaBIOS files (GPLv2+ license headers added)
<http://thread.gmane.org/gmane.comp.bios.coreboot.seabios/5949>:

 src/acpi-dsdt-cpu-hotplug.dsl    |   15 +++++++++++++++
 src/acpi-dsdt-dbug.dsl           |   15 +++++++++++++++
 src/acpi-dsdt-hpet.dsl           |   15 +++++++++++++++
 src/acpi-dsdt-isa.dsl            |   15 +++++++++++++++
 src/acpi-dsdt-pci-crs.dsl        |   15 +++++++++++++++
 src/acpi.c                       |   14 +++++++++++++-
 src/acpi.h                       |   14 ++++++++++++++
 src/ssdt-misc.dsl                |   15 +++++++++++++++
 src/ssdt-pcihp.dsl               |   15 +++++++++++++++
 src/ssdt-proc.dsl                |   15 +++++++++++++++
 tools/acpi_extract.py            |   13 ++++++++++++-
 tools/acpi_extract_preprocess.py |   13 ++++++++++++-
 12 files changed, 171 insertions(+), 3 deletions(-)

Each one of the listed people agreed to the following:

Quoted 5 lines

If you allow the use of your contribution in QEMU under the terms of GPLv2 or later as proposed by this patch, please respond to this mail including the line:

Acked-by Name <email address>

Changes since v1, based on prototype code from Michael Tsirkin:
- "hw/i386/pc.c" is too big, create new file "hw/i386/acpi.c" with i386-specific ACPI table stuff,
- separate preparation of individual tables from their installation as fw_cfg files,
- install these fw_cfg files inside pc_memory_init(), which is shared by piix4/q35,
- add the above licensing-related block to the commit message.

---
 hw/i386/acpi.h        |    9 +++
 hw/i386/acpi.c        |  159 +++++++++++++++++++++++++++++++++++++++++++++++++
 hw/i386/pc.c          |   16 +++++
 hw/i386/Makefile.objs |    1 +
 4 files changed, 185 insertions(+), 0 deletions(-)
 create mode 100644 hw/i386/acpi.h
 create mode 100644 hw/i386/acpi.c
hw/i386/acpi.h new file +9 -0
new file mode 100644
index 0000000..94f9ad3
@@ -0,0 +1,9 @@
+#ifndef QEMU_HW_I386_ACPI_H
+#define QEMU_HW_I386_ACPI_H
+
+#include <stddef.h>
+
+void acpi_build_madt(unsigned char **out_blob, size_t *out_blob_size,
+                     unsigned num_lapic);
+
+#endif
hw/i386/acpi.c new file +159 -0

159 lines not on this page · raw message

hw/i386/pc.c +16 -0
index 8727489..f91ed21 100644
@@ -53,6 +53,7 @@
 #include "qemu/bitmap.h"
 #include "qemu/config-file.h"
 #include "hw/acpi/acpi.h"
+#include "hw/i386/acpi.h"
 
 /* debug PC/ISA interrupts */
 //#define DEBUG_IRQ
@@ -922,6 +923,19 @@ void pc_acpi_init(const char *default_dsdt)
     }
 }
 
+static void pc_acpi_madt(FWCfgState *fw_cfg)
+{
+    unsigned num_lapic;
+    char unsigned *blob;
+    size_t blob_size;
+
+    /* see note on FW_CFG_MAX_CPUS in bochs_bios_init() */
+    num_lapic = pc_apic_id_limit(max_cpus);
+
+    acpi_build_madt(&blob, &blob_size, num_lapic);
+    fw_cfg_add_file(fw_cfg, "etc/acpi/APIC", blob, blob_size);
+}
+
 FWCfgState *pc_memory_init(MemoryRegion *system_memory,
                            const char *kernel_filename,
                            const char *kernel_cmdline,
@@ -974,6 +988,8 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory,
     fw_cfg = bochs_bios_init();
     rom_set_fw(fw_cfg);
 
+    pc_acpi_madt(fw_cfg);
+
     if (linux_boot) {
         load_linux(fw_cfg, kernel_filename, initrd_filename, kernel_cmdline, below_4g_mem_size);
     }
hw/i386/Makefile.objs +1 -0
index 205d22e..a55da29 100644
@@ -1,6 +1,7 @@
 obj-$(CONFIG_KVM) += kvm/
 obj-y += multiboot.o smbios.o
 obj-y += pc.o pc_piix.o pc_q35.o
+obj-y += acpi.o
 obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
 
 obj-y += kvmvapic.o
Signature · 1 line
1.7.1
#10 lore raw

Re: [Qemu-devel] [PATCH v2 7/7] hw/i386: build ACPI MADT (APIC) for fw_cfg clients

In reply to Laszlo Ersek
Quoted 8 lines · Laszlo Ersek

This patch reuses some code from SeaBIOS, which was originally under LGPLv2 and then relicensed to GPLv3 or LGPLv3, in QEMU under GPLv2+. This relicensing has been acked by all contributors that had contributed to the code since the v2->v3 relicense. ACKs approving the v2+ relicensing are listed below. The list might include ACKs from people not holding copyright on any parts of the reused code, but it's better to err on the side of caution and include them.

...

Thanks for tracking that down.

Quoted 9 lines

Changes since v1, based on prototype code from Michael Tsirkin:
- "hw/i386/pc.c" is too big, create new file "hw/i386/acpi.c" with i386-specific ACPI table stuff,
- separate preparation of individual tables from their installation as fw_cfg files,
- install these fw_cfg files inside pc_memory_init(), which is shared by piix4/q35,
- add the above licensing-related block to the commit message.

This paragraph of information usually appears...

Quoted 3 lines

---

...here, so someone doing 'git am' on the message doesn't include information that is essential to the review process, but worthless to the ultimate git history (readers of 'git log' don't care how many iterations a patch took before it was ready to be included).

Quoted 7 lines
 hw/i386/acpi.h        |    9 +++
 hw/i386/acpi.c        |  159 +++++++++++++++++++++++++++++++++++++++++++++++++
 hw/i386/pc.c          |   16 +++++
 hw/i386/Makefile.objs |    1 +
 4 files changed, 185 insertions(+), 0 deletions(-)
 create mode 100644 hw/i386/acpi.h
 create mode 100644 hw/i386/acpi.c

Sorry - I just did a superficial review of the commit message, but this is in code that I'm not familiar enough with to do any sort of formal review.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#11 lore raw

Re: [Qemu-devel] [PATCH v2 7/7] hw/i386: build ACPI MADT (APIC) for fw_cfg clients

In reply to Eric Blake
Quoted 9 lines · Eric Blake
Quoted 8 lines · Laszlo Ersek

This patch reuses some code from SeaBIOS, which was originally under LGPLv2 and then relicensed to GPLv3 or LGPLv3, in QEMU under GPLv2+. This relicensing has been acked by all contributors that had contributed to the code since the v2->v3 relicense. ACKs approving the v2+ relicensing are listed below. The list might include ACKs from people not holding copyright on any parts of the reused code, but it's better to err on the side of caution and include them.

Quoted 3 lines

...

Thanks for tracking that down.

The credits belong to Michael.

Quoted 12 lines
Quoted 8 lines

Changes since v1, based on prototype code from Michael Tsirkin:
- "hw/i386/pc.c" is too big, create new file "hw/i386/acpi.c" with i386-specific ACPI table stuff,
- separate preparation of individual tables from their installation as fw_cfg files,
- install these fw_cfg files inside pc_memory_init(), which is shared by piix4/q35,
- add the above licensing-related block to the commit message.

This paragraph of information usually appears...

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

---

...here, so someone doing 'git am' on the message doesn't include information that is essential to the review process, but worthless to the ultimate git history (readers of 'git log' don't care how many iterations a patch took before it was ready to be included).

I'm aware and agree in general; on this occasion I left it in on purpose. The v1->v2 changes are somewhat relevant on their own IMHO, plus I wanted to save for posterity that v2 of this patch has been greatly influenced by a patch Michael sent me in private.

If you think it's important I can respin and mayhap reword.

Quoted 3 lines

Sorry - I just did a superficial review of the commit message, but this is in code that I'm not familiar enough with to do any sort of formal review.

Thank you very much for the review! I can't imagine where you got the energy from to look at random patches on the list.

Laszlo