Skip to contentSkip to conversation

pc/q35: refactor ISA and SMBUS AML generation

PATCH Superseded Igor Mammedov 4 participants 56 messages May 16, 2022 – Jun 7, 2022 Arm/Amlogic Meson SoC support

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover pc/q35: refactor ISA and SMBUS AML generation

Series is excerpt form larger refactoring that does the same for PCI devices, but it's too large at this point, so I've split off a relatively self-contained ISA/SMBUS patches into a smaller separate series, and PCI refactoring will follow up on top of this series using the same AcpiDevAmlIf interface.

Series consolidates and unifies how pc/q35 machine generates AML for ISA and SMBUS devices. It adds a new more generic interface 'AcpiDevAmlIf' that replaces ISA specific ISADeviceClass::build_aml hook and should allow to use the same approach (i.e. ask a device to provide its own AML) but not limited to ISA bus.
Series applies AcpiDevAmlIf interface to a few ISA devices that were already using ISADeviceClass::build_aml and to devices /tpm, applesmc,pvpanic,ipmi/ that were generated in custom way. The AML generation for the later class is normalized to behave like any other ISA device that were using ISADeviceClass::build_aml and converted to interface 'AcpiDevAmlIf'. It simplifies process of building DSDT and eliminates custom probing/wiring for those devices as AML for them is generated at the time ISA/SMBUS is enumerated.

Changes to DSDT tables QEMU generates are mostly contextual where devices scattered across DSDT are consolidated under respective device that hosts bus they are attached to.

PS:
+ series adds several ACPI tests for devices that were missing them.

Igor Mammedov (35):
acpi: add interface to build device specific AML
acpi: make isa_build_aml() support AcpiDevAmlIf interface
acpi: fdc-isa: replace ISADeviceClass::build_aml with
AcpiDevAmlIfClass:build_dev_aml
acpi: parallel port: replace ISADeviceClass::build_aml with
AcpiDevAmlIfClass:build_dev_aml
acpi: serial-is: replace ISADeviceClass::build_aml with
AcpiDevAmlIfClass:build_dev_aml
acpi: mc146818rtc: replace ISADeviceClass::build_aml with
AcpiDevAmlIfClass:build_dev_aml
acpi: pckbd: replace ISADeviceClass::build_aml with
AcpiDevAmlIfClass:build_dev_aml
isa-bus: drop no longer used ISADeviceClass::build_aml
tests: acpi: add and whitelist DSDT.ipmismbus expected blob
tests: acpi: q35: add test for smbus-ipmi device
tests: acpi: update expected blob DSDT.ipmismbus
tests: acpi: whitelist DSDT.ipmismbus expected blob
ipmi: acpi: use relative path to resource source
tests: acpi: update expected DSDT.ipmismbus blob
acpi: ich9-smb: add support for AcpiDevAmlIf interface
acpi: ipmi: use AcpiDevAmlIf interface to build IPMI device
descriptors
q35: acpi: drop not needed PCMachineClass::do_not_add_smb_acpi
tests: acpi: white-list to be re-factored pc/q35 DSDT
acpi: pc: isa bridge: use AcpiDevAmlIf interface to build ISA device
descriptors
acpi: q35: isa bridge: use AcpiDevAmlIf interface to build ISA device
descriptors
tests: acpi: update expected blobs
tests: acpi: add and white-list DSDT.applesmc expected blob
tests: acpi: add applesmc testcase
acpi: applesmc: use AcpiDevAmlIfClass:build_dev_aml to provide
device's AML
tests: acpi: update expected blobs
tests: acpi: white-lists expected DSDT.pvpanic-isa blob
tests: acpi: add pvpanic-isa: testcase
acpi: pvpanic-isa: use AcpiDevAmlIfClass:build_dev_aml to provide
device's AML
tests: acpi: update expected DSDT.pvpanic-isa blob
tests: acpi: white-list DSDT.tis.tpm2/DSDT.tis.tpm12 expected blobs
acpi: pc/q35: tpm-tis: fix TPM device scope
acpi: pc/q35: remove not needed 'if' condition on pci bus
acpi: tpm-tis: use AcpiDevAmlIfClass:build_dev_aml to provide device's
AML
tests: acpi: update expected DSDT.tis.tpm2/DSDT.tis.tpm12 blobs
x86: acpi-build: do not include hw/isa/isa.h directly

 include/hw/acpi/acpi_aml_interface.h  |  40 ++++++
 include/hw/acpi/ipmi.h                |   9 +-
 include/hw/i386/pc.h                  |   1 -
 include/hw/isa/isa.h                  |  15 ---
 include/hw/misc/pvpanic.h             |   9 --
 hw/acpi/acpi_interface.c              |   8 ++
 hw/acpi/ipmi-stub.c                   |   2 +-
 hw/acpi/ipmi.c                        |  53 +++-----
 hw/acpi/meson.build                   |   2 +-
 hw/block/fdc-isa.c                    |  16 ++-
 hw/char/parallel.c                    |  14 ++-
 hw/char/serial-isa.c                  |  14 ++-
 hw/i2c/smbus_ich9.c                   |  15 +++
 hw/i386/acpi-build.c                  | 171 ++++++--------------------
 hw/i386/pc_piix.c                     |   1 -
 hw/i386/pc_q35.c                      |   1 -
 hw/input/pckbd.c                      |  14 ++-
 hw/ipmi/isa_ipmi_bt.c                 |   4 +
 hw/ipmi/isa_ipmi_kcs.c                |   4 +
 hw/ipmi/smbus_ipmi.c                  |   4 +
 hw/isa/isa-bus.c                      |   9 +-
 hw/isa/lpc_ich9.c                     |  19 +++
 hw/isa/piix3.c                        |  17 +++
 hw/misc/applesmc.c                    |  29 +++++
 hw/misc/pvpanic-isa.c                 |  42 +++++++
 hw/rtc/mc146818rtc.c                  |  14 ++-
 hw/tpm/tpm_tis_isa.c                  |  32 +++++
 tests/data/acpi/pc/DSDT               | Bin 6002 -> 5987 bytes
 tests/data/acpi/pc/DSDT.acpierst      | Bin 5969 -> 5954 bytes
 tests/data/acpi/pc/DSDT.acpihmat      | Bin 7327 -> 7312 bytes
 tests/data/acpi/pc/DSDT.bridge        | Bin 8668 -> 8653 bytes
 tests/data/acpi/pc/DSDT.cphp          | Bin 6466 -> 6451 bytes
 tests/data/acpi/pc/DSDT.dimmpxm       | Bin 7656 -> 7641 bytes
 tests/data/acpi/pc/DSDT.hpbridge      | Bin 5969 -> 5954 bytes
 tests/data/acpi/pc/DSDT.hpbrroot      | Bin 3084 -> 3069 bytes
 tests/data/acpi/pc/DSDT.ipmikcs       | Bin 6074 -> 6059 bytes
 tests/data/acpi/pc/DSDT.memhp         | Bin 7361 -> 7346 bytes
 tests/data/acpi/pc/DSDT.nohpet        | Bin 5860 -> 5845 bytes
 tests/data/acpi/pc/DSDT.numamem       | Bin 6008 -> 5993 bytes
 tests/data/acpi/pc/DSDT.roothp        | Bin 6210 -> 6195 bytes
 tests/data/acpi/q35/DSDT              | Bin 8289 -> 8274 bytes
 tests/data/acpi/q35/DSDT.acpierst     | Bin 8306 -> 8291 bytes
 tests/data/acpi/q35/DSDT.acpihmat     | Bin 9614 -> 9599 bytes
 tests/data/acpi/q35/DSDT.applesmc     | Bin 0 -> 8320 bytes
 tests/data/acpi/q35/DSDT.bridge       | Bin 11003 -> 10988 bytes
 tests/data/acpi/q35/DSDT.cphp         | Bin 8753 -> 8738 bytes
 tests/data/acpi/q35/DSDT.dimmpxm      | Bin 9943 -> 9928 bytes
 tests/data/acpi/q35/DSDT.ipmibt       | Bin 8364 -> 8349 bytes
 tests/data/acpi/q35/DSDT.ipmismbus    | Bin 0 -> 8363 bytes
 tests/data/acpi/q35/DSDT.ivrs         | Bin 8306 -> 8291 bytes
 tests/data/acpi/q35/DSDT.memhp        | Bin 9648 -> 9633 bytes
 tests/data/acpi/q35/DSDT.mmio64       | Bin 9419 -> 9404 bytes
 tests/data/acpi/q35/DSDT.multi-bridge | Bin 8583 -> 8568 bytes
 tests/data/acpi/q35/DSDT.nohpet       | Bin 8147 -> 8132 bytes
 tests/data/acpi/q35/DSDT.numamem      | Bin 8295 -> 8280 bytes
 tests/data/acpi/q35/DSDT.pvpanic-isa  | Bin 0 -> 8375 bytes
 tests/data/acpi/q35/DSDT.tis.tpm12    | Bin 8900 -> 8880 bytes
 tests/data/acpi/q35/DSDT.tis.tpm2     | Bin 8921 -> 8906 bytes
 tests/data/acpi/q35/DSDT.viot         | Bin 9398 -> 9383 bytes
 tests/data/acpi/q35/DSDT.xapic        | Bin 35652 -> 35637 bytes
 tests/qtest/bios-tables-test.c        |  40 ++++++
 61 files changed, 360 insertions(+), 239 deletions(-)
 create mode 100644 include/hw/acpi/acpi_aml_interface.h
 create mode 100644 tests/data/acpi/q35/DSDT.applesmc
 create mode 100644 tests/data/acpi/q35/DSDT.ipmismbus
 create mode 100644 tests/data/acpi/q35/DSDT.pvpanic-isa
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/35 acpi: add interface to build device specific AML

There is already ISADeviceClass::build_aml() callback which builds device specific AML blob for some ISA devices. To extend the same idea to other devices, add TYPE_ACPI_DEV_AML_IF Interface that will provide a more generic callback which will be used not only for ISA but other devices. It will allow get rid of some data-mining and ad-hoc AML building, by asking device(s) to generate its own AML blob like it's done for ISA devices.

---
 include/hw/acpi/acpi_aml_interface.h | 40 ++++++++++++++++++++++++++++
 hw/acpi/acpi_interface.c             |  8 ++++++
 hw/acpi/meson.build                  |  2 +-
 3 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 include/hw/acpi/acpi_aml_interface.h
include/hw/acpi/acpi_aml_interface.h new file +40 -0
new file mode 100644
index 0000000000..ab76f0e55d
@@ -0,0 +1,40 @@
+#ifndef ACPI_AML_INTERFACE_H
+#define ACPI_AML_INTERFACE_H
+
+#include "qom/object.h"
+#include "hw/acpi/aml-build.h"
+
+#define TYPE_ACPI_DEV_AML_IF "acpi-dev-aml-interface"
+typedef struct AcpiDevAmlIfClass AcpiDevAmlIfClass;
+DECLARE_CLASS_CHECKERS(AcpiDevAmlIfClass, ACPI_DEV_AML_IF, TYPE_ACPI_DEV_AML_IF)
+#define ACPI_DEV_AML_IF(obj) \
+     INTERFACE_CHECK(AcpiDevAmlIf, (obj), TYPE_ACPI_DEV_AML_IF)
+
+typedef struct AcpiDevAmlIf AcpiDevAmlIf;
+typedef void (*dev_aml_fn)(AcpiDevAmlIf *adev, Aml *scope);
+
+/**
+ * AcpiDevAmlIfClass:
+ *
+ * build_dev_aml: adds device specific AML blob to provided scope
+ *
+ * Interface is designed for providing generic callback that builds device
+ * specific AML blob.
+ */
+struct AcpiDevAmlIfClass {
+    /* <private> */
+    InterfaceClass parent_class;
+
+    /* <public> */
+    dev_aml_fn build_dev_aml;
+};
+
+static inline void call_dev_aml_func(DeviceState *dev, Aml *scope)
+{
+    if (object_dynamic_cast(OBJECT(dev), TYPE_ACPI_DEV_AML_IF)) {
+        AcpiDevAmlIfClass *klass = ACPI_DEV_AML_IF_GET_CLASS(dev);
+        klass->build_dev_aml(ACPI_DEV_AML_IF(dev), scope);
+    }
+}
+
+#endif
hw/acpi/acpi_interface.c +8 -0
index 6583917b8e..c668d361f6 100644
@@ -1,5 +1,6 @@
 #include "qemu/osdep.h"
 #include "hw/acpi/acpi_dev_interface.h"
+#include "hw/acpi/acpi_aml_interface.h"
 #include "qemu/module.h"
 
 void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event)
@@ -18,8 +19,15 @@ static void register_types(void)
         .parent        = TYPE_INTERFACE,
         .class_size = sizeof(AcpiDeviceIfClass),
     };
+    static const TypeInfo acpi_dev_aml_if_info = {
+        .name          = TYPE_ACPI_DEV_AML_IF,
+        .parent        = TYPE_INTERFACE,
+        .class_size = sizeof(AcpiDevAmlIfClass),
+    };
+
 
     type_register_static(&acpi_dev_if_info);
+    type_register_static(&acpi_dev_aml_if_info);
 }
 
 type_init(register_types)
hw/acpi/meson.build +1 -1
index 8bea2e6933..9504f5ce09 100644
@@ -28,7 +28,7 @@ acpi_ss.add(when: 'CONFIG_PC', if_false: files('acpi-x86-stub.c'))
 if have_tpm
   acpi_ss.add(files('tpm.c'))
 endif
-softmmu_ss.add(when: 'CONFIG_ACPI', if_false: files('acpi-stub.c', 'aml-build-stub.c', 'ghes-stub.c'))
+softmmu_ss.add(when: 'CONFIG_ACPI', if_false: files('acpi-stub.c', 'aml-build-stub.c', 'ghes-stub.c', 'acpi_interface.c'))
 softmmu_ss.add_all(when: 'CONFIG_ACPI', if_true: acpi_ss)
 softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('acpi-stub.c', 'aml-build-stub.c',
                                                   'acpi-x86-stub.c', 'ipmi-stub.c', 'ghes-stub.c',
Signature · 1 line
2.31.1
#2 lore raw

Re: [PATCH 01/35] acpi: add interface to build device specific AML

Quoted 27 lines · Igor Mammedov

There is already ISADeviceClass::build_aml() callback which builds device specific AML blob for some ISA devices. To extend the same idea to other devices, add TYPE_ACPI_DEV_AML_IF Interface that will provide a more generic callback which will be used not only for ISA but other devices. It will allow get rid of some data-mining and ad-hoc AML building, by asking device(s) to generate its own AML blob like it's done for ISA devices.

---
 include/hw/acpi/acpi_aml_interface.h | 40 ++++++++++++++++++++++++++++
 hw/acpi/acpi_interface.c             |  8 ++++++
 hw/acpi/meson.build                  |  2 +-
 3 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 include/hw/acpi/acpi_aml_interface.h
include/hw/acpi/acpi_aml_interface.h new file +3 -0
new file mode 100644
index 0000000000..ab76f0e55d
@@ -0,0 +1,40 @@
+#ifndef ACPI_AML_INTERFACE_H
+#define ACPI_AML_INTERFACE_H
+

include/hw/acpi/acpi_aml_interface.h line 13

Quoted 10 lines
include/hw/acpi/acpi_aml_interface.h new file +10 -0
+#include "qom/object.h"
+#include "hw/acpi/aml-build.h"
+
+#define TYPE_ACPI_DEV_AML_IF "acpi-dev-aml-interface"
+typedef struct AcpiDevAmlIfClass AcpiDevAmlIfClass;
+DECLARE_CLASS_CHECKERS(AcpiDevAmlIfClass, ACPI_DEV_AML_IF, TYPE_ACPI_DEV_AML_IF)
+#define ACPI_DEV_AML_IF(obj) \
+     INTERFACE_CHECK(AcpiDevAmlIf, (obj), TYPE_ACPI_DEV_AML_IF)
+
+typedef struct AcpiDevAmlIf AcpiDevAmlIf;

I do not see where struct AcpiDevAmlIf is defined. I guess this is through the macro magic.

Quoted 59 lines
include/hw/acpi/acpi_aml_interface.h new file +27 -0
+typedef void (*dev_aml_fn)(AcpiDevAmlIf *adev, Aml *scope);
+
+/**
+ * AcpiDevAmlIfClass:
+ *
+ * build_dev_aml: adds device specific AML blob to provided scope
+ *
+ * Interface is designed for providing generic callback that builds device
+ * specific AML blob.
+ */
+struct AcpiDevAmlIfClass {
+    /* <private> */
+    InterfaceClass parent_class;
+
+    /* <public> */
+    dev_aml_fn build_dev_aml;
+};
+
+static inline void call_dev_aml_func(DeviceState *dev, Aml *scope)
+{
+    if (object_dynamic_cast(OBJECT(dev), TYPE_ACPI_DEV_AML_IF)) {
+        AcpiDevAmlIfClass *klass = ACPI_DEV_AML_IF_GET_CLASS(dev);
+        klass->build_dev_aml(ACPI_DEV_AML_IF(dev), scope);
+    }
+}
+
+#endif
hw/acpi/acpi_interface.c +8 -0
index 6583917b8e..c668d361f6 100644
@@ -1,5 +1,6 @@
 #include "qemu/osdep.h"
 #include "hw/acpi/acpi_dev_interface.h"
+#include "hw/acpi/acpi_aml_interface.h"
 #include "qemu/module.h"
 
 void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event)
@@ -18,8 +19,15 @@ static void register_types(void)
         .parent        = TYPE_INTERFACE,
         .class_size = sizeof(AcpiDeviceIfClass),
     };
+    static const TypeInfo acpi_dev_aml_if_info = {
+        .name          = TYPE_ACPI_DEV_AML_IF,
+        .parent        = TYPE_INTERFACE,
+        .class_size = sizeof(AcpiDevAmlIfClass),
+    };
+
 
     type_register_static(&acpi_dev_if_info);
+    type_register_static(&acpi_dev_aml_if_info);
 }
 
 type_init(register_types)
hw/acpi/meson.build +0 -0
index 8bea2e6933..9504f5ce09 100644

hw/acpi/meson.build acpi_ss.add(when: 'CONFIG_PC', if_false: files('acpi-x86-stub.c')) · line 31

Quoted 5 lines
hw/acpi/meson.build +1 -1
@@ -28,7 +28,7 @@ acpi_ss.add(when: 'CONFIG_PC', if_false: files('acpi-x86-stub.c'))
 if have_tpm
   acpi_ss.add(files('tpm.c'))
 endif
-softmmu_ss.add(when: 'CONFIG_ACPI', if_false: files('acpi-stub.c', 'aml-build-stub.c', 'ghes-stub.c'))
+softmmu_ss.add(when: 'CONFIG_ACPI', if_false: files('acpi-stub.c', 'aml-build-stub.c', 'ghes-stub.c', 'acpi_interface.c'))

This is wrong. It should be the stub file not the real thing.

Quoted 6 lines
hw/acpi/meson.build +0 -1
 softmmu_ss.add_all(when: 'CONFIG_ACPI', if_true: acpi_ss)
 softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('acpi-stub.c', 'aml-build-stub.c',
                                                   'acpi-x86-stub.c', 'ipmi-stub.c', 'ghes-stub.c',
--

2.31.1

#3 lore raw

Re: [PATCH 01/35] acpi: add interface to build device specific AML

Quoted 33 lines · On Wed, 18 May 2022 15:30:07 +0530 Ani Sinha <[email protected]> wrote:
Quoted 32 lines · Igor Mammedov

There is already ISADeviceClass::build_aml() callback which builds device specific AML blob for some ISA devices. To extend the same idea to other devices, add TYPE_ACPI_DEV_AML_IF Interface that will provide a more generic callback which will be used not only for ISA but other devices. It will allow get rid of some data-mining and ad-hoc AML building, by asking device(s) to generate its own AML blob like it's done for ISA devices.

---
 include/hw/acpi/acpi_aml_interface.h | 40 ++++++++++++++++++++++++++++
 hw/acpi/acpi_interface.c             |  8 ++++++
 hw/acpi/meson.build                  |  2 +-
 3 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 include/hw/acpi/acpi_aml_interface.h
include/hw/acpi/acpi_aml_interface.h new file +8 -0
new file mode 100644
index 0000000000..ab76f0e55d
@@ -0,0 +1,40 @@
+#ifndef ACPI_AML_INTERFACE_H
+#define ACPI_AML_INTERFACE_H
+
+#include "qom/object.h"
+#include "hw/acpi/aml-build.h"
+
+#define TYPE_ACPI_DEV_AML_IF "acpi-dev-aml-interface"
+typedef struct AcpiDevAmlIfClass AcpiDevAmlIfClass;
Quoted 8 lines

include/hw/acpi/acpi_aml_interface.h line 13

Quoted 5 lines
include/hw/acpi/acpi_aml_interface.h new file +5 -0
+DECLARE_CLASS_CHECKERS(AcpiDevAmlIfClass, ACPI_DEV_AML_IF, TYPE_ACPI_DEV_AML_IF)
+#define ACPI_DEV_AML_IF(obj) \
+     INTERFACE_CHECK(AcpiDevAmlIf, (obj), TYPE_ACPI_DEV_AML_IF)
+
+typedef struct AcpiDevAmlIf AcpiDevAmlIf;  

I do not see where struct AcpiDevAmlIf is defined. I guess this is through the macro magic.

it's used for type checking only of opaque pointer (Interfaces are not supposed to have any state)

Quoted 53 lines
Quoted 53 lines
include/hw/acpi/acpi_aml_interface.h new file +27 -0
+typedef void (*dev_aml_fn)(AcpiDevAmlIf *adev, Aml *scope);
+
+/**
+ * AcpiDevAmlIfClass:
+ *
+ * build_dev_aml: adds device specific AML blob to provided scope
+ *
+ * Interface is designed for providing generic callback that builds device
+ * specific AML blob.
+ */
+struct AcpiDevAmlIfClass {
+    /* <private> */
+    InterfaceClass parent_class;
+
+    /* <public> */
+    dev_aml_fn build_dev_aml;
+};
+
+static inline void call_dev_aml_func(DeviceState *dev, Aml *scope)
+{
+    if (object_dynamic_cast(OBJECT(dev), TYPE_ACPI_DEV_AML_IF)) {
+        AcpiDevAmlIfClass *klass = ACPI_DEV_AML_IF_GET_CLASS(dev);
+        klass->build_dev_aml(ACPI_DEV_AML_IF(dev), scope);
+    }
+}
+
+#endif
hw/acpi/acpi_interface.c +8 -0
index 6583917b8e..c668d361f6 100644
@@ -1,5 +1,6 @@
 #include "qemu/osdep.h"
 #include "hw/acpi/acpi_dev_interface.h"
+#include "hw/acpi/acpi_aml_interface.h"
 #include "qemu/module.h"
 
 void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event)
@@ -18,8 +19,15 @@ static void register_types(void)
         .parent        = TYPE_INTERFACE,
         .class_size = sizeof(AcpiDeviceIfClass),
     };
+    static const TypeInfo acpi_dev_aml_if_info = {
+        .name          = TYPE_ACPI_DEV_AML_IF,
+        .parent        = TYPE_INTERFACE,
+        .class_size = sizeof(AcpiDevAmlIfClass),
+    };
+
 
     type_register_static(&acpi_dev_if_info);
+    type_register_static(&acpi_dev_aml_if_info);
 }
 
Quoted 13 lines

hw/acpi/meson.build acpi_ss.add(when: 'CONFIG_PC', if_false: files('acpi-x86-stub.c')) · line 31

Quoted 11 lines
hw/acpi/acpi_interface.c +0 -0
 type_init(register_types)
hw/acpi/meson.build +1 -1
index 8bea2e6933..9504f5ce09 100644
@@ -28,7 +28,7 @@ acpi_ss.add(when: 'CONFIG_PC', if_false: files('acpi-x86-stub.c'))
 if have_tpm
   acpi_ss.add(files('tpm.c'))
 endif
-softmmu_ss.add(when: 'CONFIG_ACPI', if_false: files('acpi-stub.c', 'aml-build-stub.c', 'ghes-stub.c'))
+softmmu_ss.add(when: 'CONFIG_ACPI', if_false: files('acpi-stub.c', 'aml-build-stub.c', 'ghes-stub.c', 'acpi_interface.c'))  

This is wrong. It should be the stub file not the real thing.

