Skip to contentSkip to conversation

Support ACPI Control Method Sleep button

PATCH In review Annie Li 3 participants 28 messages May 28, 2025 – Aug 11, 2025 Arm/Amlogic Meson SoC support

lore
Share & tools
lore

Annie Li

author
#0 lore raw

cover Support ACPI Control Method Sleep button

The ACPI sleep button can be implemented as a fixed hardware button or Control Method Sleep button.

The patch of implementing a fixed hardware sleep button was posted here 1). More discussions can be found here 2). Essentially, the discussion mainly focuses on whether the sleep button is implemented as a fixed hardware button or Control Method Sleep button. The latter benefits various architectures since the code can be shared among them.

This patch set implements Control Method Sleep button for both x86 and microvm. The RFC V1 patch set was posted previously here 3). We rebase all the patches on QEMU9.1.0 and re-post RFC V2 here 4). The RFC V3 patch is based on QEMU 10.0.0-rc3 at 5). This patch set here is rebased on QEMU 10.0.1. The sleep button support for microvm is added, however, its support for ARM platform in V2 is removed due to lower interests of it and more efforts in the firmware.

For x86, a sleep button GPE event handler is implemented, so a GPE event is triggered to indicate the OSPM the sleep button is pressed. Tests have been done for Linux guest, and Windows Server guest, this sleep button works as expected.

For microvm, a GED event is triggered to notify the OSPM. This GED event is also applicable for ARM platform, as mentioned earlier, the implementation for ARM platform has been removed since RFC V3 patch set. Tests have been run for Linux microvm guests.

System_wakeup doesn't work for microvm for now due to the missing support of it. This patch set only covers system_sleep, not the wakeup part.

1) https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg06478.html
2) https://lore.kernel.org/all/[email protected]/T/#mfe24f89778020deeacfe45083f3eea3cf9f55961
3) https://lore.kernel.org/all/[email protected]/T/
4) https://patchwork.kernel.org/project/qemu-devel/cover/[email protected]/
5) https://lore.kernel.org/all/[email protected]/

----Changes from RFC V3----
Improve source code and comment based on comments on RFC V3
---------------------------

Annie Li (12):
acpi: Implement control method sleep button
test/acpi: allow DSDT table changes for x86 platform
acpi: Support Control Method sleep button for x86 tests/qtest/bios-table-tests: Update ACPI table binaries for x86
acpi: Send the GPE event of sleep for x86
test/acpi: allow DSDT table changes for microvm
microvm: Add ACPI Control Method Sleep Button
microvm: enable sleep GED event tests/qtest/bios-table-tests: Update ACPI table binaries for microvm
microvm: suspend the system as requested
microvm: enable suspend
acpi: hmp/qmp: Add hmp/qmp support for system_sleep

Miguel Luis (1):
hw/acpi: Add ACPI GED support for the sleep event

 hmp-commands.hx                               |  14 +++++++
 hw/acpi/control_method_device.c               |  38 ++++++++++++++++++
 hw/acpi/core.c                                |  12 ++++++
 hw/acpi/generic_event_device.c                |  12 ++++++
 hw/acpi/meson.build                           |   1 +
 hw/core/machine-hmp-cmds.c                    |   5 +++
 hw/core/machine-qmp-cmds.c                    |  11 +++++
 hw/i386/acpi-build.c                          |  24 ++++++++++-
 hw/i386/acpi-microvm.c                        |  13 +++++-
 hw/i386/microvm.c                             |   4 +-
 include/hw/acpi/acpi.h                        |   1 +
 include/hw/acpi/acpi_dev_interface.h          |   1 +
 include/hw/acpi/control_method_device.h       |  21 ++++++++++
 include/hw/acpi/generic_event_device.h        |   2 +
 include/monitor/hmp.h                         |   1 +
 qapi/machine.json                             |  20 +++++++++
 qapi/pragma.json                              |   1 +
 tests/data/acpi/x86/microvm/DSDT              | Bin 365 -> 442 bytes
 tests/data/acpi/x86/microvm/DSDT.ioapic2      | Bin 365 -> 442 bytes
 tests/data/acpi/x86/microvm/DSDT.pcie         | Bin 3023 -> 3100 bytes
 tests/data/acpi/x86/microvm/DSDT.rtc          | Bin 404 -> 481 bytes
 tests/data/acpi/x86/microvm/DSDT.usb          | Bin 414 -> 491 bytes
 tests/data/acpi/x86/pc/DSDT                   | Bin 8611 -> 8721 bytes
 tests/data/acpi/x86/pc/DSDT.acpierst          | Bin 8522 -> 8632 bytes
 tests/data/acpi/x86/pc/DSDT.acpihmat          | Bin 9936 -> 10046 bytes
 tests/data/acpi/x86/pc/DSDT.bridge            | Bin 15482 -> 15592 bytes
 tests/data/acpi/x86/pc/DSDT.cphp              | Bin 9075 -> 9185 bytes
 tests/data/acpi/x86/pc/DSDT.dimmpxm           | Bin 10265 -> 10375 bytes
 tests/data/acpi/x86/pc/DSDT.hpbridge          | Bin 8562 -> 8672 bytes
 tests/data/acpi/x86/pc/DSDT.hpbrroot          | Bin 5100 -> 5210 bytes
 tests/data/acpi/x86/pc/DSDT.ipmikcs           | Bin 8683 -> 8793 bytes
 tests/data/acpi/x86/pc/DSDT.memhp             | Bin 9970 -> 10080 bytes
 tests/data/acpi/x86/pc/DSDT.nohpet            | Bin 8469 -> 8579 bytes
 tests/data/acpi/x86/pc/DSDT.numamem           | Bin 8617 -> 8727 bytes
 tests/data/acpi/x86/pc/DSDT.roothp            | Bin 12404 -> 12514 bytes
 tests/data/acpi/x86/q35/DSDT                  | Bin 8440 -> 8550 bytes
 tests/data/acpi/x86/q35/DSDT.acpierst         | Bin 8457 -> 8567 bytes
 tests/data/acpi/x86/q35/DSDT.acpihmat         | Bin 9765 -> 9875 bytes
 .../data/acpi/x86/q35/DSDT.acpihmat-generic-x | Bin 12650 -> 12760 bytes
 .../acpi/x86/q35/DSDT.acpihmat-noinitiator    | Bin 8719 -> 8829 bytes
 tests/data/acpi/x86/q35/DSDT.applesmc         | Bin 8486 -> 8596 bytes
 tests/data/acpi/x86/q35/DSDT.bridge           | Bin 12053 -> 12163 bytes
 tests/data/acpi/x86/q35/DSDT.core-count       | Bin 12998 -> 13108 bytes
 tests/data/acpi/x86/q35/DSDT.core-count2      | Bin 33855 -> 33965 bytes
 tests/data/acpi/x86/q35/DSDT.cphp             | Bin 8904 -> 9014 bytes
 tests/data/acpi/x86/q35/DSDT.cxl              | Bin 13231 -> 13341 bytes
 tests/data/acpi/x86/q35/DSDT.dimmpxm          | Bin 10094 -> 10204 bytes
 tests/data/acpi/x86/q35/DSDT.ipmibt           | Bin 8515 -> 8625 bytes
 tests/data/acpi/x86/q35/DSDT.ipmismbus        | Bin 8528 -> 8638 bytes
 tests/data/acpi/x86/q35/DSDT.ivrs             | Bin 8457 -> 8567 bytes
 tests/data/acpi/x86/q35/DSDT.memhp            | Bin 9799 -> 9909 bytes
 tests/data/acpi/x86/q35/DSDT.mmio64           | Bin 9570 -> 9680 bytes
 tests/data/acpi/x86/q35/DSDT.multi-bridge     | Bin 13293 -> 13403 bytes
 tests/data/acpi/x86/q35/DSDT.noacpihp         | Bin 8302 -> 8412 bytes
 tests/data/acpi/x86/q35/DSDT.nohpet           | Bin 8298 -> 8408 bytes
 tests/data/acpi/x86/q35/DSDT.numamem          | Bin 8446 -> 8556 bytes
 tests/data/acpi/x86/q35/DSDT.pvpanic-isa      | Bin 8541 -> 8651 bytes
 tests/data/acpi/x86/q35/DSDT.thread-count     | Bin 12998 -> 13108 bytes
 tests/data/acpi/x86/q35/DSDT.thread-count2    | Bin 33855 -> 33965 bytes
 tests/data/acpi/x86/q35/DSDT.tis.tpm12        | Bin 9046 -> 9156 bytes
 tests/data/acpi/x86/q35/DSDT.tis.tpm2         | Bin 9072 -> 9182 bytes
 tests/data/acpi/x86/q35/DSDT.type4-count      | Bin 18674 -> 18784 bytes
 tests/data/acpi/x86/q35/DSDT.viot             | Bin 14697 -> 14807 bytes
 tests/data/acpi/x86/q35/DSDT.xapic            | Bin 35803 -> 35913 bytes
 64 files changed, 178 insertions(+), 3 deletions(-)
 create mode 100644 hw/acpi/control_method_device.c
 create mode 100644 include/hw/acpi/control_method_device.h
Signature · 1 line
2.43.5
author
#1 lore raw

PATCH 1/13 acpi: Implement control method sleep button

The fixed hardware sleep button isn't appropriate for hardware reduced platform. This patch implements the control method sleep button in a separate source file so that the button can be added for various platforms.

---
 hw/acpi/control_method_device.c         | 38 +++++++++++++++++++++++++
 hw/acpi/meson.build                     |  1 +
 include/hw/acpi/control_method_device.h | 21 ++++++++++++++
 3 files changed, 60 insertions(+)
hw/acpi/control_method_device.c new file +38 -0
new file mode 100644
index 0000000000..f8d691ee04
@@ -0,0 +1,38 @@
+/*
+ * Control Method Device
+ *
+ * Copyright (c) 2023 Oracle and/or its affiliates.
+ *
+ *
+ * Authors:
+ *     Annie Li <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/acpi/control_method_device.h"
+#include "hw/acpi/aml-build.h"
+
+/*
+ * The control method sleep button[ACPI v6.5 Section 4.8.2.2.2.2]
+ * resides in generic hardware address spaces. The sleep button
+ * is defined as _HID("PNP0C0E") that associates with device "SLPB".
+ */
+void acpi_dsdt_add_sleep_button(Aml *scope)
+{
+    Aml *dev = aml_device(ACPI_SLEEP_BUTTON_DEVICE);
+    aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C0E")));
+    /*
+     * No _PRW, the sleep button device is always tied to GPE L07
+     * event handler for x86 platform, or a GED event for other
+     * platforms such as virt, ARM, microvm, etc.
+     */
+    aml_append(dev, aml_operation_region("\\SLP", AML_SYSTEM_IO,
+                                         aml_int(0x201), 0x1));
+    Aml *field = aml_field("\\SLP", AML_BYTE_ACC, AML_NOLOCK,
+                           AML_WRITE_AS_ZEROS);
+    aml_append(field, aml_named_field("SBP", 1));
+    aml_append(dev, field);
+    aml_append(scope, dev);
+}
hw/acpi/meson.build +1 -0
index 73f02b9691..a62e625cef 100644
@@ -17,6 +17,7 @@ acpi_ss.add(when: 'CONFIG_ACPI_CXL', if_true: files('cxl.c'), if_false: files('c
 acpi_ss.add(when: 'CONFIG_ACPI_VMGENID', if_true: files('vmgenid.c'))
 acpi_ss.add(when: 'CONFIG_ACPI_VMCLOCK', if_true: files('vmclock.c'))
 acpi_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: files('generic_event_device.c'))
+acpi_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: files('control_method_device.c'))
 acpi_ss.add(when: 'CONFIG_ACPI_HMAT', if_true: files('hmat.c'))
 acpi_ss.add(when: 'CONFIG_ACPI_APEI', if_true: files('ghes.c'), if_false: files('ghes-stub.c'))
 acpi_ss.add(when: 'CONFIG_ACPI_PIIX4', if_true: files('piix4.c'))
include/hw/acpi/control_method_device.h new file +21 -0
new file mode 100644
index 0000000000..079f1a74dd
@@ -0,0 +1,21 @@
+/*
+ * Control Method Device
+ *
+ * Copyright (c) 2023 Oracle and/or its affiliates.
+ *
+ *
+ * Authors:
+ *     Annie Li <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+
+#ifndef HW_ACPI_CONTROL_METHOD_DEVICE_H
+#define HW_ACPI_CONTROL_NETHOD_DEVICE_H
+
+#define ACPI_SLEEP_BUTTON_DEVICE "SLPB"
+
+void acpi_dsdt_add_sleep_button(Aml *scope);
+
+#endif
Signature · 1 line
2.43.5
#2 lore raw

Re: [PATCH 01/13] acpi: Implement control method sleep button

hw/acpi/control_method_device.c

Quoted 14 lines · On Wed, 28 May 2025 12:38:34 -0400 Annie Li <[email protected]> wrote:

The fixed hardware sleep button isn't appropriate for hardware reduced platform. This patch implements the control method sleep button in a separate source file so that the button can be added for various platforms.

---
 hw/acpi/control_method_device.c         | 38 +++++++++++++++++++++++++
 hw/acpi/meson.build                     |  1 +
 include/hw/acpi/control_method_device.h | 21 ++++++++++++++
 3 files changed, 60 insertions(+)
hw/acpi/control_method_device.c +0 -0

sleep_button would be more to the point

Quoted 27 lines

new file mode 100644
index 0000000000..f8d691ee04

hw/acpi/control_method_device.c new file +22 -0
@@ -0,0 +1,38 @@
+/*
+ * Control Method Device
+ *
+ * Copyright (c) 2023 Oracle and/or its affiliates.
+ *
+ *
+ * Authors:
+ *     Annie Li <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/acpi/control_method_device.h"
+#include "hw/acpi/aml-build.h"
+
+/*
+ * The control method sleep button[ACPI v6.5 Section 4.8.2.2.2.2]
+ * resides in generic hardware address spaces. The sleep button
+ * is defined as _HID("PNP0C0E") that associates with device "SLPB".
+ */
+void acpi_dsdt_add_sleep_button(Aml *scope)

