Skip to content

Qemu acpi devs v3#3

Closed
blochl wants to merge 4 commits intomasterfrom
qemu-acpi-devs-v2
Closed

Qemu acpi devs v3#3
blochl wants to merge 4 commits intomasterfrom
qemu-acpi-devs-v2

Conversation

@blochl
Copy link
Copy Markdown
Owner

@blochl blochl commented Aug 27, 2025

No description provided.

blochl added 4 commits August 28, 2025 00:14
This patch extends the GPE (General Purpose Event) handling to support
the maximum number of interrupts available based on the machine's GPE
register length, rather than being limited to the first 8 bits.

This change is needed to support additional ACPI devices that will be
introduced in subsequent patches (Battery, AC adapter, and button devices).
These new devices require GPE event bits beyond the first 8, which were
previously not being properly handled by the event sending and SCI
(System Control Interrupt) update mechanisms.

The actual number of available GPE interrupts varies by machine type:
- PIIX4: GPE_LEN = 4 (32 bits total across status and enable registers)
- ICH9: ICH9_PMIO_GPE0_LEN = 16 (128 bits total)

The patch modifies:
- acpi_send_gpe_event(): Now properly propagates status bits across all
  available GPE registers based on the machine's gpe.len value
- acpi_update_sci(): Checks all GPE registers for pending interrupts,
  not just the first byte

Note: A future enhancement could refactor the GPE handling to use the
bitmap API from bitops.h instead of the current manual bit manipulation,
which would provide a cleaner interface for these operations.

Signed-off-by: Leonid Bloch <lb.workbox@gmail.com>
The battery device communicates battery state to the guest via ACPI.
It supports two modes of operation:

1. QMP control mode (default): Battery state is controlled programmatically
   via QMP commands, making the device deterministic and migration-safe.

2. Host mirroring mode (optional): The device reflects the host's battery
   state from sysfs. Probing occurs on guest ACPI requests and at timed
   intervals (default 2 seconds, configurable via 'probe_interval' property
   in milliseconds). State changes trigger ACPI notifications to the guest.

Properties:
- 'use-qmp': Enable QMP control mode (default: true)
- 'enable-sysfs': Enable host battery mirroring (default: false)
- 'probe_interval': Probe interval in ms for sysfs mode (default: 2000)
- 'sysfs_path': Override default sysfs path /sys/class/power_supply/

The device implements the ACPI_DEV_AML_IF interface to generate its
own AML code, placing the BAT0 device directly under \_SB scope as
per ACPI specification.

QMP commands:
- battery-set-state: Set battery state (present, charging, capacity, rate)
- query-battery: Query current battery state

This allows testing without host battery access and provides a stable
interface for virtualization management systems.

Signed-off-by: Leonid Bloch <lb.workbox@gmail.com>
Signed-off-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
The AC adapter device communicates AC power state to the guest via ACPI.
It supports two modes of operation:

1. QMP control mode (default): AC adapter state is controlled
   programmatically via QMP commands, ensuring deterministic behavior.

2. Host mirroring mode (optional): The device reflects the host's AC
   adapter state from sysfs. Probing occurs on guest ACPI requests and
   at timed intervals. State changes trigger ACPI notifications.

Properties:
- 'use-qmp': Enable QMP control mode (default: true)
- 'enable-sysfs': Enable host AC adapter mirroring (default: false)
- 'probe_interval': Probe interval in ms for sysfs mode (default: 2000)
- 'sysfs_path': Override default sysfs path /sys/class/power_supply/

The device implements the ACPI_DEV_AML_IF interface to generate its
own AML code, placing the ADP0 device directly under \_SB scope.

QMP commands:
- ac-adapter-set-state: Set AC adapter connection state
- query-ac-adapter: Query current AC adapter state

Signed-off-by: Leonid Bloch <lb.workbox@gmail.com>
The lid button device communicates laptop lid state to the guest via ACPI.
It supports two modes of operation:

1. QMP control mode (default): Lid state is controlled programmatically
   via QMP commands for consistent behavior across environments.

2. Host mirroring mode (optional): The device reflects the host's lid
   button state from procfs (/proc/acpi/button/lid/*/state). State
   changes trigger ACPI notifications to the guest.

Properties:
- 'use-qmp': Enable QMP control mode (default: true)
- 'enable-procfs': Enable host lid button mirroring (default: false)
- 'probe_interval': Probe interval in ms for procfs mode (default: 2000)
- 'procfs_path': Override default procfs path /proc/acpi/button

The device implements the ACPI_DEV_AML_IF interface to generate its
own AML code, placing the LID0 device directly under \_SB scope.

QMP commands:
- lid-button-set-state: Set lid open/closed state
- query-lid-button: Query current lid state

Signed-off-by: Leonid Bloch <lb.workbox@gmail.com>
@github-actions
Copy link
Copy Markdown

Thank you for your interest in the QEMU project.

This repository is a read-only mirror of the project's repostories hosted
on https://gitlab.com/qemu-project/qemu.git.
The project does not process merge requests filed on GitHub.

QEMU welcomes contributions of code (either fixing bugs or adding new
functionality). However, we get a lot of patches, and so we have some
guidelines about contributing on the project website:
https://www.qemu.org/contribute/

@github-actions github-actions bot closed this Aug 27, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Aug 27, 2025
@blochl blochl deleted the qemu-acpi-devs-v2 branch October 29, 2025 14:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant