Skip to contentSkip to conversation

hw/acpi: Improve build modularity (targeting MIPS/PPC)

PATCH In review Philippe Mathieu-Daudé 2 participants 9 messages Apr 28, 2019 – May 2, 2019

lore
Share & tools
lore
#0 lore raw

v2 cover hw/acpi: Improve build modularity (targeting MIPS/PPC)

Hi,

This series is not related to the previous one I just send:
hw/i386/acpi: Improve build modularity (isapc/q35/...)
https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg04678.html

While the first only concern X86 (changes within the architecture), this one allow the core ACPI feature to be used by the MIPS and PPC archs (specific series will follow).

v2:
- Fixed IPMI build error (patchew)
- Added possibility to build without ACPI (X86)

v1: https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg04696.html

Regards,

Phil.

Philippe Mathieu-Daudé (6):
hw/acpi: Move the IPMI stub to the stubs/ directory hw/acpi: Move the ACPI stub to the stubs/ directory hw/acpi: Simplify the Makefile logic
hw/acpi: Always build the 'core' ACPI functions
stubs: Add missing ACPI symbols
vl: Do not set acpi_enabled when ACPI is disabled at build time

 MAINTAINERS                         |  2 ++
 hw/acpi/Makefile.objs               | 22 +++++++---------------
 hw/acpi/core.c                      |  1 +
 stubs/Makefile.objs                 |  2 ++
 hw/acpi/acpi-stub.c => stubs/acpi.c |  6 ++++++
 hw/acpi/ipmi-stub.c => stubs/ipmi.c |  0
 vl.c                                |  1 -
 7 files changed, 18 insertions(+), 16 deletions(-)
 rename hw/acpi/acpi-stub.c => stubs/acpi.c (93%)
 rename hw/acpi/ipmi-stub.c => stubs/ipmi.c (100%)
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/6 hw/acpi: Move the IPMI stub to the stubs/ directory

Move the IPMI stub file to the stubs/ directory to simplify the hw/acpi Makefile.

---
 MAINTAINERS                         | 1 +
 hw/acpi/Makefile.objs               | 3 +--
 stubs/Makefile.objs                 | 1 +
 hw/acpi/ipmi-stub.c => stubs/ipmi.c | 0
 4 files changed, 3 insertions(+), 2 deletions(-)
 rename hw/acpi/ipmi-stub.c => stubs/ipmi.c (100%)