I can put type definition into acpi-stub.c, but will be exact duplicate (i.e. you can't stub QOM type definition), hence acpi_interface.c (which is mostly QOM type definitions) is being included in non acpi build to avoid duplication.

Quoted 8 lines
Quoted 7 lines
hw/acpi/meson.build +0 -1
 softmmu_ss.add_all(when: 'CONFIG_ACPI', if_true: acpi_ss)
 softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('acpi-stub.c', 'aml-build-stub.c',
                                                   'acpi-x86-stub.c', 'ipmi-stub.c', 'ghes-stub.c',
--

2.31.1

#4 lore raw

PATCH 2/35 acpi: make isa_build_aml() support AcpiDevAmlIf interface

In reply to Igor Mammedov

To allow incremental conversion from ISADeviceClass::build_aml to AcpiDevAmlIf, add support for the later without removing the former. Once conversion is complete, another commit will drop ISADeviceClass::build_aml related code.

---
 hw/isa/isa-bus.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/isa/isa-bus.c +5 -0
index cd5ad3687d..237e2cee12 100644
@@ -24,6 +24,7 @@
 #include "hw/sysbus.h"
 #include "sysemu/sysemu.h"
 #include "hw/isa/isa.h"
+#include "hw/acpi/acpi_aml_interface.h"
 
 static ISABus *isabus;
 
@@ -196,8 +197,12 @@ void isa_build_aml(ISABus *bus, Aml *scope)
     QTAILQ_FOREACH(kid, &bus->parent_obj.children, sibling) {
         dev = ISA_DEVICE(kid->child);
         dc = ISA_DEVICE_GET_CLASS(dev);
+        bool has_build_dev_aml = !!object_dynamic_cast(OBJECT(dev),
+                                                       TYPE_ACPI_DEV_AML_IF);
         if (dc->build_aml) {
             dc->build_aml(dev, scope);
+        } else if (has_build_dev_aml) {
+            call_dev_aml_func(DEVICE(dev), scope);
         }
     }
 }
Signature · 1 line
2.31.1
Reviewed-by on v1 2/35
#5 lore raw

Re: [PATCH 02/35] acpi: make isa_build_aml() support AcpiDevAmlIf interface

Quoted 7 lines · Igor Mammedov

To allow incremental conversion from ISADeviceClass::build_aml to AcpiDevAmlIf, add support for the later without removing the former. Once conversion is complete, another commit will drop ISADeviceClass::build_aml related code.

Quoted 32 lines
---
 hw/isa/isa-bus.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/isa/isa-bus.c +5 -1
index cd5ad3687d..237e2cee12 100644
@@ -24,6 +24,7 @@
 #include "hw/sysbus.h"
 #include "sysemu/sysemu.h"
 #include "hw/isa/isa.h"
+#include "hw/acpi/acpi_aml_interface.h"
 
 static ISABus *isabus;
 
@@ -196,8 +197,12 @@ void isa_build_aml(ISABus *bus, Aml *scope)
     QTAILQ_FOREACH(kid, &bus->parent_obj.children, sibling) {
         dev = ISA_DEVICE(kid->child);
         dc = ISA_DEVICE_GET_CLASS(dev);
+        bool has_build_dev_aml = !!object_dynamic_cast(OBJECT(dev),
+                                                       TYPE_ACPI_DEV_AML_IF);
         if (dc->build_aml) {
             dc->build_aml(dev, scope);
+        } else if (has_build_dev_aml) {
+            call_dev_aml_func(DEVICE(dev), scope);
         }
     }
 }
--

2.31.1

#6 lore raw

PATCH 3/35 acpi: fdc-isa: replace ISADeviceClass::build_aml with AcpiDevAmlIfClass:build_dev_aml

In reply to Igor Mammedov
---
 hw/block/fdc-isa.c   | 16 ++++++++++------
 hw/i386/acpi-build.c |  1 -
 2 files changed, 10 insertions(+), 7 deletions(-)
hw/block/fdc-isa.c +10 -6
index fa20450747..fee1ca68a8 100644
@@ -32,7 +32,7 @@
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "qemu/timer.h"
-#include "hw/acpi/aml-build.h"
+#include "hw/acpi/acpi_aml_interface.h"
 #include "hw/irq.h"
 #include "hw/isa/isa.h"
 #include "hw/qdev-properties.h"
@@ -214,9 +214,9 @@ int cmos_get_fd_drive_type(FloppyDriveType fd0)
     return val;
 }
 
-static void fdc_isa_build_aml(ISADevice *isadev, Aml *scope)
+static void build_fdc_aml(AcpiDevAmlIf *adev, Aml *scope)
 {
-    FDCtrlISABus *isa = ISA_FDC(isadev);
+    FDCtrlISABus *isa = ISA_FDC(adev);
     Aml *dev;
     Aml *crs;
     int i;
@@ -241,7 +241,7 @@ static void fdc_isa_build_aml(ISADevice *isadev, Aml *scope)
     aml_append(dev, aml_name_decl("_CRS", crs));
 
     for (i = 0; i < MIN(MAX_FD, ACPI_FDE_MAX_FD); i++) {
-        FloppyDriveType type = isa_fdc_get_drive_type(isadev, i);
+        FloppyDriveType type = isa_fdc_get_drive_type(ISA_DEVICE(adev), i);
 
         if (type < FLOPPY_DRIVE_TYPE_NONE) {
             fde_buf[i] = cpu_to_le32(1);  /* drive present */
@@ -283,14 +283,14 @@ static Property isa_fdc_properties[] = {
 static void isabus_fdc_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    ISADeviceClass *isa = ISA_DEVICE_CLASS(klass);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
 
     dc->desc = "virtual floppy controller";
     dc->realize = isabus_fdc_realize;
     dc->fw_name = "fdc";
     dc->reset = fdctrl_external_reset_isa;
     dc->vmsd = &vmstate_isa_fdc;
-    isa->build_aml = fdc_isa_build_aml;
+    adevc->build_dev_aml = build_fdc_aml;
     device_class_set_props(dc, isa_fdc_properties);
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
 }
@@ -313,6 +313,10 @@ static const TypeInfo isa_fdc_info = {
     .instance_size = sizeof(FDCtrlISABus),
     .class_init    = isabus_fdc_class_init,
     .instance_init = isabus_fdc_instance_init,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_ACPI_DEV_AML_IF },
+        { },
+    },
 };
 
 static void isa_fdc_register_types(void)
hw/i386/acpi-build.c +0 -1
index dcf6ece3d0..92455579b2 100644
@@ -39,7 +39,6 @@
 #include "hw/acpi/bios-linker-loader.h"
 #include "hw/isa/isa.h"
 #include "hw/input/i8042.h"
-#include "hw/block/fdc.h"
 #include "hw/acpi/memory_hotplug.h"
 #include "sysemu/tpm.h"
 #include "hw/acpi/tpm.h"
Signature · 1 line
2.31.1
#7 lore raw

PATCH 4/35 acpi: parallel port: replace ISADeviceClass::build_aml with AcpiDevAmlIfClass:build_dev_aml

In reply to Igor Mammedov
---
 hw/char/parallel.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
hw/char/parallel.c +9 -5
index f735a6cd7f..1c9ca47820 100644
@@ -28,7 +28,7 @@
 #include "qemu/module.h"
 #include "chardev/char-parallel.h"
 #include "chardev/char-fe.h"
-#include "hw/acpi/aml-build.h"
+#include "hw/acpi/acpi_aml_interface.h"
 #include "hw/irq.h"
 #include "hw/isa/isa.h"
 #include "hw/qdev-properties.h"
@@ -570,9 +570,9 @@ static void parallel_isa_realizefn(DeviceState *dev, Error **errp)
                              s, "parallel");
 }
 
-static void parallel_isa_build_aml(ISADevice *isadev, Aml *scope)
+static void parallel_isa_build_aml(AcpiDevAmlIf *adev, Aml *scope)
 {
-    ISAParallelState *isa = ISA_PARALLEL(isadev);
+    ISAParallelState *isa = ISA_PARALLEL(adev);
     Aml *dev;
     Aml *crs;
 
@@ -645,11 +645,11 @@ static Property parallel_isa_properties[] = {
 static void parallel_isa_class_initfn(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    ISADeviceClass *isa = ISA_DEVICE_CLASS(klass);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
 
     dc->realize = parallel_isa_realizefn;
     dc->vmsd = &vmstate_parallel_isa;
-    isa->build_aml = parallel_isa_build_aml;
+    adevc->build_dev_aml = parallel_isa_build_aml;
     device_class_set_props(dc, parallel_isa_properties);
     set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
 }
@@ -659,6 +659,10 @@ static const TypeInfo parallel_isa_info = {
     .parent        = TYPE_ISA_DEVICE,
     .instance_size = sizeof(ISAParallelState),
     .class_init    = parallel_isa_class_initfn,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_ACPI_DEV_AML_IF },
+        { },
+    },
 };
 
 static void parallel_register_types(void)
Signature · 1 line
2.31.1
#8 lore raw

PATCH 5/35 acpi: serial-is: replace ISADeviceClass::build_aml with AcpiDevAmlIfClass:build_dev_aml

In reply to Igor Mammedov
---
 hw/char/serial-isa.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
hw/char/serial-isa.c +9 -5
index 7a7ed239cd..141a6cb168 100644
@@ -27,7 +27,7 @@
 #include "qapi/error.h"
 #include "qemu/module.h"
 #include "sysemu/sysemu.h"
-#include "hw/acpi/aml-build.h"
+#include "hw/acpi/acpi_aml_interface.h"
 #include "hw/char/serial.h"
 #include "hw/isa/isa.h"
 #include "hw/qdev-properties.h"
@@ -83,9 +83,9 @@ static void serial_isa_realizefn(DeviceState *dev, Error **errp)
     isa_register_ioport(isadev, &s->io, isa->iobase);
 }
 
-static void serial_isa_build_aml(ISADevice *isadev, Aml *scope)
+static void serial_isa_build_aml(AcpiDevAmlIf *adev, Aml *scope)
 {
-    ISASerialState *isa = ISA_SERIAL(isadev);
+    ISASerialState *isa = ISA_SERIAL(adev);
     Aml *dev;
     Aml *crs;
 
@@ -122,11 +122,11 @@ static Property serial_isa_properties[] = {
 static void serial_isa_class_initfn(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    ISADeviceClass *isa = ISA_DEVICE_CLASS(klass);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
 
     dc->realize = serial_isa_realizefn;
     dc->vmsd = &vmstate_isa_serial;
-    isa->build_aml = serial_isa_build_aml;
+    adevc->build_dev_aml = serial_isa_build_aml;
     device_class_set_props(dc, serial_isa_properties);
     set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
 }
@@ -146,6 +146,10 @@ static const TypeInfo serial_isa_info = {
     .instance_size = sizeof(ISASerialState),
     .instance_init = serial_isa_initfn,
     .class_init    = serial_isa_class_initfn,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_ACPI_DEV_AML_IF },
+        { },
+    },
 };
 
 static void serial_register_types(void)
Signature · 1 line
2.31.1
#9 lore raw

PATCH 6/35 acpi: mc146818rtc: replace ISADeviceClass::build_aml with AcpiDevAmlIfClass:build_dev_aml

In reply to Igor Mammedov
---
 hw/rtc/mc146818rtc.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
hw/rtc/mc146818rtc.c +9 -5
index f235c2ddbe..ef9765bb8f 100644
@@ -26,7 +26,7 @@
 #include "qemu/cutils.h"
 #include "qemu/module.h"
 #include "qemu/bcd.h"
-#include "hw/acpi/aml-build.h"
+#include "hw/acpi/acpi_aml_interface.h"
 #include "hw/irq.h"
 #include "hw/qdev-properties.h"
 #include "hw/qdev-properties-system.h"
@@ -1017,9 +1017,9 @@ static void rtc_reset_hold(Object *obj)
     qemu_irq_lower(s->irq);
 }
 
-static void rtc_build_aml(ISADevice *isadev, Aml *scope)
+static void rtc_build_aml(AcpiDevAmlIf *adev, Aml *scope)
 {
-    RTCState *s = MC146818_RTC(isadev);
+    RTCState *s = MC146818_RTC(adev);
     Aml *dev;
     Aml *crs;
 
@@ -1043,13 +1043,13 @@ static void rtc_class_initfn(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     ResettableClass *rc = RESETTABLE_CLASS(klass);
-    ISADeviceClass *isa = ISA_DEVICE_CLASS(klass);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
 
     dc->realize = rtc_realizefn;
     dc->vmsd = &vmstate_rtc;
     rc->phases.enter = rtc_reset_enter;
     rc->phases.hold = rtc_reset_hold;
-    isa->build_aml = rtc_build_aml;
+    adevc->build_dev_aml = rtc_build_aml;
     device_class_set_props(dc, mc146818rtc_properties);
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
 }
@@ -1059,6 +1059,10 @@ static const TypeInfo mc146818rtc_info = {
     .parent        = TYPE_ISA_DEVICE,
     .instance_size = sizeof(RTCState),
     .class_init    = rtc_class_initfn,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_ACPI_DEV_AML_IF },
+        { },
+    },
 };
 
 static void mc146818rtc_register_types(void)
Signature · 1 line
2.31.1
#10 lore raw

PATCH 7/35 acpi: pckbd: replace ISADeviceClass::build_aml with AcpiDevAmlIfClass:build_dev_aml

In reply to Igor Mammedov
---
 hw/input/pckbd.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
hw/input/pckbd.c +9 -5
index 4efdf75620..45c40fe3f3 100644
@@ -29,7 +29,7 @@
 #include "qapi/error.h"
 #include "hw/isa/isa.h"
 #include "migration/vmstate.h"
-#include "hw/acpi/aml-build.h"
+#include "hw/acpi/acpi_aml_interface.h"
 #include "hw/input/ps2.h"
 #include "hw/irq.h"
 #include "hw/input/i8042.h"
@@ -767,9 +767,9 @@ static void i8042_realizefn(DeviceState *dev, Error **errp)
     qemu_register_reset(kbd_reset, s);
 }
 
-static void i8042_build_aml(ISADevice *isadev, Aml *scope)
+static void i8042_build_aml(AcpiDevAmlIf *adev, Aml *scope)
 {
-    ISAKBDState *isa_s = I8042(isadev);
+    ISAKBDState *isa_s = I8042(adev);
     Aml *kbd;
     Aml *mou;
     Aml *crs;
@@ -807,12 +807,12 @@ static Property i8042_properties[] = {
 static void i8042_class_initfn(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    ISADeviceClass *isa = ISA_DEVICE_CLASS(klass);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
 
     device_class_set_props(dc, i8042_properties);
     dc->realize = i8042_realizefn;
     dc->vmsd = &vmstate_kbd_isa;
-    isa->build_aml = i8042_build_aml;
+    adevc->build_dev_aml = i8042_build_aml;
     set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
 }
 
@@ -822,6 +822,10 @@ static const TypeInfo i8042_info = {
     .instance_size = sizeof(ISAKBDState),
     .instance_init = i8042_initfn,
     .class_init    = i8042_class_initfn,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_ACPI_DEV_AML_IF },
+        { },
+    },
 };
 
 static void i8042_register_types(void)
Signature · 1 line
2.31.1
#11 lore raw

PATCH 8/35 isa-bus: drop no longer used ISADeviceClass::build_aml

In reply to Igor Mammedov
---
 include/hw/isa/isa.h |  1 -
 hw/isa/isa-bus.c     | 12 +-----------
 2 files changed, 1 insertion(+), 12 deletions(-)
include/hw/isa/isa.h +0 -1
index 034d706ba1..5c5a3d43a7 100644
@@ -64,7 +64,6 @@ struct IsaDmaClass {
 
 struct ISADeviceClass {
     DeviceClass parent_class;
-    void (*build_aml)(ISADevice *dev, Aml *scope);
 };
 
 struct ISABus {
hw/isa/isa-bus.c +1 -11
index 237e2cee12..1bee1a47f1 100644
@@ -191,19 +191,9 @@ ISADevice *isa_vga_init(ISABus *bus)
 void isa_build_aml(ISABus *bus, Aml *scope)
 {
     BusChild *kid;
-    ISADevice *dev;
-    ISADeviceClass *dc;
 
     QTAILQ_FOREACH(kid, &bus->parent_obj.children, sibling) {
-        dev = ISA_DEVICE(kid->child);
-        dc = ISA_DEVICE_GET_CLASS(dev);
-        bool has_build_dev_aml = !!object_dynamic_cast(OBJECT(dev),
-                                                       TYPE_ACPI_DEV_AML_IF);
-        if (dc->build_aml) {
-            dc->build_aml(dev, scope);
-        } else if (has_build_dev_aml) {
-            call_dev_aml_func(DEVICE(dev), scope);
-        }
+        call_dev_aml_func(DEVICE(kid->child), scope);
     }
 }
 
Signature · 1 line
2.31.1
#12 lore raw

PATCH 9/35 tests: acpi: add and whitelist DSDT.ipmismbus expected blob

In reply to Igor Mammedov

.. which will be used by follow up smbus-ipmi test-case

---
 tests/qtest/bios-tables-test-allowed-diff.h | 1 +
 tests/data/acpi/q35/DSDT.ipmismbus          | 0
 2 files changed, 1 insertion(+)
 create mode 100644 tests/data/acpi/q35/DSDT.ipmismbus
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
index dfb8523c8b..b4687d1cc8 100644
@@ -1 +1,2 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/q35/DSDT.ipmismbus",
tests/data/acpi/q35/DSDT.ipmismbus new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
Signature · 1 line
2.31.1
#13 lore raw

PATCH 10/35 tests: acpi: q35: add test for smbus-ipmi device

In reply to Igor Mammedov

expected new device node:

    Device (MI1)
    {
        Name (_HID, EisaId ("IPI0001"))  // _HID: Hardware ID
        Name (_STR, "ipmi_smbus")  // _STR: Description String
        Name (_UID, One)  // _UID: Unique ID
        Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
        {
            I2cSerialBusV2 (0x0000, ControllerInitiated, 0x000186A0,
                AddressingMode7Bit, "\\_SB.PCI0.SMB0",
                0x00, ResourceProducer, , Exclusive,
                )
        })
        Name (_IFT, 0x04)  // _IFT: IPMI Interface Type
        Name (_SRV, 0x0200)  // _SRV: IPMI Spec Revision
    }
---
 tests/qtest/bios-tables-test.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
tests/qtest/bios-tables-test.c +16 -0
index 5dddedabcd..615cbdaf17 100644
@@ -955,6 +955,21 @@ static void test_acpi_q35_tcg_ipmi(void)
     free_test_data(&data);
 }
 
+static void test_acpi_q35_tcg_smbus_ipmi(void)
+{
+    test_data data;
+
+    memset(&data, 0, sizeof(data));
+    data.machine = MACHINE_Q35;
+    data.variant = ".ipmismbus";
+    data.required_struct_types = ipmi_required_struct_types;
+    data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types);
+    test_acpi_one("-device ipmi-bmc-sim,id=bmc0"
+                  " -device smbus-ipmi,bmc=bmc0",
+                  &data);
+    free_test_data(&data);
+}
+
 static void test_acpi_piix4_tcg_ipmi(void)
 {
     test_data data;
@@ -1700,6 +1715,7 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64);
         qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi);
         qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi);
+        qtest_add_func("acpi/q35/smbus/ipmi", test_acpi_q35_tcg_smbus_ipmi);
         qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp);
         qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp);
         qtest_add_func("acpi/piix4/memhp", test_acpi_piix4_tcg_memhp);
Signature · 1 line
2.31.1
#14 lore raw

PATCH 11/35 tests: acpi: update expected blob DSDT.ipmismbus

In reply to Igor Mammedov

basic q35 DSDT with an extra device node:

  Device (MI1)
    {
        Name (_HID, EisaId ("IPI0001"))  // _HID: Hardware ID
        Name (_STR, "ipmi_smbus")  // _STR: Description String
        Name (_UID, One)  // _UID: Unique ID
        Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
        {
      I2cSerialBusV2 (0x0000, ControllerInitiated, 0x000186A0,
          AddressingMode7Bit, "\\_SB.PCI0.SMB0",
          0x00, ResourceProducer, , Exclusive,
          )
        })
        Name (_IFT, 0x04)  // _IFT: IPMI Interface Type
        Name (_SRV, 0x0200)  // _SRV: IPMI Spec Revision
    }
---
 tests/qtest/bios-tables-test-allowed-diff.h |   1 -
 tests/data/acpi/q35/DSDT.ipmismbus          | Bin 0 -> 8391 bytes
 2 files changed, 1 deletion(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
index b4687d1cc8..dfb8523c8b 100644
@@ -1,2 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/q35/DSDT.ipmismbus",
tests/data/acpi/q35/DSDT.ipmismbus binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..07ba873b79caadd73ed9721fcbeee84c57676e2a 100644
GIT binary patch
Signature · 1 line
2.31.1
#15 lore raw

PATCH 12/35 tests: acpi: whitelist DSDT.ipmismbus expected blob

In reply to Igor Mammedov
---
 tests/qtest/bios-tables-test-allowed-diff.h | 1 +
 1 file changed, 1 insertion(+)
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
index dfb8523c8b..b4687d1cc8 100644
@@ -1 +1,2 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/q35/DSDT.ipmismbus",
Signature · 1 line
2.31.1
#16 lore raw

PATCH 13/35 ipmi: acpi: use relative path to resource source

In reply to Igor Mammedov

smbus-ipmi AML description needs to specify a path to its parent node in _CRS. The rest of IPMI inplementations (ISA based) do not need path at all. Instead of passing through a full path use relative path to point to smbus-ipmi's parent node, it will let follow up patches to create IPMI device AML in a generic way instead of current ad-hoc way. (i.e. AML will be generated the same way it's done for other ISA device, and smbus will be converted to generate AML for its slave devices the same way as ISA)

expected AML change:

     Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
     {
        I2cSerialBusV2 (0x0000, ControllerInitiated, 0x000186A0,
-           AddressingMode7Bit, "\\_SB.PCI0.SMB0",
+           AddressingMode7Bit, "^",
            0x00, ResourceProducer, , Exclusive,
            )
      })
---
 include/hw/acpi/ipmi.h |  2 +-
 hw/acpi/ipmi-stub.c    |  2 +-
 hw/acpi/ipmi.c         | 12 ++++++------
 hw/i386/acpi-build.c   |  4 ++--
 4 files changed, 10 insertions(+), 10 deletions(-)
include/hw/acpi/ipmi.h +1 -1
index c14ad682ac..c38483565c 100644
@@ -16,6 +16,6 @@
  * bus matches the given bus.  The resource is the ACPI resource that
  * contains the IPMI device, this is required for the I2C CRS.
  */
-void build_acpi_ipmi_devices(Aml *table, BusState *bus, const char *resource);
+void build_acpi_ipmi_devices(Aml *table, BusState *bus);
 
 #endif /* HW_ACPI_IPMI_H */
hw/acpi/ipmi-stub.c +1 -1
index 8634fb325c..f525f71c2d 100644
@@ -10,6 +10,6 @@
 #include "qemu/osdep.h"
 #include "hw/acpi/ipmi.h"
 
-void build_acpi_ipmi_devices(Aml *table, BusState *bus, const char *resource)
+void build_acpi_ipmi_devices(Aml *table, BusState *bus)
 {
 }
hw/acpi/ipmi.c +6 -6
index 96e48eba15..c30b44fcf5 100644
@@ -13,7 +13,7 @@
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/ipmi.h"
 
-static Aml *aml_ipmi_crs(IPMIFwInfo *info, const char *resource)
+static Aml *aml_ipmi_crs(IPMIFwInfo *info)
 {
     Aml *crs = aml_resource_template();
 
@@ -49,7 +49,7 @@ static Aml *aml_ipmi_crs(IPMIFwInfo *info, const char *resource)
         break;
     case IPMI_MEMSPACE_SMBUS:
         aml_append(crs, aml_i2c_serial_bus_device(info->base_address,
-                                                  resource));
+                                                  "^"));
         break;
     default:
         abort();
@@ -62,7 +62,7 @@ static Aml *aml_ipmi_crs(IPMIFwInfo *info, const char *resource)
     return crs;
 }
 
-static Aml *aml_ipmi_device(IPMIFwInfo *info, const char *resource)
+static Aml *aml_ipmi_device(IPMIFwInfo *info)
 {
     Aml *dev;
     uint16_t version = ((info->ipmi_spec_major_revision << 8)
@@ -75,14 +75,14 @@ static Aml *aml_ipmi_device(IPMIFwInfo *info, const char *resource)
     aml_append(dev, aml_name_decl("_STR", aml_string("ipmi_%s",
                                                      info->interface_name)));
     aml_append(dev, aml_name_decl("_UID", aml_int(info->uuid)));
-    aml_append(dev, aml_name_decl("_CRS", aml_ipmi_crs(info, resource)));
+    aml_append(dev, aml_name_decl("_CRS", aml_ipmi_crs(info)));
     aml_append(dev, aml_name_decl("_IFT", aml_int(info->interface_type)));
     aml_append(dev, aml_name_decl("_SRV", aml_int(version)));
 
     return dev;
 }
 
-void build_acpi_ipmi_devices(Aml *scope, BusState *bus, const char *resource)
+void build_acpi_ipmi_devices(Aml *scope, BusState *bus)
 {
 
     BusChild *kid;
@@ -102,6 +102,6 @@ void build_acpi_ipmi_devices(Aml *scope, BusState *bus, const char *resource)
         iic = IPMI_INTERFACE_GET_CLASS(obj);
         memset(&info, 0, sizeof(info));
         iic->get_fwinfo(ii, &info);
-        aml_append(scope, aml_ipmi_device(&info, resource));
+        aml_append(scope, aml_ipmi_device(&info));
     }
 }
hw/i386/acpi-build.c +2 -2
index 92455579b2..6dce8354cc 100644
@@ -870,7 +870,7 @@ static void build_isa_devices_aml(Aml *table)
     assert(obj && !ambiguous);
 
     scope = aml_scope("_SB.PCI0.ISA");
-    build_acpi_ipmi_devices(scope, BUS(obj), "\\_SB.PCI0.ISA");
+    build_acpi_ipmi_devices(scope, BUS(obj));
     isa_build_aml(ISA_BUS(obj), scope);
 
     aml_append(table, scope);
@@ -1403,7 +1403,7 @@ static void build_smb0(Aml *table, I2CBus *smbus, int devnr, int func)
     Aml *dev = aml_device("SMB0");
 
     aml_append(dev, aml_name_decl("_ADR", aml_int(devnr << 16 | func)));
-    build_acpi_ipmi_devices(dev, BUS(smbus), "\\_SB.PCI0.SMB0");
+    build_acpi_ipmi_devices(dev, BUS(smbus));
     aml_append(scope, dev);
     aml_append(table, scope);
 }
Signature · 1 line
2.31.1
#17 lore raw

PATCH 14/35 tests: acpi: update expected DSDT.ipmismbus blob

In reply to Igor Mammedov

expected AML change:

         Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
         {
            I2cSerialBusV2 (0x0000, ControllerInitiated, 0x000186A0,
    -           AddressingMode7Bit, "\\_SB.PCI0.SMB0",
    +           AddressingMode7Bit, "^",
                0x00, ResourceProducer, , Exclusive,
                )
          })
