Skip to contentSkip to conversation

hw/i386: Cleanups around 'hw/i386/pc.h'

PATCH In review Philippe Mathieu-Daudé 5 participants 15 messages Feb 13, 2024 – Feb 15, 2024

lore
Share & tools
lore
#0 lore raw

cover hw/i386: Cleanups around 'hw/i386/pc.h'

Trivial patches removing uses of "hw/i386/pc.h".

Philippe Mathieu-Daudé (7):
target/i386/monitor: Remove unused 'hw/i386/pc.h' header hw/timer: Move HPET_INTCAP definition to "hpet.h" hw/isa/lpc_ich9: Remove unused 'hw/i386/pc.h' hw/i386/acpi: Declare pc_madt_cpu_entry() in 'acpi-common.h' hw/i386/port92: Add missing 'hw/isa/isa.h' header hw/acpi/cpu_hotplug: Include 'pci_device.h' instead of 'pci.h' hw/acpi/cpu_hotplug: Include 'x86.h' instead of 'pc.h'

 hw/i386/acpi-common.h   | 3 +++
 include/hw/i386/pc.h    | 6 ------
 include/hw/timer/hpet.h | 2 ++
 hw/acpi/cpu_hotplug.c   | 4 ++--
 hw/i386/acpi-common.c   | 1 -
 hw/i386/port92.c        | 1 +
 hw/isa/lpc_ich9.c       | 1 -
 hw/timer/hpet.c         | 1 -
 target/i386/monitor.c   | 1 -
 9 files changed, 8 insertions(+), 12 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/7 target/i386/monitor: Remove unused 'hw/i386/pc.h' header

---
 target/i386/monitor.c | 1 -
 1 file changed, 1 deletion(-)
target/i386/monitor.c +0 -1
index 950ff9ccbc..3a281dab02 100644
@@ -33,7 +33,6 @@
 #include "qapi/error.h"
 #include "qapi/qapi-commands-misc-target.h"
 #include "qapi/qapi-commands-misc.h"
-#include "hw/i386/pc.h"
 
 /* Perform linear address sign extension */
 static hwaddr addr_canonical(CPUArchState *env, hwaddr addr)
Signature · 1 line
2.41.0
#2 lore raw

PATCH 2/7 hw/timer: Move HPET_INTCAP definition to "hpet.h"

In reply to Philippe Mathieu-Daudé

HPET_INTCAP is specific to TYPE_HPET, so define it there. hpet.c doesn't need to include "hw/i386/pc.h" anymore.

---
 include/hw/i386/pc.h    | 2 --
 include/hw/timer/hpet.h | 2 ++
 hw/timer/hpet.c         | 1 -
 3 files changed, 2 insertions(+), 3 deletions(-)
include/hw/i386/pc.h +0 -2
index ec0e5efcb2..f9fc42c2be 100644
@@ -15,8 +15,6 @@
 #include "hw/firmware/smbios.h"
 #include "hw/cxl/cxl.h"
 
-#define HPET_INTCAP "hpet-intcap"
-
 /**
  * PCMachineState:
  * @acpi_dev: link to ACPI PM device that performs ACPI hotplug handling
include/hw/timer/hpet.h +2 -0
index f04c4d3238..d17a8d4319 100644
@@ -78,6 +78,8 @@ extern struct hpet_fw_config hpet_cfg;
 
 #define TYPE_HPET "hpet"
 
+#define HPET_INTCAP "hpet-intcap"
+
 static inline bool hpet_find(void)
 {
     return object_resolve_path_type("", TYPE_HPET, NULL);
hw/timer/hpet.c +0 -1
index 1672faa4f2..01efe4885d 100644
@@ -25,7 +25,6 @@
  */
 
 #include "qemu/osdep.h"
-#include "hw/i386/pc.h"
 #include "hw/irq.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
Signature · 1 line
2.41.0
#3 lore raw

PATCH 3/7 hw/isa/lpc_ich9: Remove unused 'hw/i386/pc.h'

In reply to Philippe Mathieu-Daudé

Commit c461f3e382 ("hw/acpi/acpi_dev_interface: Remove now unused madt_cpu virtual method") removed the need for "hw/i386/pc.h".

---
 hw/isa/lpc_ich9.c | 1 -
 1 file changed, 1 deletion(-)
