From: "Chalios, Babis" <bchalios@amazon.es>
To: "mst@redhat.com" <mst@redhat.com>,
"imammedo@redhat.com" <imammedo@redhat.com>,
"cohuck@redhat.com" <cohuck@redhat.com>,
"pbonzini@redhat.com" <pbonzini@redhat.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"dwmw2@infradead.org" <dwmw2@infradead.org>,
"Chalios, Babis" <bchalios@amazon.es>, "Graf (AWS),
Alexander" <graf@amazon.de>,
"mzxreary@0pointer.de" <mzxreary@0pointer.de>
Subject: [RFC PATCH 4/4] hw/acpi: add ACPI notification to VMClock device
Date: Mon, 1 Dec 2025 12:51:22 +0000 [thread overview]
Message-ID: <20251201125023.18344-6-bchalios@amazon.es> (raw)
In-Reply-To: <20251201125023.18344-1-bchalios@amazon.es>
Extend VMClock device to send an ACPI notification every time the
seqcount changes to a new even value. Use GPE E08 event, which now
becomes part of the guest ABI.
Signed-off-by: Babis Chalios <bchalios@amazon.es>
---
hw/acpi/vmclock.c | 17 +++++++++++++++--
include/hw/acpi/acpi_dev_interface.h | 1 +
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/hw/acpi/vmclock.c b/hw/acpi/vmclock.c
index 47cbba4496..f6f242cb66 100644
--- a/hw/acpi/vmclock.c
+++ b/hw/acpi/vmclock.c
@@ -28,7 +28,7 @@
void vmclock_build_acpi(VmclockState *vms, GArray *table_data,
BIOSLinker *linker, const char *oem_id)
{
- Aml *ssdt, *dev, *scope, *crs;
+ Aml *ssdt, *dev, *scope, *crs, *method;
AcpiTable table = { .sig = "SSDT", .rev = 1,
.oem_id = oem_id, .oem_table_id = "VMCLOCK" };
@@ -57,6 +57,11 @@ void vmclock_build_acpi(VmclockState *vms, GArray *table_data,
aml_append(scope, dev);
aml_append(ssdt, scope);
+ /* Attach an ACPI notify */
+ method = aml_method("\\_GPE._E08", 0, AML_NOTSERIALIZED);
+ aml_append(method, aml_notify(aml_name("\\_SB.VCLK"), aml_int(0x80)));
+ aml_append(ssdt, method);
+
g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len);
acpi_table_end(linker, &table);
free_aml_allocator();
@@ -67,6 +72,10 @@ static void vmclock_update_guest(VmclockState *vms)
uint64_t disruption_marker;
uint64_t vm_generation_counter;
uint32_t seq_count;
+ Object *obj = object_resolve_path_type("", TYPE_ACPI_DEVICE_IF, NULL);
+ if (!obj) {
+ return;
+ }
if (!vms->clk) {
return;
@@ -94,6 +103,9 @@ static void vmclock_update_guest(VmclockState *vms)
/* These barriers pair with read barriers in the guest */
smp_wmb();
vms->clk->seq_count = cpu_to_le32(seq_count + 1);
+
+ /* Send _GPE.E08 event */
+ acpi_send_event(DEVICE(obj), ACPI_VMCLOCK_CHANGE_STATUS);
}
/*
@@ -156,7 +168,8 @@ static void vmclock_realize(DeviceState *dev, Error **errp)
vms->clk->magic = cpu_to_le32(VMCLOCK_MAGIC);
vms->clk->size = cpu_to_le16(VMCLOCK_SIZE);
vms->clk->version = cpu_to_le16(1);
- vms->clk->flags = cpu_to_le64(VMCLOCK_FLAG_VM_GEN_COUNTER_PRESENT);
+ vms->clk->flags = cpu_to_le64(VMCLOCK_FLAG_VM_GEN_COUNTER_PRESENT |
+ VMCLOCK_FLAG_NOTIFICATION_PRESENT);
/* These are all zero and thus default, but be explicit */
vms->clk->clock_status = VMCLOCK_STATUS_UNKNOWN;
diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
index 8294f8f0cc..f51f6065f9 100644
--- a/include/hw/acpi/acpi_dev_interface.h
+++ b/include/hw/acpi/acpi_dev_interface.h
@@ -14,6 +14,7 @@ typedef enum {
ACPI_VMGENID_CHANGE_STATUS = 32,
ACPI_POWER_DOWN_STATUS = 64,
ACPI_GENERIC_ERROR = 128,
+ ACPI_VMCLOCK_CHANGE_STATUS = 256,
} AcpiEventStatusBits;
#define TYPE_ACPI_DEVICE_IF "acpi-device-interface"
--
2.34.1
next prev parent reply other threads:[~2025-12-01 12:52 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 12:50 [RFC PATCH 0/4] vmclock: add support for VM generation counter and notifications Chalios, Babis
2025-12-01 12:50 ` Chalios, Babis
2025-12-01 12:52 ` Babis Chalios
2025-12-01 12:50 ` [RFC PATCH 1/4] acpi: fix acpi_send_gpe_event() to handle more events Chalios, Babis
2025-12-01 12:50 ` [RFC PATCH 2/4] hw/acpi: add new fields in VMClock ABI Chalios, Babis
2025-12-01 13:04 ` Cornelia Huck
2025-12-01 13:11 ` Babis Chalios
2025-12-01 13:36 ` Cornelia Huck
2025-12-01 13:24 ` David Woodhouse
2025-12-01 13:38 ` Cornelia Huck
2025-12-01 14:27 ` David Woodhouse
2025-12-01 15:05 ` Babis Chalios
2025-12-01 15:21 ` David Woodhouse
2025-12-01 15:10 ` Cornelia Huck
2025-12-01 12:51 ` [RFC PATCH 3/4] hw/acpi: add VM generation counter field to VMClock Chalios, Babis
2025-12-01 14:12 ` Daniel P. Berrangé
2025-12-01 14:29 ` David Woodhouse
2025-12-01 14:41 ` Daniel P. Berrangé
2025-12-01 15:01 ` Babis Chalios
2025-12-01 15:28 ` David Woodhouse
2025-12-01 12:51 ` Chalios, Babis [this message]
2025-12-01 15:10 ` [RFC PATCH 0/4] vmclock: add support for VM generation counter and notifications Daniel P. Berrangé
2025-12-01 15:23 ` David Woodhouse
2025-12-01 15:46 ` Babis Chalios
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251201125023.18344-6-bchalios@amazon.es \
--to=bchalios@amazon.es \
--cc=cohuck@redhat.com \
--cc=dwmw2@infradead.org \
--cc=graf@amazon.de \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=mzxreary@0pointer.de \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).