---
 tests/qtest/bios-tables-test-allowed-diff.h |   1 -
 tests/data/acpi/q35/DSDT.ipmismbus          | Bin 8391 -> 8378 bytes
 2 files changed, 1 deletion(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
index b4687d1cc8..dfb8523c8b 100644
@@ -1,2 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/q35/DSDT.ipmismbus",
tests/data/acpi/q35/DSDT.ipmismbus binary +0 -0
index 07ba873b79caadd73ed9721fcbeee84c57676e2a..415fe08a407690c0e118743d872de79d22f01a4c 100644
GIT binary patch
Signature · 1 line
2.31.1
#18 lore raw

PATCH 15/35 acpi: ich9-smb: add support for AcpiDevAmlIf interface

In reply to Igor Mammedov

wire AcpiDevAmlIf interface to build ich9-smb and its slave devices AML. It will be used by followup patches to switch from creating AML in ad-hoc way to a more systematic one that will scan present devices and ask them to provide their AML code like it's done with ISA devices.

This patch is a partial conversion, as it only fetches AML from slave devices attached to its I2C bus.

The conversion will be completed when PCI bus is switched to use AcpiDevAmlIf and build_smb0() could be dropped.

---
 hw/i2c/smbus_ich9.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
hw/i2c/smbus_ich9.c +15 -0
index 44dd5653b7..ee50ba1f2c 100644
@@ -29,6 +29,7 @@
 
 #include "hw/i386/ich9.h"
 #include "qom/object.h"
+#include "hw/acpi/acpi_aml_interface.h"
 
 OBJECT_DECLARE_SIMPLE_TYPE(ICH9SMBState, ICH9_SMB_DEVICE)
 
@@ -94,10 +95,22 @@ static void ich9_smbus_realize(PCIDevice *d, Error **errp)
                      &s->smb.io);
 }
 
+static void build_ich9_smb_aml(AcpiDevAmlIf *adev, Aml *scope)
+{
+    BusChild *kid;
+    ICH9SMBState *s = ICH9_SMB_DEVICE(adev);
+    BusState *bus = BUS(s->smb.smbus);
+
+    QTAILQ_FOREACH(kid, &bus->children, sibling) {
+            call_dev_aml_func(DEVICE(kid->child), scope);
+    }
+}
+
 static void ich9_smb_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
 
     k->vendor_id = PCI_VENDOR_ID_INTEL;
     k->device_id = PCI_DEVICE_ID_INTEL_ICH9_6;
@@ -112,6 +125,7 @@ static void ich9_smb_class_init(ObjectClass *klass, void *data)
      * pc_q35_init()
      */
     dc->user_creatable = false;
+    adevc->build_dev_aml = build_ich9_smb_aml;
 }
 
 static void ich9_smb_set_irq(PMSMBus *pmsmb, bool enabled)
@@ -143,6 +157,7 @@ static const TypeInfo ich9_smb_info = {
     .class_init = ich9_smb_class_init,
     .interfaces = (InterfaceInfo[]) {
         { INTERFACE_CONVENTIONAL_PCI_DEVICE },
+        { TYPE_ACPI_DEV_AML_IF },
         { },
     },
 };
Signature · 1 line
2.31.1
#19 lore raw

PATCH 16/35 acpi: ipmi: use AcpiDevAmlIf interface to build IPMI device descriptors

In reply to Igor Mammedov

convert ad-hoc way we use to generate AML for ISA/SMB IPMI devices to a generic approach (i.e. make devices provide its own AML blobs like it is done with other ISA devices (ex. KBD))

---
 include/hw/acpi/ipmi.h |  9 ++------
 hw/acpi/ipmi-stub.c    |  2 +-
 hw/acpi/ipmi.c         | 49 +++++++++++++-----------------------------
 hw/i386/acpi-build.c   | 17 ++++++++++-----
 hw/ipmi/isa_ipmi_bt.c  |  4 ++++
 hw/ipmi/isa_ipmi_kcs.c |  4 ++++
 hw/ipmi/smbus_ipmi.c   |  4 ++++
 7 files changed, 42 insertions(+), 47 deletions(-)
include/hw/acpi/ipmi.h +2 -7
index c38483565c..6c8079c97a 100644
@@ -9,13 +9,8 @@
 #ifndef HW_ACPI_IPMI_H
 #define HW_ACPI_IPMI_H
 
-#include "hw/acpi/aml-build.h"
+#include "hw/acpi/acpi_aml_interface.h"
 
-/*
- * Add ACPI IPMI entries for all registered IPMI devices whose parent
- * bus matches the given bus.  The resource is the ACPI resource that
- * contains the IPMI device, this is required for the I2C CRS.
- */
-void build_acpi_ipmi_devices(Aml *table, BusState *bus);
+void build_ipmi_dev_aml(AcpiDevAmlIf *adev, Aml *scope);
 
 #endif /* HW_ACPI_IPMI_H */
hw/acpi/ipmi-stub.c +1 -1
index f525f71c2d..befaf0a882 100644
@@ -10,6 +10,6 @@
 #include "qemu/osdep.h"
 #include "hw/acpi/ipmi.h"
 
-void build_acpi_ipmi_devices(Aml *table, BusState *bus)
+void build_ipmi_dev_aml(AcpiDevAmlIf *adev, Aml *scope)
 {
 }
hw/acpi/ipmi.c +15 -34

61 lines not on this page · raw message

hw/i386/acpi-build.c +12 -5
index 6dce8354cc..ca5cab87ba 100644
@@ -38,6 +38,7 @@
 #include "hw/nvram/fw_cfg.h"
 #include "hw/acpi/bios-linker-loader.h"
 #include "hw/isa/isa.h"
+#include "hw/acpi/acpi_aml_interface.h"
 #include "hw/input/i8042.h"
 #include "hw/acpi/memory_hotplug.h"
 #include "sysemu/tpm.h"
@@ -71,7 +72,6 @@
 #include "hw/i386/intel_iommu.h"
 #include "hw/virtio/virtio-iommu.h"
 
-#include "hw/acpi/ipmi.h"
 #include "hw/acpi/hmat.h"
 #include "hw/acpi/viot.h"
 
@@ -870,7 +870,6 @@ static void build_isa_devices_aml(Aml *table)
     assert(obj && !ambiguous);
 
     scope = aml_scope("_SB.PCI0.ISA");
-    build_acpi_ipmi_devices(scope, BUS(obj));
     isa_build_aml(ISA_BUS(obj), scope);
 
     aml_append(table, scope);
@@ -1397,13 +1396,21 @@ static Aml *build_q35_osc_method(bool enable_native_pcie_hotplug)
     return method;
 }
 
-static void build_smb0(Aml *table, I2CBus *smbus, int devnr, int func)
+static void build_smb0(Aml *table, int devnr, int func)
 {
     Aml *scope = aml_scope("_SB.PCI0");
     Aml *dev = aml_device("SMB0");
+    bool ambiguous;
+    Object *obj;
+    /*
+     * temporarily fish out device hosting SMBUS, build_smb0 will be gone once
+     * PCI enumeration will be switched to call_dev_aml_func()
+     */
+    obj = object_resolve_path_type("", TYPE_ICH9_SMB_DEVICE, &ambiguous);
+    assert(obj && !ambiguous);
 
     aml_append(dev, aml_name_decl("_ADR", aml_int(devnr << 16 | func)));
-    build_acpi_ipmi_devices(dev, BUS(smbus));
+    call_dev_aml_func(DEVICE(obj), dev);
     aml_append(scope, dev);
     aml_append(table, scope);
 }
@@ -1504,7 +1511,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         }
         build_q35_pci0_int(dsdt);
         if (pcms->smbus && !pcmc->do_not_add_smb_acpi) {
-            build_smb0(dsdt, pcms->smbus, ICH9_SMB_DEV, ICH9_SMB_FUNC);
+            build_smb0(dsdt, ICH9_SMB_DEV, ICH9_SMB_FUNC);
         }
     }
 
hw/ipmi/isa_ipmi_bt.c +4 -0
index 88aa734e9e..a83e7243d6 100644
@@ -31,6 +31,7 @@
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "qom/object.h"
+#include "hw/acpi/ipmi.h"
 
 #define TYPE_ISA_IPMI_BT "isa-ipmi-bt"
 OBJECT_DECLARE_SIMPLE_TYPE(ISAIPMIBTDevice, ISA_IPMI_BT)
@@ -144,6 +145,7 @@ static void isa_ipmi_bt_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
     IPMIInterfaceClass *iic = IPMI_INTERFACE_CLASS(oc);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(oc);
 
     dc->realize = isa_ipmi_bt_realize;
     device_class_set_props(dc, ipmi_isa_properties);
@@ -151,6 +153,7 @@ static void isa_ipmi_bt_class_init(ObjectClass *oc, void *data)
     iic->get_backend_data = isa_ipmi_bt_get_backend_data;
     ipmi_bt_class_init(iic);
     iic->get_fwinfo = isa_ipmi_bt_get_fwinfo;
+    adevc->build_dev_aml = build_ipmi_dev_aml;
 }
 
 static const TypeInfo isa_ipmi_bt_info = {
@@ -161,6 +164,7 @@ static const TypeInfo isa_ipmi_bt_info = {
     .class_init    = isa_ipmi_bt_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_IPMI_INTERFACE },
+        { TYPE_ACPI_DEV_AML_IF },
         { }
     }
 };
hw/ipmi/isa_ipmi_kcs.c +4 -0
index afabb95ebe..b2ed70b9da 100644
@@ -31,6 +31,7 @@
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "qom/object.h"
+#include "hw/acpi/ipmi.h"
 
 #define TYPE_ISA_IPMI_KCS "isa-ipmi-kcs"
 OBJECT_DECLARE_SIMPLE_TYPE(ISAIPMIKCSDevice, ISA_IPMI_KCS)
@@ -151,6 +152,7 @@ static void isa_ipmi_kcs_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
     IPMIInterfaceClass *iic = IPMI_INTERFACE_CLASS(oc);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(oc);
 
     dc->realize = ipmi_isa_realize;
     device_class_set_props(dc, ipmi_isa_properties);
@@ -158,6 +160,7 @@ static void isa_ipmi_kcs_class_init(ObjectClass *oc, void *data)
     iic->get_backend_data = isa_ipmi_kcs_get_backend_data;
     ipmi_kcs_class_init(iic);
     iic->get_fwinfo = isa_ipmi_kcs_get_fwinfo;
+    adevc->build_dev_aml = build_ipmi_dev_aml;
 }
 
 static const TypeInfo isa_ipmi_kcs_info = {
@@ -168,6 +171,7 @@ static const TypeInfo isa_ipmi_kcs_info = {
     .class_init    = isa_ipmi_kcs_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_IPMI_INTERFACE },
+        { TYPE_ACPI_DEV_AML_IF },
         { }
     }
 };
hw/ipmi/smbus_ipmi.c +4 -0
index 1fdf0a66b6..9ef9112dd5 100644
@@ -28,6 +28,7 @@
 #include "qemu/error-report.h"
 #include "hw/ipmi/ipmi.h"
 #include "qom/object.h"
+#include "hw/acpi/ipmi.h"
 
 #define TYPE_SMBUS_IPMI "smbus-ipmi"
 OBJECT_DECLARE_SIMPLE_TYPE(SMBusIPMIDevice, SMBUS_IPMI)
@@ -353,6 +354,7 @@ static void smbus_ipmi_class_init(ObjectClass *oc, void *data)
     DeviceClass *dc = DEVICE_CLASS(oc);
     IPMIInterfaceClass *iic = IPMI_INTERFACE_CLASS(oc);
     SMBusDeviceClass *sc = SMBUS_DEVICE_CLASS(oc);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(oc);
 
     sc->receive_byte = ipmi_receive_byte;
     sc->write_data = ipmi_write_data;
@@ -363,6 +365,7 @@ static void smbus_ipmi_class_init(ObjectClass *oc, void *data)
     iic->handle_if_event = smbus_ipmi_handle_event;
     iic->set_irq_enable = smbus_ipmi_set_irq_enable;
     iic->get_fwinfo = smbus_ipmi_get_fwinfo;
+    adevc->build_dev_aml = build_ipmi_dev_aml;
 }
 
 static const TypeInfo smbus_ipmi_info = {
@@ -373,6 +376,7 @@ static const TypeInfo smbus_ipmi_info = {
     .class_init    = smbus_ipmi_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_IPMI_INTERFACE },
+        { TYPE_ACPI_DEV_AML_IF },
         { }
     }
 };
Signature · 1 line
2.31.1
#20 lore raw

Re: [PATCH 16/35] acpi: ipmi: use AcpiDevAmlIf interface to build IPMI device descriptors

Quoted 5 lines · Igor Mammedov

convert ad-hoc way we use to generate AML for ISA/SMB IPMI devices to a generic approach (i.e. make devices provide its own AML blobs like it is done with other ISA devices (ex. KBD))

could not apply this. rebase and repost?

Quoted 279 lines
---
 include/hw/acpi/ipmi.h |  9 ++------
 hw/acpi/ipmi-stub.c    |  2 +-
 hw/acpi/ipmi.c         | 49 +++++++++++++-----------------------------
 hw/i386/acpi-build.c   | 17 ++++++++++-----
 hw/ipmi/isa_ipmi_bt.c  |  4 ++++
 hw/ipmi/isa_ipmi_kcs.c |  4 ++++
 hw/ipmi/smbus_ipmi.c   |  4 ++++
 7 files changed, 42 insertions(+), 47 deletions(-)
include/hw/acpi/ipmi.h +2 -7
index c38483565c..6c8079c97a 100644
@@ -9,13 +9,8 @@
 #ifndef HW_ACPI_IPMI_H
 #define HW_ACPI_IPMI_H
 
-#include "hw/acpi/aml-build.h"
+#include "hw/acpi/acpi_aml_interface.h"
 
-/*
- * Add ACPI IPMI entries for all registered IPMI devices whose parent
- * bus matches the given bus.  The resource is the ACPI resource that
- * contains the IPMI device, this is required for the I2C CRS.
- */
-void build_acpi_ipmi_devices(Aml *table, BusState *bus);
+void build_ipmi_dev_aml(AcpiDevAmlIf *adev, Aml *scope);
 
 #endif /* HW_ACPI_IPMI_H */
hw/acpi/ipmi-stub.c +1 -1
index f525f71c2d..befaf0a882 100644
@@ -10,6 +10,6 @@
 #include "qemu/osdep.h"
 #include "hw/acpi/ipmi.h"
 
-void build_acpi_ipmi_devices(Aml *table, BusState *bus)
+void build_ipmi_dev_aml(AcpiDevAmlIf *adev, Aml *scope)
 {
 }
hw/acpi/ipmi.c +15 -34
index c30b44fcf5..a20e57d465 100644
@@ -62,46 +62,27 @@ static Aml *aml_ipmi_crs(IPMIFwInfo *info)
     return crs;
 }
 
-static Aml *aml_ipmi_device(IPMIFwInfo *info)
+void build_ipmi_dev_aml(AcpiDevAmlIf *adev, Aml *scope)
 {
     Aml *dev;
-    uint16_t version = ((info->ipmi_spec_major_revision << 8)
-                        | (info->ipmi_spec_minor_revision << 4));
+    IPMIFwInfo info = {};
+    IPMIInterface *ii = IPMI_INTERFACE(adev);
+    IPMIInterfaceClass *iic = IPMI_INTERFACE_GET_CLASS(ii);
+    uint16_t version;
 
-    assert(info->ipmi_spec_minor_revision <= 15);
+    iic->get_fwinfo(ii, &info);
+    assert(info.ipmi_spec_minor_revision <= 15);
+    version = ((info.ipmi_spec_major_revision << 8)
+              | (info.ipmi_spec_minor_revision << 4));
 
-    dev = aml_device("MI%d", info->uuid);
+    dev = aml_device("MI%d", info.uuid);
     aml_append(dev, aml_name_decl("_HID", aml_eisaid("IPI0001")));
     aml_append(dev, aml_name_decl("_STR", aml_string("ipmi_%s",
-                                                     info->interface_name)));
-    aml_append(dev, aml_name_decl("_UID", aml_int(info->uuid)));
-    aml_append(dev, aml_name_decl("_CRS", aml_ipmi_crs(info)));
-    aml_append(dev, aml_name_decl("_IFT", aml_int(info->interface_type)));
+                                                     info.interface_name)));
+    aml_append(dev, aml_name_decl("_UID", aml_int(info.uuid)));
+    aml_append(dev, aml_name_decl("_CRS", aml_ipmi_crs(&info)));
+    aml_append(dev, aml_name_decl("_IFT", aml_int(info.interface_type)));
     aml_append(dev, aml_name_decl("_SRV", aml_int(version)));
 
-    return dev;
-}
-
-void build_acpi_ipmi_devices(Aml *scope, BusState *bus)
-{
-
-    BusChild *kid;
-
-    QTAILQ_FOREACH(kid, &bus->children,  sibling) {
-        IPMIInterface *ii;
-        IPMIInterfaceClass *iic;
-        IPMIFwInfo info;
-        Object *obj = object_dynamic_cast(OBJECT(kid->child),
-                                          TYPE_IPMI_INTERFACE);
-
-        if (!obj) {
-            continue;
-        }
-
-        ii = IPMI_INTERFACE(obj);
-        iic = IPMI_INTERFACE_GET_CLASS(obj);
-        memset(&info, 0, sizeof(info));
-        iic->get_fwinfo(ii, &info);
-        aml_append(scope, aml_ipmi_device(&info));
-    }
+    aml_append(scope, dev);
 }
hw/i386/acpi-build.c +12 -5
index 6dce8354cc..ca5cab87ba 100644
@@ -38,6 +38,7 @@
 #include "hw/nvram/fw_cfg.h"
 #include "hw/acpi/bios-linker-loader.h"
 #include "hw/isa/isa.h"
+#include "hw/acpi/acpi_aml_interface.h"
 #include "hw/input/i8042.h"
 #include "hw/acpi/memory_hotplug.h"
 #include "sysemu/tpm.h"
@@ -71,7 +72,6 @@
 #include "hw/i386/intel_iommu.h"
 #include "hw/virtio/virtio-iommu.h"
 
-#include "hw/acpi/ipmi.h"
 #include "hw/acpi/hmat.h"
 #include "hw/acpi/viot.h"
 
@@ -870,7 +870,6 @@ static void build_isa_devices_aml(Aml *table)
     assert(obj && !ambiguous);
 
     scope = aml_scope("_SB.PCI0.ISA");
-    build_acpi_ipmi_devices(scope, BUS(obj));
     isa_build_aml(ISA_BUS(obj), scope);
 
     aml_append(table, scope);
@@ -1397,13 +1396,21 @@ static Aml *build_q35_osc_method(bool enable_native_pcie_hotplug)
     return method;
 }
 
-static void build_smb0(Aml *table, I2CBus *smbus, int devnr, int func)
+static void build_smb0(Aml *table, int devnr, int func)
 {
     Aml *scope = aml_scope("_SB.PCI0");
     Aml *dev = aml_device("SMB0");
+    bool ambiguous;
+    Object *obj;
+    /*
+     * temporarily fish out device hosting SMBUS, build_smb0 will be gone once
+     * PCI enumeration will be switched to call_dev_aml_func()
+     */
+    obj = object_resolve_path_type("", TYPE_ICH9_SMB_DEVICE, &ambiguous);
+    assert(obj && !ambiguous);
 
     aml_append(dev, aml_name_decl("_ADR", aml_int(devnr << 16 | func)));
-    build_acpi_ipmi_devices(dev, BUS(smbus));
+    call_dev_aml_func(DEVICE(obj), dev);
     aml_append(scope, dev);
     aml_append(table, scope);
 }
@@ -1504,7 +1511,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         }
         build_q35_pci0_int(dsdt);
         if (pcms->smbus && !pcmc->do_not_add_smb_acpi) {
-            build_smb0(dsdt, pcms->smbus, ICH9_SMB_DEV, ICH9_SMB_FUNC);
+            build_smb0(dsdt, ICH9_SMB_DEV, ICH9_SMB_FUNC);
         }
     }
 
hw/ipmi/isa_ipmi_bt.c +4 -0
index 88aa734e9e..a83e7243d6 100644
@@ -31,6 +31,7 @@
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "qom/object.h"
+#include "hw/acpi/ipmi.h"
 
 #define TYPE_ISA_IPMI_BT "isa-ipmi-bt"
 OBJECT_DECLARE_SIMPLE_TYPE(ISAIPMIBTDevice, ISA_IPMI_BT)
@@ -144,6 +145,7 @@ static void isa_ipmi_bt_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
     IPMIInterfaceClass *iic = IPMI_INTERFACE_CLASS(oc);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(oc);
 
     dc->realize = isa_ipmi_bt_realize;
     device_class_set_props(dc, ipmi_isa_properties);
@@ -151,6 +153,7 @@ static void isa_ipmi_bt_class_init(ObjectClass *oc, void *data)
     iic->get_backend_data = isa_ipmi_bt_get_backend_data;
     ipmi_bt_class_init(iic);
     iic->get_fwinfo = isa_ipmi_bt_get_fwinfo;
+    adevc->build_dev_aml = build_ipmi_dev_aml;
 }
 
 static const TypeInfo isa_ipmi_bt_info = {
@@ -161,6 +164,7 @@ static const TypeInfo isa_ipmi_bt_info = {
     .class_init    = isa_ipmi_bt_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_IPMI_INTERFACE },
+        { TYPE_ACPI_DEV_AML_IF },
         { }
     }
 };
hw/ipmi/isa_ipmi_kcs.c +4 -0
index afabb95ebe..b2ed70b9da 100644
@@ -31,6 +31,7 @@
 #include "hw/qdev-properties.h"
 #include "migration/vmstate.h"
 #include "qom/object.h"
+#include "hw/acpi/ipmi.h"
 
 #define TYPE_ISA_IPMI_KCS "isa-ipmi-kcs"
 OBJECT_DECLARE_SIMPLE_TYPE(ISAIPMIKCSDevice, ISA_IPMI_KCS)
@@ -151,6 +152,7 @@ static void isa_ipmi_kcs_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
     IPMIInterfaceClass *iic = IPMI_INTERFACE_CLASS(oc);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(oc);
 
     dc->realize = ipmi_isa_realize;
     device_class_set_props(dc, ipmi_isa_properties);
@@ -158,6 +160,7 @@ static void isa_ipmi_kcs_class_init(ObjectClass *oc, void *data)
     iic->get_backend_data = isa_ipmi_kcs_get_backend_data;
     ipmi_kcs_class_init(iic);
     iic->get_fwinfo = isa_ipmi_kcs_get_fwinfo;
+    adevc->build_dev_aml = build_ipmi_dev_aml;
 }
 
 static const TypeInfo isa_ipmi_kcs_info = {
@@ -168,6 +171,7 @@ static const TypeInfo isa_ipmi_kcs_info = {
     .class_init    = isa_ipmi_kcs_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_IPMI_INTERFACE },
+        { TYPE_ACPI_DEV_AML_IF },
         { }
     }
 };
hw/ipmi/smbus_ipmi.c +4 -0
index 1fdf0a66b6..9ef9112dd5 100644
@@ -28,6 +28,7 @@
 #include "qemu/error-report.h"
 #include "hw/ipmi/ipmi.h"
 #include "qom/object.h"
+#include "hw/acpi/ipmi.h"
 
 #define TYPE_SMBUS_IPMI "smbus-ipmi"
 OBJECT_DECLARE_SIMPLE_TYPE(SMBusIPMIDevice, SMBUS_IPMI)
@@ -353,6 +354,7 @@ static void smbus_ipmi_class_init(ObjectClass *oc, void *data)
     DeviceClass *dc = DEVICE_CLASS(oc);
     IPMIInterfaceClass *iic = IPMI_INTERFACE_CLASS(oc);
     SMBusDeviceClass *sc = SMBUS_DEVICE_CLASS(oc);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(oc);
 
     sc->receive_byte = ipmi_receive_byte;
     sc->write_data = ipmi_write_data;
@@ -363,6 +365,7 @@ static void smbus_ipmi_class_init(ObjectClass *oc, void *data)
     iic->handle_if_event = smbus_ipmi_handle_event;
     iic->set_irq_enable = smbus_ipmi_set_irq_enable;
     iic->get_fwinfo = smbus_ipmi_get_fwinfo;
+    adevc->build_dev_aml = build_ipmi_dev_aml;
 }
 
 static const TypeInfo smbus_ipmi_info = {
@@ -373,6 +376,7 @@ static const TypeInfo smbus_ipmi_info = {
     .class_init    = smbus_ipmi_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_IPMI_INTERFACE },
+        { TYPE_ACPI_DEV_AML_IF },
         { }
     }
 };
Signature · 1 line
2.31.1
#21 lore raw

PATCH 17/35 q35: acpi: drop not needed PCMachineClass::do_not_add_smb_acpi

In reply to Igor Mammedov

by default we do not version ACPI AML as it's considered a part of firmware. Drop do_not_add_smb_acpi that blocked SMBUS AML description on 3.1 and older machine types without providing justification.

---
we can keep this bit if anyone can prove/report adverse effect on VM.

---
 include/hw/i386/pc.h | 1 -
 hw/i386/acpi-build.c | 2 +-
 hw/i386/pc_piix.c    | 1 -
 hw/i386/pc_q35.c     | 1 -
 4 files changed, 1 insertion(+), 4 deletions(-)