hw/acpi/control_method_device.c line 32

Quoted 10 lines
hw/acpi/control_method_device.c new file +10 -0
+{
+    Aml *dev = aml_device(ACPI_SLEEP_BUTTON_DEVICE);
+    aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C0E")));
+    /*
+     * No _PRW, the sleep button device is always tied to GPE L07
+     * event handler for x86 platform, or a GED event for other
+     * platforms such as virt, ARM, microvm, etc.
+     */
+    aml_append(dev, aml_operation_region("\\SLP", AML_SYSTEM_IO,
+                                         aml_int(0x201), 0x1));

^^^^^^
where does this come from?

Quoted 11 lines
hw/acpi/control_method_device.c new file +6 -0
+    Aml *field = aml_field("\\SLP", AML_BYTE_ACC, AML_NOLOCK,
+                           AML_WRITE_AS_ZEROS);
+    aml_append(field, aml_named_field("SBP", 1));
+    aml_append(dev, field);
+    aml_append(scope, dev);
+}
hw/acpi/meson.build +0 -0
index 73f02b9691..a62e625cef 100644

hw/acpi/meson.build acpi_ss.add(when: 'CONFIG_ACPI_CXL', if_true: files('cxl.c'), if_false: files('c · line 20

Quoted 4 lines
hw/acpi/meson.build +1 -0
@@ -17,6 +17,7 @@ acpi_ss.add(when: 'CONFIG_ACPI_CXL', if_true: files('cxl.c'), if_false: files('c
 acpi_ss.add(when: 'CONFIG_ACPI_VMGENID', if_true: files('vmgenid.c'))
 acpi_ss.add(when: 'CONFIG_ACPI_VMCLOCK', if_true: files('vmclock.c'))
 acpi_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: files('generic_event_device.c'))
+acpi_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: files('control_method_device.c'))

that would build only for microvm + arm, and pc/q35 wouldn't get it if microvm were disabled.

Quoted 30 lines
hw/acpi/meson.build +0 -0
 acpi_ss.add(when: 'CONFIG_ACPI_HMAT', if_true: files('hmat.c'))
 acpi_ss.add(when: 'CONFIG_ACPI_APEI', if_true: files('ghes.c'), if_false: files('ghes-stub.c'))
 acpi_ss.add(when: 'CONFIG_ACPI_PIIX4', if_true: files('piix4.c'))
include/hw/acpi/control_method_device.h new file +21 -0
new file mode 100644
index 0000000000..079f1a74dd
@@ -0,0 +1,21 @@
+/*
+ * Control Method Device
+ *
+ * Copyright (c) 2023 Oracle and/or its affiliates.
+ *
+ *
+ * Authors:
+ *     Annie Li <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+
+#ifndef HW_ACPI_CONTROL_METHOD_DEVICE_H
+#define HW_ACPI_CONTROL_NETHOD_DEVICE_H
+
+#define ACPI_SLEEP_BUTTON_DEVICE "SLPB"
+
+void acpi_dsdt_add_sleep_button(Aml *scope);
+
+#endif
author
#3 lore raw

Re: [PATCH 01/13] acpi: Implement control method sleep button

Hello Igor,

Quoted 16 lines · Igor Mammedov
Quoted 13 lines · On Wed, 28 May 2025 12:38:34 -0400 Annie Li<[email protected]> wrote:

The fixed hardware sleep button isn't appropriate for hardware reduced platform. This patch implements the control method sleep button in a separate source file so that the button can be added for various platforms.

---
  hw/acpi/control_method_device.c         | 38 +++++++++++++++++++++++++
  hw/acpi/meson.build                     |  1 +
  include/hw/acpi/control_method_device.h | 21 ++++++++++++++
  3 files changed, 60 insertions(+)
Quoted 2 lines

hw/acpi/control_method_device.c

Quoted 1 line
hw/acpi/control_method_device.c +0 -0

sleep_button would be more to the point

Was thinking of more control method devices may be added in future, so choose this general name(control_method_device) just in case. I'll rename it to control_method_sleep_button then.

Quoted 32 lines
Quoted 32 lines

new file mode 100644
index 0000000000..f8d691ee04

hw/acpi/control_method_device.c new file +26 -0
@@ -0,0 +1,38 @@
+/*
+ * Control Method Device
+ *
+ * Copyright (c) 2023 Oracle and/or its affiliates.
+ *
+ *
+ * Authors:
+ *     Annie Li<[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/acpi/control_method_device.h"
+#include "hw/acpi/aml-build.h"
+
+/*
+ * The control method sleep button[ACPI v6.5 Section 4.8.2.2.2.2]
+ * resides in generic hardware address spaces. The sleep button
+ * is defined as _HID("PNP0C0E") that associates with device "SLPB".
+ */
+void acpi_dsdt_add_sleep_button(Aml *scope)
+{
+    Aml *dev = aml_device(ACPI_SLEEP_BUTTON_DEVICE);
+    aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C0E")));
+    /*
Quoted 8 lines

hw/acpi/control_method_device.c line 32

Quoted 6 lines
hw/acpi/control_method_device.c new file +6 -0
+     * No _PRW, the sleep button device is always tied to GPE L07
+     * event handler for x86 platform, or a GED event for other
+     * platforms such as virt, ARM, microvm, etc.
+     */
+    aml_append(dev, aml_operation_region("\\SLP", AML_SYSTEM_IO,
+                                         aml_int(0x201), 0x1));

^^^^^^
where does this come from?

Got it from an example in ACPI spec[ACPI v6.5 Section 4.8.2.2.2.2]. "• Creates an operational region for the control method sleep button’s programming model: System I/O space at 0x201." Any suggestions are welcome.

Quoted 11 lines
Quoted 11 lines
hw/acpi/control_method_device.c new file +6 -0
+    Aml *field = aml_field("\\SLP", AML_BYTE_ACC, AML_NOLOCK,
+                           AML_WRITE_AS_ZEROS);
+    aml_append(field, aml_named_field("SBP", 1));
+    aml_append(dev, field);
+    aml_append(scope, dev);
+}
hw/acpi/meson.build +0 -1
index 73f02b9691..a62e625cef 100644
--- a/hw/acpi/meson.build
Quoted 8 lines

hw/acpi/meson.build acpi_ss.add(when: 'CONFIG_ACPI_CXL', if_true: files('cxl.c'), if_false: files('c · line 20

Quoted 6 lines

+++ b/hw/acpi/meson.build

hw/acpi/meson.build +1 -0
@@ -17,6 +17,7 @@ acpi_ss.add(when: 'CONFIG_ACPI_CXL', if_true: files('cxl.c'), if_false: files('c
  acpi_ss.add(when: 'CONFIG_ACPI_VMGENID', if_true: files('vmgenid.c'))
  acpi_ss.add(when: 'CONFIG_ACPI_VMCLOCK', if_true: files('vmclock.c'))
  acpi_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: files('generic_event_device.c'))
+acpi_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: files('control_method_device.c'))

that would build only for microvm + arm, and pc/q35 wouldn't get it if microvm were disabled.

True.
How about the following?
acpi_ss.add(files(
  'acpi_interface.c',
  'aml-build.c',
  'bios-linker-loader.c',
  'core.c',
  'utils.c',
+'control_method_device.c',
))

Thanks

Annie

Quoted 31 lines
Quoted 31 lines
hw/acpi/meson.build +0 -0
  acpi_ss.add(when: 'CONFIG_ACPI_HMAT', if_true: files('hmat.c'))
  acpi_ss.add(when: 'CONFIG_ACPI_APEI', if_true: files('ghes.c'), if_false: files('ghes-stub.c'))
  acpi_ss.add(when: 'CONFIG_ACPI_PIIX4', if_true: files('piix4.c'))
include/hw/acpi/control_method_device.h new file +21 -0
new file mode 100644
index 0000000000..079f1a74dd
@@ -0,0 +1,21 @@
+/*
+ * Control Method Device
+ *
+ * Copyright (c) 2023 Oracle and/or its affiliates.
+ *
+ *
+ * Authors:
+ *     Annie Li<[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+
+#ifndef HW_ACPI_CONTROL_METHOD_DEVICE_H
+#define HW_ACPI_CONTROL_NETHOD_DEVICE_H
+
+#define ACPI_SLEEP_BUTTON_DEVICE "SLPB"
+
+void acpi_dsdt_add_sleep_button(Aml *scope);
+
+#endif
#4 lore raw

Re: [PATCH 01/13] acpi: Implement control method sleep button

Quoted 64 lines · On Tue, 3 Jun 2025 15:08:49 -0400 Annie Li <[email protected]> wrote:

Hello Igor,

Quoted 16 lines · Igor Mammedov
Quoted 13 lines · On Wed, 28 May 2025 12:38:34 -0400 Annie Li<[email protected]> wrote:

The fixed hardware sleep button isn't appropriate for hardware reduced platform. This patch implements the control method sleep button in a separate source file so that the button can be added for various platforms.

---
  hw/acpi/control_method_device.c         | 38 +++++++++++++++++++++++++
  hw/acpi/meson.build                     |  1 +
  include/hw/acpi/control_method_device.h | 21 ++++++++++++++
  3 files changed, 60 insertions(+)
Quoted 2 lines

hw/acpi/control_method_device.c

Quoted 1 line
hw/acpi/control_method_device.c +0 -0

sleep_button would be more to the point

Was thinking of more control method devices may be added in future, so choose this general name(control_method_device) just in case. I'll rename it to control_method_sleep_button then.

Quoted 32 lines
Quoted 32 lines

new file mode 100644
index 0000000000..f8d691ee04

hw/acpi/control_method_device.c new file +26 -0
@@ -0,0 +1,38 @@
+/*
+ * Control Method Device
+ *
+ * Copyright (c) 2023 Oracle and/or its affiliates.
+ *
+ *
+ * Authors:
+ *     Annie Li<[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/acpi/control_method_device.h"
+#include "hw/acpi/aml-build.h"
+
+/*
+ * The control method sleep button[ACPI v6.5 Section 4.8.2.2.2.2]
+ * resides in generic hardware address spaces. The sleep button
+ * is defined as _HID("PNP0C0E") that associates with device "SLPB".
+ */
+void acpi_dsdt_add_sleep_button(Aml *scope)
+{
+    Aml *dev = aml_device(ACPI_SLEEP_BUTTON_DEVICE);
+    aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C0E")));
+    /*
Quoted 8 lines

hw/acpi/control_method_device.c line 32

Quoted 6 lines
hw/acpi/control_method_device.c new file +6 -0
+     * No _PRW, the sleep button device is always tied to GPE L07
+     * event handler for x86 platform, or a GED event for other
+     * platforms such as virt, ARM, microvm, etc.
+     */
+    aml_append(dev, aml_operation_region("\\SLP", AML_SYSTEM_IO,
+                                         aml_int(0x201), 0x1));  

^^^^^^
where does this come from?

Quoted 3 lines

Got it from an example in ACPI spec[ACPI v6.5 Section 4.8.2.2.2.2]. "• Creates an operational region for the control method sleep button’s programming model: System I/O space at 0x201." Any suggestions are welcome.

rather than giving answer, I'd ask
* what it's supposed to do
* does QEMU has this register or its alternative

answers to above likely will help with answering my original question or ideas how to fix patch

Quoted 19 lines
Quoted 11 lines
Quoted 11 lines
hw/acpi/control_method_device.c new file +6 -0
+    Aml *field = aml_field("\\SLP", AML_BYTE_ACC, AML_NOLOCK,
+                           AML_WRITE_AS_ZEROS);
+    aml_append(field, aml_named_field("SBP", 1));
+    aml_append(dev, field);
+    aml_append(scope, dev);
+}
hw/acpi/meson.build +0 -1
index 73f02b9691..a62e625cef 100644
--- a/hw/acpi/meson.build
Quoted 8 lines

hw/acpi/meson.build acpi_ss.add(when: 'CONFIG_ACPI_CXL', if_true: files('cxl.c'), if_false: files('c · line 20

Quoted 6 lines

+++ b/hw/acpi/meson.build

hw/acpi/meson.build +1 -0
@@ -17,6 +17,7 @@ acpi_ss.add(when: 'CONFIG_ACPI_CXL', if_true: files('cxl.c'), if_false: files('c
  acpi_ss.add(when: 'CONFIG_ACPI_VMGENID', if_true: files('vmgenid.c'))
  acpi_ss.add(when: 'CONFIG_ACPI_VMCLOCK', if_true: files('vmclock.c'))
  acpi_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: files('generic_event_device.c'))
+acpi_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: files('control_method_device.c'))  

that would build only for microvm + arm, and pc/q35 wouldn't get it if microvm were disabled.

Quoted 10 lines

True.
How about the following?
acpi_ss.add(files(
  'acpi_interface.c',
  'aml-build.c',
  'bios-linker-loader.c',
  'core.c',
  'utils.c',
+'control_method_device.c',
))

perhaps this is better

Quoted 37 lines

Thanks

Annie

Quoted 31 lines
Quoted 31 lines
hw/acpi/meson.build +0 -0
  acpi_ss.add(when: 'CONFIG_ACPI_HMAT', if_true: files('hmat.c'))
  acpi_ss.add(when: 'CONFIG_ACPI_APEI', if_true: files('ghes.c'), if_false: files('ghes-stub.c'))
  acpi_ss.add(when: 'CONFIG_ACPI_PIIX4', if_true: files('piix4.c'))
include/hw/acpi/control_method_device.h new file +21 -0
new file mode 100644
index 0000000000..079f1a74dd
@@ -0,0 +1,21 @@
+/*
+ * Control Method Device
+ *
+ * Copyright (c) 2023 Oracle and/or its affiliates.
+ *
+ *
+ * Authors:
+ *     Annie Li<[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+
+#ifndef HW_ACPI_CONTROL_METHOD_DEVICE_H
+#define HW_ACPI_CONTROL_NETHOD_DEVICE_H
+
+#define ACPI_SLEEP_BUTTON_DEVICE "SLPB"
+
+void acpi_dsdt_add_sleep_button(Aml *scope);
+
+#endif  
author
#5 lore raw

PATCH 2/13 test/acpi: allow DSDT table changes for x86 platform

In reply to Annie Li

List changed files in tests/qtest/bios-tables-test-allowed-diff.h

---
 tests/qtest/bios-tables-test-allowed-diff.h | 42 +++++++++++++++++++++
 1 file changed, 42 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +42 -0
index dfb8523c8b..a1047913af 100644
@@ -1 +1,43 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/x86/pc/DSDT",
+"tests/data/acpi/x86/pc/DSDT.acpierst",
+"tests/data/acpi/x86/pc/DSDT.acpihmat",
+"tests/data/acpi/x86/pc/DSDT.bridge",
+"tests/data/acpi/x86/pc/DSDT.cphp",
+"tests/data/acpi/x86/pc/DSDT.dimmpxm",
+"tests/data/acpi/x86/pc/DSDT.hpbridge",
+"tests/data/acpi/x86/pc/DSDT.hpbrroot",
+"tests/data/acpi/x86/pc/DSDT.ipmikcs",
+"tests/data/acpi/x86/pc/DSDT.memhp",
+"tests/data/acpi/x86/pc/DSDT.nohpet",
+"tests/data/acpi/x86/pc/DSDT.numamem",
+"tests/data/acpi/x86/pc/DSDT.roothp",
+"tests/data/acpi/x86/q35/DSDT",
+"tests/data/acpi/x86/q35/DSDT.acpierst",
+"tests/data/acpi/x86/q35/DSDT.acpihmat",
+"tests/data/acpi/x86/q35/DSDT.acpihmat-generic-x",
+"tests/data/acpi/x86/q35/DSDT.acpihmat-noinitiator",
+"tests/data/acpi/x86/q35/DSDT.applesmc",
+"tests/data/acpi/x86/q35/DSDT.bridge",
+"tests/data/acpi/x86/q35/DSDT.core-count",
+"tests/data/acpi/x86/q35/DSDT.core-count2",
+"tests/data/acpi/x86/q35/DSDT.cphp",
+"tests/data/acpi/x86/q35/DSDT.cxl",
+"tests/data/acpi/x86/q35/DSDT.dimmpxm",
+"tests/data/acpi/x86/q35/DSDT.ipmibt",
+"tests/data/acpi/x86/q35/DSDT.ipmismbus",
+"tests/data/acpi/x86/q35/DSDT.ivrs",
+"tests/data/acpi/x86/q35/DSDT.memhp",
+"tests/data/acpi/x86/q35/DSDT.mmio64",
+"tests/data/acpi/x86/q35/DSDT.multi-bridge",
+"tests/data/acpi/x86/q35/DSDT.noacpihp",
+"tests/data/acpi/x86/q35/DSDT.nohpet",
+"tests/data/acpi/x86/q35/DSDT.numamem",
+"tests/data/acpi/x86/q35/DSDT.pvpanic-isa",
+"tests/data/acpi/x86/q35/DSDT.thread-count",
+"tests/data/acpi/x86/q35/DSDT.thread-count2",
+"tests/data/acpi/x86/q35/DSDT.tis.tpm12",
+"tests/data/acpi/x86/q35/DSDT.tis.tpm2",
+"tests/data/acpi/x86/q35/DSDT.type4-count",
+"tests/data/acpi/x86/q35/DSDT.viot",
+"tests/data/acpi/x86/q35/DSDT.xapic",
Signature · 1 line
2.43.5
author
#6 lore raw

PATCH 3/13 acpi: Support Control Method sleep button for x86

In reply to Annie Li

Add Control Method Sleep button and its GPE event handler for x86 platform. The GPE event handler notifies OSPM when the Sleep button event is triggered.

---
 hw/i386/acpi-build.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
hw/i386/acpi-build.c +23 -1
index 3fffa4a332..2ddf669006 100644
@@ -40,6 +40,7 @@
 #include "hw/acpi/acpi_aml_interface.h"
 #include "hw/input/i8042.h"
 #include "hw/acpi/memory_hotplug.h"
+#include "hw/acpi/control_method_device.h"
 #include "system/tpm.h"
 #include "hw/acpi/tpm.h"
 #include "hw/acpi/vmgenid.h"
@@ -1359,7 +1360,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
                                                      NULL);
     Object *q35 = object_resolve_type_unambiguous(TYPE_Q35_HOST_DEVICE, NULL);
     CrsRangeEntry *entry;
-    Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs;
+    Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs, *condition;
     CrsRangeSet crs_range_set;
     PCMachineState *pcms = PC_MACHINE(machine);
     PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(machine);
@@ -1465,6 +1466,27 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
     }
     aml_append(dsdt, scope);
 
+    sb_scope = aml_scope("_SB");
+    acpi_dsdt_add_sleep_button(sb_scope);
+    aml_append(dsdt, sb_scope);
+
+    /*
+     * The event handler for the control method sleep button is generated
+     * for notifying OSPM (ACPI v6.5, Section 4.8.2.2.2.2).
+     */
+    scope =  aml_scope("\\_GPE");
+    method = aml_method("_L07", 0, AML_NOTSERIALIZED);
+    condition = aml_if(aml_name("\\_SB."ACPI_SLEEP_BUTTON_DEVICE".SBP"));
+    aml_append(condition,
+               aml_store(aml_int(1),
+                         aml_name("\\_SB."ACPI_SLEEP_BUTTON_DEVICE".SBP")));
+    aml_append(condition,
+               aml_notify(aml_name("\\_SB."ACPI_SLEEP_BUTTON_DEVICE),
+                                    aml_int(0x80)));
+    aml_append(method, condition);
+    aml_append(scope, method);
+    aml_append(dsdt, scope);
+
     if (pcmc->legacy_cpu_hotplug) {
         build_legacy_cpu_hotplug_aml(dsdt, machine, pm->cpu_hp_io_base);
     } else {
Signature · 1 line
2.43.5
#7 lore raw

Re: [PATCH 03/13] acpi: Support Control Method sleep button for x86

Quoted 35 lines · On Wed, 28 May 2025 12:39:17 -0400 Annie Li <[email protected]> wrote:

Add Control Method Sleep button and its GPE event handler for x86 platform. The GPE event handler notifies OSPM when the Sleep button event is triggered.

---
 hw/i386/acpi-build.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
hw/i386/acpi-build.c +3 -1
index 3fffa4a332..2ddf669006 100644
@@ -40,6 +40,7 @@
 #include "hw/acpi/acpi_aml_interface.h"
 #include "hw/input/i8042.h"
 #include "hw/acpi/memory_hotplug.h"
+#include "hw/acpi/control_method_device.h"
 #include "system/tpm.h"
 #include "hw/acpi/tpm.h"
 #include "hw/acpi/vmgenid.h"
@@ -1359,7 +1360,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
                                                      NULL);
     Object *q35 = object_resolve_type_unambiguous(TYPE_Q35_HOST_DEVICE, NULL);
     CrsRangeEntry *entry;
-    Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs;
+    Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs, *condition;
     CrsRangeSet crs_range_set;
     PCMachineState *pcms = PC_MACHINE(machine);
     PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(machine);
@@ -1465,6 +1466,27 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
     }
     aml_append(dsdt, scope);
 
+    sb_scope = aml_scope("_SB");

hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1479

Quoted 10 lines
hw/i386/acpi-build.c +10 -0
+    acpi_dsdt_add_sleep_button(sb_scope);
+    aml_append(dsdt, sb_scope);
+
+    /*
+     * The event handler for the control method sleep button is generated
+     * for notifying OSPM (ACPI v6.5, Section 4.8.2.2.2.2).
+     */
+    scope =  aml_scope("\\_GPE");
+    method = aml_method("_L07", 0, AML_NOTSERIALIZED);
+    condition = aml_if(aml_name("\\_SB."ACPI_SLEEP_BUTTON_DEVICE".SBP"));

s/condition/if_ctx/
also use full form 'if something == something' for condtion

hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1482

Quoted 3 lines
hw/i386/acpi-build.c +3 -0
+    aml_append(condition,
+               aml_store(aml_int(1),
+                         aml_name("\\_SB."ACPI_SLEEP_BUTTON_DEVICE".SBP")));

so what is handling this write on qemu side?
and why it's here to begin with? (commit says that it sends event to OSMP but nothing about this write)

Quoted 10 lines
hw/i386/acpi-build.c +7 -0
+    aml_append(condition,
+               aml_notify(aml_name("\\_SB."ACPI_SLEEP_BUTTON_DEVICE),
+                                    aml_int(0x80)));
+    aml_append(method, condition);
+    aml_append(scope, method);
+    aml_append(dsdt, scope);
+
     if (pcmc->legacy_cpu_hotplug) {
         build_legacy_cpu_hotplug_aml(dsdt, machine, pm->cpu_hp_io_base);
     } else {
author
#8 lore raw

Re: [PATCH 03/13] acpi: Support Control Method sleep button for x86

Hi Igor,

Quoted 37 lines · Igor Mammedov
Quoted 34 lines · On Wed, 28 May 2025 12:39:17 -0400 Annie Li <[email protected]> wrote:

Add Control Method Sleep button and its GPE event handler for x86 platform. The GPE event handler notifies OSPM when the Sleep button event is triggered.

---
  hw/i386/acpi-build.c | 24 +++++++++++++++++++++++-
  1 file changed, 23 insertions(+), 1 deletion(-)
hw/i386/acpi-build.c +2 -1
index 3fffa4a332..2ddf669006 100644
@@ -40,6 +40,7 @@
  #include "hw/acpi/acpi_aml_interface.h"
  #include "hw/input/i8042.h"
  #include "hw/acpi/memory_hotplug.h"
+#include "hw/acpi/control_method_device.h"
  #include "system/tpm.h"
  #include "hw/acpi/tpm.h"
  #include "hw/acpi/vmgenid.h"
@@ -1359,7 +1360,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
                                                       NULL);
      Object *q35 = object_resolve_type_unambiguous(TYPE_Q35_HOST_DEVICE, NULL);
      CrsRangeEntry *entry;
-    Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs;
+    Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs, *condition;
      CrsRangeSet crs_range_set;
      PCMachineState *pcms = PC_MACHINE(machine);
      PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(machine);
@@ -1465,6 +1466,27 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
      }
      aml_append(dsdt, scope);
 
Quoted 13 lines

hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1479

Quoted 11 lines
hw/i386/acpi-build.c +11 -0
+    sb_scope = aml_scope("_SB");
+    acpi_dsdt_add_sleep_button(sb_scope);
+    aml_append(dsdt, sb_scope);
+
+    /*
+     * The event handler for the control method sleep button is generated
+     * for notifying OSPM (ACPI v6.5, Section 4.8.2.2.2.2).
+     */
+    scope =  aml_scope("\\_GPE");
+    method = aml_method("_L07", 0, AML_NOTSERIALIZED);
+    condition = aml_if(aml_name("\\_SB."ACPI_SLEEP_BUTTON_DEVICE".SBP"));

s/condition/if_ctx/
also use full form 'if something == something' for condtion

Implemented based on the spec, will look into it.

Quoted 5 lines

hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1482

Quoted 4 lines
hw/i386/acpi-build.c +3 -0
+    aml_append(condition,
+               aml_store(aml_int(1),
+                         aml_name("\\_SB."ACPI_SLEEP_BUTTON_DEVICE".SBP")));

so what is handling this write on qemu side?

Qemu only triggers the GPE event for x86 or GED event for reduced hardware platforms to notify OSPM to go to sleep. However, no writing operation has been done corresponding to the above clearing.
Per the spec,
"When this bit is set it is the responsibility of the AML code to clear it ". Since GPE/GED events are being sent to notify the OSPM, I am wondering if handling this write is needed on qemu side? or just removing this clearing operation above?

Quoted 1 line

and why it's here to begin with? (commit says that it sends event to OSMP but nothing about this write)

Added this to clear sleep button status per the spec.

Thanks
Annie

Quoted 11 lines
Quoted 11 lines
hw/i386/acpi-build.c +7 -0
+    aml_append(condition,
+               aml_notify(aml_name("\\_SB."ACPI_SLEEP_BUTTON_DEVICE),
+                                    aml_int(0x80)));
+    aml_append(method, condition);
+    aml_append(scope, method);
+    aml_append(dsdt, scope);
+
      if (pcmc->legacy_cpu_hotplug) {
          build_legacy_cpu_hotplug_aml(dsdt, machine, pm->cpu_hp_io_base);
      } else {
author
#9 lore raw

PATCH 4/13 tests/qtest/bios-table-tests: Update ACPI table binaries for x86

In reply to Annie Li

Following is the diff generated by the step 5 and 6 in tests/qtest/bios-tables-test.c

Diff from iasl to show changes in DSDT table:

@@ -1,30 +1,30 @@
/*
* Intel ACPI Component Architecture
* AML/ASL+ Disassembler version 20210604 (64-bit version)
* Copyright (c) 2000 - 2021 Intel Corporation
*
* Disassembling to symbolic ASL+ operators
*
* Disassembly of tests/data/acpi/x86/q35/DSDT, Tue May 27 15:40:59 2025 *
* Original Table Header:

  *     Signature        "DSDT"
- *     Length           0x000020F8 (8440)
+ *     Length           0x00002166 (8550)
  *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
- *     Checksum         0xBE
+ *     Checksum         0x1E
  *     OEM ID           "BOCHS "
  *     OEM Table ID     "BXPC    "
  *     OEM Revision     0x00000001 (1)
  *     Compiler ID      "BXPC"
  *     Compiler Version 0x00000001 (1)
  */
 DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC    ", 0x00000001)
 {
     Scope (\)
     {
         OperationRegion (DBG, SystemIO, 0x0402, One)
         Field (DBG, ByteAcc, NoLock, Preserve)
         {
             DBGB,   8
         }

@@ -2852,32 +2852,57 @@

             {
                 Memory32Fixed (ReadOnly,
                     0xFED00000,         // Address Base
                     0x00000400,         // Address Length
                     )
             })
         }
     }

     Scope (_GPE)
     {
         Name (_HID, "ACPI0006" /* GPE Block Device */)  // _HID: Hardware ID
     }

     Scope (_SB)
     {
+        Device (SLPB)
+        {
+            Name (_HID, EisaId ("PNP0C0E") /* Sleep Button Device */)  // _HID: Hardware ID
+            OperationRegion (\SLP, SystemIO, 0x0201, One)
+            Field (\SLP, ByteAcc, NoLock, WriteAsZeros)
+            {

+ SBP, 1
+ }
+ }
+ }
+
+ Scope (\_GPE)
+ {
+ Method (_L07, 0, NotSerialized) // _Lxx: Level-Triggered GPE, xx=0x00-0xFF
+ {
+ If (\_SB.SLPB.SBP)
+ {
+ \_SB.SLPB.SBP = One
+ Notify (\_SB.SLPB, 0x80) // Status Change
+ }
+ }
+ }
+
+ Scope (_SB)

+    {
         Device (\_SB.PCI0.PRES)
         {
             Name (_HID, EisaId ("PNP0A06") /* Generic Container Device */)  // _HID: Hardware ID
             Name (_UID, "CPU Hotplug resources")  // _UID: Unique ID
             Mutex (CPLK, 0x00)
             Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
             {
                 IO (Decode16,
                     0x0CD8,             // Range Minimum
                     0x0CD8,             // Range Maximum
                     0x01,               // Alignment
                     0x0C,               // Length
                     )
             })
             OperationRegion (PRST, SystemIO, 0x0CD8, 0x0C)
             Field (PRST, ByteAcc, NoLock, WriteAsZeros)
---
 tests/data/acpi/x86/pc/DSDT                   | Bin 8611 -> 8721 bytes
 tests/data/acpi/x86/pc/DSDT.acpierst          | Bin 8522 -> 8632 bytes
 tests/data/acpi/x86/pc/DSDT.acpihmat          | Bin 9936 -> 10046 bytes
 tests/data/acpi/x86/pc/DSDT.bridge            | Bin 15482 -> 15592 bytes
 tests/data/acpi/x86/pc/DSDT.cphp              | Bin 9075 -> 9185 bytes
 tests/data/acpi/x86/pc/DSDT.dimmpxm           | Bin 10265 -> 10375 bytes
 tests/data/acpi/x86/pc/DSDT.hpbridge          | Bin 8562 -> 8672 bytes
 tests/data/acpi/x86/pc/DSDT.hpbrroot          | Bin 5100 -> 5210 bytes
 tests/data/acpi/x86/pc/DSDT.ipmikcs           | Bin 8683 -> 8793 bytes
 tests/data/acpi/x86/pc/DSDT.memhp             | Bin 9970 -> 10080 bytes
 tests/data/acpi/x86/pc/DSDT.nohpet            | Bin 8469 -> 8579 bytes
 tests/data/acpi/x86/pc/DSDT.numamem           | Bin 8617 -> 8727 bytes
 tests/data/acpi/x86/pc/DSDT.roothp            | Bin 12404 -> 12514 bytes
 tests/data/acpi/x86/q35/DSDT                  | Bin 8440 -> 8550 bytes
 tests/data/acpi/x86/q35/DSDT.acpierst         | Bin 8457 -> 8567 bytes
 tests/data/acpi/x86/q35/DSDT.acpihmat         | Bin 9765 -> 9875 bytes
 .../data/acpi/x86/q35/DSDT.acpihmat-generic-x | Bin 12650 -> 12760 bytes
 .../acpi/x86/q35/DSDT.acpihmat-noinitiator    | Bin 8719 -> 8829 bytes
 tests/data/acpi/x86/q35/DSDT.applesmc         | Bin 8486 -> 8596 bytes
 tests/data/acpi/x86/q35/DSDT.bridge           | Bin 12053 -> 12163 bytes
 tests/data/acpi/x86/q35/DSDT.core-count       | Bin 12998 -> 13108 bytes
 tests/data/acpi/x86/q35/DSDT.core-count2      | Bin 33855 -> 33965 bytes
 tests/data/acpi/x86/q35/DSDT.cphp             | Bin 8904 -> 9014 bytes
 tests/data/acpi/x86/q35/DSDT.cxl              | Bin 13231 -> 13341 bytes
 tests/data/acpi/x86/q35/DSDT.dimmpxm          | Bin 10094 -> 10204 bytes
 tests/data/acpi/x86/q35/DSDT.ipmibt           | Bin 8515 -> 8625 bytes
 tests/data/acpi/x86/q35/DSDT.ipmismbus        | Bin 8528 -> 8638 bytes
 tests/data/acpi/x86/q35/DSDT.ivrs             | Bin 8457 -> 8567 bytes
 tests/data/acpi/x86/q35/DSDT.memhp            | Bin 9799 -> 9909 bytes
 tests/data/acpi/x86/q35/DSDT.mmio64           | Bin 9570 -> 9680 bytes
 tests/data/acpi/x86/q35/DSDT.multi-bridge     | Bin 13293 -> 13403 bytes
 tests/data/acpi/x86/q35/DSDT.noacpihp         | Bin 8302 -> 8412 bytes
 tests/data/acpi/x86/q35/DSDT.nohpet           | Bin 8298 -> 8408 bytes
 tests/data/acpi/x86/q35/DSDT.numamem          | Bin 8446 -> 8556 bytes
 tests/data/acpi/x86/q35/DSDT.pvpanic-isa      | Bin 8541 -> 8651 bytes
 tests/data/acpi/x86/q35/DSDT.thread-count     | Bin 12998 -> 13108 bytes
 tests/data/acpi/x86/q35/DSDT.thread-count2    | Bin 33855 -> 33965 bytes
 tests/data/acpi/x86/q35/DSDT.tis.tpm12        | Bin 9046 -> 9156 bytes
 tests/data/acpi/x86/q35/DSDT.tis.tpm2         | Bin 9072 -> 9182 bytes
 tests/data/acpi/x86/q35/DSDT.type4-count      | Bin 18674 -> 18784 bytes
 tests/data/acpi/x86/q35/DSDT.viot             | Bin 14697 -> 14807 bytes
 tests/data/acpi/x86/q35/DSDT.xapic            | Bin 35803 -> 35913 bytes
 tests/qtest/bios-tables-test-allowed-diff.h   |  42 ------------------
 43 files changed, 42 deletions(-)
tests/data/acpi/x86/pc/DSDT binary +0 -0
index 4beb5194b84a711fcb52e3e52cc2096497d18442..62bd8eae9602af4c590c6962689da54e4bff9c70 100644
GIT binary patch
tests/data/acpi/x86/pc/DSDT.acpierst binary +0 -0
index abda6863b64c5dc8ba5aba1a286cbfa76772a1e4..6c9cf3df3902fb30c704b7a657c4c08402c28837 100644
GIT binary patch
tests/data/acpi/x86/pc/DSDT.acpihmat binary +0 -0
index d081db26d7ba504b3344fad130d5812419291ac0..36f952d730a1d64c1babf7adf05c0ed364f559f3 100644
GIT binary patch
tests/data/acpi/x86/pc/DSDT.bridge binary +0 -0
index e16897dc5f0fbb3f7b4de8db913884046246cc3b..da189168ffdae5817a4fe7b0e62531a333cb3d75 100644
GIT binary patch
tests/data/acpi/x86/pc/DSDT.cphp binary +0 -0
index e95711cd9cde5d50b841b701ae0fed5a4b15e872..d6f96a071f1a7d570400dffedfd10af38eee0faf 100644
GIT binary patch
tests/data/acpi/x86/pc/DSDT.dimmpxm binary +0 -0
index 90ba66b9164f9a958d5a3c4371b1eec03e922828..ee06a74106606a3725b7f6882d020cf487873771 100644
GIT binary patch
tests/data/acpi/x86/pc/DSDT.hpbridge binary +0 -0
index 0eafe5fbf3d73719c9c3e6e26371863bfb44ed2f..1730d2ca1d83c08eca05e35ac1691e559a618489 100644
GIT binary patch
tests/data/acpi/x86/pc/DSDT.hpbrroot binary +0 -0
index 077a4cc988dc417a1bc9317dddd2dbd96ff1ff50..4ae9b5586f27761f77eabc801467a343a88d84a4 100644
GIT binary patch
tests/data/acpi/x86/pc/DSDT.ipmikcs binary +0 -0
index 8d465f027772f9c59b0c328c1a099e374a6d2a90..71e2566c59b03670df98d8f3dced9b7f7df1a985 100644
GIT binary patch
tests/data/acpi/x86/pc/DSDT.memhp binary +0 -0
index e3b49757cb7abd7536ee89a6824967d2cb2485cf..5955bc2920d5327a90ae604d406496d73d543378 100644
GIT binary patch
tests/data/acpi/x86/pc/DSDT.nohpet binary +0 -0
index 9e772c1316d0ea07c51717466c4c7e383553f345..2eef579e2fb3629b3e6a66eccb1565e2fbf2864d 100644
GIT binary patch
tests/data/acpi/x86/pc/DSDT.numamem binary +0 -0
index 9bfbfc28213713c208dfc38a85abb46fb190871d..b2c8220fefd1175ff403a77f77ea2fab7675d096 100644
GIT binary patch
tests/data/acpi/x86/pc/DSDT.roothp binary +0 -0
index efbee6d8aa5c62ff4fcb83e6c5cff59542977850..287ec23844e6887a24276d21b9bdcc415796e656 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT binary +0 -0
index e5e8d1e041e20e1b3ee56a5c93fe3d6ebd721ee6..813e489f98b6be8958d8bf9bcf1d0b2eed691a5e 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.acpierst binary +0 -0
index 072a3fe2cd17dfe06658dfd82588f69787810114..2d81bcbc781d3fc68a053d5319fbdcfa153a4653 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.acpihmat binary +0 -0
index 2a4f2fc1d5c5649673353186e67ff5b5e59e8d53..0b911c9425d2f59fc6e0a2aac97fe23ee0b4a18d 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.acpihmat-generic-x binary +0 -0
index 7911c058bba5005d318b8db8d6da5c1ee381b0f1..bd0f517847bd71eb78db72010df699c1bea64d4a 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.acpihmat-noinitiator binary +0 -0
index 580b4a456a20fc0cc0a832eaf74193b46d8ae8b1..3ab30d885f483c1626a9ab5a3501610923485462 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.applesmc binary +0 -0
index 5e8220e38d6f88b103f6eb3eb7c78dfa466882dc..7e17c9ebb3b7d28526bd04c9af5ca05a3461ac13 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.bridge binary +0 -0
index ee039453af1071e00a81ee7b37cf8f417f524257..9da24d83ea7ab37c354a0cdbecbcf5129a3e1621 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.core-count binary +0 -0
index 7ebfceeb66460d0ad98471924ce224b7153e87ef..22bf4a17db1b8175db939c5159e1686c8bc54066 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.core-count2 binary +0 -0
index d0394558a1faa0b4ba43abab66d474d96b477ff3..69e710caba4a353d3c0805acc8faba7043bf0ff3 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.cphp binary +0 -0
index a055c2e7d3c4f5a00a03be20fd73227e322283a4..0b9e315600b8665a8cb4ddfc57c4cf60968d0b4f 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.cxl binary +0 -0
index 20843549f54af1cb0e6017c4cfff7463318d9eb7..0a49b62f39f1e4e00db2d03bbf34de4e20f2ed7d 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.dimmpxm binary +0 -0
index 664e926e90765550136242f7e3e0bdc7719c1853..1c14b91bb4d341d16527d330e2bb0515e2fafb81 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.ipmibt binary +0 -0
index 4066a76d26aa380dfbecc58aa3f83ab5db2baadb..5561088d97a871f858461680d77d016f6b71d799 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.ipmismbus binary +0 -0
index 6d0b6b95c2a9fd01befc37b26650781ee1562e2a..cecba8c0629f89d2ccdd017791be69e5a98f52fa 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.ivrs binary +0 -0
index 072a3fe2cd17dfe06658dfd82588f69787810114..2d81bcbc781d3fc68a053d5319fbdcfa153a4653 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.memhp binary +0 -0
index 4f2f9bcfceff076490cc49b8286380295a340004..056366a2c9fd535fa02d7494181e76b6a76b4cfb 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.mmio64 binary +0 -0
index 0fb6aab16f1bd79f3c0790cc9f644f7e52ac37b1..3ab05c9ec6afa014ad53ad246fcba7336bef3901 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.multi-bridge binary +0 -0
index f6afa6d96d2525d512cc46f17439f7a49962b730..41543787c443606ccef7191c2b0bee6737efe752 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.noacpihp binary +0 -0
index 9f7261d1b06bbf5d8a3e5a7a46b247a2a21eb544..1c09aff8b5b8955730d5ca1737e4e7f6e698e401 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.nohpet binary +0 -0
index 99ad629c9171ff6ab346d6b4c519e77ca23e5b1c..86a109d6b12d38501d4353b5f8e31e9f3c15dd43 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.numamem binary +0 -0
index fd1d8a79d3d9b071c8796e5e99b76698a9a8d29c..454aa65803d8da71c9d5f1a263fa0b59bb76af4f 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.pvpanic-isa binary +0 -0
index 89032fa0290f496be0c06c6382586541aa1118a8..8ef053f6dc2f1c3086756698c5953e857067df9d 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.thread-count binary +0 -0
index 7ebfceeb66460d0ad98471924ce224b7153e87ef..22bf4a17db1b8175db939c5159e1686c8bc54066 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.thread-count2 binary +0 -0
index d0394558a1faa0b4ba43abab66d474d96b477ff3..69e710caba4a353d3c0805acc8faba7043bf0ff3 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.tis.tpm12 binary +0 -0
index f2ed40ca70cb13e733e39f4bad756be8688e01fe..a36710dd89085f8ec5f173b84d4cd2a25473530e 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.tis.tpm2 binary +0 -0
index 5c975d2162d0bfee5a3a089e79b5ba038f82b7ef..c7d737509dfd229d2dde46ea92d292039d854f79 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.type4-count binary +0 -0
index 3194a82b8b4f66aff1ecf7d2d60b4890181fc600..2d8b82a36ef1a8a4325817b164f77ceda78dd42e 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.viot binary +0 -0
index 129d43e1e561be3fd7cd71406829ab81d0a8aba0..3920d98b2501b08a4e0d57767a8c47cd57080748 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.xapic binary +0 -0
index b37ab591110d1c8201575ad6bba83449d7b90b21..1c6c420f9edb16f2e706d2b495d6e856441de000 100644
GIT binary patch
tests/qtest/bios-tables-test-allowed-diff.h +0 -42

43 lines not on this page · raw message

Signature · 1 line
2.43.5
author
#10 lore raw

PATCH 5/13 acpi: Send the GPE event of sleep for x86

In reply to Annie Li

The GPE event is triggered to notify x86 guest to sleep itself. The function acpi_send_sleep_event will also trigger GED events on HW-reduced systems where ACPI GED sleep event is supported.

---
 hw/acpi/core.c                       | 12 ++++++++++++
 include/hw/acpi/acpi.h               |  1 +
 include/hw/acpi/acpi_dev_interface.h |  1 +
 3 files changed, 14 insertions(+)
hw/acpi/core.c +12 -0
index 58f8964e13..dcabe881bf 100644
@@ -359,6 +359,18 @@ int acpi_get_slic_oem(AcpiSlicOem *oem)
     return -1;
 }
 
+void acpi_send_sleep_event(void)
+{
+    bool ambiguous;
+    Object *obj = object_resolve_path_type("", TYPE_ACPI_DEVICE_IF, &ambiguous);
+
+    assert(!ambiguous);
+    if (obj) {
+        /* Send sleep event */
+        acpi_send_event(DEVICE(obj), ACPI_SLEEP_STATUS);
+    }
+}
+
 static void acpi_notify_wakeup(Notifier *notifier, void *data)
 {
     ACPIREGS *ar = container_of(notifier, ACPIREGS, wakeup);
include/hw/acpi/acpi.h +1 -0
index d1a4fa2af8..64d3ff78ed 100644
@@ -184,6 +184,7 @@ uint32_t acpi_gpe_ioport_readb(ACPIREGS *ar, uint32_t addr);
 
 void acpi_send_gpe_event(ACPIREGS *ar, qemu_irq irq,
                          AcpiEventStatusBits status);
+void acpi_send_sleep_event(void);
 
 void acpi_update_sci(ACPIREGS *acpi_regs, qemu_irq irq);
 
include/hw/acpi/acpi_dev_interface.h +1 -0
index 68d9d15f50..1cb050cd3a 100644
@@ -13,6 +13,7 @@ typedef enum {
     ACPI_NVDIMM_HOTPLUG_STATUS = 16,
     ACPI_VMGENID_CHANGE_STATUS = 32,
     ACPI_POWER_DOWN_STATUS = 64,
+    ACPI_SLEEP_STATUS = 128,
 } AcpiEventStatusBits;
 
 #define TYPE_ACPI_DEVICE_IF "acpi-device-interface"
Signature · 1 line
2.43.5
#11 lore raw

Re: [PATCH 05/13] acpi: Send the GPE event of sleep for x86

Quoted 17 lines · On Wed, 28 May 2025 12:39:52 -0400 Annie Li <[email protected]> wrote:

The GPE event is triggered to notify x86 guest to sleep itself. The function acpi_send_sleep_event will also trigger GED events on HW-reduced systems where ACPI GED sleep event is supported.

---
 hw/acpi/core.c                       | 12 ++++++++++++
 include/hw/acpi/acpi.h               |  1 +
 include/hw/acpi/acpi_dev_interface.h |  1 +
 3 files changed, 14 insertions(+)
hw/acpi/core.c +0 -0
index 58f8964e13..dcabe881bf 100644

hw/acpi/core.c int acpi_get_slic_oem(AcpiSlicOem *oem) · line 368

Quoted 10 lines
hw/acpi/core.c +7 -0
@@ -359,6 +359,18 @@ int acpi_get_slic_oem(AcpiSlicOem *oem)
     return -1;
 }
 
+void acpi_send_sleep_event(void)
+{
+    bool ambiguous;
+    Object *obj = object_resolve_path_type("", TYPE_ACPI_DEVICE_IF, &ambiguous);
+
+    assert(!ambiguous);
+    if (obj) {

Can it ever be NULL?
If not drop condition.

Quoted 32 lines
hw/acpi/core.c +5 -0
+        /* Send sleep event */
+        acpi_send_event(DEVICE(obj), ACPI_SLEEP_STATUS);
+    }
+}
+
 static void acpi_notify_wakeup(Notifier *notifier, void *data)
 {
     ACPIREGS *ar = container_of(notifier, ACPIREGS, wakeup);
include/hw/acpi/acpi.h +1 -0
index d1a4fa2af8..64d3ff78ed 100644
@@ -184,6 +184,7 @@ uint32_t acpi_gpe_ioport_readb(ACPIREGS *ar, uint32_t addr);
 
 void acpi_send_gpe_event(ACPIREGS *ar, qemu_irq irq,
                          AcpiEventStatusBits status);
+void acpi_send_sleep_event(void);
 
 void acpi_update_sci(ACPIREGS *acpi_regs, qemu_irq irq);
 
include/hw/acpi/acpi_dev_interface.h +1 -0
index 68d9d15f50..1cb050cd3a 100644
@@ -13,6 +13,7 @@ typedef enum {
     ACPI_NVDIMM_HOTPLUG_STATUS = 16,
     ACPI_VMGENID_CHANGE_STATUS = 32,
     ACPI_POWER_DOWN_STATUS = 64,
+    ACPI_SLEEP_STATUS = 128,
 } AcpiEventStatusBits;
 
 #define TYPE_ACPI_DEVICE_IF "acpi-device-interface"
author
#12 lore raw

Re: [PATCH 05/13] acpi: Send the GPE event of sleep for x86

Hi Igor,

Quoted 23 lines · Igor Mammedov
Quoted 20 lines · On Wed, 28 May 2025 12:39:52 -0400 Annie Li <[email protected]> wrote:

The GPE event is triggered to notify x86 guest to sleep itself. The function acpi_send_sleep_event will also trigger GED events on HW-reduced systems where ACPI GED sleep event is supported.

---
  hw/acpi/core.c                       | 12 ++++++++++++
  include/hw/acpi/acpi.h               |  1 +
  include/hw/acpi/acpi_dev_interface.h |  1 +
  3 files changed, 14 insertions(+)
hw/acpi/core.c +0 -0
index 58f8964e13..dcabe881bf 100644
@@ -359,6 +359,18 @@ int acpi_get_slic_oem(AcpiSlicOem *oem)
      return -1;
  }
 
Quoted 9 lines

hw/acpi/core.c int acpi_get_slic_oem(AcpiSlicOem *oem) · line 368

Quoted 7 lines
hw/acpi/core.c +7 -0
+void acpi_send_sleep_event(void)
+{
+    bool ambiguous;
+    Object *obj = object_resolve_path_type("", TYPE_ACPI_DEVICE_IF, &ambiguous);
+
+    assert(!ambiguous);
+    if (obj) {

Can it ever be NULL?
If not drop condition.

assert happens earlier if it is NULL.

will drop it.

Thanks

Annie

Quoted 33 lines
Quoted 33 lines
hw/acpi/core.c +5 -0
+        /* Send sleep event */
+        acpi_send_event(DEVICE(obj), ACPI_SLEEP_STATUS);
+    }
+}
+
  static void acpi_notify_wakeup(Notifier *notifier, void *data)
  {
      ACPIREGS *ar = container_of(notifier, ACPIREGS, wakeup);
include/hw/acpi/acpi.h +1 -0
index d1a4fa2af8..64d3ff78ed 100644
@@ -184,6 +184,7 @@ uint32_t acpi_gpe_ioport_readb(ACPIREGS *ar, uint32_t addr);
 
  void acpi_send_gpe_event(ACPIREGS *ar, qemu_irq irq,
                           AcpiEventStatusBits status);
+void acpi_send_sleep_event(void);
 
  void acpi_update_sci(ACPIREGS *acpi_regs, qemu_irq irq);
 
include/hw/acpi/acpi_dev_interface.h +1 -0
index 68d9d15f50..1cb050cd3a 100644
@@ -13,6 +13,7 @@ typedef enum {
      ACPI_NVDIMM_HOTPLUG_STATUS = 16,
      ACPI_VMGENID_CHANGE_STATUS = 32,
      ACPI_POWER_DOWN_STATUS = 64,
+    ACPI_SLEEP_STATUS = 128,
  } AcpiEventStatusBits;
 
  #define TYPE_ACPI_DEVICE_IF "acpi-device-interface"
author
#13 lore raw

PATCH 6/13 test/acpi: allow DSDT table changes for microvm

In reply to Annie Li

List changed files in tests/qtest/bios-tables-test-allowed-diff.h

---
 tests/qtest/bios-tables-test-allowed-diff.h | 5 +++++
 1 file changed, 5 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +5 -0
index dfb8523c8b..bb028db137 100644
@@ -1 +1,6 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/x86/microvm/DSDT",
+"tests/data/acpi/x86/microvm/DSDT.ioapic2",
+"tests/data/acpi/x86/microvm/DSDT.pcie",
+"tests/data/acpi/x86/microvm/DSDT.rtc",
+"tests/data/acpi/x86/microvm/DSDT.usb",
Signature · 1 line
2.43.5
author
#14 lore raw

PATCH 7/13 microvm: Add ACPI Control Method Sleep Button

In reply to Annie Li

Add the support of ACPI Control Method Sleep Button and System S3 Sleeping State for microvm.

---
 hw/i386/acpi-microvm.c                 | 13 ++++++++++++-
 include/hw/acpi/generic_event_device.h |  1 +
 2 files changed, 13 insertions(+), 1 deletion(-)
hw/i386/acpi-microvm.c +12 -1
index 279da6b4aa..c14e12b2d8 100644
@@ -32,6 +32,7 @@
 #include "hw/acpi/generic_event_device.h"
 #include "hw/acpi/utils.h"
 #include "hw/acpi/erst.h"
+#include "hw/acpi/control_method_device.h"
 #include "hw/i386/fw_cfg.h"
 #include "hw/i386/microvm.h"
 #include "hw/pci/pci.h"
@@ -123,12 +124,22 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *linker,
     build_ged_aml(sb_scope, GED_DEVICE, x86ms->acpi_dev,
                   GED_MMIO_IRQ, AML_SYSTEM_MEMORY, GED_MMIO_BASE);
     acpi_dsdt_add_power_button(sb_scope);
+    acpi_dsdt_add_sleep_button(sb_scope);
     acpi_dsdt_add_virtio(sb_scope, mms);
     acpi_dsdt_add_xhci(sb_scope, mms);
     acpi_dsdt_add_pci(sb_scope, mms);
     aml_append(dsdt, sb_scope);
 
-    /* ACPI 5.0: Table 7-209 System State Package */
+    /* ACPI 6.5, Table 7.11: System State Package */
+    scope = aml_scope("\\");
+    pkg = aml_package(4);
+    aml_append(pkg, aml_int(ACPI_GED_SLP_TYP_S3));
+    aml_append(pkg, aml_int(0)); /* ignored */
+    aml_append(pkg, aml_int(0)); /* reserved */
+    aml_append(pkg, aml_int(0)); /* reserved */
+    aml_append(scope, aml_name_decl("_S3", pkg));
+    aml_append(dsdt, scope);
+
     scope = aml_scope("\\");
     pkg = aml_package(4);
     aml_append(pkg, aml_int(ACPI_GED_SLP_TYP_S5));
include/hw/acpi/generic_event_device.h +1 -0
index d2dac87b4a..28c5785863 100644
@@ -85,6 +85,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(AcpiGedState, ACPI_GED)
 #define ACPI_GED_SLP_TYP_POS       0x2   /* SLP_TYPx Bit Offset */
 #define ACPI_GED_SLP_TYP_MASK      0x07  /* SLP_TYPx 3-bit mask */
 #define ACPI_GED_SLP_TYP_S5        0x05  /* System _S5 State (Soft Off) */
+#define ACPI_GED_SLP_TYP_S3        0x03  /* System _S3 State (Sleeping State) */
 #define ACPI_GED_SLP_EN            0x20  /* SLP_EN write-only bit */
 
 #define GED_DEVICE      "GED"
Signature · 1 line
2.43.5
author
#15 lore raw

PATCH 8/13 hw/acpi: Add ACPI GED support for the sleep event

In reply to Annie Li

From: Miguel Luis <[email protected]>

Add support for ACPI GED sleep event on the ACPI device interface so that HW-reduced systems can enable guests to sleep.

---
 hw/acpi/generic_event_device.c         | 9 +++++++++
 include/hw/acpi/generic_event_device.h | 1 +
 2 files changed, 10 insertions(+)
hw/acpi/generic_event_device.c +9 -0
index c85d97ca37..5a1ac8e362 100644
@@ -13,6 +13,7 @@
 #include "qapi/error.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/generic_event_device.h"
+#include "hw/acpi/control_method_device.h"
 #include "hw/irq.h"
 #include "hw/mem/pc-dimm.h"
 #include "hw/mem/nvdimm.h"
@@ -26,6 +27,7 @@ static const uint32_t ged_supported_events[] = {
     ACPI_GED_PWR_DOWN_EVT,
     ACPI_GED_NVDIMM_HOTPLUG_EVT,
     ACPI_GED_CPU_HOTPLUG_EVT,
+    ACPI_GED_SLEEP_EVT,
 };
 
 /*
@@ -121,6 +123,11 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev,
                            aml_notify(aml_name("\\_SB.NVDR"),
                                       aml_int(0x80)));
                 break;
+            case ACPI_GED_SLEEP_EVT:
+                aml_append(if_ctx,
+                           aml_notify(aml_name(ACPI_SLEEP_BUTTON_DEVICE),
+                                      aml_int(0x80)));
+                break;
             default:
                 /*
                  * Please make sure all the events in ged_supported_events[]
@@ -295,6 +302,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
         sel = ACPI_GED_MEM_HOTPLUG_EVT;
     } else if (ev & ACPI_POWER_DOWN_STATUS) {
         sel = ACPI_GED_PWR_DOWN_EVT;
+    } else if (ev & ACPI_SLEEP_STATUS) {
+        sel = ACPI_GED_SLEEP_EVT;
     } else if (ev & ACPI_NVDIMM_HOTPLUG_STATUS) {
         sel = ACPI_GED_NVDIMM_HOTPLUG_EVT;
     } else if (ev & ACPI_CPU_HOTPLUG_STATUS) {
include/hw/acpi/generic_event_device.h +1 -0
index 28c5785863..71503e0100 100644
@@ -102,6 +102,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(AcpiGedState, ACPI_GED)
 #define ACPI_GED_PWR_DOWN_EVT      0x2
 #define ACPI_GED_NVDIMM_HOTPLUG_EVT 0x4
 #define ACPI_GED_CPU_HOTPLUG_EVT    0x8
+#define ACPI_GED_SLEEP_EVT          0x10
 
 typedef struct GEDState {
     MemoryRegion evt;
Signature · 1 line
2.43.5
author
#16 lore raw

PATCH 9/13 microvm: enable sleep GED event

In reply to Annie Li

The sleep GED event is enabled for microvm. Also, the system suspend is enabled when the GED register is set for sleep.

---
 hw/i386/microvm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/i386/microvm.c +2 -1
index d0a236c74f..eba33c4365 100644
@@ -205,7 +205,8 @@ static void microvm_devices_init(MicrovmMachineState *mms)
     /* Optional and legacy devices */
     if (x86_machine_is_acpi_enabled(x86ms)) {
         DeviceState *dev = qdev_new(TYPE_ACPI_GED);
-        qdev_prop_set_uint32(dev, "ged-event", ACPI_GED_PWR_DOWN_EVT);
+        qdev_prop_set_uint32(dev, "ged-event",
+                             ACPI_GED_PWR_DOWN_EVT | ACPI_GED_SLEEP_EVT);
         sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
         sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, GED_MMIO_BASE);
         /* sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, GED_MMIO_BASE_MEMHP); */
Signature · 1 line
2.43.5
author
#17 lore raw

PATCH 10/13 tests/qtest/bios-table-tests: Update ACPI table binaries for microvm

In reply to Annie Li

Following is the diff generated by the step 5 and 6 in tests/qtest/bios-tables-test.c

Diff from iasl to show changes in DSDT table:

@@ -1,30 +1,30 @@
/*
* Intel ACPI Component Architecture
* AML/ASL+ Disassembler version 20210604 (64-bit version)
* Copyright (c) 2000 - 2021 Intel Corporation
*
* Disassembling to symbolic ASL+ operators
*
* Disassembly of tests/data/acpi/x86/microvm/DSDT, Tue May 27 16:20:08 2025 *
* Original Table Header:

  *     Signature        "DSDT"
- *     Length           0x0000016D (365)
+ *     Length           0x000001BA (442)
  *     Revision         0x02
- *     Checksum         0x11
+ *     Checksum         0xD5
  *     OEM ID           "BOCHS "
  *     OEM Table ID     "BXPC    "
  *     OEM Revision     0x00000001 (1)
  *     Compiler ID      "BXPC"
  *     Compiler Version 0x00000001 (1)
  */
 DefinitionBlock ("", "DSDT", 2, "BOCHS ", "BXPC    ", 0x00000001)
 {
     Scope (_SB)
     {
         Device (FWCF)
         {
             Name (_HID, "QEMU0002")  // _HID: Hardware ID
             Name (_STA, 0x0B)  // _STA: Status
             Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
             {
@@ -66,56 +66,82 @@
                     0x00000009,
                 }
             })
             OperationRegion (EREG, SystemMemory, 0xFEA00000, 0x04)
             Field (EREG, DWordAcc, NoLock, WriteAsZeros)
             {
                 ESEL,   32
             }

             Method (_EVT, 1, Serialized)  // _EVT: Event
             {
                 Local0 = ESEL /* \_SB_.GED_.ESEL */
                 If (((Local0 & 0x02) == 0x02))
                 {
                     Notify (PWRB, 0x80) // Status Change
                 }

+
+ If (((Local0 & 0x10) == 0x10))
+ {
+ Notify (SLPB, 0x80) // Status Change
+ }

             }
         }

         Device (PWRB)
         {
             Name (_HID, "PNP0C0C" /* Power Button Device */)  // _HID: Hardware ID
             Name (_UID, Zero)  // _UID: Unique ID
         }

+ Device (SLPB)
+ {

+            Name (_HID, EisaId ("PNP0C0E") /* Sleep Button Device */)  // _HID: Hardware ID
+            OperationRegion (\SLP, SystemIO, 0x0201, One)
+            Field (\SLP, ByteAcc, NoLock, WriteAsZeros)
+            {

+ SBP, 1
+ }
+ }
+

         Device (VR07)
         {
             Name (_HID, "LNRO0005")  // _HID: Hardware ID
             Name (_UID, 0x07)  // _UID: Unique ID
             Name (_CCA, One)  // _CCA: Cache Coherency Attribute
             Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
             {
                 Memory32Fixed (ReadWrite,
                     0xFEB00E00,         // Address Base
                     0x00000200,         // Address Length
                     )
                 Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
                 {
                     0x00000017,
                 }
             })
         }
     }

     Scope (\)
     {
+        Name (_S3, Package (0x04)  // _S3_: S3 System State
+        {
+            0x03,
+            Zero,
+            Zero,
+            Zero

+ })
+ }
+
+ Scope (\)

+    {
         Name (_S5, Package (0x04)  // _S5_: S5 System State
         {
             0x05,
             Zero,
             Zero,
             Zero
         })
     }

}

---
 tests/data/acpi/x86/microvm/DSDT            | Bin 365 -> 442 bytes
 tests/data/acpi/x86/microvm/DSDT.ioapic2    | Bin 365 -> 442 bytes
 tests/data/acpi/x86/microvm/DSDT.pcie       | Bin 3023 -> 3100 bytes
 tests/data/acpi/x86/microvm/DSDT.rtc        | Bin 404 -> 481 bytes
 tests/data/acpi/x86/microvm/DSDT.usb        | Bin 414 -> 491 bytes
 tests/qtest/bios-tables-test-allowed-diff.h |   5 -----
 6 files changed, 5 deletions(-)
tests/data/acpi/x86/microvm/DSDT binary +0 -0
index f477668f2ee80241e47b340ad4a30f5480df2049..ee199a4fb65ab1a2d811f37d9b5bc67bccd34939 100644
GIT binary patch
tests/data/acpi/x86/microvm/DSDT.ioapic2 binary +0 -0
index e5924a49962e0cff4228bcfc77ebcf48cb4a2219..7512d1527cf222d6f75a92f051f9eda402e28376 100644
GIT binary patch
tests/data/acpi/x86/microvm/DSDT.pcie binary +0 -0
index 8eacd21d6ecdf9a3cd3e4f03cf1b40748dcbf53e..5e3f80cbf82cab52fe310160c88d0a11ff069bf5 100644
GIT binary patch
tests/data/acpi/x86/microvm/DSDT.rtc binary +0 -0
index e375473b5f033d374dd2a64a9f814fd16c3e262f..11258908703b64a835bd14307490c62c5ef7301f 100644
GIT binary patch
tests/data/acpi/x86/microvm/DSDT.usb binary +0 -0
index d63fd84620a2689120b32262f964e6a098d71632..7250d9f8ad45fca91afeda1089090eee11cd6594 100644
GIT binary patch
tests/qtest/bios-tables-test-allowed-diff.h +0 -5
index bb028db137..dfb8523c8b 100644
@@ -1,6 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/x86/microvm/DSDT",
-"tests/data/acpi/x86/microvm/DSDT.ioapic2",
-"tests/data/acpi/x86/microvm/DSDT.pcie",
-"tests/data/acpi/x86/microvm/DSDT.rtc",
-"tests/data/acpi/x86/microvm/DSDT.usb",
Signature · 1 line
2.43.5
author
#18 lore raw

PATCH 11/13 microvm: suspend the system as requested

In reply to Annie Li

Once the microvm guest requests to go to sleep state and sets the GED register with S3 type, QEMU needs to continue suspending the system.

---
 hw/acpi/generic_event_device.c | 3 +++
 1 file changed, 3 insertions(+)
hw/acpi/generic_event_device.c +3 -0
index 5a1ac8e362..bc53551a45 100644
@@ -213,6 +213,9 @@ static void ged_regs_write(void *opaque, hwaddr addr, uint64_t data,
         if (slp_en && slp_typ == ACPI_GED_SLP_TYP_S5) {
             qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
         }
+        if (slp_en && slp_typ == ACPI_GED_SLP_TYP_S3) {
+            qemu_system_suspend_request();
+        }
         return;
     case ACPI_GED_REG_SLEEP_STS:
         return;
Signature · 1 line
2.43.5
author
#19 lore raw

PATCH 12/13 microvm: enable suspend

In reply to Annie Li

The function qemu_wakeup_suspend_enabled combines the suspend and wakeup together. However, the microvm doesn't support wakeup yet. Suspend is enabled here, but wakeup doesn't actually work for microvm now.

---
 hw/i386/microvm.c | 1 +
 1 file changed, 1 insertion(+)
hw/i386/microvm.c +1 -0
index eba33c4365..da5d4126e5 100644
@@ -489,6 +489,7 @@ static void microvm_machine_state_init(MachineState *machine)
     qemu_add_machine_init_done_notifier(&mms->machine_done);
     mms->powerdown_req.notify = microvm_powerdown_req;
     qemu_register_powerdown_notifier(&mms->powerdown_req);
+    qemu_register_wakeup_support();
 
     microvm_memory_init(mms);
 
Signature · 1 line
2.43.5
#20 lore raw

Re: [PATCH 12/13] microvm: enable suspend

Quoted 4 lines · On Wed, 28 May 2025 12:42:03 -0400 Annie Li <[email protected]> wrote:

The function qemu_wakeup_suspend_enabled combines the suspend and wakeup together. However, the microvm doesn't support wakeup yet. Suspend is enabled here, but wakeup doesn't actually work for microvm now.

why wakeup doesn't work?

Quoted 18 lines
---
 hw/i386/microvm.c | 1 +
 1 file changed, 1 insertion(+)
hw/i386/microvm.c +1 -0
index eba33c4365..da5d4126e5 100644
@@ -489,6 +489,7 @@ static void microvm_machine_state_init(MachineState *machine)
     qemu_add_machine_init_done_notifier(&mms->machine_done);
     mms->powerdown_req.notify = microvm_powerdown_req;
     qemu_register_powerdown_notifier(&mms->powerdown_req);
+    qemu_register_wakeup_support();
 
     microvm_memory_init(mms);
 
author
#21 lore raw

Re: [PATCH 12/13] microvm: enable suspend

Hi Igor,

Quoted 8 lines · Igor Mammedov
Quoted 4 lines · On Wed, 28 May 2025 12:42:03 -0400 Annie Li <[email protected]> wrote:

The function qemu_wakeup_suspend_enabled combines the suspend and wakeup together. However, the microvm doesn't support wakeup yet. Suspend is enabled here, but wakeup doesn't actually work for microvm now.

why wakeup doesn't work?

Microvm is missing the support for wakeup now, such as, wakeup notifier, the sleep status needs to be set, etc.
Details are in "Table 4.20: Sleep Status Register" in ACPI spec 6.5.

I've only covered the sleep support for microvm since this patch focuses on the sleep button.

Thanks

Annie

Quoted 18 lines
Quoted 18 lines
---
  hw/i386/microvm.c | 1 +
  1 file changed, 1 insertion(+)
hw/i386/microvm.c +1 -0
index eba33c4365..da5d4126e5 100644
@@ -489,6 +489,7 @@ static void microvm_machine_state_init(MachineState *machine)
      qemu_add_machine_init_done_notifier(&mms->machine_done);
      mms->powerdown_req.notify = microvm_powerdown_req;
      qemu_register_powerdown_notifier(&mms->powerdown_req);
+    qemu_register_wakeup_support();
 
      microvm_memory_init(mms);
 
#22 lore raw

Re: [PATCH 12/13] microvm: enable suspend

Quoted 6 lines · On Tue, 3 Jun 2025 15:22:27 -0400 Annie Li <[email protected]> wrote:

Hi Igor,

Quoted 3 lines · Igor Mammedov

On Wed, 28 May 2025 12:42:03 -0400
Annie Li <[email protected]> wrote:

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines

The function qemu_wakeup_suspend_enabled combines the suspend and wakeup together. However, the microvm doesn't support wakeup yet. Suspend is enabled here, but wakeup doesn't actually work for microvm now.

why wakeup doesn't work?

Microvm is missing the support for wakeup now, such as, wakeup notifier, the sleep status needs to be set, etc.
Details are in "Table 4.20: Sleep Status Register" in ACPI spec 6.5.

how hard would it be to implement wakeup in microvm?

Quoted 26 lines

I've only covered the sleep support for microvm since this patch focuses on the sleep button.

Thanks

Annie

Quoted 18 lines
Quoted 18 lines
---
  hw/i386/microvm.c | 1 +
  1 file changed, 1 insertion(+)
hw/i386/microvm.c +1 -0
index eba33c4365..da5d4126e5 100644
@@ -489,6 +489,7 @@ static void microvm_machine_state_init(MachineState *machine)
      qemu_add_machine_init_done_notifier(&mms->machine_done);
      mms->powerdown_req.notify = microvm_powerdown_req;
      qemu_register_powerdown_notifier(&mms->powerdown_req);
+    qemu_register_wakeup_support();
 
      microvm_memory_init(mms);
 
author
#23 lore raw

PATCH 13/13 acpi: hmp/qmp: Add hmp/qmp support for system_sleep

In reply to Annie Li

Following hmp/qmp commands are implemented for pressing virtual sleep button,

hmp: system_sleep
qmp: { "execute": "system_sleep" }

These commands put the guest into suspend or other power states depending on the power settings inside the guest.

These hmp/qmp command are in '*_*' format, it is intended to do so to align to existing 'system_*' commands.

---
 hmp-commands.hx            | 14 ++++++++++++++
 hw/core/machine-hmp-cmds.c |  5 +++++
 hw/core/machine-qmp-cmds.c | 11 +++++++++++
 include/monitor/hmp.h      |  1 +
 qapi/machine.json          | 20 ++++++++++++++++++++
 qapi/pragma.json           |  1 +
 6 files changed, 52 insertions(+)
hmp-commands.hx +14 -0
index 06746f0afc..12f08f3444 100644
@@ -639,6 +639,20 @@ SRST
   whether profiling is on or off.
 ERST
 
+    {
+        .name       = "system_sleep",
+        .args_type  = "",
+        .params     = "",
+        .help       = "send system sleep event",
+        .cmd = hmp_system_sleep,
+    },
+
+SRST
+``system_sleep``
+  Push the virtual sleep button; if supported, the system will enter
+  an ACPI sleep state.
+ERST
+
     {
         .name       = "system_reset",
         .args_type  = "",
hw/core/machine-hmp-cmds.c +5 -0
index c6325cdcaa..f8a7c1de88 100644
@@ -189,6 +189,11 @@ void hmp_system_reset(Monitor *mon, const QDict *qdict)
     qmp_system_reset(NULL);
 }
 
+void hmp_system_sleep(Monitor *mon, const QDict *qdict)
+{
+    qmp_system_sleep(NULL);
+}
+
 void hmp_system_powerdown(Monitor *mon, const QDict *qdict)
 {
     qmp_system_powerdown(NULL);
hw/core/machine-qmp-cmds.c +11 -0
index 1bc21b84a4..80b877d8cd 100644
@@ -12,6 +12,7 @@
 #include "hw/boards.h"
 #include "hw/intc/intc.h"
 #include "hw/mem/memory-device.h"
+#include "hw/acpi/acpi.h"
 #include "qapi/error.h"
 #include "qapi/qapi-builtin-visit.h"
 #include "qapi/qapi-commands-machine.h"
@@ -277,6 +278,16 @@ void qmp_system_reset(Error **errp)
     qemu_system_reset_request(SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET);
 }
 
+void qmp_system_sleep(Error **errp)
+{
+    if (!qemu_wakeup_suspend_enabled()) {
+        error_setg(errp,
+                   "suspend from running is not supported by this machine");
+        return;
+    }
+    acpi_send_sleep_event();
+}
+
 void qmp_system_powerdown(Error **errp)
 {
     qemu_system_powerdown_request();
include/monitor/hmp.h +1 -0
index ae116d9804..e543eec109 100644
@@ -43,6 +43,7 @@ void hmp_quit(Monitor *mon, const QDict *qdict);
 void hmp_stop(Monitor *mon, const QDict *qdict);
 void hmp_sync_profile(Monitor *mon, const QDict *qdict);
 void hmp_system_reset(Monitor *mon, const QDict *qdict);
+void hmp_system_sleep(Monitor *mon, const QDict *qdict);
 void hmp_system_powerdown(Monitor *mon, const QDict *qdict);
 void hmp_exit_preconfig(Monitor *mon, const QDict *qdict);
 void hmp_announce_self(Monitor *mon, const QDict *qdict);
qapi/machine.json +20 -0
index a6b8795b09..3efaf82f7d 100644
@@ -361,6 +361,26 @@
 ##
 { 'command': 'system_reset' }
 
+##
+# @system_sleep:
+#
+# Requests that the guest perform a ACPI sleep transition by pushing
+# the virtual sleep button.
+#
+# Since:10.0
+#
+# .. note:: A guest may or may not respond to this command.  This
+#        command returning does not indicate that a guest has
+#        accepted the request or that it has gone to sleep.
+#
+# .. qmp-example::
+#
+# -> { "execute": "system_sleep" }
+# <- { "return": {} }
+#
+##
+{ 'command': 'system_sleep' }
+
 ##
 # @system_powerdown:
 #
qapi/pragma.json +1 -0
index 023a2ef7bc..285ce82e9b 100644
@@ -23,6 +23,7 @@
         'set_password',
         'system_powerdown',
         'system_reset',
+        'system_sleep',
         'system_wakeup' ],
     # Commands allowed to return a non-dictionary
     'command-returns-exceptions': [
Signature · 1 line
2.43.5
#24 lore raw

Re: [PATCH 13/13] acpi: hmp/qmp: Add hmp/qmp support for system_sleep

Quoted 13 lines · Annie Li

Following hmp/qmp commands are implemented for pressing virtual sleep button,

hmp: system_sleep
qmp: { "execute": "system_sleep" }

These commands put the guest into suspend or other power states depending on the power settings inside the guest.

These hmp/qmp command are in '*_*' format, it is intended to do so to align to existing 'system_*' commands.

[...]

Quoted 5 lines
qapi/machine.json +0 -0
index a6b8795b09..3efaf82f7d 100644

qapi/machine.json line 370

Quoted 10 lines
qapi/machine.json +7 -0
@@ -361,6 +361,26 @@
 ##
 { 'command': 'system_reset' }
 
+##
+# @system_sleep:
+#
+# Requests that the guest perform a ACPI sleep transition by pushing
+# the virtual sleep button.
+#
+# Since:10.0

10.1

qapi/machine.json line 374

Quoted 4 lines
qapi/machine.json +4 -0
+#
+# .. note:: A guest may or may not respond to this command.  This
+#        command returning does not indicate that a guest has
+#        accepted the request or that it has gone to sleep.

Please indent like this for consistency:

   # .. note:: A guest may or may not respond to this command.  This
   #    command returning does not indicate that a guest has accepted the
   #    request or that it has gone to sleep.

The same note on system_powerdown additionally has "Many guests will respond to this command by prompting the user in some way." I guess you did not copy this part, because it's not true here. Correct?

Quoted 24 lines
qapi/machine.json +9 -0
+#
+# .. qmp-example::
+#
+# -> { "execute": "system_sleep" }
+# <- { "return": {} }
+#
+##
+{ 'command': 'system_sleep' }
+
 ##
 # @system_powerdown:
 #
qapi/pragma.json +1 -0
index 023a2ef7bc..285ce82e9b 100644
@@ -23,6 +23,7 @@
         'set_password',
         'system_powerdown',
         'system_reset',
+        'system_sleep',
         'system_wakeup' ],
     # Commands allowed to return a non-dictionary
     'command-returns-exceptions': [
author
#25 lore raw

Re: [PATCH 13/13] acpi: hmp/qmp: Add hmp/qmp support for system_sleep

Hello Markus,

Quoted 25 lines · Markus Armbruster
Quoted 13 lines · Annie Li

Following hmp/qmp commands are implemented for pressing virtual sleep button,

hmp: system_sleep
qmp: { "execute": "system_sleep" }

These commands put the guest into suspend or other power states depending on the power settings inside the guest.

These hmp/qmp command are in '*_*' format, it is intended to do so to align to existing 'system_*' commands.

[...]

Quoted 8 lines
qapi/machine.json +0 -0
index a6b8795b09..3efaf82f7d 100644
@@ -361,6 +361,26 @@
  ##
  { 'command': 'system_reset' }
 
Quoted 8 lines

qapi/machine.json line 370

Quoted 7 lines
qapi/machine.json +7 -0
+##
+# @system_sleep:
+#
+# Requests that the guest perform a ACPI sleep transition by pushing
+# the virtual sleep button.
+#
+# Since:10.0

10.1

Good catch.

Quoted 6 lines

qapi/machine.json line 374

Quoted 5 lines
qapi/machine.json +4 -0
+#
+# .. note:: A guest may or may not respond to this command.  This
+#        command returning does not indicate that a guest has
+#        accepted the request or that it has gone to sleep.

Please indent like this for consistency:

Nod

Quoted 8 lines
    # .. note:: A guest may or may not respond to this command.  This
    #    command returning does not indicate that a guest has accepted the
    #    request or that it has gone to sleep.

The same note on system_powerdown additionally has "Many guests will respond to this command by prompting the user in some way." I guess you did not copy this part, because it's not true here. Correct?

Very likely(but ignored indentation).

Don't recall clearly since it has been a while since RFC V1 patch :)

Thanks

Annie

Quoted 25 lines
Quoted 25 lines
qapi/machine.json +9 -0
+#
+# .. qmp-example::
+#
+# -> { "execute": "system_sleep" }
+# <- { "return": {} }
+#
+##
+{ 'command': 'system_sleep' }
+
  ##
  # @system_powerdown:
  #
qapi/pragma.json +1 -0
index 023a2ef7bc..285ce82e9b 100644
@@ -23,6 +23,7 @@
          'set_password',
          'system_powerdown',
          'system_reset',
+        'system_sleep',
          'system_wakeup' ],
      # Commands allowed to return a non-dictionary
      'command-returns-exceptions': [
#26 lore raw
In reply to Annie Li
Quoted 10 lines · On Wed, 28 May 2025 12:35:45 -0400 Annie Li <[email protected]> wrote:

The ACPI sleep button can be implemented as a fixed hardware button or Control Method Sleep button.

The patch of implementing a fixed hardware sleep button was posted here 1). More discussions can be found here 2). Essentially, the discussion mainly focuses on whether the sleep button is implemented as a fixed hardware button or Control Method Sleep button. The latter benefits various architectures since the code can be shared among them.

Quoted 7 lines

This patch set implements Control Method Sleep button for both x86 and microvm. The RFC V1 patch set was posted previously here 3). We rebase all the patches on QEMU9.1.0 and re-post RFC V2 here 4). The RFC V3 patch is based on QEMU 10.0.0-rc3 at 5). This patch set here is rebased on QEMU 10.0.1. The sleep button support for microvm is added, however, its support for ARM platform in V2 is removed due to lower interests of it and more efforts in the firmware.