hw/isa/lpc_ich9.c +0 -1
index 3924eec483..b39d840ccd 100644
@@ -41,7 +41,6 @@
 #include "hw/isa/apm.h"
 #include "hw/pci/pci.h"
 #include "hw/southbridge/ich9.h"
-#include "hw/i386/pc.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/ich9.h"
 #include "hw/pci/pci_bus.h"
Signature · 1 line
2.41.0
#4 lore raw

PATCH 4/7 hw/i386/acpi: Declare pc_madt_cpu_entry() in 'acpi-common.h'

In reply to Philippe Mathieu-Daudé

Since pc_madt_cpu_entry() is only used by:
- hw/i386/acpi-build.c // single call
- hw/i386/acpi-common.c // definition
there is no need to expose it outside of hw/i386/. Declare it in "acpi-common.h". acpi-build.c doesn't need "hw/i386/pc.h" anymore.

---
 hw/i386/acpi-common.h | 3 +++
 include/hw/i386/pc.h  | 4 ----
 hw/i386/acpi-common.c | 1 -
 3 files changed, 3 insertions(+), 5 deletions(-)
hw/i386/acpi-common.h +3 -0
index b3c56ee014..e305aaac15 100644
@@ -1,12 +1,15 @@
 #ifndef HW_I386_ACPI_COMMON_H
 #define HW_I386_ACPI_COMMON_H
 
+#include "hw/boards.h"
 #include "hw/acpi/bios-linker-loader.h"
 #include "hw/i386/x86.h"
 
 /* Default IOAPIC ID */
 #define ACPI_BUILD_IOAPIC_ID 0x0
 
+void pc_madt_cpu_entry(int uid, const CPUArchIdList *apic_ids,
+                       GArray *entry, bool force_enabled);
 void acpi_build_madt(GArray *table_data, BIOSLinker *linker,
                      X86MachineState *x86ms,
                      const char *oem_id, const char *oem_table_id);
include/hw/i386/pc.h +0 -4
index f9fc42c2be..ce442372ac 100644
@@ -199,10 +199,6 @@ bool pc_system_ovmf_table_find(const char *entry, uint8_t **data,
                                int *data_len);
 void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size_t flash_size);
 
-/* hw/i386/acpi-common.c */
-void pc_madt_cpu_entry(int uid, const CPUArchIdList *apic_ids,
-                       GArray *entry, bool force_enabled);
-
 /* sgx.c */
 void pc_machine_init_sgx_epc(PCMachineState *pcms);
 
hw/i386/acpi-common.c +0 -1
index 43dc23f7e0..f1a11f833a 100644
@@ -27,7 +27,6 @@
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/aml-build.h"
 #include "hw/acpi/utils.h"
-#include "hw/i386/pc.h"
 #include "target/i386/cpu.h"
 
 #include "acpi-build.h"
Signature · 1 line
2.41.0
#5 lore raw

Re: [PATCH 4/7] hw/i386/acpi: Declare pc_madt_cpu_entry() in 'acpi-common.h'

Am 13. Februar 2024 12:01:49 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:

Quoted 20 lines

Since pc_madt_cpu_entry() is only used by:
- hw/i386/acpi-build.c // single call
- hw/i386/acpi-common.c // definition there is no need to expose it outside of hw/i386/. Declare it in "acpi-common.h". acpi-build.c doesn't need "hw/i386/pc.h" anymore.

---

hw/i386/acpi-common.h | 3 +++
include/hw/i386/pc.h  | 4 ----
hw/i386/acpi-common.c | 1 -
3 files changed, 3 insertions(+), 5 deletions(-)
hw/i386/acpi-common.h +0 -0
index b3c56ee014..e305aaac15 100644
@@ -1,12 +1,15 @@
 #ifndef HW_I386_ACPI_COMMON_H

hw/i386/acpi-common.h line 11

Quoted 10 lines
hw/i386/acpi-common.h +2 -0
 #define HW_I386_ACPI_COMMON_H
 
+#include "hw/boards.h"
 #include "hw/acpi/bios-linker-loader.h"
 #include "hw/i386/x86.h"
 
 /* Default IOAPIC ID */
 #define ACPI_BUILD_IOAPIC_ID 0x0
 