include/hw/i386/pc.h +0 -1
index aff8add155..da2ebfc33a 100644
@@ -106,7 +106,6 @@ struct PCMachineClass {
     bool rsdp_in_ram;
     int legacy_acpi_table_size;
     unsigned acpi_data_size;
-    bool do_not_add_smb_acpi;
     int pci_root_uid;
 
     /* SMBIOS compat: */
hw/i386/acpi-build.c +1 -1
index ca5cab87ba..250a7c07af 100644
@@ -1510,7 +1510,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
             build_x86_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
         }
         build_q35_pci0_int(dsdt);
-        if (pcms->smbus && !pcmc->do_not_add_smb_acpi) {
+        if (pcms->smbus) {
             build_smb0(dsdt, ICH9_SMB_DEV, ICH9_SMB_FUNC);
         }
     }
hw/i386/pc_piix.c +0 -1
index f843dd906f..d4b37b4652 100644
@@ -562,7 +562,6 @@ static void pc_i440fx_3_1_machine_options(MachineClass *m)
 
     pc_i440fx_4_0_machine_options(m);
     m->is_default = false;
-    pcmc->do_not_add_smb_acpi = true;
     m->smbus_no_migration_support = true;
     m->alias = NULL;
     pcmc->pvh_enabled = false;
hw/i386/pc_q35.c +0 -1
index 302288342a..ad3f519f77 100644
@@ -512,7 +512,6 @@ static void pc_q35_3_1_machine_options(MachineClass *m)
 
     pc_q35_4_0_machine_options(m);
     m->default_kernel_irqchip_split = false;
-    pcmc->do_not_add_smb_acpi = true;
     m->smbus_no_migration_support = true;
     m->alias = NULL;
     pcmc->pvh_enabled = false;
Signature · 1 line
2.31.1
#22 lore raw

PATCH 18/35 tests: acpi: white-list to be re-factored pc/q35 DSDT

In reply to Igor Mammedov
---
 tests/qtest/bios-tables-test-allowed-diff.h | 31 +++++++++++++++++++++
 1 file changed, 31 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +31 -0
index dfb8523c8b..d95f4b25c4 100644
@@ -1 +1,32 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/pc/DSDT",
+"tests/data/acpi/pc/DSDT.acpierst",
+"tests/data/acpi/pc/DSDT.acpihmat",
+"tests/data/acpi/pc/DSDT.bridge",
+"tests/data/acpi/pc/DSDT.cphp",
+"tests/data/acpi/pc/DSDT.dimmpxm",
+"tests/data/acpi/pc/DSDT.hpbridge",
+"tests/data/acpi/pc/DSDT.ipmikcs",
+"tests/data/acpi/pc/DSDT.memhp",
+"tests/data/acpi/pc/DSDT.nohpet",
+"tests/data/acpi/pc/DSDT.numamem",
+"tests/data/acpi/pc/DSDT.roothp",
+"tests/data/acpi/pc/DSDT.hpbrroot",
+"tests/data/acpi/q35/DSDT",
+"tests/data/acpi/q35/DSDT.acpierst",
+"tests/data/acpi/q35/DSDT.acpihmat",
+"tests/data/acpi/q35/DSDT.bridge",
+"tests/data/acpi/q35/DSDT.cphp",
+"tests/data/acpi/q35/DSDT.dimmpxm",
+"tests/data/acpi/q35/DSDT.ipmibt",
+"tests/data/acpi/q35/DSDT.ivrs",
+"tests/data/acpi/q35/DSDT.memhp",
+"tests/data/acpi/q35/DSDT.mmio64",
+"tests/data/acpi/q35/DSDT.multi-bridge",
+"tests/data/acpi/q35/DSDT.nohpet",
+"tests/data/acpi/q35/DSDT.numamem",
+"tests/data/acpi/q35/DSDT.tis.tpm12",
+"tests/data/acpi/q35/DSDT.tis.tpm2",
+"tests/data/acpi/q35/DSDT.viot",
+"tests/data/acpi/q35/DSDT.xapic",
+"tests/data/acpi/q35/DSDT.ipmismbus",
Signature · 1 line
2.31.1
#23 lore raw

PATCH 19/35 acpi: pc: isa bridge: use AcpiDevAmlIf interface to build ISA device descriptors

In reply to Igor Mammedov

replaces ad-hoc build_isa_devices_aml() with generic AcpiDevAmlIf way to build bridge AML including all devices that are attached to its ISA bus.

Later when PCI is converted to AcpiDevAmlIf, build_piix4_isa_bridge() will also be dropped since PCI parts itself will take care of building device prologue/epilogue AML for each enumerated PCI device.

Expected AML change is contextual, where ISA devices are moved from separately declared _SB.PCI0.ISA scope , directly under Device(ISA) node.

---
 hw/i386/acpi-build.c | 16 +++++++++++-----
 hw/isa/piix3.c       | 17 +++++++++++++++++
 2 files changed, 28 insertions(+), 5 deletions(-)
hw/i386/acpi-build.c +11 -5
index 250a7c07af..a5dd3e4fee 100644
@@ -1277,15 +1277,22 @@ static void build_piix4_isa_bridge(Aml *table)
 {
     Aml *dev;
     Aml *scope;
+    Object *obj;
+    bool ambiguous;
+
+    /*
+     * temporarily fish out isa bridge, build_piix4_isa_bridge() will be dropped
+     * once PCI is converted to AcpiDevAmlIf and would be ble to generate
+     * AML for bridge itself
+     */
+    obj = object_resolve_path_type("", TYPE_PIIX3_PCI_DEVICE, &ambiguous);
+    assert(obj && !ambiguous);
 
     scope =  aml_scope("_SB.PCI0");
     dev = aml_device("ISA");
     aml_append(dev, aml_name_decl("_ADR", aml_int(0x00010000)));
 
-    /* PIIX PCI to ISA irq remapping */
-    aml_append(dev, aml_operation_region("P40C", AML_PCI_CONFIG,
-                                         aml_int(0x60), 0x04));
-
+    call_dev_aml_func(DEVICE(obj), dev);
     aml_append(scope, dev);
     aml_append(table, scope);
 }
@@ -1456,7 +1463,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
             build_hpet_aml(dsdt);
         }
         build_piix4_isa_bridge(dsdt);
-        build_isa_devices_aml(dsdt);
         if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
             build_x86_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
         }
hw/isa/piix3.c +17 -0
index dab901c9ad..bfccd666d4 100644
@@ -32,6 +32,7 @@
 #include "sysemu/reset.h"
 #include "sysemu/runstate.h"
 #include "migration/vmstate.h"
+#include "hw/acpi/acpi_aml_interface.h"
 
 #define XEN_PIIX_NUM_PIRQS      128ULL
 
@@ -286,10 +287,24 @@ static void piix3_realize(PCIDevice *dev, Error **errp)
     qemu_register_reset(piix3_reset, d);
 }
 
+static void build_pci_isa_aml(AcpiDevAmlIf *adev, Aml *scope)
+{
+    BusChild *kid;
+    BusState *bus = qdev_get_child_bus(DEVICE(adev), "isa.0");
+
+    /* PIIX PCI to ISA irq remapping */
+    aml_append(scope, aml_operation_region("P40C", AML_PCI_CONFIG,
+                                         aml_int(0x60), 0x04));
+    QTAILQ_FOREACH(kid, &bus->children, sibling) {
+        call_dev_aml_func(DEVICE(kid->child), scope);
+    }
+}
+
 static void pci_piix3_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
 
     dc->desc        = "ISA bridge";
     dc->vmsd        = &vmstate_piix3;
@@ -304,6 +319,7 @@ static void pci_piix3_class_init(ObjectClass *klass, void *data)
      * pc_piix.c's pc_init1()
      */
     dc->user_creatable = false;
+    adevc->build_dev_aml = build_pci_isa_aml;
 }
 
 static const TypeInfo piix3_pci_type_info = {
@@ -314,6 +330,7 @@ static const TypeInfo piix3_pci_type_info = {
     .class_init = pci_piix3_class_init,
     .interfaces = (InterfaceInfo[]) {
         { INTERFACE_CONVENTIONAL_PCI_DEVICE },
+        { TYPE_ACPI_DEV_AML_IF },
         { },
     },
 };
Signature · 1 line
2.31.1
#24 lore raw

PATCH 20/35 acpi: q35: isa bridge: use AcpiDevAmlIf interface to build ISA device descriptors

In reply to Igor Mammedov

replaces adhoc build_isa_devices_aml() with generic AcpiDevAmlIf way to build bridge AML including all devices that are attached to its ISA bus.

Later when PCI is converted to AcpiDevAmlIf, build_q35_isa_bridge() will also be dropped since PCI parts itself will take care of building device prologue/epilogue AML for each enumerated PCI device.

Expected AML change is contextual, where ISA devices are moved from separately declared _SB.PCI0.ISA scope, directly under Device(ISA) node.

---
 hw/i386/acpi-build.c | 30 +++++++++++-------------------
 hw/isa/lpc_ich9.c    | 19 +++++++++++++++++++
 2 files changed, 30 insertions(+), 19 deletions(-)
hw/i386/acpi-build.c +11 -19
index a5dd3e4fee..33ee5bfcfb 100644
@@ -861,20 +861,6 @@ static Aml *build_vmbus_device_aml(VMBusBridge *vmbus_bridge)
     return dev;
 }
 
-static void build_isa_devices_aml(Aml *table)
-{
-    bool ambiguous;
-    Object *obj = object_resolve_path_type("", TYPE_ISA_BUS, &ambiguous);
-    Aml *scope;
-
-    assert(obj && !ambiguous);
-
-    scope = aml_scope("_SB.PCI0.ISA");
-    isa_build_aml(ISA_BUS(obj), scope);
-
-    aml_append(table, scope);
-}
-
 static void build_dbg_aml(Aml *table)
 {
     Aml *field;
@@ -1260,15 +1246,22 @@ static void build_q35_isa_bridge(Aml *table)
 {
     Aml *dev;
     Aml *scope;
+    Object *obj;
+    bool ambiguous;
+
+    /*
+     * temporarily fish out isa bridge, build_q35_isa_bridge() will be dropped
+     * once PCI is converted to AcpiDevAmlIf and would be ble to generate
+     * AML for bridge itself
+     */
+    obj = object_resolve_path_type("", TYPE_ICH9_LPC_DEVICE, &ambiguous);
+    assert(obj && !ambiguous);
 
     scope =  aml_scope("_SB.PCI0");
     dev = aml_device("ISA");
     aml_append(dev, aml_name_decl("_ADR", aml_int(0x001F0000)));
 
-    /* ICH9 PCI to ISA irq remapping */
-    aml_append(dev, aml_operation_region("PIRQ", AML_PCI_CONFIG,
-                                         aml_int(0x60), 0x0C));
-
+    call_dev_aml_func(DEVICE(obj), dev);
     aml_append(scope, dev);
     aml_append(table, scope);
 }
@@ -1511,7 +1504,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
             build_hpet_aml(dsdt);
         }
         build_q35_isa_bridge(dsdt);
-        build_isa_devices_aml(dsdt);
         if (pm->pcihp_bridge_en) {
             build_x86_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
         }
hw/isa/lpc_ich9.c +19 -0
index 5f143dca17..4553b5925b 100644
@@ -50,6 +50,7 @@
 #include "hw/core/cpu.h"
 #include "hw/nvram/fw_cfg.h"
 #include "qemu/cutils.h"
+#include "hw/acpi/acpi_aml_interface.h"
 
 /*****************************************************************************/
 /* ICH9 LPC PCI to ISA bridge */
@@ -803,12 +804,28 @@ static void ich9_send_gpe(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
     acpi_send_gpe_event(&s->pm.acpi_regs, s->pm.irq, ev);
 }
 
+static void build_ich9_isa_aml(AcpiDevAmlIf *adev, Aml *scope)
+{
+    BusChild *kid;
+    ICH9LPCState *s = ICH9_LPC_DEVICE(adev);
+    BusState *bus = BUS(s->isa_bus);
+
+    /* ICH9 PCI to ISA irq remapping */
+    aml_append(scope, aml_operation_region("PIRQ", AML_PCI_CONFIG,
+                                           aml_int(0x60), 0x0C));
+
+    QTAILQ_FOREACH(kid, &bus->children, sibling) {
+            call_dev_aml_func(DEVICE(kid->child), scope);
+    }
+}
+
 static void ich9_lpc_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
     AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_CLASS(klass);
+    AcpiDevAmlIfClass *amldevc = ACPI_DEV_AML_IF_CLASS(klass);
 
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->reset = ich9_lpc_reset;
@@ -833,6 +850,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data)
     adevc->ospm_status = ich9_pm_ospm_status;
     adevc->send_event = ich9_send_gpe;
     adevc->madt_cpu = pc_madt_cpu_entry;
+    amldevc->build_dev_aml = build_ich9_isa_aml;
 }
 
 static const TypeInfo ich9_lpc_info = {
@@ -845,6 +863,7 @@ static const TypeInfo ich9_lpc_info = {
         { TYPE_HOTPLUG_HANDLER },
         { TYPE_ACPI_DEVICE_IF },
         { INTERFACE_CONVENTIONAL_PCI_DEVICE },
+        { TYPE_ACPI_DEV_AML_IF },
         { }
     }
 };
Signature · 1 line
2.31.1
#25 lore raw

PATCH 21/35 tests: acpi: update expected blobs

In reply to Igor Mammedov

Expected AML change:
ISA devices under separate _SB.PCI0.ISA scope are moved directly under Device(ISA) node.

Example from PC machine, and q35 have similar changes:

         {
             Name (_ADR, 0x00010000)  // _ADR: Address
             OperationRegion (P40C, PCI_Config, 0x60, 0x04)

- }
- }
-
- Scope (_SB.PCI0.ISA)
- {
- Device (KBD)
- {

-            Name (_HID, EisaId ("PNP0303") /* IBM Enhanced Keyboard (101/102-key, PS/2 Mouse) */)  // _HID: Hardware ID
-            Name (_STA, 0x0F)  // _STA: Status
-            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
+            Device (KBD)
             {
-                IO (Decode16,
-                    0x0060,             // Range Minimum
-                    0x0060,             // Range Maximum
-                    0x01,               // Alignment
-                    0x01,               // Length
-                    )
-                IO (Decode16,
-                    0x0064,             // Range Minimum
-                    0x0064,             // Range Maximum
-                    0x01,               // Alignment
-                    0x01,               // Length
-                    )

- IRQNoFlags ()
- {1}
- })
- }
-
- Device (MOU)
- {

-            Name (_HID, EisaId ("PNP0F13") /* PS/2 Mouse */)  // _HID: Hardware ID
-            Name (_STA, 0x0F)  // _STA: Status
-            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
-            {

- IRQNoFlags ()
- {12}
- })
- }

+                Name (_HID, EisaId ("PNP0303") /* IBM Enhanced Keyboard (101/102-key, PS/2 Mouse) */)  // _HID: Hardware ID
+                Name (_STA, 0x0F)  // _STA: Status
+                Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
+                {
+                    IO (Decode16,
+                        0x0060,             // Range Minimum
+                        0x0060,             // Range Maximum
+                        0x01,               // Alignment
+                        0x01,               // Length
+                        )
+                    IO (Decode16,
+                        0x0064,             // Range Minimum
+                        0x0064,             // Range Maximum
+                        0x01,               // Alignment
+                        0x01,               // Length
+                        )

+ IRQNoFlags ()
+ {1}
+ })
+ }

- Device (FDC0)
- {

-            Name (_HID, EisaId ("PNP0700"))  // _HID: Hardware ID
-            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
-            {
-                IO (Decode16,
-                    0x03F2,             // Range Minimum
-                    0x03F2,             // Range Maximum
-                    0x00,               // Alignment
-                    0x04,               // Length
-                    )
-                IO (Decode16,
-                    0x03F7,             // Range Minimum
-                    0x03F7,             // Range Maximum
-                    0x00,               // Alignment
-                    0x01,               // Length
-                    )

- IRQNoFlags ()
- {6}
- DMA (Compatibility, NotBusMaster, Transfer8, )
- {2}

-            })
-            Device (FLPA)
+            Device (MOU)
             {
-                Name (_ADR, Zero)  // _ADR: Address
-                Name (_FDI, Package (0x10)  // _FDI: Floppy Drive Information
+                Name (_HID, EisaId ("PNP0F13") /* PS/2 Mouse */)  // _HID: Hardware ID
+                Name (_STA, 0x0F)  // _STA: Status
+                Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
                 {
-                    Zero,
-                    0x05,
-                    0x4F,
-                    0x30,
-                    One,
-                    0xAF,
-                    0x02,
-                    0x25,
-                    0x02,
-                    0x12,
-                    0x1B,
-                    0xFF,
-                    0x6C,
-                    0xF6,
-                    0x0F,
-                    0x08
+                    IRQNoFlags ()
+                        {12}
                 })
             }

- Name (_FDE, Buffer (0x14) // _FDE: Floppy Disk Enumerate
+ Device (FDC0)

             {
-                /* 0000 */  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // ........
-                /* 0008 */  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // ........
-                /* 0010 */  0x02, 0x00, 0x00, 0x00                           // ....
-            })
-        }
+                Name (_HID, EisaId ("PNP0700"))  // _HID: Hardware ID
+                Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
+                {
+                    IO (Decode16,
+                        0x03F2,             // Range Minimum
+                        0x03F2,             // Range Maximum
+                        0x00,               // Alignment
+                        0x04,               // Length
+                        )
+                    IO (Decode16,
+                        0x03F7,             // Range Minimum
+                        0x03F7,             // Range Maximum
+                        0x00,               // Alignment
+                        0x01,               // Length
+                        )

+ IRQNoFlags ()
+ {6}
+ DMA (Compatibility, NotBusMaster, Transfer8, )
+ {2}

+                })
+                Device (FLPA)
+                {
+                    Name (_ADR, Zero)  // _ADR: Address
+                    Name (_FDI, Package (0x10)  // _FDI: Floppy Drive Information
+                    {
+                        Zero,
+                        0x05,
+                        0x4F,
+                        0x30,
+                        One,
+                        0xAF,
+                        0x02,
+                        0x25,
+                        0x02,
+                        0x12,
+                        0x1B,
+                        0xFF,
+                        0x6C,
+                        0xF6,
+                        0x0F,
+                        0x08

+ })
+ }

- Device (LPT1)
- {

-            Name (_HID, EisaId ("PNP0400") /* Standard LPT Parallel Port */)  // _HID: Hardware ID
-            Name (_UID, One)  // _UID: Unique ID
-            Name (_STA, 0x0F)  // _STA: Status
-            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
+                Name (_FDE, Buffer (0x14)  // _FDE: Floppy Disk Enumerate
+                {
+                    /* 0000 */  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // ........
+                    /* 0008 */  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // ........
+                    /* 0010 */  0x02, 0x00, 0x00, 0x00                           // ....

+ })
+ }
+
+ Device (LPT1)

             {
-                IO (Decode16,
-                    0x0378,             // Range Minimum
-                    0x0378,             // Range Maximum
-                    0x08,               // Alignment
-                    0x08,               // Length
-                    )

- IRQNoFlags ()
- {7}
- })
- }

+                Name (_HID, EisaId ("PNP0400") /* Standard LPT Parallel Port */)  // _HID: Hardware ID
+                Name (_UID, One)  // _UID: Unique ID
+                Name (_STA, 0x0F)  // _STA: Status
+                Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
+                {
+                    IO (Decode16,
+                        0x0378,             // Range Minimum
+                        0x0378,             // Range Maximum
+                        0x08,               // Alignment
+                        0x08,               // Length
+                        )

+ IRQNoFlags ()
+ {7}
+ })
+ }

- Device (COM1)
- {

-            Name (_HID, EisaId ("PNP0501") /* 16550A-compatible COM Serial Port */)  // _HID: Hardware ID
-            Name (_UID, One)  // _UID: Unique ID
-            Name (_STA, 0x0F)  // _STA: Status
-            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
+            Device (COM1)
             {
-                IO (Decode16,
-                    0x03F8,             // Range Minimum
-                    0x03F8,             // Range Maximum
-                    0x00,               // Alignment
-                    0x08,               // Length
-                    )

- IRQNoFlags ()
- {4}
- })
- }

+                Name (_HID, EisaId ("PNP0501") /* 16550A-compatible COM Serial Port */)  // _HID: Hardware ID
+                Name (_UID, One)  // _UID: Unique ID
+                Name (_STA, 0x0F)  // _STA: Status
+                Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
+                {
+                    IO (Decode16,
+                        0x03F8,             // Range Minimum
+                        0x03F8,             // Range Maximum
+                        0x00,               // Alignment
+                        0x08,               // Length
+                        )

+ IRQNoFlags ()
+ {4}
+ })
+ }

- Device (RTC)
- {

-            Name (_HID, EisaId ("PNP0B00") /* AT Real-Time Clock */)  // _HID: Hardware ID
-            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
+            Device (RTC)
             {
-                IO (Decode16,
-                    0x0070,             // Range Minimum
-                    0x0070,             // Range Maximum
-                    0x01,               // Alignment
-                    0x08,               // Length
-                    )
-                IRQNoFlags ()
-                    {8}
-            })
+                Name (_HID, EisaId ("PNP0B00") /* AT Real-Time Clock */)  // _HID: Hardware ID
+                Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
+                {
+                    IO (Decode16,
+                        0x0070,             // Range Minimum
+                        0x0070,             // Range Maximum
+                        0x01,               // Alignment
+                        0x08,               // Length
+                        )

+ IRQNoFlags ()
+ {8}
+ })
+ }

         }
     }
---
 tests/qtest/bios-tables-test-allowed-diff.h |  31 --------------------
 tests/data/acpi/pc/DSDT                     | Bin 6002 -> 5987 bytes
 tests/data/acpi/pc/DSDT.acpierst            | Bin 5969 -> 5954 bytes
 tests/data/acpi/pc/DSDT.acpihmat            | Bin 7327 -> 7312 bytes
 tests/data/acpi/pc/DSDT.bridge              | Bin 8668 -> 8653 bytes
 tests/data/acpi/pc/DSDT.cphp                | Bin 6466 -> 6451 bytes
 tests/data/acpi/pc/DSDT.dimmpxm             | Bin 7656 -> 7641 bytes
 tests/data/acpi/pc/DSDT.hpbridge            | Bin 5969 -> 5954 bytes
 tests/data/acpi/pc/DSDT.hpbrroot            | Bin 3084 -> 3069 bytes
 tests/data/acpi/pc/DSDT.ipmikcs             | Bin 6074 -> 6059 bytes
 tests/data/acpi/pc/DSDT.memhp               | Bin 7361 -> 7346 bytes
 tests/data/acpi/pc/DSDT.nohpet              | Bin 5860 -> 5845 bytes
 tests/data/acpi/pc/DSDT.numamem             | Bin 6008 -> 5993 bytes
 tests/data/acpi/pc/DSDT.roothp              | Bin 6210 -> 6195 bytes
 tests/data/acpi/q35/DSDT                    | Bin 8289 -> 8274 bytes
 tests/data/acpi/q35/DSDT.acpierst           | Bin 8306 -> 8291 bytes
 tests/data/acpi/q35/DSDT.acpihmat           | Bin 9614 -> 9599 bytes
 tests/data/acpi/q35/DSDT.bridge             | Bin 11003 -> 10988 bytes
 tests/data/acpi/q35/DSDT.cphp               | Bin 8753 -> 8738 bytes
 tests/data/acpi/q35/DSDT.dimmpxm            | Bin 9943 -> 9928 bytes
 tests/data/acpi/q35/DSDT.ipmibt             | Bin 8364 -> 8349 bytes
 tests/data/acpi/q35/DSDT.ipmismbus          | Bin 8378 -> 8363 bytes
 tests/data/acpi/q35/DSDT.ivrs               | Bin 8306 -> 8291 bytes
 tests/data/acpi/q35/DSDT.memhp              | Bin 9648 -> 9633 bytes
 tests/data/acpi/q35/DSDT.mmio64             | Bin 9419 -> 9404 bytes
 tests/data/acpi/q35/DSDT.multi-bridge       | Bin 8583 -> 8568 bytes
 tests/data/acpi/q35/DSDT.nohpet             | Bin 8147 -> 8132 bytes
 tests/data/acpi/q35/DSDT.numamem            | Bin 8295 -> 8280 bytes
 tests/data/acpi/q35/DSDT.tis.tpm12          | Bin 8900 -> 8885 bytes
 tests/data/acpi/q35/DSDT.tis.tpm2           | Bin 8921 -> 8906 bytes
 tests/data/acpi/q35/DSDT.viot               | Bin 9398 -> 9383 bytes
 tests/data/acpi/q35/DSDT.xapic              | Bin 35652 -> 35637 bytes
 32 files changed, 31 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -31
index d95f4b25c4..dfb8523c8b 100644
@@ -1,32 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/pc/DSDT",
-"tests/data/acpi/pc/DSDT.acpierst",
-"tests/data/acpi/pc/DSDT.acpihmat",
-"tests/data/acpi/pc/DSDT.bridge",
-"tests/data/acpi/pc/DSDT.cphp",
-"tests/data/acpi/pc/DSDT.dimmpxm",
-"tests/data/acpi/pc/DSDT.hpbridge",
-"tests/data/acpi/pc/DSDT.ipmikcs",
-"tests/data/acpi/pc/DSDT.memhp",
-"tests/data/acpi/pc/DSDT.nohpet",
-"tests/data/acpi/pc/DSDT.numamem",
-"tests/data/acpi/pc/DSDT.roothp",
-"tests/data/acpi/pc/DSDT.hpbrroot",
-"tests/data/acpi/q35/DSDT",
-"tests/data/acpi/q35/DSDT.acpierst",
-"tests/data/acpi/q35/DSDT.acpihmat",
-"tests/data/acpi/q35/DSDT.bridge",
-"tests/data/acpi/q35/DSDT.cphp",
-"tests/data/acpi/q35/DSDT.dimmpxm",
-"tests/data/acpi/q35/DSDT.ipmibt",
-"tests/data/acpi/q35/DSDT.ivrs",
-"tests/data/acpi/q35/DSDT.memhp",
-"tests/data/acpi/q35/DSDT.mmio64",
-"tests/data/acpi/q35/DSDT.multi-bridge",
-"tests/data/acpi/q35/DSDT.nohpet",
-"tests/data/acpi/q35/DSDT.numamem",
-"tests/data/acpi/q35/DSDT.tis.tpm12",
-"tests/data/acpi/q35/DSDT.tis.tpm2",
-"tests/data/acpi/q35/DSDT.viot",
-"tests/data/acpi/q35/DSDT.xapic",
-"tests/data/acpi/q35/DSDT.ipmismbus",
tests/data/acpi/pc/DSDT binary +0 -0
index cc1223773e9c459a8d2f20666c051a74338d40b7..e80bef30317b5ef3bf0d2fb7aaabd6def109adb6 100644
GIT binary patch
tests/data/acpi/pc/DSDT.acpierst binary +0 -0
index bb0593eeb8730d51a6f0fe51a00a00df9c83c419..d5a2ca51652dfc3637a817bac4a02d6ff6dc8ac2 100644
GIT binary patch
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
index 2d0678eb83277088b156d386067429b0f29f9338..f86c743c4d64041c7fbd9999cc700e88416770b7 100644
GIT binary patch
tests/data/acpi/pc/DSDT.bridge binary +0 -0
index 77778c3a69946efd501e7eff0a73af309b553f13..14ed0d995a9f6540deae5a25a7853ed4493a6e06 100644
GIT binary patch
tests/data/acpi/pc/DSDT.cphp binary +0 -0
index af046b40b0a150b4ab1e113bd9d77912c707074f..c653302a84a42d063a74a22c6adf910beeba7c60 100644
GIT binary patch
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
index b56b2e089017f933f8a3089c4fd2389fb8ef1e40..247a1796b1cf31c24b1a981e48937609f84fe2cb 100644
GIT binary patch
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
index bb0593eeb8730d51a6f0fe51a00a00df9c83c419..d5a2ca51652dfc3637a817bac4a02d6ff6dc8ac2 100644
GIT binary patch
tests/data/acpi/pc/DSDT.hpbrroot binary +0 -0
index 6ff6f198c7caf445d25c01117a6357b398358cbf..ec99b1622934a0fd8bc316291c33231e4c57dce0 100644
GIT binary patch
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
index 2e618e49d357ae1d0ac20d822f71d676ea90f2fc..f0d9e75841ea3d69fed9384e439bc4e94c7a4c4e 100644
GIT binary patch
tests/data/acpi/pc/DSDT.memhp binary +0 -0
index c32d28575b967aff40afb9138822ecd3186dd4ce..d0a7c462094fea9a457cbf537784735e74f7d7d5 100644
GIT binary patch
tests/data/acpi/pc/DSDT.nohpet binary +0 -0
index 623f06a900d12500d2197d101f76f6875e92ed64..cb7bf7d850f340e12a7237c987f570300fd9c92b 100644
GIT binary patch
tests/data/acpi/pc/DSDT.numamem binary +0 -0
index f0a3fa92de94f55d5406f0fafce331776dbb0317..2f512cfbe158f1739803c0c7009fe5e907bdec54 100644
GIT binary patch
tests/data/acpi/pc/DSDT.roothp binary +0 -0
index cee3b4d80b51ad30153953ace46127923ce8b271..46e03d39e00ea70e55d6a12333ca2b98c5e5bb53 100644
GIT binary patch
tests/data/acpi/q35/DSDT binary +0 -0
index c1965f6051ef2af81dd8412abe169d87845bb033..2cd8d5fc470fc3159fbc464af97e76c8de2136e3 100644
GIT binary patch
tests/data/acpi/q35/DSDT.acpierst binary +0 -0
index cad26e3f0c27a40a33101155a5282ed9bcb1d441..0bc5de80652ae7328fdc07ccda34afff39ade56f 100644
GIT binary patch
tests/data/acpi/q35/DSDT.acpihmat binary +0 -0
index f24d4874bff8d327a165ed7c36de507aea114edd..af10345e8806c78a0074b3a8819b5cfca4d70c01 100644
GIT binary patch
tests/data/acpi/q35/DSDT.bridge binary +0 -0
index 424d51bd1cb39ea73501ef7d0044ee52cec5bdac..d820098355e0b79dc69d714817fe906064852f4d 100644
GIT binary patch
tests/data/acpi/q35/DSDT.cphp binary +0 -0
index f1275606f68eeba54bfb11e63d818420385a62b9..ac8456a43d54209d77917163b282954d7429b331 100644
GIT binary patch
tests/data/acpi/q35/DSDT.dimmpxm binary +0 -0
index 76e451e829ec4c245315f7eed8731aa1be45a747..bb0eadf869fe366fc139f8b0fd2ed811d3b16814 100644
GIT binary patch
tests/data/acpi/q35/DSDT.ipmibt binary +0 -0
index 6ad2411d0ec95f204cfc64b430c537bce09c35bd..bb258279506e78b50545f6f9030bd25afe433c29 100644
GIT binary patch
tests/data/acpi/q35/DSDT.ipmismbus binary +0 -0
index 415fe08a407690c0e118743d872de79d22f01a4c..15000c357fdabf1bceef6f860bd35e9a33024927 100644
GIT binary patch
tests/data/acpi/q35/DSDT.ivrs binary +0 -0
index cad26e3f0c27a40a33101155a5282ed9bcb1d441..0bc5de80652ae7328fdc07ccda34afff39ade56f 100644
GIT binary patch
tests/data/acpi/q35/DSDT.memhp binary +0 -0
index 4e9cb3dc6896bb79ccac0fe342a404549f6610e8..663456fc0d3c71a51b541f5ab952e05c9dac01e6 100644
GIT binary patch
tests/data/acpi/q35/DSDT.mmio64 binary +0 -0
index eb5a1c7171c02d153487bfcecfb7019b7c1bf406..91afd01d598c7c2c733387dfb5140d0fcad54adb 100644
GIT binary patch
tests/data/acpi/q35/DSDT.multi-bridge binary +0 -0
index 45808eb03b78d07ebbe853f674abfed589d35e26..afde339a181628ae9153251eee026b437ab685bc 100644
GIT binary patch
tests/data/acpi/q35/DSDT.nohpet binary +0 -0
index 83d1aa00ac5686df479673fb0d7830f946e25dea..0fb09121cf8f6ad8810587c8b77df9552dd31f42 100644
GIT binary patch
tests/data/acpi/q35/DSDT.numamem binary +0 -0
index 050aaa237b466b0bda8cca5cfaa06f84661d622e..e537669949a07adbaa4255021ea14bb4a9dc672f 100644
GIT binary patch
tests/data/acpi/q35/DSDT.tis.tpm12 binary +0 -0
index fb9dd1f0599afd6b555ea570ecd00a3bb227aa84..0b5c97fdb5da8b7b55d6b5f2af498a447fda7bf8 100644
GIT binary patch
tests/data/acpi/q35/DSDT.tis.tpm2 binary +0 -0
index 00d732e46f5d9d056e557bd026fa30f9db3b8c30..4e16b126cc1c32f2346078fa69c5261c245d15e8 100644
GIT binary patch
tests/data/acpi/q35/DSDT.viot binary +0 -0
index 1c3b4da5cbe81ecab5e1ef50d383b561c5e0f55f..e20e4ee5e92e11ccf890a18fbdd78181c43f3b5c 100644
GIT binary patch
tests/data/acpi/q35/DSDT.xapic binary +0 -0
index 17552ce363ae81985f69f9ae85837a1540b79ae0..3cab5956eee60363251a6fab0cc981bbbda64443 100644
GIT binary patch
Signature · 1 line
2.31.1
#26 lore raw

PATCH 22/35 tests: acpi: add and white-list DSDT.applesmc expected blob

In reply to Igor Mammedov
---
 tests/qtest/bios-tables-test-allowed-diff.h | 1 +
 tests/data/acpi/q35/DSDT.applesmc           | 0
 2 files changed, 1 insertion(+)
 create mode 100644 tests/data/acpi/q35/DSDT.applesmc
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
index dfb8523c8b..e893029d87 100644
@@ -1 +1,2 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/q35/DSDT.applesmc",
tests/data/acpi/q35/DSDT.applesmc new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
Signature · 1 line
2.31.1
#27 lore raw

PATCH 23/35 tests: acpi: add applesmc testcase

In reply to Igor Mammedov
---
 tests/qtest/bios-tables-test.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tests/qtest/bios-tables-test.c +12 -0
index 615cbdaf17..b7be634d23 100644
@@ -1582,6 +1582,17 @@ static void test_acpi_q35_slic(void)
     free_test_data(&data);
 }
 
+static void test_acpi_q35_applesmc(void)
+{
+    test_data data = {
+        .machine = MACHINE_Q35,
+        .variant = ".applesmc",
+    };
+
+    test_acpi_one("-device isa-applesmc", &data);
+    free_test_data(&data);
+}
+
 static void test_oem_fields(test_data *data)
 {
     int i;
@@ -1740,6 +1751,7 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/acpihmat", test_acpi_q35_tcg_acpi_hmat);
         qtest_add_func("acpi/piix4/acpierst", test_acpi_piix4_acpi_erst);
         qtest_add_func("acpi/q35/acpierst", test_acpi_q35_acpi_erst);
+        qtest_add_func("acpi/q35/applesmc", test_acpi_q35_applesmc);
         qtest_add_func("acpi/microvm", test_acpi_microvm_tcg);
         qtest_add_func("acpi/microvm/usb", test_acpi_microvm_usb_tcg);
         qtest_add_func("acpi/microvm/rtc", test_acpi_microvm_rtc_tcg);
Signature · 1 line
2.31.1
#28 lore raw

PATCH 24/35 acpi: applesmc: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML

In reply to Igor Mammedov

.. and clean up not longer needed conditionals in DSTD build
code. applesmc AML will be fetched and included when ISA bridge will build its own AML code (incl. attached devices).

Expected AML change:
the device under separate _SB.PCI0.ISA scope is moved directly under Device(ISA) node.

---
 include/hw/isa/isa.h | 14 --------------
 hw/i386/acpi-build.c | 22 ----------------------
 hw/misc/applesmc.c   | 29 +++++++++++++++++++++++++++++
 3 files changed, 29 insertions(+), 36 deletions(-)
include/hw/isa/isa.h +0 -14
index 5c5a3d43a7..6f9380007d 100644
@@ -16,20 +16,6 @@ OBJECT_DECLARE_TYPE(ISADevice, ISADeviceClass, ISA_DEVICE)
 #define TYPE_ISA_BUS "ISA"
 OBJECT_DECLARE_SIMPLE_TYPE(ISABus, ISA_BUS)
 
-#define TYPE_APPLE_SMC "isa-applesmc"
-#define APPLESMC_MAX_DATA_LENGTH       32
-#define APPLESMC_PROP_IO_BASE "iobase"
-
-static inline uint16_t applesmc_port(void)
-{
-    Object *obj = object_resolve_path_type("", TYPE_APPLE_SMC, NULL);
-
-    if (obj) {
-        return object_property_get_uint(obj, APPLESMC_PROP_IO_BASE, NULL);
-    }
-    return 0;
-}
-
 #define TYPE_ISADMA "isa-dma"
 
 typedef struct IsaDmaClass IsaDmaClass;
hw/i386/acpi-build.c +0 -22
index 33ee5bfcfb..517818cd9f 100644
@@ -118,7 +118,6 @@ typedef struct AcpiMiscInfo {
     const unsigned char *dsdt_code;
     unsigned dsdt_size;
     uint16_t pvpanic_port;
-    uint16_t applesmc_io_base;
 } AcpiMiscInfo;
 
 typedef struct AcpiBuildPciBusHotplugState {
@@ -304,7 +303,6 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
     info->tpm_version = tpm_get_version(tpm_find());
 #endif
     info->pvpanic_port = pvpanic_port();
-    info->applesmc_io_base = applesmc_port();
 }
 
 /*
@@ -1751,26 +1749,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         aml_append(dsdt, scope);
     }
 
-    if (misc->applesmc_io_base) {
-        scope = aml_scope("\\_SB.PCI0.ISA");
-        dev = aml_device("SMC");
-
-        aml_append(dev, aml_name_decl("_HID", aml_eisaid("APP0001")));
-        /* device present, functioning, decoding, not shown in UI */
-        aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
-
-        crs = aml_resource_template();
-        aml_append(crs,
-            aml_io(AML_DECODE16, misc->applesmc_io_base, misc->applesmc_io_base,
-                   0x01, APPLESMC_MAX_DATA_LENGTH)
-        );
-        aml_append(crs, aml_irq_no_flags(6));
-        aml_append(dev, aml_name_decl("_CRS", crs));
-
-        aml_append(scope, dev);
-        aml_append(dsdt, scope);
-    }
-
     if (misc->pvpanic_port) {
         scope = aml_scope("\\_SB.PCI0.ISA");
 
hw/misc/applesmc.c +29 -0
index 81cd6b6423..5f9c742e50 100644
@@ -37,10 +37,14 @@
 #include "qemu/module.h"
 #include "qemu/timer.h"
 #include "qom/object.h"
+#include "hw/acpi/acpi_aml_interface.h"
 
 /* #define DEBUG_SMC */
 
 #define APPLESMC_DEFAULT_IOBASE        0x300
+#define TYPE_APPLE_SMC "isa-applesmc"
+#define APPLESMC_MAX_DATA_LENGTH       32
+#define APPLESMC_PROP_IO_BASE "iobase"
 
 enum {
     APPLESMC_DATA_PORT               = 0x00,
@@ -347,14 +351,35 @@ static Property applesmc_isa_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
+static void build_applesmc_aml(AcpiDevAmlIf *adev, Aml *scope)
+{
+    Aml *crs;
+    AppleSMCState *s = APPLE_SMC(adev);
+    uint32_t iobase = s->iobase;
+    Aml *dev = aml_device("SMC");
+
+    aml_append(dev, aml_name_decl("_HID", aml_eisaid("APP0001")));
+    /* device present, functioning, decoding, not shown in UI */
+    aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
+    crs = aml_resource_template();
+    aml_append(crs,
+        aml_io(AML_DECODE16, iobase, iobase, 0x01, APPLESMC_MAX_DATA_LENGTH)
+    );
+    aml_append(crs, aml_irq_no_flags(6));
+    aml_append(dev, aml_name_decl("_CRS", crs));
+    aml_append(scope, dev);
+}
+
 static void qdev_applesmc_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
 
     dc->realize = applesmc_isa_realize;
     dc->reset = qdev_applesmc_isa_reset;
     device_class_set_props(dc, applesmc_isa_properties);
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+    adevc->build_dev_aml = build_applesmc_aml;
 }
 
 static const TypeInfo applesmc_isa_info = {
@@ -362,6 +387,10 @@ static const TypeInfo applesmc_isa_info = {
     .parent        = TYPE_ISA_DEVICE,
     .instance_size = sizeof(AppleSMCState),
     .class_init    = qdev_applesmc_class_init,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_ACPI_DEV_AML_IF },
+        { },
+    },
 };
 
 static void applesmc_register_types(void)
Signature · 1 line
2.31.1
#29 lore raw

PATCH 25/35 tests: acpi: update expected blobs

In reply to Igor Mammedov

@@ -145,6 +145,23 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)

         {
             Name (_ADR, 0x001F0000)  // _ADR: Address
             OperationRegion (PIRQ, PCI_Config, 0x60, 0x0C)
+            Device (SMC)
+            {
+                Name (_HID, EisaId ("APP0001"))  // _HID: Hardware ID
+                Name (_STA, 0x0B)  // _STA: Status
+                Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
+                {
+                    IO (Decode16,
+                        0x0300,             // Range Minimum
+                        0x0300,             // Range Maximum
+                        0x01,               // Alignment
+                        0x20,               // Length
+                        )

+ IRQNoFlags ()
+ {6}
+ })
+ }
+

             Device (KBD)
             {
                 Name (_HID, EisaId ("PNP0303") /* IBM Enhanced Keyboard (101/102-key, PS/2 Mouse) */)  // _HID: Hardware ID
@@ -3246,26 +3263,6 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC    ", 0x00000001)
         }
     }