here we probably need a pointer to these efforts, or some kind of description about what's wrong with ARM/firmare

Quoted 12 lines

For x86, a sleep button GPE event handler is implemented, so a GPE event is triggered to indicate the OSPM the sleep button is pressed. Tests have been done for Linux guest, and Windows Server guest, this sleep button works as expected.

For microvm, a GED event is triggered to notify the OSPM. This GED event is also applicable for ARM platform, as mentioned earlier, the implementation for ARM platform has been removed since RFC V3 patch set. Tests have been run for Linux microvm guests.

Quoted 3 lines

System_wakeup doesn't work for microvm for now due to the missing support of it. This patch set only covers system_sleep, not the wakeup part.

ditto (aka what's wrong with wakeup)

Quoted 96 lines

1) https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg06478.html
2) https://lore.kernel.org/all/[email protected]/T/#mfe24f89778020deeacfe45083f3eea3cf9f55961
3) https://lore.kernel.org/all/[email protected]/T/
4) https://patchwork.kernel.org/project/qemu-devel/cover/[email protected]/
5) https://lore.kernel.org/all/[email protected]/

----Changes from RFC V3----
Improve source code and comment based on comments on RFC V3
---------------------------

Annie Li (12):
acpi: Implement control method sleep button
test/acpi: allow DSDT table changes for x86 platform
acpi: Support Control Method sleep button for x86 tests/qtest/bios-table-tests: Update ACPI table binaries for x86
acpi: Send the GPE event of sleep for x86
test/acpi: allow DSDT table changes for microvm
microvm: Add ACPI Control Method Sleep Button
microvm: enable sleep GED event tests/qtest/bios-table-tests: Update ACPI table binaries for microvm
microvm: suspend the system as requested
microvm: enable suspend
acpi: hmp/qmp: Add hmp/qmp support for system_sleep