+void pc_madt_cpu_entry(int uid, const CPUArchIdList *apic_ids,

Since the function is apparently not pc but rather x86-specific: Does it make sense to rename the function as well, e.g. to x86_madt_cpu_entry()?

Best regards,
Bernhard

Quoted 31 lines
hw/i386/acpi-common.h +1 -0
+                       GArray *entry, bool force_enabled);
 void acpi_build_madt(GArray *table_data, BIOSLinker *linker,
                     X86MachineState *x86ms,
                     const char *oem_id, const char *oem_table_id);
include/hw/i386/pc.h +0 -4
index f9fc42c2be..ce442372ac 100644
@@ -199,10 +199,6 @@ bool pc_system_ovmf_table_find(const char *entry, uint8_t **data,
                               int *data_len);
 void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size_t flash_size);
 
-/* hw/i386/acpi-common.c */
-void pc_madt_cpu_entry(int uid, const CPUArchIdList *apic_ids,
-                       GArray *entry, bool force_enabled);
-
 /* sgx.c */
 void pc_machine_init_sgx_epc(PCMachineState *pcms);
 
hw/i386/acpi-common.c +0 -1
index 43dc23f7e0..f1a11f833a 100644
@@ -27,7 +27,6 @@
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/aml-build.h"
 #include "hw/acpi/utils.h"
-#include "hw/i386/pc.h"
 #include "target/i386/cpu.h"
 
 #include "acpi-build.h"
#6 lore raw

Re: [PATCH 4/7] hw/i386/acpi: Declare pc_madt_cpu_entry() in 'acpi-common.h'

Quoted 29 lines · Bernhard Beschow

Am 13. Februar 2024 12:01:49 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:

Quoted 26 lines

Since pc_madt_cpu_entry() is only used by:
- hw/i386/acpi-build.c // single call
- hw/i386/acpi-common.c // definition there is no need to expose it outside of hw/i386/. Declare it in "acpi-common.h". acpi-build.c doesn't need "hw/i386/pc.h" anymore.

---

hw/i386/acpi-common.h | 3 +++
include/hw/i386/pc.h  | 4 ----
hw/i386/acpi-common.c | 1 -
3 files changed, 3 insertions(+), 5 deletions(-)
hw/i386/acpi-common.h +1 -0
index b3c56ee014..e305aaac15 100644
@@ -1,12 +1,15 @@
 #ifndef HW_I386_ACPI_COMMON_H
 #define HW_I386_ACPI_COMMON_H
 
+#include "hw/boards.h"
 #include "hw/acpi/bios-linker-loader.h"
 #include "hw/i386/x86.h"
 
Quoted 6 lines

hw/i386/acpi-common.h line 11

Quoted 4 lines
hw/i386/acpi-common.h +1 -0
 /* Default IOAPIC ID */
 #define ACPI_BUILD_IOAPIC_ID 0x0
 
+void pc_madt_cpu_entry(int uid, const CPUArchIdList *apic_ids,

Since the function is apparently not pc but rather x86-specific: Does it make sense to rename the function as well, e.g. to x86_madt_cpu_entry()?

I don't know much about ACPI tables. Is it?
Ani, can you confirm and do you mind posting a cleanup patch on top? :)

Regards,

Phil.

#7 lore raw

PATCH 5/7 hw/i386/port92: Add missing 'hw/isa/isa.h' header

In reply to Philippe Mathieu-Daudé

TYPE_PORT92 inherits TYPE_ISA_DEVICE, so need to include "hw/isa/isa.h" to get its declarations (currently we indirectly include this header via "hw/i386/pc.h").

---
 hw/i386/port92.c | 1 +
 1 file changed, 1 insertion(+)
hw/i386/port92.c +1 -0
index 1070bfbf36..b25157f6e4 100644
@@ -10,6 +10,7 @@
 #include "sysemu/runstate.h"
 #include "migration/vmstate.h"
 #include "hw/irq.h"
+#include "hw/isa/isa.h"
 #include "hw/i386/pc.h"
 #include "trace.h"
 #include "qom/object.h"
Signature · 1 line
2.41.0
#8 lore raw

PATCH 6/7 hw/acpi/cpu_hotplug: Include 'pci_device.h' instead of 'pci.h'

In reply to Philippe Mathieu-Daudé

cpu_hotplug.c only needs the PCI *device* definitions.

---
 hw/acpi/cpu_hotplug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/acpi/cpu_hotplug.c +1 -1
index 6f78db0ccb..f7fe905e0a 100644
@@ -14,7 +14,7 @@
 #include "qapi/error.h"
 #include "hw/core/cpu.h"
 #include "hw/i386/pc.h"
-#include "hw/pci/pci.h"
+#include "hw/pci/pci_device.h"
 #include "qemu/error-report.h"
 
 #define CPU_EJECT_METHOD "CPEJ"
Signature · 1 line
2.41.0
#9 lore raw

PATCH 7/7 hw/acpi/cpu_hotplug: Include 'x86.h' instead of 'pc.h'

In reply to Philippe Mathieu-Daudé

X86 CPU hotplug isn't specific to PC machines.

---
 hw/acpi/cpu_hotplug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/acpi/cpu_hotplug.c +1 -1
index f7fe905e0a..83b8bc5deb 100644
@@ -13,7 +13,7 @@
 #include "hw/acpi/cpu_hotplug.h"
 #include "qapi/error.h"
 #include "hw/core/cpu.h"
-#include "hw/i386/pc.h"
+#include "hw/i386/x86.h"
 #include "hw/pci/pci_device.h"
 #include "qemu/error-report.h"
 
Signature · 1 line
2.41.0
Reviewed-by on the v1 series
#10 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 22 lines · Philippe Mathieu-Daudé

Trivial patches removing uses of "hw/i386/pc.h".

Philippe Mathieu-Daudé (7):
target/i386/monitor: Remove unused 'hw/i386/pc.h' header hw/timer: Move HPET_INTCAP definition to "hpet.h" hw/isa/lpc_ich9: Remove unused 'hw/i386/pc.h' hw/i386/acpi: Declare pc_madt_cpu_entry() in 'acpi-common.h' hw/i386/port92: Add missing 'hw/isa/isa.h' header hw/acpi/cpu_hotplug: Include 'pci_device.h' instead of 'pci.h' hw/acpi/cpu_hotplug: Include 'x86.h' instead of 'pc.h'

 hw/i386/acpi-common.h   | 3 +++
 include/hw/i386/pc.h    | 6 ------
 include/hw/timer/hpet.h | 2 ++
 hw/acpi/cpu_hotplug.c   | 4 ++--
 hw/i386/acpi-common.c   | 1 -
 hw/i386/port92.c        | 1 +
 hw/isa/lpc_ich9.c       | 1 -
 hw/timer/hpet.c         | 1 -
 target/i386/monitor.c   | 1 -
 9 files changed, 8 insertions(+), 12 deletions(-)
Quoted 4 lines

--
2.41.0

For the series:

#11 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 1 line · Philippe Mathieu-Daudé

Trivial patches removing uses of "hw/i386/pc.h".

How did you test that it's indeed unused?

Quoted 22 lines

Philippe Mathieu-Daudé (7):
target/i386/monitor: Remove unused 'hw/i386/pc.h' header hw/timer: Move HPET_INTCAP definition to "hpet.h" hw/isa/lpc_ich9: Remove unused 'hw/i386/pc.h' hw/i386/acpi: Declare pc_madt_cpu_entry() in 'acpi-common.h' hw/i386/port92: Add missing 'hw/isa/isa.h' header hw/acpi/cpu_hotplug: Include 'pci_device.h' instead of 'pci.h' hw/acpi/cpu_hotplug: Include 'x86.h' instead of 'pc.h'

 hw/i386/acpi-common.h   | 3 +++
 include/hw/i386/pc.h    | 6 ------
 include/hw/timer/hpet.h | 2 ++
 hw/acpi/cpu_hotplug.c   | 4 ++--
 hw/i386/acpi-common.c   | 1 -
 hw/i386/port92.c        | 1 +
 hw/isa/lpc_ich9.c       | 1 -
 hw/timer/hpet.c         | 1 -
 target/i386/monitor.c   | 1 -
 9 files changed, 8 insertions(+), 12 deletions(-)
Signature · 1 line
2.41.0
#12 lore raw
Quoted 4 lines · Michael S. Tsirkin
Quoted 1 line · Philippe Mathieu-Daudé

Trivial patches removing uses of "hw/i386/pc.h".

How did you test that it's indeed unused?

I put and #error in hw/i386/pc.h and built :)
(I'm trying to remove the PC dependency on generic devices.)

The few generic devices left are not as trivial.

Quoted 23 lines
Quoted 22 lines

Philippe Mathieu-Daudé (7):
target/i386/monitor: Remove unused 'hw/i386/pc.h' header hw/timer: Move HPET_INTCAP definition to "hpet.h" hw/isa/lpc_ich9: Remove unused 'hw/i386/pc.h' hw/i386/acpi: Declare pc_madt_cpu_entry() in 'acpi-common.h' hw/i386/port92: Add missing 'hw/isa/isa.h' header hw/acpi/cpu_hotplug: Include 'pci_device.h' instead of 'pci.h' hw/acpi/cpu_hotplug: Include 'x86.h' instead of 'pc.h'

  hw/i386/acpi-common.h   | 3 +++
  include/hw/i386/pc.h    | 6 ------
  include/hw/timer/hpet.h | 2 ++
  hw/acpi/cpu_hotplug.c   | 4 ++--
  hw/i386/acpi-common.c   | 1 -
  hw/i386/port92.c        | 1 +
  hw/isa/lpc_ich9.c       | 1 -
  hw/timer/hpet.c         | 1 -
  target/i386/monitor.c   | 1 -
  9 files changed, 8 insertions(+), 12 deletions(-)
Signature · 1 line
2.41.0
#13 lore raw

Am 13. Februar 2024 16:00:26 UTC schrieb "Philippe Mathieu-Daudé" <[email protected]>:

Quoted 26 lines · Michael S. Tsirkin
Quoted 4 lines · Philippe Mathieu-Daudé
Quoted 1 line

Trivial patches removing uses of "hw/i386/pc.h".

How did you test that it's indeed unused?

I put and #error in hw/i386/pc.h and built :)
(I'm trying to remove the PC dependency on generic devices.)

The few generic devices left are not as trivial.

Quoted 15 lines
Quoted 15 lines

Philippe Mathieu-Daudé (7):
target/i386/monitor: Remove unused 'hw/i386/pc.h' header hw/timer: Move HPET_INTCAP definition to "hpet.h" hw/isa/lpc_ich9: Remove unused 'hw/i386/pc.h' hw/i386/acpi: Declare pc_madt_cpu_entry() in 'acpi-common.h' hw/i386/port92: Add missing 'hw/isa/isa.h' header hw/acpi/cpu_hotplug: Include 'pci_device.h' instead of 'pci.h' hw/acpi/cpu_hotplug: Include 'x86.h' instead of 'pc.h'

  hw/i386/acpi-common.h   | 3 +++
  include/hw/i386/pc.h    | 6 ------
  include/hw/timer/hpet.h | 2 ++
  hw/acpi/cpu_hotplug.c   | 4 ++--
  hw/i386/acpi-common.c   | 1 -
  hw/i386/port92.c        | 1 +

I'd take care of port92 and make it part of all our three south bridge families (which models the real hardware more closely).

Best regards,
Bernhard

Quoted 9 lines
Quoted 8 lines
Quoted 7 lines
  hw/isa/lpc_ich9.c       | 1 -
  hw/timer/hpet.c         | 1 -
  target/i386/monitor.c   | 1 -
  9 files changed, 8 insertions(+), 12 deletions(-)
Signature · 1 line
2.41.0
Reviewed-by on the v1 series
#14 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

Trivial patches removing uses of "hw/i386/pc.h".

Philippe Mathieu-Daudé (7):
target/i386/monitor: Remove unused 'hw/i386/pc.h' header hw/timer: Move HPET_INTCAP definition to "hpet.h" hw/isa/lpc_ich9: Remove unused 'hw/i386/pc.h' hw/i386/acpi: Declare pc_madt_cpu_entry() in 'acpi-common.h' hw/i386/port92: Add missing 'hw/isa/isa.h' header hw/acpi/cpu_hotplug: Include 'pci_device.h' instead of 'pci.h' hw/acpi/cpu_hotplug: Include 'x86.h' instead of 'pc.h'

Quoted 10 lines
  hw/i386/acpi-common.h   | 3 +++
  include/hw/i386/pc.h    | 6 ------
  include/hw/timer/hpet.h | 2 ++
  hw/acpi/cpu_hotplug.c   | 4 ++--
  hw/i386/acpi-common.c   | 1 -
  hw/i386/port92.c        | 1 +
  hw/isa/lpc_ich9.c       | 1 -
  hw/timer/hpet.c         | 1 -
  target/i386/monitor.c   | 1 -
  9 files changed, 8 insertions(+), 12 deletions(-)

For the series:

and picked up for trivial-patches.

Thanks,

/mjt