- Scope (\_SB.PCI0.ISA)
- {
- Device (SMC)
- {

-            Name (_HID, EisaId ("APP0001"))  // _HID: Hardware ID
-            Name (_STA, 0x0B)  // _STA: Status
-            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
-            {
-                IO (Decode16,
-                    0x0300,             // Range Minimum
-                    0x0300,             // Range Maximum
-                    0x01,               // Alignment
-                    0x20,               // Length
-                    )

- IRQNoFlags ()
- {6}
- })
- }
- }
-

     Scope (\_SB)
     {
         Scope (PCI0)
---
 tests/qtest/bios-tables-test-allowed-diff.h |   1 -
 tests/data/acpi/q35/DSDT.applesmc           | Bin 0 -> 8320 bytes
 2 files changed, 1 deletion(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
index e893029d87..dfb8523c8b 100644
@@ -1,2 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/q35/DSDT.applesmc",
tests/data/acpi/q35/DSDT.applesmc binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..00092aacc6ce44dd8792b00a0fa183e5b06d33c6 100644
GIT binary patch
Signature · 1 line
2.31.1
#30 lore raw

PATCH 26/35 tests: acpi: white-lists expected DSDT.pvpanic-isa blob

In reply to Igor Mammedov
---
 tests/qtest/bios-tables-test-allowed-diff.h | 1 +
 tests/data/acpi/q35/DSDT.pvpanic-isa        | 0
 2 files changed, 1 insertion(+)
 create mode 100644 tests/data/acpi/q35/DSDT.pvpanic-isa
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
index dfb8523c8b..d5cd7aa4f5 100644
@@ -1 +1,2 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/q35/DSDT.pvpanic-isa",
tests/data/acpi/q35/DSDT.pvpanic-isa new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
Signature · 1 line
2.31.1
#31 lore raw

PATCH 27/35 tests: acpi: add pvpanic-isa: testcase

In reply to Igor Mammedov
---
 tests/qtest/bios-tables-test.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tests/qtest/bios-tables-test.c +12 -0
index b7be634d23..ecbb4dab5a 100644
@@ -1593,6 +1593,17 @@ static void test_acpi_q35_applesmc(void)
     free_test_data(&data);
 }
 
+static void test_acpi_q35_pvpanic_isa(void)
+{
+    test_data data = {
+        .machine = MACHINE_Q35,
+        .variant = ".pvpanic-isa",
+    };
+
+    test_acpi_one("-device pvpanic", &data);
+    free_test_data(&data);
+}
+
 static void test_oem_fields(test_data *data)
 {
     int i;
@@ -1752,6 +1763,7 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/piix4/acpierst", test_acpi_piix4_acpi_erst);
         qtest_add_func("acpi/q35/acpierst", test_acpi_q35_acpi_erst);
         qtest_add_func("acpi/q35/applesmc", test_acpi_q35_applesmc);
+        qtest_add_func("acpi/q35/pvpanic-isa", test_acpi_q35_pvpanic_isa);
         qtest_add_func("acpi/microvm", test_acpi_microvm_tcg);
         qtest_add_func("acpi/microvm/usb", test_acpi_microvm_usb_tcg);
         qtest_add_func("acpi/microvm/rtc", test_acpi_microvm_rtc_tcg);
Signature · 1 line
2.31.1
#32 lore raw

PATCH 28/35 acpi: pvpanic-isa: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML

In reply to Igor Mammedov

.. and clean up not longer needed conditionals in DSTD build code pvpanic-isa AML will be fetched and included when ISA bridge will build its own AML code (including attached devices).

Expected AML change:
the device under separate _SB.PCI0.ISA scope is moved directly under Device(ISA) node.

---
 include/hw/misc/pvpanic.h |  9 ---------
 hw/i386/acpi-build.c      | 37 ----------------------------------
 hw/misc/pvpanic-isa.c     | 42 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 46 deletions(-)
include/hw/misc/pvpanic.h +0 -9
index 7f16cc9b16..e520566ab0 100644
@@ -33,13 +33,4 @@ struct PVPanicState {
 
 void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size);
 
-static inline uint16_t pvpanic_port(void)
-{
-    Object *o = object_resolve_path_type("", TYPE_PVPANIC_ISA_DEVICE, NULL);
-    if (!o) {
-        return 0;
-    }
-    return object_property_get_uint(o, PVPANIC_IOPORT_PROP, NULL);
-}
-
 #endif
hw/i386/acpi-build.c +0 -37
index 517818cd9f..a42f41f373 100644
@@ -30,7 +30,6 @@
 #include "hw/pci/pci.h"
 #include "hw/core/cpu.h"
 #include "target/i386/cpu.h"
-#include "hw/misc/pvpanic.h"
 #include "hw/timer/hpet.h"
 #include "hw/acpi/acpi-defs.h"
 #include "hw/acpi/acpi.h"
@@ -117,7 +116,6 @@ typedef struct AcpiMiscInfo {
 #endif
     const unsigned char *dsdt_code;
     unsigned dsdt_size;
-    uint16_t pvpanic_port;
 } AcpiMiscInfo;
 
 typedef struct AcpiBuildPciBusHotplugState {
@@ -302,7 +300,6 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
 #ifdef CONFIG_TPM
     info->tpm_version = tpm_get_version(tpm_find());
 #endif
-    info->pvpanic_port = pvpanic_port();
 }
 
 /*
@@ -1749,40 +1746,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         aml_append(dsdt, scope);
     }
 
-    if (misc->pvpanic_port) {
-        scope = aml_scope("\\_SB.PCI0.ISA");
-
-        dev = aml_device("PEVT");
-        aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0001")));
-
-        crs = aml_resource_template();
-        aml_append(crs,
-            aml_io(AML_DECODE16, misc->pvpanic_port, misc->pvpanic_port, 1, 1)
-        );
-        aml_append(dev, aml_name_decl("_CRS", crs));
-
-        aml_append(dev, aml_operation_region("PEOR", AML_SYSTEM_IO,
-                                              aml_int(misc->pvpanic_port), 1));
-        field = aml_field("PEOR", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
-        aml_append(field, aml_named_field("PEPT", 8));
-        aml_append(dev, field);
-
-        /* device present, functioning, decoding, shown in UI */
-        aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
-
-        method = aml_method("RDPT", 0, AML_NOTSERIALIZED);
-        aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
-        aml_append(method, aml_return(aml_local(0)));
-        aml_append(dev, method);
-
-        method = aml_method("WRPT", 1, AML_NOTSERIALIZED);
-        aml_append(method, aml_store(aml_arg(0), aml_name("PEPT")));
-        aml_append(dev, method);
-
-        aml_append(scope, dev);
-        aml_append(dsdt, scope);
-    }
-
     sb_scope = aml_scope("\\_SB");
     {
         Object *pci_host;
hw/misc/pvpanic-isa.c +42 -0

70 lines not on this page · raw message

Signature · 1 line
2.31.1
#33 lore raw

Re: [PATCH 28/35] acpi: pvpanic-isa: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML

Quoted 159 lines · Igor Mammedov

.. and clean up not longer needed conditionals in DSTD build code pvpanic-isa AML will be fetched and included when ISA bridge will build its own AML code (including attached devices).

Expected AML change:
the device under separate _SB.PCI0.ISA scope is moved directly under Device(ISA) node.

---
 include/hw/misc/pvpanic.h |  9 ---------
 hw/i386/acpi-build.c      | 37 ----------------------------------
 hw/misc/pvpanic-isa.c     | 42 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 46 deletions(-)
include/hw/misc/pvpanic.h +0 -9
index 7f16cc9b16..e520566ab0 100644
@@ -33,13 +33,4 @@ struct PVPanicState {
 
 void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size);
 
-static inline uint16_t pvpanic_port(void)
-{
-    Object *o = object_resolve_path_type("", TYPE_PVPANIC_ISA_DEVICE, NULL);
-    if (!o) {
-        return 0;
-    }
-    return object_property_get_uint(o, PVPANIC_IOPORT_PROP, NULL);
-}
-
 #endif
hw/i386/acpi-build.c +0 -37
index 517818cd9f..a42f41f373 100644
@@ -30,7 +30,6 @@
 #include "hw/pci/pci.h"
 #include "hw/core/cpu.h"
 #include "target/i386/cpu.h"
-#include "hw/misc/pvpanic.h"
 #include "hw/timer/hpet.h"
 #include "hw/acpi/acpi-defs.h"
 #include "hw/acpi/acpi.h"
@@ -117,7 +116,6 @@ typedef struct AcpiMiscInfo {
 #endif
     const unsigned char *dsdt_code;
     unsigned dsdt_size;
-    uint16_t pvpanic_port;
 } AcpiMiscInfo;
 
 typedef struct AcpiBuildPciBusHotplugState {
@@ -302,7 +300,6 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
 #ifdef CONFIG_TPM
     info->tpm_version = tpm_get_version(tpm_find());
 #endif
-    info->pvpanic_port = pvpanic_port();
 }
 
 /*
@@ -1749,40 +1746,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         aml_append(dsdt, scope);
     }
 
-    if (misc->pvpanic_port) {
-        scope = aml_scope("\\_SB.PCI0.ISA");
-
-        dev = aml_device("PEVT");
-        aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0001")));
-
-        crs = aml_resource_template();
-        aml_append(crs,
-            aml_io(AML_DECODE16, misc->pvpanic_port, misc->pvpanic_port, 1, 1)
-        );
-        aml_append(dev, aml_name_decl("_CRS", crs));
-
-        aml_append(dev, aml_operation_region("PEOR", AML_SYSTEM_IO,
-                                              aml_int(misc->pvpanic_port), 1));
-        field = aml_field("PEOR", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
-        aml_append(field, aml_named_field("PEPT", 8));
-        aml_append(dev, field);
-
-        /* device present, functioning, decoding, shown in UI */
-        aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
-
-        method = aml_method("RDPT", 0, AML_NOTSERIALIZED);
-        aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
-        aml_append(method, aml_return(aml_local(0)));
-        aml_append(dev, method);
-
-        method = aml_method("WRPT", 1, AML_NOTSERIALIZED);
-        aml_append(method, aml_store(aml_arg(0), aml_name("PEPT")));
-        aml_append(dev, method);
-
-        aml_append(scope, dev);
-        aml_append(dsdt, scope);
-    }
-
     sb_scope = aml_scope("\\_SB");
     {
         Object *pci_host;
hw/misc/pvpanic-isa.c +36 -0
index b84d4d458d..ccec50f61b 100644
@@ -22,6 +22,7 @@
 #include "qom/object.h"
 #include "hw/isa/isa.h"
 #include "standard-headers/linux/pvpanic.h"
+#include "hw/acpi/acpi_aml_interface.h"
 
 OBJECT_DECLARE_SIMPLE_TYPE(PVPanicISAState, PVPANIC_ISA_DEVICE)
 
@@ -63,6 +64,41 @@ static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
     isa_register_ioport(d, &ps->mr, s->ioport);
 }
 
+static void build_pvpanic_isa_aml(AcpiDevAmlIf *adev, Aml *scope)
+{
+    Aml *crs, *field, *method;
+    PVPanicISAState *s = PVPANIC_ISA_DEVICE(adev);
+    Aml *dev = aml_device("PEVT");
+
+    aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0001")));
+
+    crs = aml_resource_template();
+    aml_append(crs,
+        aml_io(AML_DECODE16, s->ioport, s->ioport, 1, 1)
+    );
+    aml_append(dev, aml_name_decl("_CRS", crs));
+
+    aml_append(dev, aml_operation_region("PEOR", AML_SYSTEM_IO,
+                                          aml_int(s->ioport), 1));
+    field = aml_field("PEOR", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
+    aml_append(field, aml_named_field("PEPT", 8));
+    aml_append(dev, field);
+
+    /* device present, functioning, decoding, shown in UI */
+    aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
+
+    method = aml_method("RDPT", 0, AML_NOTSERIALIZED);
+    aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
+    aml_append(method, aml_return(aml_local(0)));
+    aml_append(dev, method);
+
+    method = aml_method("WRPT", 1, AML_NOTSERIALIZED);
+    aml_append(method, aml_store(aml_arg(0), aml_name("PEPT")));
+    aml_append(dev, method);
+
+    aml_append(scope, dev);
+}
+
 static Property pvpanic_isa_properties[] = {
     DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicISAState, ioport, 0x505),
     DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events,
@@ -73,10 +109,12 @@ static Property pvpanic_isa_properties[] = {
 static void pvpanic_isa_class_init(ObjectClass *klass, void *data)
 {

hw/misc/pvpanic-isa.c static Property pvpanic_isa_properties[] = { · line 120

Quoted 10 lines
hw/misc/pvpanic-isa.c +2 -0
     DeviceClass *dc = DEVICE_CLASS(klass);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
 
     dc->realize = pvpanic_isa_realizefn;
     device_class_set_props(dc, pvpanic_isa_properties);
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+    adevc->build_dev_aml = build_pvpanic_isa_aml;
 }
 
 static const TypeInfo pvpanic_isa_info = {

So this really makes the device depend on ACPI. What if the device is also built for a platform without ACPI? Looks like it will fail to build.

E.g. mips has ISA too. What if one was to add pvpanic there?

I am not sure how important this is at the moment, but I think the APIs should support this cleanly.

How about an inline function along the lines of:

acpi_set_build_dev_aml(DeviceClass *dc, ....)

the build function itself is static, so compiler will remove it if unused.

Quoted 13 lines
hw/misc/pvpanic-isa.c +4 -0
@@ -85,6 +123,10 @@ static const TypeInfo pvpanic_isa_info = {
     .instance_size = sizeof(PVPanicISAState),
     .instance_init = pvpanic_isa_initfn,
     .class_init    = pvpanic_isa_class_init,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_ACPI_DEV_AML_IF },
+        { },
+    },
 };
 
 static void pvpanic_register_types(void)
Signature · 1 line
2.31.1
#34 lore raw

Re: [PATCH 28/35] acpi: pvpanic-isa: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML

Quoted 169 lines · Michael S. Tsirkin
Quoted 168 lines · Igor Mammedov

.. and clean up not longer needed conditionals in DSTD build code pvpanic-isa AML will be fetched and included when ISA bridge will build its own AML code (including attached devices).

Expected AML change:
the device under separate _SB.PCI0.ISA scope is moved directly under Device(ISA) node.

---
 include/hw/misc/pvpanic.h |  9 ---------
 hw/i386/acpi-build.c      | 37 ----------------------------------
 hw/misc/pvpanic-isa.c     | 42 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 46 deletions(-)
include/hw/misc/pvpanic.h +0 -9
index 7f16cc9b16..e520566ab0 100644
@@ -33,13 +33,4 @@ struct PVPanicState {
 
 void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size);
 
-static inline uint16_t pvpanic_port(void)
-{
-    Object *o = object_resolve_path_type("", TYPE_PVPANIC_ISA_DEVICE, NULL);
-    if (!o) {
-        return 0;
-    }
-    return object_property_get_uint(o, PVPANIC_IOPORT_PROP, NULL);
-}
-
 #endif
hw/i386/acpi-build.c +0 -37
index 517818cd9f..a42f41f373 100644
@@ -30,7 +30,6 @@
 #include "hw/pci/pci.h"
 #include "hw/core/cpu.h"
 #include "target/i386/cpu.h"
-#include "hw/misc/pvpanic.h"
 #include "hw/timer/hpet.h"
 #include "hw/acpi/acpi-defs.h"
 #include "hw/acpi/acpi.h"
@@ -117,7 +116,6 @@ typedef struct AcpiMiscInfo {
 #endif
     const unsigned char *dsdt_code;
     unsigned dsdt_size;
-    uint16_t pvpanic_port;
 } AcpiMiscInfo;
 
 typedef struct AcpiBuildPciBusHotplugState {
@@ -302,7 +300,6 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
 #ifdef CONFIG_TPM
     info->tpm_version = tpm_get_version(tpm_find());
 #endif
-    info->pvpanic_port = pvpanic_port();
 }
 
 /*
@@ -1749,40 +1746,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         aml_append(dsdt, scope);
     }
 
-    if (misc->pvpanic_port) {
-        scope = aml_scope("\\_SB.PCI0.ISA");
-
-        dev = aml_device("PEVT");
-        aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0001")));
-
-        crs = aml_resource_template();
-        aml_append(crs,
-            aml_io(AML_DECODE16, misc->pvpanic_port, misc->pvpanic_port, 1, 1)
-        );
-        aml_append(dev, aml_name_decl("_CRS", crs));
-
-        aml_append(dev, aml_operation_region("PEOR", AML_SYSTEM_IO,
-                                              aml_int(misc->pvpanic_port), 1));
-        field = aml_field("PEOR", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
-        aml_append(field, aml_named_field("PEPT", 8));
-        aml_append(dev, field);
-
-        /* device present, functioning, decoding, shown in UI */
-        aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
-
-        method = aml_method("RDPT", 0, AML_NOTSERIALIZED);
-        aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
-        aml_append(method, aml_return(aml_local(0)));
-        aml_append(dev, method);
-
-        method = aml_method("WRPT", 1, AML_NOTSERIALIZED);
-        aml_append(method, aml_store(aml_arg(0), aml_name("PEPT")));
-        aml_append(dev, method);
-
-        aml_append(scope, dev);
-        aml_append(dsdt, scope);
-    }
-
     sb_scope = aml_scope("\\_SB");
     {
         Object *pci_host;
hw/misc/pvpanic-isa.c +38 -0
index b84d4d458d..ccec50f61b 100644
@@ -22,6 +22,7 @@
 #include "qom/object.h"
 #include "hw/isa/isa.h"
 #include "standard-headers/linux/pvpanic.h"
+#include "hw/acpi/acpi_aml_interface.h"
 
 OBJECT_DECLARE_SIMPLE_TYPE(PVPanicISAState, PVPANIC_ISA_DEVICE)
 
@@ -63,6 +64,41 @@ static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
     isa_register_ioport(d, &ps->mr, s->ioport);
 }
 
+static void build_pvpanic_isa_aml(AcpiDevAmlIf *adev, Aml *scope)
+{
+    Aml *crs, *field, *method;
+    PVPanicISAState *s = PVPANIC_ISA_DEVICE(adev);
+    Aml *dev = aml_device("PEVT");
+
+    aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0001")));
+
+    crs = aml_resource_template();
+    aml_append(crs,
+        aml_io(AML_DECODE16, s->ioport, s->ioport, 1, 1)
+    );
+    aml_append(dev, aml_name_decl("_CRS", crs));
+
+    aml_append(dev, aml_operation_region("PEOR", AML_SYSTEM_IO,
+                                          aml_int(s->ioport), 1));
+    field = aml_field("PEOR", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
+    aml_append(field, aml_named_field("PEPT", 8));
+    aml_append(dev, field);
+
+    /* device present, functioning, decoding, shown in UI */
+    aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
+
+    method = aml_method("RDPT", 0, AML_NOTSERIALIZED);
+    aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
+    aml_append(method, aml_return(aml_local(0)));
+    aml_append(dev, method);
+
+    method = aml_method("WRPT", 1, AML_NOTSERIALIZED);
+    aml_append(method, aml_store(aml_arg(0), aml_name("PEPT")));
+    aml_append(dev, method);
+
+    aml_append(scope, dev);
+}
+
 static Property pvpanic_isa_properties[] = {
     DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicISAState, ioport, 0x505),
     DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events,
@@ -73,10 +109,12 @@ static Property pvpanic_isa_properties[] = {
 static void pvpanic_isa_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
 
     dc->realize = pvpanic_isa_realizefn;
     device_class_set_props(dc, pvpanic_isa_properties);
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+    adevc->build_dev_aml = build_pvpanic_isa_aml;
 }
 
Quoted 6 lines

hw/misc/pvpanic-isa.c static Property pvpanic_isa_properties[] = { · line 120

Quoted 1 line
hw/misc/pvpanic-isa.c +0 -0
 static const TypeInfo pvpanic_isa_info = {

So this really makes the device depend on ACPI. What if the device is also built for a platform without ACPI? Looks like it will fail to build.

That problem isn't new and we already have a bunch of aml_* stubs because of that. I expect it'll work just fine, at worst we'll have to add a stub or two in case some calls are not covered yet.

take care,
Gerd

#35 lore raw

Re: [PATCH 28/35] acpi: pvpanic-isa: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML

Quoted 3 lines · Gerd Hoffmann

That problem isn't new and we already have a bunch of aml_* stubs because of that. I expect it'll work just fine, at worst we'll have to add a stub or two in case some calls are not covered yet.

Right but adding these stubs is a bother, we keep missing some. If possible I'd like the solution to be cleaner than the status quo. Is adding a wrapper instead of setting a method directly such a big problem really?

Signature · 1 line
MST
#36 lore raw

Re: [PATCH 28/35] acpi: pvpanic-isa: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML

Quoted 9 lines · On Wed, 18 May 2022 12:29:25 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 3 lines · Gerd Hoffmann

That problem isn't new and we already have a bunch of aml_* stubs because of that. I expect it'll work just fine, at worst we'll have to add a stub or two in case some calls are not covered yet.

Right but adding these stubs is a bother, we keep missing some. If possible I'd like the solution to be cleaner than the status quo. Is adding a wrapper instead of setting a method directly such a big problem really?

Stubs are the bother but not much compared to alternatives. I can't recall missing stubs recently (it's hard to miss them as it's build time failure that won't pass CI).

However wrapper would introduce ifdeffenry instead of a stub. And my understanding was that it's not acceptable and stubs are what consensus approach is/was to eliminate/minimize ifdefs in the code.

Also adding wrapper won't help anything, we also need to decouple AML code into separate source files to avoid dependency on AML routines and that is a bigger crunch that includes not only new source files but spreading CONFIG_APCI all over the tree, so I'm not sure if end result won't be worse compared to stubs. Stubs are not the cleanest ways around the issue but they would be simpler to maintain in the end.

#37 lore raw

Re: [PATCH 28/35] acpi: pvpanic-isa: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML

In reply to Michael S. Tsirkin
Quoted 10 lines · On Wed, 18 May 2022 12:29:25 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 3 lines · Gerd Hoffmann

That problem isn't new and we already have a bunch of aml_* stubs because of that. I expect it'll work just fine, at worst we'll have to add a stub or two in case some calls are not covered yet.

Right but adding these stubs is a bother, we keep missing some. If possible I'd like the solution to be cleaner than the status quo. Is adding a wrapper instead of setting a method directly such a big problem really?

here is stub based ACPI decoupling for isa devices we currently have in the tree:

https://gitlab.com/imammedo/qemu/-/commits/decouple_build_aml_v1/

If it looks acceptable to you, I can prep/post it first and then rebase this series on top to reduce unnecessary churning.

#38 lore raw

Re: [PATCH 28/35] acpi: pvpanic-isa: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML

In reply to Michael S. Tsirkin
Quoted 176 lines · On Mon, 16 May 2022 16:46:29 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 159 lines · Igor Mammedov

.. and clean up not longer needed conditionals in DSTD build code pvpanic-isa AML will be fetched and included when ISA bridge will build its own AML code (including attached devices).

Expected AML change:
the device under separate _SB.PCI0.ISA scope is moved directly under Device(ISA) node.

---
 include/hw/misc/pvpanic.h |  9 ---------
 hw/i386/acpi-build.c      | 37 ----------------------------------
 hw/misc/pvpanic-isa.c     | 42 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 46 deletions(-)
include/hw/misc/pvpanic.h +0 -9
index 7f16cc9b16..e520566ab0 100644
@@ -33,13 +33,4 @@ struct PVPanicState {
 
 void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size);
 
-static inline uint16_t pvpanic_port(void)
-{
-    Object *o = object_resolve_path_type("", TYPE_PVPANIC_ISA_DEVICE, NULL);
-    if (!o) {
-        return 0;
-    }
-    return object_property_get_uint(o, PVPANIC_IOPORT_PROP, NULL);
-}
-
 #endif
hw/i386/acpi-build.c +0 -37
index 517818cd9f..a42f41f373 100644
@@ -30,7 +30,6 @@
 #include "hw/pci/pci.h"
 #include "hw/core/cpu.h"
 #include "target/i386/cpu.h"
-#include "hw/misc/pvpanic.h"
 #include "hw/timer/hpet.h"
 #include "hw/acpi/acpi-defs.h"
 #include "hw/acpi/acpi.h"
@@ -117,7 +116,6 @@ typedef struct AcpiMiscInfo {
 #endif
     const unsigned char *dsdt_code;
     unsigned dsdt_size;
-    uint16_t pvpanic_port;
 } AcpiMiscInfo;
 
 typedef struct AcpiBuildPciBusHotplugState {
@@ -302,7 +300,6 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
 #ifdef CONFIG_TPM
     info->tpm_version = tpm_get_version(tpm_find());
 #endif
-    info->pvpanic_port = pvpanic_port();
 }
 
 /*
@@ -1749,40 +1746,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         aml_append(dsdt, scope);
     }
 
-    if (misc->pvpanic_port) {
-        scope = aml_scope("\\_SB.PCI0.ISA");
-
-        dev = aml_device("PEVT");
-        aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0001")));
-
-        crs = aml_resource_template();
-        aml_append(crs,
-            aml_io(AML_DECODE16, misc->pvpanic_port, misc->pvpanic_port, 1, 1)
-        );
-        aml_append(dev, aml_name_decl("_CRS", crs));
-
-        aml_append(dev, aml_operation_region("PEOR", AML_SYSTEM_IO,
-                                              aml_int(misc->pvpanic_port), 1));
-        field = aml_field("PEOR", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
-        aml_append(field, aml_named_field("PEPT", 8));
-        aml_append(dev, field);
-
-        /* device present, functioning, decoding, shown in UI */
-        aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
-
-        method = aml_method("RDPT", 0, AML_NOTSERIALIZED);
-        aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
-        aml_append(method, aml_return(aml_local(0)));
-        aml_append(dev, method);
-
-        method = aml_method("WRPT", 1, AML_NOTSERIALIZED);
-        aml_append(method, aml_store(aml_arg(0), aml_name("PEPT")));
-        aml_append(dev, method);
-
-        aml_append(scope, dev);
-        aml_append(dsdt, scope);
-    }
-
     sb_scope = aml_scope("\\_SB");
     {
         Object *pci_host;
hw/misc/pvpanic-isa.c +36 -0
index b84d4d458d..ccec50f61b 100644
@@ -22,6 +22,7 @@
 #include "qom/object.h"
 #include "hw/isa/isa.h"
 #include "standard-headers/linux/pvpanic.h"
+#include "hw/acpi/acpi_aml_interface.h"
 
 OBJECT_DECLARE_SIMPLE_TYPE(PVPanicISAState, PVPANIC_ISA_DEVICE)
 
@@ -63,6 +64,41 @@ static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
     isa_register_ioport(d, &ps->mr, s->ioport);
 }
 
+static void build_pvpanic_isa_aml(AcpiDevAmlIf *adev, Aml *scope)
+{
+    Aml *crs, *field, *method;
+    PVPanicISAState *s = PVPANIC_ISA_DEVICE(adev);
+    Aml *dev = aml_device("PEVT");
+
+    aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0001")));
+
+    crs = aml_resource_template();
+    aml_append(crs,
+        aml_io(AML_DECODE16, s->ioport, s->ioport, 1, 1)
+    );
+    aml_append(dev, aml_name_decl("_CRS", crs));
+
+    aml_append(dev, aml_operation_region("PEOR", AML_SYSTEM_IO,
+                                          aml_int(s->ioport), 1));
+    field = aml_field("PEOR", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
+    aml_append(field, aml_named_field("PEPT", 8));
+    aml_append(dev, field);
+
+    /* device present, functioning, decoding, shown in UI */
+    aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
+
+    method = aml_method("RDPT", 0, AML_NOTSERIALIZED);
+    aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
+    aml_append(method, aml_return(aml_local(0)));
+    aml_append(dev, method);
+
+    method = aml_method("WRPT", 1, AML_NOTSERIALIZED);
+    aml_append(method, aml_store(aml_arg(0), aml_name("PEPT")));
+    aml_append(dev, method);
+
+    aml_append(scope, dev);
+}
+
 static Property pvpanic_isa_properties[] = {
     DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicISAState, ioport, 0x505),
     DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events,
@@ -73,10 +109,12 @@ static Property pvpanic_isa_properties[] = {
 static void pvpanic_isa_class_init(ObjectClass *klass, void *data)
 {

hw/misc/pvpanic-isa.c static Property pvpanic_isa_properties[] = { · line 120

Quoted 10 lines
hw/misc/pvpanic-isa.c +2 -0
     DeviceClass *dc = DEVICE_CLASS(klass);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
 
     dc->realize = pvpanic_isa_realizefn;
     device_class_set_props(dc, pvpanic_isa_properties);
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+    adevc->build_dev_aml = build_pvpanic_isa_aml;
 }
 
 static const TypeInfo pvpanic_isa_info = {  

So this really makes the device depend on ACPI. What if the device is also built for a platform without ACPI? Looks like it will fail to build.

Quoted 4 lines

E.g. mips has ISA too. What if one was to add pvpanic there?

I am not sure how important this is at the moment, but I think the APIs should support this cleanly.

it compiles/passes tests with current code, but otherwise as Gerd already mentioned, current pattern for such issues is stub functions.

Also we are currently pulling in aml_build library for ISA devices (this series spreads it to some more devices). We can isolate aml device builder into separate files (aka set of foo-device-acpi.c) to compile it out completely, but I'd prefer to do it separately from this refactoring, if you'd like to go this direction.
It's just another pre-existing issue, and out of scope of this refactoring (which is already too big for my taste). As you can notice this series mostly moves ad-hoc AML to respective devices without rewriting it, to keep it simple and review-able, the other issues can be solved on top to keep it manageable.

Quoted 6 lines

How about an inline function along the lines of:

acpi_set_build_dev_aml(DeviceClass *dc, ....)

the build function itself is static, so compiler will remove it if unused.

lets see how PCI conversion will end up, if stubs become to much of a burden, I for sure will try inline function idea. Or another a bit worse idea would be to use similar macro keyed of ACPI define.

Quoted 15 lines
Quoted 14 lines
hw/misc/pvpanic-isa.c +4 -0
@@ -85,6 +123,10 @@ static const TypeInfo pvpanic_isa_info = {
     .instance_size = sizeof(PVPanicISAState),
     .instance_init = pvpanic_isa_initfn,
     .class_init    = pvpanic_isa_class_init,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_ACPI_DEV_AML_IF },
+        { },
+    },
 };
 
 static void pvpanic_register_types(void)
Signature · 1 line
2.31.1  
#39 lore raw

Re: [PATCH 28/35] acpi: pvpanic-isa: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML

In reply to Michael S. Tsirkin
Quoted 169 lines · On Mon, 16 May 2022 16:46:29 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 168 lines · Igor Mammedov

.. and clean up not longer needed conditionals in DSTD build code pvpanic-isa AML will be fetched and included when ISA bridge will build its own AML code (including attached devices).

Expected AML change:
the device under separate _SB.PCI0.ISA scope is moved directly under Device(ISA) node.

---
 include/hw/misc/pvpanic.h |  9 ---------
 hw/i386/acpi-build.c      | 37 ----------------------------------
 hw/misc/pvpanic-isa.c     | 42 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 46 deletions(-)
include/hw/misc/pvpanic.h +0 -9
index 7f16cc9b16..e520566ab0 100644
@@ -33,13 +33,4 @@ struct PVPanicState {
 
 void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size);
 
-static inline uint16_t pvpanic_port(void)
-{
-    Object *o = object_resolve_path_type("", TYPE_PVPANIC_ISA_DEVICE, NULL);
-    if (!o) {
-        return 0;
-    }
-    return object_property_get_uint(o, PVPANIC_IOPORT_PROP, NULL);
-}
-
 #endif
hw/i386/acpi-build.c +0 -37
index 517818cd9f..a42f41f373 100644
@@ -30,7 +30,6 @@
 #include "hw/pci/pci.h"
 #include "hw/core/cpu.h"
 #include "target/i386/cpu.h"
-#include "hw/misc/pvpanic.h"
 #include "hw/timer/hpet.h"
 #include "hw/acpi/acpi-defs.h"
 #include "hw/acpi/acpi.h"
@@ -117,7 +116,6 @@ typedef struct AcpiMiscInfo {
 #endif
     const unsigned char *dsdt_code;
     unsigned dsdt_size;
-    uint16_t pvpanic_port;
 } AcpiMiscInfo;
 
 typedef struct AcpiBuildPciBusHotplugState {
@@ -302,7 +300,6 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
 #ifdef CONFIG_TPM
     info->tpm_version = tpm_get_version(tpm_find());
 #endif
-    info->pvpanic_port = pvpanic_port();
 }
 
 /*
@@ -1749,40 +1746,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         aml_append(dsdt, scope);
     }
 
-    if (misc->pvpanic_port) {
-        scope = aml_scope("\\_SB.PCI0.ISA");
-
-        dev = aml_device("PEVT");
-        aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0001")));
-
-        crs = aml_resource_template();
-        aml_append(crs,
-            aml_io(AML_DECODE16, misc->pvpanic_port, misc->pvpanic_port, 1, 1)
-        );
-        aml_append(dev, aml_name_decl("_CRS", crs));
-
-        aml_append(dev, aml_operation_region("PEOR", AML_SYSTEM_IO,
-                                              aml_int(misc->pvpanic_port), 1));
-        field = aml_field("PEOR", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
-        aml_append(field, aml_named_field("PEPT", 8));
-        aml_append(dev, field);
-
-        /* device present, functioning, decoding, shown in UI */
-        aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
-
-        method = aml_method("RDPT", 0, AML_NOTSERIALIZED);
-        aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
-        aml_append(method, aml_return(aml_local(0)));
-        aml_append(dev, method);
-
-        method = aml_method("WRPT", 1, AML_NOTSERIALIZED);
-        aml_append(method, aml_store(aml_arg(0), aml_name("PEPT")));
-        aml_append(dev, method);
-
-        aml_append(scope, dev);
-        aml_append(dsdt, scope);
-    }
-
     sb_scope = aml_scope("\\_SB");
     {
         Object *pci_host;
hw/misc/pvpanic-isa.c +38 -0
index b84d4d458d..ccec50f61b 100644
@@ -22,6 +22,7 @@
 #include "qom/object.h"
 #include "hw/isa/isa.h"
 #include "standard-headers/linux/pvpanic.h"
+#include "hw/acpi/acpi_aml_interface.h"
 
 OBJECT_DECLARE_SIMPLE_TYPE(PVPanicISAState, PVPANIC_ISA_DEVICE)
 
@@ -63,6 +64,41 @@ static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
     isa_register_ioport(d, &ps->mr, s->ioport);
 }
 
+static void build_pvpanic_isa_aml(AcpiDevAmlIf *adev, Aml *scope)
+{
+    Aml *crs, *field, *method;
+    PVPanicISAState *s = PVPANIC_ISA_DEVICE(adev);
+    Aml *dev = aml_device("PEVT");
+
+    aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0001")));
+
+    crs = aml_resource_template();
+    aml_append(crs,
+        aml_io(AML_DECODE16, s->ioport, s->ioport, 1, 1)
+    );
+    aml_append(dev, aml_name_decl("_CRS", crs));
+
+    aml_append(dev, aml_operation_region("PEOR", AML_SYSTEM_IO,
+                                          aml_int(s->ioport), 1));
+    field = aml_field("PEOR", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
+    aml_append(field, aml_named_field("PEPT", 8));
+    aml_append(dev, field);
+
+    /* device present, functioning, decoding, shown in UI */
+    aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
+
+    method = aml_method("RDPT", 0, AML_NOTSERIALIZED);
+    aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
+    aml_append(method, aml_return(aml_local(0)));
+    aml_append(dev, method);
+
+    method = aml_method("WRPT", 1, AML_NOTSERIALIZED);
+    aml_append(method, aml_store(aml_arg(0), aml_name("PEPT")));
+    aml_append(dev, method);
+
+    aml_append(scope, dev);
+}
+
 static Property pvpanic_isa_properties[] = {
     DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicISAState, ioport, 0x505),
     DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events,
@@ -73,10 +109,12 @@ static Property pvpanic_isa_properties[] = {
 static void pvpanic_isa_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
 
     dc->realize = pvpanic_isa_realizefn;
     device_class_set_props(dc, pvpanic_isa_properties);
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+    adevc->build_dev_aml = build_pvpanic_isa_aml;
 }
 
Quoted 8 lines

hw/misc/pvpanic-isa.c static Property pvpanic_isa_properties[] = { · line 120

Quoted 1 line
hw/misc/pvpanic-isa.c +0 -0
 static const TypeInfo pvpanic_isa_info = {  

So this really makes the device depend on ACPI. What if the device is also built for a platform without ACPI? Looks like it will fail to build.

E.g. mips has ISA too. What if one was to add pvpanic there?

it turns out meson somehow figures out dependency and pulls in CONFIG_ACPI implicitly for mips (well and the same for a bunch of other targets where acpi doesn't have any stake).

Quoted 6 lines

I am not sure how important this is at the moment, but I think the APIs should support this cleanly.

How about an inline function along the lines of:

acpi_set_build_dev_aml(DeviceClass *dc, ....)

current docs/devel/build-system.rst suggests using stubs for conditional code (it even uses CONFIG_ACPI as example of such usage)

Quoted 2 lines

the build function itself is static, so compiler will remove it if unused.

what you are essentially suggesting is to make target in-depended file (that is built once. ex: fdc-isa) into several target dependent builds (due to dependency on build_aml_foo() symbol). While stubs allow to keep file independent by substituting build_aml_foo() with dummy stub. So I'm not sure we would like go that route.

Anyways, I did try to give it a shot and failed,
or maybe I misunderstood your idea completely

resistance I've met:
- CONFIG_ACPI define is poisoned (hacked around it, pretty sure in wrong way)

- couldn't figure out meson.build rule that depends on several symbols yet (meson docs suggest it's possble)
(i.e. add/build new fdc-isa-acpi.c file if both CONFIG_FDC_ISA & CONFIG_ACPI defined)
we can use only CONFIG_ACPI and hope that linker will discard object file as unused if target has ACPI but does not have CONFIG_FDC_ISA (it's still lost build time on use-less object).

- CONFIG_ACPI is not visible for target in-depended devices gave up here ...

my ugly attempt is here:
https://gitlab.com/imammedo/qemu/-/commit/9cb126c903a72582ac2f1643664b06414e25e0af

Quoted 14 lines
Quoted 13 lines
hw/misc/pvpanic-isa.c +4 -0
@@ -85,6 +123,10 @@ static const TypeInfo pvpanic_isa_info = {
     .instance_size = sizeof(PVPanicISAState),
     .instance_init = pvpanic_isa_initfn,
     .class_init    = pvpanic_isa_class_init,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_ACPI_DEV_AML_IF },
+        { },
+    },
 };
 
 static void pvpanic_register_types(void)
Signature · 1 line
2.31.1  
#40 lore raw

PATCH 29/35 tests: acpi: update expected DSDT.pvpanic-isa blob

In reply to Igor Mammedov

@@ -145,6 +145,37 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)

         {
             Name (_ADR, 0x001F0000)  // _ADR: Address
             OperationRegion (PIRQ, PCI_Config, 0x60, 0x0C)
+            Device (PEVT)
+            {
+                Name (_HID, "QEMU0001")  // _HID: Hardware ID
+                Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
+                {
+                    IO (Decode16,
+                        0x0505,             // Range Minimum
+                        0x0505,             // Range Maximum
+                        0x01,               // Alignment
+                        0x01,               // Length
+                        )
+                })
+                OperationRegion (PEOR, SystemIO, 0x0505, One)
+                Field (PEOR, ByteAcc, NoLock, Preserve)
+                {
+                    PEPT,   8
+                }
+
+                Name (_STA, 0x0F)  // _STA: Status
+                Method (RDPT, 0, NotSerialized)
+                {

+ Local0 = PEPT /* \_SB_.PCI0.ISA_.PEVT.PEPT */
+ Return (Local0)
+ }
+
+ Method (WRPT, 1, NotSerialized)
+ {
+ PEPT = Arg0
+ }
+ }
+

             Device (KBD)
             {
                 Name (_HID, EisaId ("PNP0303") /* IBM Enhanced Keyboard (101/102-key, PS/2 Mouse) */)  // _HID: Hardware ID
@@ -3246,40 +3277,6 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC    ", 0x00000001)
         }
     }

- Scope (\_SB.PCI0.ISA)
- {
- Device (PEVT)
- {

-            Name (_HID, "QEMU0001")  // _HID: Hardware ID
-            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
-            {
-                IO (Decode16,
-                    0x0505,             // Range Minimum
-                    0x0505,             // Range Maximum
-                    0x01,               // Alignment
-                    0x01,               // Length
-                    )
-            })
-            OperationRegion (PEOR, SystemIO, 0x0505, One)
-            Field (PEOR, ByteAcc, NoLock, Preserve)
-            {
-                PEPT,   8
-            }
-
-            Name (_STA, 0x0F)  // _STA: Status
-            Method (RDPT, 0, NotSerialized)
-            {

- Local0 = PEPT /* \_SB_.PCI0.ISA_.PEVT.PEPT */
- Return (Local0)
- }
-
- Method (WRPT, 1, NotSerialized)
- {
- PEPT = Arg0
- }
- }
- }
-

     Scope (\_SB)
     {
         Scope (PCI0)
---
 tests/qtest/bios-tables-test-allowed-diff.h |   1 -
 tests/data/acpi/q35/DSDT.pvpanic-isa        | Bin 0 -> 8375 bytes
 2 files changed, 1 deletion(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
index d5cd7aa4f5..dfb8523c8b 100644
@@ -1,2 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/q35/DSDT.pvpanic-isa",
tests/data/acpi/q35/DSDT.pvpanic-isa binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..cc545b5d2505246d33f83d2482273968aa1be032 100644
GIT binary patch
Signature · 1 line
2.31.1
#41 lore raw

PATCH 30/35 tests: acpi: white-list DSDT.tis.tpm2/DSDT.tis.tpm12 expected blobs

In reply to Igor Mammedov
---
 tests/qtest/bios-tables-test-allowed-diff.h | 2 ++
 1 file changed, 2 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +2 -0
index dfb8523c8b..7b3bf9a207 100644
@@ -1 +1,3 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/q35/DSDT.tis.tpm2",
+"tests/data/acpi/q35/DSDT.tis.tpm12",
Signature · 1 line
2.31.1
Acked-by on v1 30/35
#42 lore raw

Re: [PATCH 30/35] tests: acpi: white-list DSDT.tis.tpm2/DSDT.tis.tpm12 expected blobs

Quoted 2 lines · Igor Mammedov
Quoted 15 lines
---
 tests/qtest/bios-tables-test-allowed-diff.h | 2 ++
 1 file changed, 2 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +2 -1
index dfb8523c8b..7b3bf9a207 100644
@@ -1 +1,3 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/q35/DSDT.tis.tpm2",
+"tests/data/acpi/q35/DSDT.tis.tpm12",
--

2.31.1

#43 lore raw

PATCH 31/35 acpi: pc/q35: tpm-tis: fix TPM device scope

In reply to Igor Mammedov

tpm-tis, is not a PCI device but ISA one, move it
under ISA scope to fix incorrect placement.

Fixes 24cf5413aa0 (acpi: Make TPM 2.0 with TIS available as MSFT0101)
---
 hw/i386/acpi-build.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/i386/acpi-build.c +1 -2
index a42f41f373..85a7313cad 100644
@@ -1764,15 +1764,14 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
 
 #ifdef CONFIG_TPM
             if (TPM_IS_TIS_ISA(tpm)) {
+                dev = aml_device("ISA.TPM");
                 if (misc->tpm_version == TPM_VERSION_2_0) {
-                    dev = aml_device("TPM");
                     aml_append(dev, aml_name_decl("_HID",
                                                   aml_string("MSFT0101")));
                     aml_append(dev,
                                aml_name_decl("_STR",
                                              aml_string("TPM 2.0 Device")));
                 } else {
-                    dev = aml_device("ISA.TPM");
                     aml_append(dev, aml_name_decl("_HID",
                                                   aml_eisaid("PNP0C31")));
                 }
Signature · 1 line
2.31.1
Reviewed-by on v1 31/35
#44 lore raw

Re: [PATCH 31/35] acpi: pc/q35: tpm-tis: fix TPM device scope

Quoted 3 lines · Igor Mammedov

tpm-tis, is not a PCI device but ISA one, move it
under ISA scope to fix incorrect placement.

This description is a little misleading. What we fix here is for TPM-tis 2.0 only. TPM 1.2 was already previously under ISA scope.

Quoted 3 lines
Fixes 24cf5413aa0 (acpi: Make TPM 2.0 with TIS available as MSFT0101)

modulo that above comment,

Quoted 28 lines
---
 hw/i386/acpi-build.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/i386/acpi-build.c +1 -3
index a42f41f373..85a7313cad 100644
@@ -1764,15 +1764,14 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
 
 #ifdef CONFIG_TPM
             if (TPM_IS_TIS_ISA(tpm)) {
+                dev = aml_device("ISA.TPM");
                 if (misc->tpm_version == TPM_VERSION_2_0) {
-                    dev = aml_device("TPM");
                     aml_append(dev, aml_name_decl("_HID",
                                                   aml_string("MSFT0101")));
                     aml_append(dev,
                                aml_name_decl("_STR",
                                              aml_string("TPM 2.0 Device")));
                 } else {
-                    dev = aml_device("ISA.TPM");
                     aml_append(dev, aml_name_decl("_HID",
                                                   aml_eisaid("PNP0C31")));
                 }
--

2.31.1

#45 lore raw

Re: [PATCH 31/35] acpi: pc/q35: tpm-tis: fix TPM device scope

Quoted 7 lines · On Wed, 18 May 2022 14:33:12 +0530 Ani Sinha <[email protected]> wrote:
Quoted 3 lines · Igor Mammedov

tpm-tis, is not a PCI device but ISA one, move it
under ISA scope to fix incorrect placement.

This description is a little misleading. What we fix here is for TPM-tis 2.0 only. TPM 1.2 was already previously under ISA scope.

I'll fix it up on respin

Quoted 36 lines
Quoted 3 lines
Fixes 24cf5413aa0 (acpi: Make TPM 2.0 with TIS available as MSFT0101)

modulo that above comment,

Quoted 28 lines
---
 hw/i386/acpi-build.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/i386/acpi-build.c +1 -3
index a42f41f373..85a7313cad 100644
@@ -1764,15 +1764,14 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
 
 #ifdef CONFIG_TPM
             if (TPM_IS_TIS_ISA(tpm)) {
+                dev = aml_device("ISA.TPM");
                 if (misc->tpm_version == TPM_VERSION_2_0) {
-                    dev = aml_device("TPM");
                     aml_append(dev, aml_name_decl("_HID",
                                                   aml_string("MSFT0101")));
                     aml_append(dev,
                                aml_name_decl("_STR",
                                              aml_string("TPM 2.0 Device")));
                 } else {
-                    dev = aml_device("ISA.TPM");
                     aml_append(dev, aml_name_decl("_HID",
                                                   aml_eisaid("PNP0C31")));
                 }
--

2.31.1

#46 lore raw

PATCH 32/35 acpi: pc/q35: remove not needed 'if' condition on pci bus

In reply to Igor Mammedov
---
 hw/i386/acpi-build.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
hw/i386/acpi-build.c +2 -8
index 85a7313cad..414b9240b2 100644
@@ -1748,16 +1748,10 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
 
     sb_scope = aml_scope("\\_SB");
     {
-        Object *pci_host;
-        PCIBus *bus = NULL;
-
-        pci_host = acpi_get_i386_pci_host();
+        Object *pci_host = acpi_get_i386_pci_host();
 
         if (pci_host) {
-            bus = PCI_HOST_BRIDGE(pci_host)->bus;
-        }
-
-        if (bus) {
+            PCIBus *bus = PCI_HOST_BRIDGE(pci_host)->bus;
             Aml *scope = aml_scope("PCI0");
             /* Scan all PCI buses. Generate tables to support hotplug. */
             build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
Signature · 1 line
2.31.1
Reviewed-by on v1 32/35
#47 lore raw

Re: [PATCH 32/35] acpi: pc/q35: remove not needed 'if' condition on pci bus

Quoted 2 lines · Igor Mammedov
Quoted 30 lines
---
 hw/i386/acpi-build.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
hw/i386/acpi-build.c +2 -9
index 85a7313cad..414b9240b2 100644
@@ -1748,16 +1748,10 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
 
     sb_scope = aml_scope("\\_SB");
     {
-        Object *pci_host;
-        PCIBus *bus = NULL;
-
-        pci_host = acpi_get_i386_pci_host();
+        Object *pci_host = acpi_get_i386_pci_host();
 
         if (pci_host) {
-            bus = PCI_HOST_BRIDGE(pci_host)->bus;
-        }
-
-        if (bus) {
+            PCIBus *bus = PCI_HOST_BRIDGE(pci_host)->bus;
             Aml *scope = aml_scope("PCI0");
             /* Scan all PCI buses. Generate tables to support hotplug. */
             build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
--

2.31.1

#48 lore raw

PATCH 33/35 acpi: tpm-tis: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML

In reply to Igor Mammedov

.. and clean up not longer needed conditionals in DSTD build code tpm-tis AML will be fetched and included when ISA bridge will build its own AML code (including attached devices).

Expected AML change:
the device under separate _SB.PCI0.ISA scope is moved directly under Device(ISA) node.

---
 hw/i386/acpi-build.c | 34 ----------------------------------
 hw/tpm/tpm_tis_isa.c | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 34 deletions(-)
hw/i386/acpi-build.c +0 -34
index 414b9240b2..58284438f8 100644
@@ -1755,40 +1755,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
             Aml *scope = aml_scope("PCI0");
             /* Scan all PCI buses. Generate tables to support hotplug. */
             build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
-
-#ifdef CONFIG_TPM
-            if (TPM_IS_TIS_ISA(tpm)) {
-                dev = aml_device("ISA.TPM");
-                if (misc->tpm_version == TPM_VERSION_2_0) {
-                    aml_append(dev, aml_name_decl("_HID",
-                                                  aml_string("MSFT0101")));
-                    aml_append(dev,
-                               aml_name_decl("_STR",
-                                             aml_string("TPM 2.0 Device")));
-                } else {
-                    aml_append(dev, aml_name_decl("_HID",
-                                                  aml_eisaid("PNP0C31")));
-                }
-                aml_append(dev, aml_name_decl("_UID", aml_int(1)));
-
-                aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
-                crs = aml_resource_template();
-                aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
-                           TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
-                /*
-                    FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs,
-                    Rewrite to take IRQ from TPM device model and
-                    fix default IRQ value there to use some unused IRQ
-                 */
-                /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */
-                aml_append(dev, aml_name_decl("_CRS", crs));
-
-                tpm_build_ppi_acpi(tpm, dev);
-
-                aml_append(scope, dev);
-            }
-#endif
-
             aml_append(sb_scope, scope);
         }
     }
hw/tpm/tpm_tis_isa.c +32 -0
index 3477afd735..91e3792248 100644
@@ -30,6 +30,7 @@
 #include "tpm_prop.h"
 #include "tpm_tis.h"
 #include "qom/object.h"
+#include "hw/acpi/acpi_aml_interface.h"
 
 struct TPMStateISA {
     /*< private >*/
@@ -138,10 +139,39 @@ static void tpm_tis_isa_realizefn(DeviceState *dev, Error **errp)
     }
 }
 
+static void build_tpm_tis_isa_aml(AcpiDevAmlIf *adev, Aml *scope)
+{
+    Aml *dev, *crs;
+    TPMStateISA *isadev = TPM_TIS_ISA(adev);
+    TPMIf *ti = TPM_IF(isadev);
+
+    dev = aml_device("TPM");
+    if (tpm_tis_isa_get_tpm_version(ti) == TPM_VERSION_2_0) {
+        aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101")));
+        aml_append(dev, aml_name_decl("_STR", aml_string("TPM 2.0 Device")));
+    } else {
+        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
+    }
+    aml_append(dev, aml_name_decl("_UID", aml_int(1)));
+    aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
+    crs = aml_resource_template();
+    aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE, TPM_TIS_ADDR_SIZE,
+                                      AML_READ_WRITE));
+    /*
+     * FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs,
+     * fix default TPM_TIS_IRQ value there to use some unused IRQ
+     */
+    /* aml_append(crs, aml_irq_no_flags(isadev->state.irq_num)); */
+    aml_append(dev, aml_name_decl("_CRS", crs));
+    tpm_build_ppi_acpi(ti, dev);
+    aml_append(scope, dev);
+}
+
 static void tpm_tis_isa_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     TPMIfClass *tc = TPM_IF_CLASS(klass);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
 
     device_class_set_props(dc, tpm_tis_isa_properties);
     dc->vmsd  = &vmstate_tpm_tis_isa;
@@ -151,6 +181,7 @@ static void tpm_tis_isa_class_init(ObjectClass *klass, void *data)
     tc->request_completed = tpm_tis_isa_request_completed;
     tc->get_version = tpm_tis_isa_get_tpm_version;
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+    adevc->build_dev_aml = build_tpm_tis_isa_aml;
 }
 
 static const TypeInfo tpm_tis_isa_info = {
@@ -161,6 +192,7 @@ static const TypeInfo tpm_tis_isa_info = {
     .class_init  = tpm_tis_isa_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_TPM_IF },
+        { TYPE_ACPI_DEV_AML_IF },
         { }
     }
 };
Signature · 1 line
2.31.1
Reviewed-by on v1 33/35
#49 lore raw

Re: [PATCH 33/35] acpi: tpm-tis: use AcpiDevAmlIfClass:build_dev_aml to provide device's AML

Quoted 10 lines · Igor Mammedov

.. and clean up not longer needed conditionals in DSTD build code tpm-tis AML will be fetched and included when ISA bridge will build its own AML code (including attached devices).

Expected AML change:
the device under separate _SB.PCI0.ISA scope is moved directly under Device(ISA) node.

Quoted 121 lines
---
 hw/i386/acpi-build.c | 34 ----------------------------------
 hw/tpm/tpm_tis_isa.c | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 34 deletions(-)
hw/i386/acpi-build.c +0 -34
index 414b9240b2..58284438f8 100644
@@ -1755,40 +1755,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
             Aml *scope = aml_scope("PCI0");
             /* Scan all PCI buses. Generate tables to support hotplug. */
             build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
-
-#ifdef CONFIG_TPM
-            if (TPM_IS_TIS_ISA(tpm)) {
-                dev = aml_device("ISA.TPM");
-                if (misc->tpm_version == TPM_VERSION_2_0) {
-                    aml_append(dev, aml_name_decl("_HID",
-                                                  aml_string("MSFT0101")));
-                    aml_append(dev,
-                               aml_name_decl("_STR",
-                                             aml_string("TPM 2.0 Device")));
-                } else {
-                    aml_append(dev, aml_name_decl("_HID",
-                                                  aml_eisaid("PNP0C31")));
-                }
-                aml_append(dev, aml_name_decl("_UID", aml_int(1)));
-
-                aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
-                crs = aml_resource_template();
-                aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE,
-                           TPM_TIS_ADDR_SIZE, AML_READ_WRITE));
-                /*
-                    FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs,
-                    Rewrite to take IRQ from TPM device model and
-                    fix default IRQ value there to use some unused IRQ
-                 */
-                /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */
-                aml_append(dev, aml_name_decl("_CRS", crs));
-
-                tpm_build_ppi_acpi(tpm, dev);
-
-                aml_append(scope, dev);
-            }
-#endif
-
             aml_append(sb_scope, scope);
         }
     }
hw/tpm/tpm_tis_isa.c +32 -1
index 3477afd735..91e3792248 100644
@@ -30,6 +30,7 @@
 #include "tpm_prop.h"
 #include "tpm_tis.h"
 #include "qom/object.h"
+#include "hw/acpi/acpi_aml_interface.h"
 
 struct TPMStateISA {
     /*< private >*/
@@ -138,10 +139,39 @@ static void tpm_tis_isa_realizefn(DeviceState *dev, Error **errp)
     }
 }
 