Miguel Luis (1):
hw/acpi: Add ACPI GED support for the sleep event

 hmp-commands.hx                               |  14 +++++++
 hw/acpi/control_method_device.c               |  38 ++++++++++++++++++
 hw/acpi/core.c                                |  12 ++++++
 hw/acpi/generic_event_device.c                |  12 ++++++
 hw/acpi/meson.build                           |   1 +
 hw/core/machine-hmp-cmds.c                    |   5 +++
 hw/core/machine-qmp-cmds.c                    |  11 +++++
 hw/i386/acpi-build.c                          |  24 ++++++++++-
 hw/i386/acpi-microvm.c                        |  13 +++++-
 hw/i386/microvm.c                             |   4 +-
 include/hw/acpi/acpi.h                        |   1 +
 include/hw/acpi/acpi_dev_interface.h          |   1 +
 include/hw/acpi/control_method_device.h       |  21 ++++++++++
 include/hw/acpi/generic_event_device.h        |   2 +
 include/monitor/hmp.h                         |   1 +
 qapi/machine.json                             |  20 +++++++++
 qapi/pragma.json                              |   1 +
 tests/data/acpi/x86/microvm/DSDT              | Bin 365 -> 442 bytes
 tests/data/acpi/x86/microvm/DSDT.ioapic2      | Bin 365 -> 442 bytes
 tests/data/acpi/x86/microvm/DSDT.pcie         | Bin 3023 -> 3100 bytes
 tests/data/acpi/x86/microvm/DSDT.rtc          | Bin 404 -> 481 bytes
 tests/data/acpi/x86/microvm/DSDT.usb          | Bin 414 -> 491 bytes
 tests/data/acpi/x86/pc/DSDT                   | Bin 8611 -> 8721 bytes
 tests/data/acpi/x86/pc/DSDT.acpierst          | Bin 8522 -> 8632 bytes
 tests/data/acpi/x86/pc/DSDT.acpihmat          | Bin 9936 -> 10046 bytes
 tests/data/acpi/x86/pc/DSDT.bridge            | Bin 15482 -> 15592 bytes
 tests/data/acpi/x86/pc/DSDT.cphp              | Bin 9075 -> 9185 bytes
 tests/data/acpi/x86/pc/DSDT.dimmpxm           | Bin 10265 -> 10375 bytes
 tests/data/acpi/x86/pc/DSDT.hpbridge          | Bin 8562 -> 8672 bytes
 tests/data/acpi/x86/pc/DSDT.hpbrroot          | Bin 5100 -> 5210 bytes
 tests/data/acpi/x86/pc/DSDT.ipmikcs           | Bin 8683 -> 8793 bytes
 tests/data/acpi/x86/pc/DSDT.memhp             | Bin 9970 -> 10080 bytes
 tests/data/acpi/x86/pc/DSDT.nohpet            | Bin 8469 -> 8579 bytes
 tests/data/acpi/x86/pc/DSDT.numamem           | Bin 8617 -> 8727 bytes
 tests/data/acpi/x86/pc/DSDT.roothp            | Bin 12404 -> 12514 bytes
 tests/data/acpi/x86/q35/DSDT                  | Bin 8440 -> 8550 bytes
 tests/data/acpi/x86/q35/DSDT.acpierst         | Bin 8457 -> 8567 bytes
 tests/data/acpi/x86/q35/DSDT.acpihmat         | Bin 9765 -> 9875 bytes
 .../data/acpi/x86/q35/DSDT.acpihmat-generic-x | Bin 12650 -> 12760 bytes
 .../acpi/x86/q35/DSDT.acpihmat-noinitiator    | Bin 8719 -> 8829 bytes
 tests/data/acpi/x86/q35/DSDT.applesmc         | Bin 8486 -> 8596 bytes
 tests/data/acpi/x86/q35/DSDT.bridge           | Bin 12053 -> 12163 bytes
 tests/data/acpi/x86/q35/DSDT.core-count       | Bin 12998 -> 13108 bytes
 tests/data/acpi/x86/q35/DSDT.core-count2      | Bin 33855 -> 33965 bytes
 tests/data/acpi/x86/q35/DSDT.cphp             | Bin 8904 -> 9014 bytes
 tests/data/acpi/x86/q35/DSDT.cxl              | Bin 13231 -> 13341 bytes
 tests/data/acpi/x86/q35/DSDT.dimmpxm          | Bin 10094 -> 10204 bytes
 tests/data/acpi/x86/q35/DSDT.ipmibt           | Bin 8515 -> 8625 bytes
 tests/data/acpi/x86/q35/DSDT.ipmismbus        | Bin 8528 -> 8638 bytes
 tests/data/acpi/x86/q35/DSDT.ivrs             | Bin 8457 -> 8567 bytes
 tests/data/acpi/x86/q35/DSDT.memhp            | Bin 9799 -> 9909 bytes
 tests/data/acpi/x86/q35/DSDT.mmio64           | Bin 9570 -> 9680 bytes
 tests/data/acpi/x86/q35/DSDT.multi-bridge     | Bin 13293 -> 13403 bytes
 tests/data/acpi/x86/q35/DSDT.noacpihp         | Bin 8302 -> 8412 bytes
 tests/data/acpi/x86/q35/DSDT.nohpet           | Bin 8298 -> 8408 bytes
 tests/data/acpi/x86/q35/DSDT.numamem          | Bin 8446 -> 8556 bytes
 tests/data/acpi/x86/q35/DSDT.pvpanic-isa      | Bin 8541 -> 8651 bytes
 tests/data/acpi/x86/q35/DSDT.thread-count     | Bin 12998 -> 13108 bytes
 tests/data/acpi/x86/q35/DSDT.thread-count2    | Bin 33855 -> 33965 bytes
 tests/data/acpi/x86/q35/DSDT.tis.tpm12        | Bin 9046 -> 9156 bytes
 tests/data/acpi/x86/q35/DSDT.tis.tpm2         | Bin 9072 -> 9182 bytes
 tests/data/acpi/x86/q35/DSDT.type4-count      | Bin 18674 -> 18784 bytes
 tests/data/acpi/x86/q35/DSDT.viot             | Bin 14697 -> 14807 bytes
 tests/data/acpi/x86/q35/DSDT.xapic            | Bin 35803 -> 35913 bytes
 64 files changed, 178 insertions(+), 3 deletions(-)
 create mode 100644 hw/acpi/control_method_device.c
 create mode 100644 include/hw/acpi/control_method_device.h
author
#27 lore raw

Hi Igor,

Quoted 20 lines · Igor Mammedov
Quoted 10 lines · On Wed, 28 May 2025 12:35:45 -0400 Annie Li <[email protected]> wrote:

The ACPI sleep button can be implemented as a fixed hardware button or Control Method Sleep button.

The patch of implementing a fixed hardware sleep button was posted here 1). More discussions can be found here 2). Essentially, the discussion mainly focuses on whether the sleep button is implemented as a fixed hardware button or Control Method Sleep button. The latter benefits various architectures since the code can be shared among them.

Quoted 7 lines

This patch set implements Control Method Sleep button for both x86 and microvm. The RFC V1 patch set was posted previously here 3). We rebase all the patches on QEMU9.1.0 and re-post RFC V2 here 4). The RFC V3 patch is based on QEMU 10.0.0-rc3 at 5). This patch set here is rebased on QEMU 10.0.1. The sleep button support for microvm is added, however, its support for ARM platform in V2 is removed due to lower interests of it and more efforts in the firmware.

Quoted 2 lines

here we probably need a pointer to these efforts, or some kind of description about what's wrong with ARM/firmare

will add more details.

Quoted 11 lines
Quoted 10 lines

For x86, a sleep button GPE event handler is implemented, so a GPE event is triggered to indicate the OSPM the sleep button is pressed. Tests have been done for Linux guest, and Windows Server guest, this sleep button works as expected.

For microvm, a GED event is triggered to notify the OSPM. This GED event is also applicable for ARM platform, as mentioned earlier, the implementation for ARM platform has been removed since RFC V3 patch set. Tests have been run for Linux microvm guests.

Quoted 4 lines
Quoted 3 lines

System_wakeup doesn't work for microvm for now due to the missing support of it. This patch set only covers system_sleep, not the wakeup part.

ditto (aka what's wrong with wakeup)

See the details in patch 12.

Thanks

Annie

Quoted 96 lines
Quoted 96 lines

1) https://urldefense.com/v3/__https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg06478.html__;!!ACWV5N9M2RV99hQ!NOUIn6Z6j3yl9_QWhIIz2b2X6I8pLEHf1biRwOvcRv2_K6VTcVq2KGJmuUE7rcF1VuVjTtLPBvCHid0$
2) https://urldefense.com/v3/__https://lore.kernel.org/all/[email protected]/T/*mfe24f89778020deeacfe45083f3eea3cf9f55961__;Iw!!ACWV5N9M2RV99hQ!NOUIn6Z6j3yl9_QWhIIz2b2X6I8pLEHf1biRwOvcRv2_K6VTcVq2KGJmuUE7rcF1VuVjTtLP4wjsOfs$
3) https://urldefense.com/v3/__https://lore.kernel.org/all/[email protected]/T/__;!!ACWV5N9M2RV99hQ!NOUIn6Z6j3yl9_QWhIIz2b2X6I8pLEHf1biRwOvcRv2_K6VTcVq2KGJmuUE7rcF1VuVjTtLPVmyXvjo$
4) https://urldefense.com/v3/__https://patchwork.kernel.org/project/qemu-devel/cover/[email protected]/__;!!ACWV5N9M2RV99hQ!NOUIn6Z6j3yl9_QWhIIz2b2X6I8pLEHf1biRwOvcRv2_K6VTcVq2KGJmuUE7rcF1VuVjTtLPuuktbj8$
5) https://urldefense.com/v3/__https://lore.kernel.org/all/[email protected]/__;!!ACWV5N9M2RV99hQ!NOUIn6Z6j3yl9_QWhIIz2b2X6I8pLEHf1biRwOvcRv2_K6VTcVq2KGJmuUE7rcF1VuVjTtLP7brAOZg$