MAINTAINERS +1 -0
index 23db6f8408a..e1681eca5cb 100644
@@ -1309,6 +1309,7 @@ S: Maintained
 F: include/hw/ipmi/*
 F: hw/ipmi/*
 F: hw/smbios/smbios_type_38.c
+F: stubs/ipmi.c
 F: tests/ipmi*
 T: git https://github.com/cminyard/qemu.git master-ipmi-rebase
 
hw/acpi/Makefile.objs +1 -2
index 2d46e3789ae..4e302feb885 100644
@@ -14,8 +14,7 @@ common-obj-y += aml-build.o
 common-obj-$(CONFIG_TPM) += tpm.o
 
 common-obj-$(CONFIG_IPMI) += ipmi.o
-common-obj-$(call lnot,$(CONFIG_IPMI)) += ipmi-stub.o
 else
 common-obj-y += acpi-stub.o
 endif
-common-obj-$(CONFIG_ALL) += acpi-stub.o ipmi-stub.o
+common-obj-$(CONFIG_ALL) += acpi-stub.o
stubs/Makefile.objs +1 -0
index 269dfa58326..36bb9ff0b1d 100644
@@ -9,6 +9,7 @@ stub-obj-y += error-printf.o
 stub-obj-y += fdset.o
 stub-obj-y += gdbstub.o
 stub-obj-y += get-vm-name.o
+stub-obj-y += ipmi.o
 stub-obj-y += iothread.o
 stub-obj-y += iothread-lock.o
 stub-obj-y += is-daemonized.o
stubs/ipmi.c renamed from hw/acpi/ipmi-stub.c +0 -0
similarity index 100%
rename from hw/acpi/ipmi-stub.c
rename to stubs/ipmi.c
Signature · 1 line
2.20.1
Acked-by on v2 1/6
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/6] hw/acpi: Move the IPMI stub to the stubs/ directory

Quoted 4 lines · Philippe Mathieu-Daudé

Move the IPMI stub file to the stubs/ directory to simplify the hw/acpi Makefile.

I'm not sure of the overall view of this, but this is ok from an IPMI point of view in my view.

Quoted 53 lines
---
 MAINTAINERS                         | 1 +
 hw/acpi/Makefile.objs               | 3 +--
 stubs/Makefile.objs                 | 1 +
 hw/acpi/ipmi-stub.c => stubs/ipmi.c | 0
 4 files changed, 3 insertions(+), 2 deletions(-)
 rename hw/acpi/ipmi-stub.c => stubs/ipmi.c (100%)
MAINTAINERS +1 -0
index 23db6f8408a..e1681eca5cb 100644
@@ -1309,6 +1309,7 @@ S: Maintained
 F: include/hw/ipmi/*
 F: hw/ipmi/*
 F: hw/smbios/smbios_type_38.c
+F: stubs/ipmi.c
 F: tests/ipmi*
 T: git https://github.com/cminyard/qemu.git master-ipmi-rebase
 
hw/acpi/Makefile.objs +1 -2
index 2d46e3789ae..4e302feb885 100644
@@ -14,8 +14,7 @@ common-obj-y += aml-build.o
 common-obj-$(CONFIG_TPM) += tpm.o
 
 common-obj-$(CONFIG_IPMI) += ipmi.o
-common-obj-$(call lnot,$(CONFIG_IPMI)) += ipmi-stub.o
 else
 common-obj-y += acpi-stub.o
 endif
-common-obj-$(CONFIG_ALL) += acpi-stub.o ipmi-stub.o
+common-obj-$(CONFIG_ALL) += acpi-stub.o
stubs/Makefile.objs +1 -0
index 269dfa58326..36bb9ff0b1d 100644
@@ -9,6 +9,7 @@ stub-obj-y += error-printf.o
 stub-obj-y += fdset.o
 stub-obj-y += gdbstub.o
 stub-obj-y += get-vm-name.o
+stub-obj-y += ipmi.o
 stub-obj-y += iothread.o
 stub-obj-y += iothread-lock.o
 stub-obj-y += is-daemonized.o
stubs/ipmi.c renamed from hw/acpi/ipmi-stub.c +0 -0
similarity index 100%
rename from hw/acpi/ipmi-stub.c
rename to stubs/ipmi.c
Signature · 1 line
2.20.1
#3 lore raw

Re: [Qemu-devel] [PATCH v2 1/6] hw/acpi: Move the IPMI stub to the stubs/ directory

Hi Corey,

Quoted 8 lines · Corey Minyard
Quoted 4 lines · Philippe Mathieu-Daudé

Move the IPMI stub file to the stubs/ directory to simplify the hw/acpi Makefile.

I'm not sure of the overall view of this, but this is ok from an IPMI point of view in my view.

IIRC I had linking failure when building with Kconfig +ACPI -IPMI on MIPS/PPC (series will come on top of this one).

I'll verify, I only looked at MIPS but it seems UEFI firmwares also use it on PPC and ARM (currently the ACPI table is only built on X86).

Also I'll might rename stubs/ipmi.c -> stubs/acpi-ipmi.c.

Quoted 2 lines

Thanks for the review!

Quoted 54 lines
Quoted 54 lines
---
 MAINTAINERS                         | 1 +
 hw/acpi/Makefile.objs               | 3 +--
 stubs/Makefile.objs                 | 1 +
 hw/acpi/ipmi-stub.c => stubs/ipmi.c | 0
 4 files changed, 3 insertions(+), 2 deletions(-)
 rename hw/acpi/ipmi-stub.c => stubs/ipmi.c (100%)
MAINTAINERS +1 -0
index 23db6f8408a..e1681eca5cb 100644
@@ -1309,6 +1309,7 @@ S: Maintained
 F: include/hw/ipmi/*
 F: hw/ipmi/*
 F: hw/smbios/smbios_type_38.c
+F: stubs/ipmi.c
 F: tests/ipmi*
 T: git https://github.com/cminyard/qemu.git master-ipmi-rebase
 
hw/acpi/Makefile.objs +1 -2
index 2d46e3789ae..4e302feb885 100644
@@ -14,8 +14,7 @@ common-obj-y += aml-build.o
 common-obj-$(CONFIG_TPM) += tpm.o
 
 common-obj-$(CONFIG_IPMI) += ipmi.o
-common-obj-$(call lnot,$(CONFIG_IPMI)) += ipmi-stub.o
 else
 common-obj-y += acpi-stub.o
 endif
-common-obj-$(CONFIG_ALL) += acpi-stub.o ipmi-stub.o
+common-obj-$(CONFIG_ALL) += acpi-stub.o
stubs/Makefile.objs +1 -0
index 269dfa58326..36bb9ff0b1d 100644
@@ -9,6 +9,7 @@ stub-obj-y += error-printf.o
 stub-obj-y += fdset.o
 stub-obj-y += gdbstub.o
 stub-obj-y += get-vm-name.o
+stub-obj-y += ipmi.o
 stub-obj-y += iothread.o
 stub-obj-y += iothread-lock.o
 stub-obj-y += is-daemonized.o
stubs/ipmi.c renamed from hw/acpi/ipmi-stub.c +0 -0
similarity index 100%
rename from hw/acpi/ipmi-stub.c
rename to stubs/ipmi.c
Signature · 1 line
2.20.1
#4 lore raw

PATCH v2 2/6 hw/acpi: Move the ACPI stub to the stubs/ directory

In reply to Philippe Mathieu-Daudé

Move the ACPI stub file to the stubs/ directory to greatly simplify the hw/acpi Makefile.

---
 MAINTAINERS                         | 1 +
 hw/acpi/Makefile.objs               | 5 -----
 stubs/Makefile.objs                 | 1 +
 hw/acpi/acpi-stub.c => stubs/acpi.c | 0
 4 files changed, 2 insertions(+), 5 deletions(-)
 rename hw/acpi/acpi-stub.c => stubs/acpi.c (100%)
MAINTAINERS +1 -0
index e1681eca5cb..d05a3d36511 100644
@@ -1357,6 +1357,7 @@ F: hw/acpi/*
 F: hw/smbios/*
 F: hw/i386/acpi-build.[hc]
 F: hw/arm/virt-acpi-build.c
+F: stubs/acpi.c
 F: tests/bios-tables-test.c
 F: tests/acpi-utils.[hc]
 F: tests/data/acpi/
hw/acpi/Makefile.objs +0 -5
index 4e302feb885..73eca4f7dff 100644
@@ -6,15 +6,10 @@ common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
 common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu.o
 common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o
 common-obj-$(CONFIG_ACPI_VMGENID) += vmgenid.o
-common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o
 
 common-obj-y += acpi_interface.o
 common-obj-y += bios-linker-loader.o
 common-obj-y += aml-build.o
 common-obj-$(CONFIG_TPM) += tpm.o
-
 common-obj-$(CONFIG_IPMI) += ipmi.o
-else
-common-obj-y += acpi-stub.o
 endif
-common-obj-$(CONFIG_ALL) += acpi-stub.o
stubs/Makefile.objs +1 -0
index 36bb9ff0b1d..47ee66a71f2 100644
@@ -1,3 +1,4 @@
+stub-obj-y += acpi.o
 stub-obj-y += bdrv-next-monitor-owned.o
 stub-obj-y += blk-commit-all.o
 stub-obj-y += blockdev-close-all-bdrv-states.o
stubs/acpi.c renamed from hw/acpi/acpi-stub.c +0 -0
similarity index 100%
rename from hw/acpi/acpi-stub.c
rename to stubs/acpi.c
Signature · 1 line
2.20.1
#5 lore raw

PATCH v2 3/6 hw/acpi: Simplify the Makefile logic

In reply to Philippe Mathieu-Daudé

Simplify the Makefile logic to ease further modifications/reviews.

---
 hw/acpi/Makefile.objs | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
hw/acpi/Makefile.objs +5 -8
index 73eca4f7dff..b5515c626a6 100644
@@ -1,4 +1,3 @@
-ifeq ($(CONFIG_ACPI),y)
 common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o
 common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o
 common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o
@@ -6,10 +5,8 @@ common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
 common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu.o
 common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o
 common-obj-$(CONFIG_ACPI_VMGENID) += vmgenid.o
-
-common-obj-y += acpi_interface.o
-common-obj-y += bios-linker-loader.o
-common-obj-y += aml-build.o
-common-obj-$(CONFIG_TPM) += tpm.o
-common-obj-$(CONFIG_IPMI) += ipmi.o
-endif
+common-obj-$(CONFIG_ACPI) += acpi_interface.o
+common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
+common-obj-$(CONFIG_ACPI) += aml-build.o
+common-obj-$(call land,$(CONFIG_ACPI),$(CONFIG_TPM)) += tpm.o
+common-obj-$(call land,$(CONFIG_ACPI),$(CONFIG_IPMI)) += ipmi.o
Signature · 1 line
2.20.1
#6 lore raw

PATCH v2 4/6 hw/acpi: Always build the 'core' ACPI functions

In reply to Philippe Mathieu-Daudé

The 'core' ACPI functions are not X86-specific. Let this file be built unconditionally, this will allow us to use ACPI on non-X86 architectures.

---
 hw/acpi/Makefile.objs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/acpi/Makefile.objs +2 -1
index b5515c626a6..0427253816b 100644
@@ -1,4 +1,5 @@
-common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o
+common-obj-$(CONFIG_ACPI) += core.o
+common-obj-$(CONFIG_ACPI_X86) += piix4.o pcihp.o
 common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o
 common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o
 common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
Signature · 1 line
2.20.1
#7 lore raw

PATCH v2 5/6 stubs: Add missing ACPI symbols

In reply to Philippe Mathieu-Daudé

When building with ACPI disabled, we get:

/usr/bin/ld: hw/i386/pc.o: in function `bochs_bios_init':
/source/qemu/hw/i386/pc.c:1017: undefined reference to acpi_tables_len' /usr/bin/ld: /source/qemu/hw/i386/pc.c:1017: undefined reference to acpi_tables'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:204: qemu-system-x86_64] Error 1

These symbols are indeed declared as extern in "hw/acpi/acpi.h". Add them as stub to satisfy the linker.

---
 stubs/acpi.c | 4 ++++
 1 file changed, 4 insertions(+)
stubs/acpi.c +4 -0
index 4c9d081ed48..cd0119f9fb1 100644
@@ -23,6 +23,10 @@
 #include "qapi/qmp/qerror.h"
 #include "hw/acpi/acpi.h"
 
+size_t acpi_tables_len;
+
+char unsigned *acpi_tables;
+
 void acpi_table_add(const QemuOpts *opts, Error **errp)
 {
     error_setg(errp, QERR_UNSUPPORTED);
Signature · 1 line
2.20.1
#8 lore raw

PATCH v2 6/6 vl: Do not set acpi_enabled when ACPI is disabled at build time

In reply to Philippe Mathieu-Daudé

When building with CONFIG_ACPI disabled, the 'acpi_enabled' is still initialized to '1' (enabled).

Remove the confusion by moving the variable to hw/core/acpi.c, and adding a similar stub.

---
 hw/acpi/core.c | 1 +
 stubs/acpi.c   | 2 ++
 vl.c           | 1 -
 3 files changed, 3 insertions(+), 1 deletion(-)
hw/acpi/core.c +1 -0
index 9ed1629f367..b2730aec8a0 100644
@@ -59,6 +59,7 @@ static const char unsigned dfl_hdr[ACPI_TABLE_HDR_SIZE - ACPI_TABLE_PFX_SIZE] =
     "QEMU\1\0\0\0"           /* ASL compiler ID (4), version (4) */
     ;
 
+int acpi_enabled = 1;
 char unsigned *acpi_tables;
 size_t acpi_tables_len;
 
stubs/acpi.c +2 -0
index cd0119f9fb1..f1ef6b8e795 100644
@@ -23,6 +23,8 @@
 #include "qapi/qmp/qerror.h"
 #include "hw/acpi/acpi.h"
 
+int acpi_enabled;
+
 size_t acpi_tables_len;
 
 char unsigned *acpi_tables;
vl.c +0 -1
index ff5dfb6fbc3..c9364b4ec10 100644
@@ -166,7 +166,6 @@ int smp_cpus;
 unsigned int max_cpus;
 int smp_cores = 1;
 int smp_threads = 1;
-int acpi_enabled = 1;
 int no_hpet = 0;
 int fd_bootchk = 1;
 static int no_reboot;
Signature · 1 line
2.20.1