+static void build_tpm_tis_isa_aml(AcpiDevAmlIf *adev, Aml *scope)
+{
+    Aml *dev, *crs;
+    TPMStateISA *isadev = TPM_TIS_ISA(adev);
+    TPMIf *ti = TPM_IF(isadev);
+
+    dev = aml_device("TPM");
+    if (tpm_tis_isa_get_tpm_version(ti) == TPM_VERSION_2_0) {
+        aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101")));
+        aml_append(dev, aml_name_decl("_STR", aml_string("TPM 2.0 Device")));
+    } else {
+        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
+    }
+    aml_append(dev, aml_name_decl("_UID", aml_int(1)));
+    aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
+    crs = aml_resource_template();
+    aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE, TPM_TIS_ADDR_SIZE,
+                                      AML_READ_WRITE));
+    /*
+     * FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs,
+     * fix default TPM_TIS_IRQ value there to use some unused IRQ
+     */
+    /* aml_append(crs, aml_irq_no_flags(isadev->state.irq_num)); */
+    aml_append(dev, aml_name_decl("_CRS", crs));
+    tpm_build_ppi_acpi(ti, dev);
+    aml_append(scope, dev);
+}
+
 static void tpm_tis_isa_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     TPMIfClass *tc = TPM_IF_CLASS(klass);
+    AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
 
     device_class_set_props(dc, tpm_tis_isa_properties);
     dc->vmsd  = &vmstate_tpm_tis_isa;
@@ -151,6 +181,7 @@ static void tpm_tis_isa_class_init(ObjectClass *klass, void *data)
     tc->request_completed = tpm_tis_isa_request_completed;
     tc->get_version = tpm_tis_isa_get_tpm_version;
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+    adevc->build_dev_aml = build_tpm_tis_isa_aml;
 }
 
 static const TypeInfo tpm_tis_isa_info = {
@@ -161,6 +192,7 @@ static const TypeInfo tpm_tis_isa_info = {
     .class_init  = tpm_tis_isa_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_TPM_IF },
+        { TYPE_ACPI_DEV_AML_IF },
         { }
     }
 };
--

2.31.1

#50 lore raw

PATCH 34/35 tests: acpi: update expected DSDT.tis.tpm2/DSDT.tis.tpm12 blobs

In reply to Igor Mammedov

expected move of tmp-tis device description directly under Device(ISA) node.

for tpm-tis 2.0:

@@ -145,6 +145,189 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)

           {
               Name (_ADR, 0x001F0000)  // _ADR: Address
               OperationRegion (PIRQ, PCI_Config, 0x60, 0x0C)
  +            Device (TPM)
  +            {
  +                Name (_HID, "MSFT0101" /* TPM 2.0 Security Device */)  // _HID: Hardware ID
  +                Name (_STR, "TPM 2.0 Device")  // _STR: Description String
  +                Name (_UID, One)  // _UID: Unique ID
  +                Name (_STA, 0x0F)  // _STA: Status
    ...

+ }

@@ -3281,189 +3464,6 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)

               Method (PCNT, 0, NotSerialized)
               {
               }
  -
  -            Device (TPM)
  -            {
  -                Name (_HID, "MSFT0101" /* TPM 2.0 Security Device */)  // _HID: Hardware ID
  -                Name (_STR, "TPM 2.0 Device")  // _STR: Description String
  -                Name (_UID, One)  // _UID: Unique ID
  -                Name (_STA, 0x0F)  // _STA: Status
    ...

- }

for tpm-tis 1.2:

@@ -145,6 +145,188 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)

           {
               Name (_ADR, 0x001F0000)  // _ADR: Address
               OperationRegion (PIRQ, PCI_Config, 0x60, 0x0C)
  +            Device (TPM)
  +            {
  +                Name (_HID, EisaId ("PNP0C31"))  // _HID: Hardware ID
  +                Name (_UID, One)  // _UID: Unique ID
  +                Name (_STA, 0x0F)  // _STA: Status
    ...

+ }

@@ -3281,188 +3463,6 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)

               Method (PCNT, 0, NotSerialized)
               {
               }
  -
  -            Device (ISA.TPM)
  -            {
  -                Name (_HID, EisaId ("PNP0C31"))  // _HID: Hardware ID
  -                Name (_UID, One)  // _UID: Unique ID
  -                Name (_STA, 0x0F)  // _STA: Status
    ...

- }

---
 tests/qtest/bios-tables-test-allowed-diff.h |   2 --
 tests/data/acpi/q35/DSDT.tis.tpm12          | Bin 8885 -> 8880 bytes
 tests/data/acpi/q35/DSDT.tis.tpm2           | Bin 8906 -> 8906 bytes
 3 files changed, 2 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -2