----Changes from RFC V3----
Improve source code and comment based on comments on RFC V3
---------------------------

Annie Li (12):
acpi: Implement control method sleep button
test/acpi: allow DSDT table changes for x86 platform
acpi: Support Control Method sleep button for x86 tests/qtest/bios-table-tests: Update ACPI table binaries for x86
acpi: Send the GPE event of sleep for x86
test/acpi: allow DSDT table changes for microvm
microvm: Add ACPI Control Method Sleep Button
microvm: enable sleep GED event tests/qtest/bios-table-tests: Update ACPI table binaries for microvm
microvm: suspend the system as requested
microvm: enable suspend
acpi: hmp/qmp: Add hmp/qmp support for system_sleep

Miguel Luis (1):
hw/acpi: Add ACPI GED support for the sleep event

  hmp-commands.hx                               |  14 +++++++
  hw/acpi/control_method_device.c               |  38 ++++++++++++++++++
  hw/acpi/core.c                                |  12 ++++++
  hw/acpi/generic_event_device.c                |  12 ++++++
  hw/acpi/meson.build                           |   1 +
  hw/core/machine-hmp-cmds.c                    |   5 +++
  hw/core/machine-qmp-cmds.c                    |  11 +++++
  hw/i386/acpi-build.c                          |  24 ++++++++++-
  hw/i386/acpi-microvm.c                        |  13 +++++-
  hw/i386/microvm.c                             |   4 +-
  include/hw/acpi/acpi.h                        |   1 +
  include/hw/acpi/acpi_dev_interface.h          |   1 +
  include/hw/acpi/control_method_device.h       |  21 ++++++++++
  include/hw/acpi/generic_event_device.h        |   2 +
  include/monitor/hmp.h                         |   1 +
  qapi/machine.json                             |  20 +++++++++
  qapi/pragma.json                              |   1 +
  tests/data/acpi/x86/microvm/DSDT              | Bin 365 -> 442 bytes
  tests/data/acpi/x86/microvm/DSDT.ioapic2      | Bin 365 -> 442 bytes
  tests/data/acpi/x86/microvm/DSDT.pcie         | Bin 3023 -> 3100 bytes
  tests/data/acpi/x86/microvm/DSDT.rtc          | Bin 404 -> 481 bytes
  tests/data/acpi/x86/microvm/DSDT.usb          | Bin 414 -> 491 bytes
  tests/data/acpi/x86/pc/DSDT                   | Bin 8611 -> 8721 bytes
  tests/data/acpi/x86/pc/DSDT.acpierst          | Bin 8522 -> 8632 bytes
  tests/data/acpi/x86/pc/DSDT.acpihmat          | Bin 9936 -> 10046 bytes
  tests/data/acpi/x86/pc/DSDT.bridge            | Bin 15482 -> 15592 bytes
  tests/data/acpi/x86/pc/DSDT.cphp              | Bin 9075 -> 9185 bytes
  tests/data/acpi/x86/pc/DSDT.dimmpxm           | Bin 10265 -> 10375 bytes
  tests/data/acpi/x86/pc/DSDT.hpbridge          | Bin 8562 -> 8672 bytes
  tests/data/acpi/x86/pc/DSDT.hpbrroot          | Bin 5100 -> 5210 bytes
  tests/data/acpi/x86/pc/DSDT.ipmikcs           | Bin 8683 -> 8793 bytes
  tests/data/acpi/x86/pc/DSDT.memhp             | Bin 9970 -> 10080 bytes
  tests/data/acpi/x86/pc/DSDT.nohpet            | Bin 8469 -> 8579 bytes
  tests/data/acpi/x86/pc/DSDT.numamem           | Bin 8617 -> 8727 bytes
  tests/data/acpi/x86/pc/DSDT.roothp            | Bin 12404 -> 12514 bytes
  tests/data/acpi/x86/q35/DSDT                  | Bin 8440 -> 8550 bytes
  tests/data/acpi/x86/q35/DSDT.acpierst         | Bin 8457 -> 8567 bytes
  tests/data/acpi/x86/q35/DSDT.acpihmat         | Bin 9765 -> 9875 bytes
  .../data/acpi/x86/q35/DSDT.acpihmat-generic-x | Bin 12650 -> 12760 bytes
  .../acpi/x86/q35/DSDT.acpihmat-noinitiator    | Bin 8719 -> 8829 bytes
  tests/data/acpi/x86/q35/DSDT.applesmc         | Bin 8486 -> 8596 bytes
  tests/data/acpi/x86/q35/DSDT.bridge           | Bin 12053 -> 12163 bytes
  tests/data/acpi/x86/q35/DSDT.core-count       | Bin 12998 -> 13108 bytes
  tests/data/acpi/x86/q35/DSDT.core-count2      | Bin 33855 -> 33965 bytes
  tests/data/acpi/x86/q35/DSDT.cphp             | Bin 8904 -> 9014 bytes
  tests/data/acpi/x86/q35/DSDT.cxl              | Bin 13231 -> 13341 bytes
  tests/data/acpi/x86/q35/DSDT.dimmpxm          | Bin 10094 -> 10204 bytes
  tests/data/acpi/x86/q35/DSDT.ipmibt           | Bin 8515 -> 8625 bytes
  tests/data/acpi/x86/q35/DSDT.ipmismbus        | Bin 8528 -> 8638 bytes
  tests/data/acpi/x86/q35/DSDT.ivrs             | Bin 8457 -> 8567 bytes
  tests/data/acpi/x86/q35/DSDT.memhp            | Bin 9799 -> 9909 bytes
  tests/data/acpi/x86/q35/DSDT.mmio64           | Bin 9570 -> 9680 bytes
  tests/data/acpi/x86/q35/DSDT.multi-bridge     | Bin 13293 -> 13403 bytes
  tests/data/acpi/x86/q35/DSDT.noacpihp         | Bin 8302 -> 8412 bytes
  tests/data/acpi/x86/q35/DSDT.nohpet           | Bin 8298 -> 8408 bytes
  tests/data/acpi/x86/q35/DSDT.numamem          | Bin 8446 -> 8556 bytes
  tests/data/acpi/x86/q35/DSDT.pvpanic-isa      | Bin 8541 -> 8651 bytes
  tests/data/acpi/x86/q35/DSDT.thread-count     | Bin 12998 -> 13108 bytes
  tests/data/acpi/x86/q35/DSDT.thread-count2    | Bin 33855 -> 33965 bytes
  tests/data/acpi/x86/q35/DSDT.tis.tpm12        | Bin 9046 -> 9156 bytes
  tests/data/acpi/x86/q35/DSDT.tis.tpm2         | Bin 9072 -> 9182 bytes
  tests/data/acpi/x86/q35/DSDT.type4-count      | Bin 18674 -> 18784 bytes
  tests/data/acpi/x86/q35/DSDT.viot             | Bin 14697 -> 14807 bytes
  tests/data/acpi/x86/q35/DSDT.xapic            | Bin 35803 -> 35913 bytes
  64 files changed, 178 insertions(+), 3 deletions(-)

create mode 100644 hw/acpi/control_method_device.c create mode 100644 include/hw/acpi/control_method_device.h