index 7b3bf9a207..dfb8523c8b 100644
@@ -1,3 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/q35/DSDT.tis.tpm2",
-"tests/data/acpi/q35/DSDT.tis.tpm12",
tests/data/acpi/q35/DSDT.tis.tpm12 binary +0 -0
index 0b5c97fdb5da8b7b55d6b5f2af498a447fda7bf8..a97d884c50485f848054c6ac95ecfa055ff59e5b 100644
GIT binary patch
tests/data/acpi/q35/DSDT.tis.tpm2 binary +0 -0
index 4e16b126cc1c32f2346078fa69c5261c245d15e8..1f5392919b5ea69696b49ff13aab5c37d0615919 100644
GIT binary patch
Signature · 1 line
2.31.1
Acked-by on v1 34/35
#51 lore raw

Re: [PATCH 34/35] tests: acpi: update expected DSDT.tis.tpm2/DSDT.tis.tpm12 blobs

Quoted 58 lines · Igor Mammedov

expected move of tmp-tis device description directly under Device(ISA) node.

for tpm-tis 2.0:

@@ -145,6 +145,189 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)

           {
               Name (_ADR, 0x001F0000)  // _ADR: Address
               OperationRegion (PIRQ, PCI_Config, 0x60, 0x0C)
  +            Device (TPM)
  +            {
  +                Name (_HID, "MSFT0101" /* TPM 2.0 Security Device */)  // _HID: Hardware ID
  +                Name (_STR, "TPM 2.0 Device")  // _STR: Description String
  +                Name (_UID, One)  // _UID: Unique ID
  +                Name (_STA, 0x0F)  // _STA: Status
    ...

+ }

@@ -3281,189 +3464,6 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)

               Method (PCNT, 0, NotSerialized)
               {
               }
  -
  -            Device (TPM)
  -            {
  -                Name (_HID, "MSFT0101" /* TPM 2.0 Security Device */)  // _HID: Hardware ID
  -                Name (_STR, "TPM 2.0 Device")  // _STR: Description String
  -                Name (_UID, One)  // _UID: Unique ID
  -                Name (_STA, 0x0F)  // _STA: Status
    ...

- }

for tpm-tis 1.2:

@@ -145,6 +145,188 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)

           {
               Name (_ADR, 0x001F0000)  // _ADR: Address
               OperationRegion (PIRQ, PCI_Config, 0x60, 0x0C)
  +            Device (TPM)
  +            {
  +                Name (_HID, EisaId ("PNP0C31"))  // _HID: Hardware ID
  +                Name (_UID, One)  // _UID: Unique ID
  +                Name (_STA, 0x0F)  // _STA: Status
    ...

+ }

@@ -3281,188 +3463,6 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001)

               Method (PCNT, 0, NotSerialized)
               {
               }
  -
  -            Device (ISA.TPM)
  -            {
  -                Name (_HID, EisaId ("PNP0C31"))  // _HID: Hardware ID
  -                Name (_UID, One)  // _UID: Unique ID
  -                Name (_STA, 0x0F)  // _STA: Status
    ...
Quoted 3 lines

- }

Quoted 39 lines
---
 tests/qtest/bios-tables-test-allowed-diff.h |   2 --
 tests/data/acpi/q35/DSDT.tis.tpm12          | Bin 8885 -> 8880 bytes
 tests/data/acpi/q35/DSDT.tis.tpm2           | Bin 8906 -> 8906 bytes
 3 files changed, 2 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -2
index 7b3bf9a207..dfb8523c8b 100644
@@ -1,3 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/q35/DSDT.tis.tpm2",
-"tests/data/acpi/q35/DSDT.tis.tpm12",
tests/data/acpi/q35/DSDT.tis.tpm12 binary +0 -0
index 0b5c97fdb5da8b7b55d6b5f2af498a447fda7bf8..a97d884c50485f848054c6ac95ecfa055ff59e5b 100644
GIT binary patch
tests/data/acpi/q35/DSDT.tis.tpm2 binary +0 -1
index 4e16b126cc1c32f2346078fa69c5261c245d15e8..1f5392919b5ea69696b49ff13aab5c37d0615919 100644
GIT binary patch
 
--

2.31.1

#52 lore raw

PATCH 35/35 x86: acpi-build: do not include hw/isa/isa.h directly

In reply to Igor Mammedov

the last remaining dependency on ISA in acpi-build.c is iapc_boot_arch_8042() which pulls in in isa.h in its own header hw/input/i8042.h. Clean up not longer needed direct inclusion of isa.h in acpi-build.c

---
 hw/i386/acpi-build.c | 1 -
 1 file changed, 1 deletion(-)
hw/i386/acpi-build.c +0 -1
index 58284438f8..cf7901c3bf 100644
@@ -36,7 +36,6 @@
 #include "hw/acpi/cpu.h"
 #include "hw/nvram/fw_cfg.h"
 #include "hw/acpi/bios-linker-loader.h"
-#include "hw/isa/isa.h"
 #include "hw/acpi/acpi_aml_interface.h"
 #include "hw/input/i8042.h"
 #include "hw/acpi/memory_hotplug.h"
Signature · 1 line
2.31.1
#53 lore raw
In reply to Igor Mammedov
Quoted 28 lines · Igor Mammedov

Series is excerpt form larger refactoring that does the same for PCI devices, but it's too large at this point, so I've split off a relatively self-contained ISA/SMBUS patches into a smaller separate series, and PCI refactoring will follow up on top of this series using the same AcpiDevAmlIf interface.

Series consolidates and unifies how pc/q35 machine generates AML for ISA and SMBUS devices. It adds a new more generic interface 'AcpiDevAmlIf' that replaces ISA specific ISADeviceClass::build_aml hook and should allow to use the same approach (i.e. ask a device to provide its own AML) but not limited to ISA bus.
Series applies AcpiDevAmlIf interface to a few ISA devices that were already using ISADeviceClass::build_aml and to devices /tpm, applesmc,pvpanic,ipmi/ that were generated in custom way. The AML generation for the later class is normalized to behave like any other ISA device that were using ISADeviceClass::build_aml and converted to interface 'AcpiDevAmlIf'. It simplifies process of building DSDT and eliminates custom probing/wiring for those devices as AML for them is generated at the time ISA/SMBUS is enumerated.

Quoted 4 lines

Changes to DSDT tables QEMU generates are mostly contextual where devices scattered across DSDT are consolidated under respective device that hosts bus they are attached to.

I like this. Have one further enhancement idea before applying this, sent on list.

Quoted 121 lines

PS:
+ series adds several ACPI tests for devices that were missing them.

Igor Mammedov (35):
acpi: add interface to build device specific AML
acpi: make isa_build_aml() support AcpiDevAmlIf interface
acpi: fdc-isa: replace ISADeviceClass::build_aml with
AcpiDevAmlIfClass:build_dev_aml
acpi: parallel port: replace ISADeviceClass::build_aml with
AcpiDevAmlIfClass:build_dev_aml
acpi: serial-is: replace ISADeviceClass::build_aml with
AcpiDevAmlIfClass:build_dev_aml
acpi: mc146818rtc: replace ISADeviceClass::build_aml with
AcpiDevAmlIfClass:build_dev_aml
acpi: pckbd: replace ISADeviceClass::build_aml with
AcpiDevAmlIfClass:build_dev_aml
isa-bus: drop no longer used ISADeviceClass::build_aml
tests: acpi: add and whitelist DSDT.ipmismbus expected blob
tests: acpi: q35: add test for smbus-ipmi device
tests: acpi: update expected blob DSDT.ipmismbus
tests: acpi: whitelist DSDT.ipmismbus expected blob
ipmi: acpi: use relative path to resource source
tests: acpi: update expected DSDT.ipmismbus blob
acpi: ich9-smb: add support for AcpiDevAmlIf interface
acpi: ipmi: use AcpiDevAmlIf interface to build IPMI device
descriptors
q35: acpi: drop not needed PCMachineClass::do_not_add_smb_acpi
tests: acpi: white-list to be re-factored pc/q35 DSDT
acpi: pc: isa bridge: use AcpiDevAmlIf interface to build ISA device
descriptors
acpi: q35: isa bridge: use AcpiDevAmlIf interface to build ISA device
descriptors
tests: acpi: update expected blobs
tests: acpi: add and white-list DSDT.applesmc expected blob
tests: acpi: add applesmc testcase
acpi: applesmc: use AcpiDevAmlIfClass:build_dev_aml to provide
device's AML
tests: acpi: update expected blobs
tests: acpi: white-lists expected DSDT.pvpanic-isa blob
tests: acpi: add pvpanic-isa: testcase
acpi: pvpanic-isa: use AcpiDevAmlIfClass:build_dev_aml to provide
device's AML
tests: acpi: update expected DSDT.pvpanic-isa blob
tests: acpi: white-list DSDT.tis.tpm2/DSDT.tis.tpm12 expected blobs
acpi: pc/q35: tpm-tis: fix TPM device scope
acpi: pc/q35: remove not needed 'if' condition on pci bus
acpi: tpm-tis: use AcpiDevAmlIfClass:build_dev_aml to provide device's
AML
tests: acpi: update expected DSDT.tis.tpm2/DSDT.tis.tpm12 blobs
x86: acpi-build: do not include hw/isa/isa.h directly

 include/hw/acpi/acpi_aml_interface.h  |  40 ++++++
 include/hw/acpi/ipmi.h                |   9 +-
 include/hw/i386/pc.h                  |   1 -
 include/hw/isa/isa.h                  |  15 ---
 include/hw/misc/pvpanic.h             |   9 --
 hw/acpi/acpi_interface.c              |   8 ++
 hw/acpi/ipmi-stub.c                   |   2 +-
 hw/acpi/ipmi.c                        |  53 +++-----
 hw/acpi/meson.build                   |   2 +-
 hw/block/fdc-isa.c                    |  16 ++-
 hw/char/parallel.c                    |  14 ++-
 hw/char/serial-isa.c                  |  14 ++-
 hw/i2c/smbus_ich9.c                   |  15 +++
 hw/i386/acpi-build.c                  | 171 ++++++--------------------
 hw/i386/pc_piix.c                     |   1 -
 hw/i386/pc_q35.c                      |   1 -
 hw/input/pckbd.c                      |  14 ++-
 hw/ipmi/isa_ipmi_bt.c                 |   4 +
 hw/ipmi/isa_ipmi_kcs.c                |   4 +
 hw/ipmi/smbus_ipmi.c                  |   4 +
 hw/isa/isa-bus.c                      |   9 +-
 hw/isa/lpc_ich9.c                     |  19 +++
 hw/isa/piix3.c                        |  17 +++
 hw/misc/applesmc.c                    |  29 +++++
 hw/misc/pvpanic-isa.c                 |  42 +++++++
 hw/rtc/mc146818rtc.c                  |  14 ++-
 hw/tpm/tpm_tis_isa.c                  |  32 +++++
 tests/data/acpi/pc/DSDT               | Bin 6002 -> 5987 bytes
 tests/data/acpi/pc/DSDT.acpierst      | Bin 5969 -> 5954 bytes
 tests/data/acpi/pc/DSDT.acpihmat      | Bin 7327 -> 7312 bytes
 tests/data/acpi/pc/DSDT.bridge        | Bin 8668 -> 8653 bytes
 tests/data/acpi/pc/DSDT.cphp          | Bin 6466 -> 6451 bytes
 tests/data/acpi/pc/DSDT.dimmpxm       | Bin 7656 -> 7641 bytes
 tests/data/acpi/pc/DSDT.hpbridge      | Bin 5969 -> 5954 bytes
 tests/data/acpi/pc/DSDT.hpbrroot      | Bin 3084 -> 3069 bytes
 tests/data/acpi/pc/DSDT.ipmikcs       | Bin 6074 -> 6059 bytes
 tests/data/acpi/pc/DSDT.memhp         | Bin 7361 -> 7346 bytes
 tests/data/acpi/pc/DSDT.nohpet        | Bin 5860 -> 5845 bytes
 tests/data/acpi/pc/DSDT.numamem       | Bin 6008 -> 5993 bytes
 tests/data/acpi/pc/DSDT.roothp        | Bin 6210 -> 6195 bytes
 tests/data/acpi/q35/DSDT              | Bin 8289 -> 8274 bytes
 tests/data/acpi/q35/DSDT.acpierst     | Bin 8306 -> 8291 bytes
 tests/data/acpi/q35/DSDT.acpihmat     | Bin 9614 -> 9599 bytes
 tests/data/acpi/q35/DSDT.applesmc     | Bin 0 -> 8320 bytes
 tests/data/acpi/q35/DSDT.bridge       | Bin 11003 -> 10988 bytes
 tests/data/acpi/q35/DSDT.cphp         | Bin 8753 -> 8738 bytes
 tests/data/acpi/q35/DSDT.dimmpxm      | Bin 9943 -> 9928 bytes
 tests/data/acpi/q35/DSDT.ipmibt       | Bin 8364 -> 8349 bytes
 tests/data/acpi/q35/DSDT.ipmismbus    | Bin 0 -> 8363 bytes
 tests/data/acpi/q35/DSDT.ivrs         | Bin 8306 -> 8291 bytes
 tests/data/acpi/q35/DSDT.memhp        | Bin 9648 -> 9633 bytes
 tests/data/acpi/q35/DSDT.mmio64       | Bin 9419 -> 9404 bytes
 tests/data/acpi/q35/DSDT.multi-bridge | Bin 8583 -> 8568 bytes
 tests/data/acpi/q35/DSDT.nohpet       | Bin 8147 -> 8132 bytes
 tests/data/acpi/q35/DSDT.numamem      | Bin 8295 -> 8280 bytes
 tests/data/acpi/q35/DSDT.pvpanic-isa  | Bin 0 -> 8375 bytes
 tests/data/acpi/q35/DSDT.tis.tpm12    | Bin 8900 -> 8880 bytes
 tests/data/acpi/q35/DSDT.tis.tpm2     | Bin 8921 -> 8906 bytes
 tests/data/acpi/q35/DSDT.viot         | Bin 9398 -> 9383 bytes
 tests/data/acpi/q35/DSDT.xapic        | Bin 35652 -> 35637 bytes
 tests/qtest/bios-tables-test.c        |  40 ++++++
 61 files changed, 360 insertions(+), 239 deletions(-)
 create mode 100644 include/hw/acpi/acpi_aml_interface.h
 create mode 100644 tests/data/acpi/q35/DSDT.applesmc
 create mode 100644 tests/data/acpi/q35/DSDT.ipmismbus
 create mode 100644 tests/data/acpi/q35/DSDT.pvpanic-isa
Signature · 1 line
2.31.1
#54 lore raw
Quoted 29 lines · On Mon, 16 May 2022 16:47:20 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 28 lines · Igor Mammedov

Series is excerpt form larger refactoring that does the same for PCI devices, but it's too large at this point, so I've split off a relatively self-contained ISA/SMBUS patches into a smaller separate series, and PCI refactoring will follow up on top of this series using the same AcpiDevAmlIf interface.

Series consolidates and unifies how pc/q35 machine generates AML for ISA and SMBUS devices. It adds a new more generic interface 'AcpiDevAmlIf' that replaces ISA specific ISADeviceClass::build_aml hook and should allow to use the same approach (i.e. ask a device to provide its own AML) but not limited to ISA bus.
Series applies AcpiDevAmlIf interface to a few ISA devices that were already using ISADeviceClass::build_aml and to devices /tpm, applesmc,pvpanic,ipmi/ that were generated in custom way. The AML generation for the later class is normalized to behave like any other ISA device that were using ISADeviceClass::build_aml and converted to interface 'AcpiDevAmlIf'. It simplifies process of building DSDT and eliminates custom probing/wiring for those devices as AML for them is generated at the time ISA/SMBUS is enumerated.

Quoted 7 lines
Quoted 4 lines

Changes to DSDT tables QEMU generates are mostly contextual where devices scattered across DSDT are consolidated under respective device that hosts bus they are attached to.

I like this. Have one further enhancement idea before applying this, sent on list.

I'd prefer to implement that enhancement on top of this series (and may be on top of follow up PCI conversion) if we have to do it (as the enhancement would be a bit of off-topic churn, i.e. solving another issue that we already have).

Quoted 122 lines
Quoted 121 lines

PS:
+ series adds several ACPI tests for devices that were missing them.

Igor Mammedov (35):
acpi: add interface to build device specific AML
acpi: make isa_build_aml() support AcpiDevAmlIf interface
acpi: fdc-isa: replace ISADeviceClass::build_aml with
AcpiDevAmlIfClass:build_dev_aml
acpi: parallel port: replace ISADeviceClass::build_aml with
AcpiDevAmlIfClass:build_dev_aml
acpi: serial-is: replace ISADeviceClass::build_aml with
AcpiDevAmlIfClass:build_dev_aml
acpi: mc146818rtc: replace ISADeviceClass::build_aml with
AcpiDevAmlIfClass:build_dev_aml
acpi: pckbd: replace ISADeviceClass::build_aml with
AcpiDevAmlIfClass:build_dev_aml
isa-bus: drop no longer used ISADeviceClass::build_aml
tests: acpi: add and whitelist DSDT.ipmismbus expected blob
tests: acpi: q35: add test for smbus-ipmi device
tests: acpi: update expected blob DSDT.ipmismbus
tests: acpi: whitelist DSDT.ipmismbus expected blob
ipmi: acpi: use relative path to resource source
tests: acpi: update expected DSDT.ipmismbus blob
acpi: ich9-smb: add support for AcpiDevAmlIf interface
acpi: ipmi: use AcpiDevAmlIf interface to build IPMI device
descriptors
q35: acpi: drop not needed PCMachineClass::do_not_add_smb_acpi
tests: acpi: white-list to be re-factored pc/q35 DSDT
acpi: pc: isa bridge: use AcpiDevAmlIf interface to build ISA device
descriptors
acpi: q35: isa bridge: use AcpiDevAmlIf interface to build ISA device
descriptors
tests: acpi: update expected blobs
tests: acpi: add and white-list DSDT.applesmc expected blob
tests: acpi: add applesmc testcase
acpi: applesmc: use AcpiDevAmlIfClass:build_dev_aml to provide
device's AML
tests: acpi: update expected blobs
tests: acpi: white-lists expected DSDT.pvpanic-isa blob
tests: acpi: add pvpanic-isa: testcase
acpi: pvpanic-isa: use AcpiDevAmlIfClass:build_dev_aml to provide
device's AML
tests: acpi: update expected DSDT.pvpanic-isa blob
tests: acpi: white-list DSDT.tis.tpm2/DSDT.tis.tpm12 expected blobs
acpi: pc/q35: tpm-tis: fix TPM device scope
acpi: pc/q35: remove not needed 'if' condition on pci bus
acpi: tpm-tis: use AcpiDevAmlIfClass:build_dev_aml to provide device's
AML
tests: acpi: update expected DSDT.tis.tpm2/DSDT.tis.tpm12 blobs
x86: acpi-build: do not include hw/isa/isa.h directly

 include/hw/acpi/acpi_aml_interface.h  |  40 ++++++
 include/hw/acpi/ipmi.h                |   9 +-
 include/hw/i386/pc.h                  |   1 -
 include/hw/isa/isa.h                  |  15 ---
 include/hw/misc/pvpanic.h             |   9 --
 hw/acpi/acpi_interface.c              |   8 ++
 hw/acpi/ipmi-stub.c                   |   2 +-
 hw/acpi/ipmi.c                        |  53 +++-----
 hw/acpi/meson.build                   |   2 +-
 hw/block/fdc-isa.c                    |  16 ++-
 hw/char/parallel.c                    |  14 ++-
 hw/char/serial-isa.c                  |  14 ++-
 hw/i2c/smbus_ich9.c                   |  15 +++
 hw/i386/acpi-build.c                  | 171 ++++++--------------------
 hw/i386/pc_piix.c                     |   1 -
 hw/i386/pc_q35.c                      |   1 -
 hw/input/pckbd.c                      |  14 ++-
 hw/ipmi/isa_ipmi_bt.c                 |   4 +
 hw/ipmi/isa_ipmi_kcs.c                |   4 +
 hw/ipmi/smbus_ipmi.c                  |   4 +
 hw/isa/isa-bus.c                      |   9 +-
 hw/isa/lpc_ich9.c                     |  19 +++
 hw/isa/piix3.c                        |  17 +++
 hw/misc/applesmc.c                    |  29 +++++
 hw/misc/pvpanic-isa.c                 |  42 +++++++
 hw/rtc/mc146818rtc.c                  |  14 ++-
 hw/tpm/tpm_tis_isa.c                  |  32 +++++
 tests/data/acpi/pc/DSDT               | Bin 6002 -> 5987 bytes
 tests/data/acpi/pc/DSDT.acpierst      | Bin 5969 -> 5954 bytes
 tests/data/acpi/pc/DSDT.acpihmat      | Bin 7327 -> 7312 bytes
 tests/data/acpi/pc/DSDT.bridge        | Bin 8668 -> 8653 bytes
 tests/data/acpi/pc/DSDT.cphp          | Bin 6466 -> 6451 bytes
 tests/data/acpi/pc/DSDT.dimmpxm       | Bin 7656 -> 7641 bytes
 tests/data/acpi/pc/DSDT.hpbridge      | Bin 5969 -> 5954 bytes
 tests/data/acpi/pc/DSDT.hpbrroot      | Bin 3084 -> 3069 bytes
 tests/data/acpi/pc/DSDT.ipmikcs       | Bin 6074 -> 6059 bytes
 tests/data/acpi/pc/DSDT.memhp         | Bin 7361 -> 7346 bytes
 tests/data/acpi/pc/DSDT.nohpet        | Bin 5860 -> 5845 bytes
 tests/data/acpi/pc/DSDT.numamem       | Bin 6008 -> 5993 bytes
 tests/data/acpi/pc/DSDT.roothp        | Bin 6210 -> 6195 bytes
 tests/data/acpi/q35/DSDT              | Bin 8289 -> 8274 bytes
 tests/data/acpi/q35/DSDT.acpierst     | Bin 8306 -> 8291 bytes
 tests/data/acpi/q35/DSDT.acpihmat     | Bin 9614 -> 9599 bytes
 tests/data/acpi/q35/DSDT.applesmc     | Bin 0 -> 8320 bytes
 tests/data/acpi/q35/DSDT.bridge       | Bin 11003 -> 10988 bytes
 tests/data/acpi/q35/DSDT.cphp         | Bin 8753 -> 8738 bytes
 tests/data/acpi/q35/DSDT.dimmpxm      | Bin 9943 -> 9928 bytes
 tests/data/acpi/q35/DSDT.ipmibt       | Bin 8364 -> 8349 bytes
 tests/data/acpi/q35/DSDT.ipmismbus    | Bin 0 -> 8363 bytes
 tests/data/acpi/q35/DSDT.ivrs         | Bin 8306 -> 8291 bytes
 tests/data/acpi/q35/DSDT.memhp        | Bin 9648 -> 9633 bytes
 tests/data/acpi/q35/DSDT.mmio64       | Bin 9419 -> 9404 bytes
 tests/data/acpi/q35/DSDT.multi-bridge | Bin 8583 -> 8568 bytes
 tests/data/acpi/q35/DSDT.nohpet       | Bin 8147 -> 8132 bytes
 tests/data/acpi/q35/DSDT.numamem      | Bin 8295 -> 8280 bytes
 tests/data/acpi/q35/DSDT.pvpanic-isa  | Bin 0 -> 8375 bytes
 tests/data/acpi/q35/DSDT.tis.tpm12    | Bin 8900 -> 8880 bytes
 tests/data/acpi/q35/DSDT.tis.tpm2     | Bin 8921 -> 8906 bytes
 tests/data/acpi/q35/DSDT.viot         | Bin 9398 -> 9383 bytes
 tests/data/acpi/q35/DSDT.xapic        | Bin 35652 -> 35637 bytes
 tests/qtest/bios-tables-test.c        |  40 ++++++
 61 files changed, 360 insertions(+), 239 deletions(-)
 create mode 100644 include/hw/acpi/acpi_aml_interface.h
 create mode 100644 tests/data/acpi/q35/DSDT.applesmc
 create mode 100644 tests/data/acpi/q35/DSDT.ipmismbus
 create mode 100644 tests/data/acpi/q35/DSDT.pvpanic-isa
Signature · 1 line
2.31.1  
Acked-by on the v1 series
#55 lore raw
In reply to Igor Mammedov
Quoted 28 lines · Igor Mammedov

Series is excerpt form larger refactoring that does the same for PCI devices, but it's too large at this point, so I've split off a relatively self-contained ISA/SMBUS patches into a smaller separate series, and PCI refactoring will follow up on top of this series using the same AcpiDevAmlIf interface.

Series consolidates and unifies how pc/q35 machine generates AML for ISA and SMBUS devices. It adds a new more generic interface 'AcpiDevAmlIf' that replaces ISA specific ISADeviceClass::build_aml hook and should allow to use the same approach (i.e. ask a device to provide its own AML) but not limited to ISA bus.
Series applies AcpiDevAmlIf interface to a few ISA devices that were already using ISADeviceClass::build_aml and to devices /tpm, applesmc,pvpanic,ipmi/ that were generated in custom way. The AML generation for the later class is normalized to behave like any other ISA device that were using ISADeviceClass::build_aml and converted to interface 'AcpiDevAmlIf'. It simplifies process of building DSDT and eliminates custom probing/wiring for those devices as AML for them is generated at the time ISA/SMBUS is enumerated.

Quoted 4 lines

Changes to DSDT tables QEMU generates are mostly contextual where devices scattered across DSDT are consolidated under respective device that hosts bus they are attached to.

Promoting the ISADeviceClass::build_aml idea to a more general approach certainly makes sense. ISA update is fine. Skimmed the other updates too, looks all sane to me.

take care,
Gerd