From nobody Mon Feb 9 18:44:47 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1770384138; cv=none; d=zohomail.com; s=zohoarc; b=Zj5Tvs0NlZfJZisqC3C+Q7pC+CgmopAd2dC0pSJ3+JoD2vhSeAyQx7gfHoQAi8FDOZW2FwzUF3FcOyfYTFAPGwrG0MPdUzudlovMNtsMjnrHjBMYUCzm+FTjMyB62Us++xCmr0+LOtiuxNTWEOzc7qyYYJNb6Z2lgwUwfVZrogU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770384138; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lnKc8ChwALLEnut766Pw5c8QdTxY5iSz14xAR+/k7/M=; b=CtS9KKtLmoVG0sQpAjd8TTM8Q5bKfC2VrsfQtsy7Rt9d2mF+cka6gS21BCjlOhMY8hcUjloX13K8mIvVDXtJzp1AyO+OfoK0No5146ZV+84auhd67ZE6b0JLMRQVxnt9hOjYo0Hb1VK6t0lDMng6yI0JWi+kQz58TsxUFUQMFcI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177038413891486.22563871924888; Fri, 6 Feb 2026 05:22:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1voLlA-00070P-GP; Fri, 06 Feb 2026 08:20:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1voLkp-0006q5-CJ for qemu-devel@nongnu.org; Fri, 06 Feb 2026 08:20:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1voLkm-0005bD-JZ for qemu-devel@nongnu.org; Fri, 06 Feb 2026 08:20:11 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-390-Ljm4MYWiP9Ck8oi_gM0seQ-1; Fri, 06 Feb 2026 08:15:00 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5542119540FE; Fri, 6 Feb 2026 13:14:52 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 072BD1800352; Fri, 6 Feb 2026 13:14:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770384006; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lnKc8ChwALLEnut766Pw5c8QdTxY5iSz14xAR+/k7/M=; b=fzT74PAaAdHFBqMy9Ms1/k/U0dl9pkCjU3I0+QRu0iO1RuUalCxvEmfuUNQmp+GwJVJmQo rdMJ355yVWBRSapFads7Jljetv/1ehPLNz9GjyTswe548dYnxAxrYyIQxI1bSzX7ySpigX m5H+CMhQ8VzHNkBjVUcwd6VDBZup5BA= X-MC-Unique: Ljm4MYWiP9Ck8oi_gM0seQ-1 X-Mimecast-MFC-AGG-ID: Ljm4MYWiP9Ck8oi_gM0seQ_1770383698 From: Igor Mammedov To: qemu-devel@nongnu.org Cc: mst@redhat.com, anisinha@redhat.com, pbonzini@redhat.com, peter.maydell@linaro.org, shannon.zhaosl@gmail.com, philmd@linaro.org, zhao1.liu@intel.com, rad@semihalf.com, leif.lindholm@oss.qualcomm.com Subject: [PATCH 03/11] x86: q35: generate WDAT ACPI table Date: Fri, 6 Feb 2026 14:14:30 +0100 Message-ID: <20260206131438.1857182-4-imammedo@redhat.com> In-Reply-To: <20260206131438.1857182-1-imammedo@redhat.com> References: <20260206131438.1857182-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1770384141942154100 It will generate WDAT table [1] customized for TCO watchdog. This allows Windows guests (Windows Server 2008/Vista+) to use TCO watchdog using built-in generic driver, which aleviates need to install vendor specific drivers. Given that enabling it might change guest behaviour (both Windows/Linux) the feature is disabled by default. Users that need it can enable the feature with following CLI option. -machine 'acpi-watchdog=3Don' 1) "Hardware Watchdog Timers Design=C2=A0Specification" https://uefi.org/acpi 'Watchdog Action Table (WDAT)' Signed-off-by: Igor Mammedov --- include/hw/acpi/wdat-ich9.h | 15 +++++++ hw/acpi/meson.build | 3 +- hw/acpi/wdat-ich9-stub.c | 15 +++++++ hw/acpi/wdat-ich9.c | 87 +++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 12 +++++ 5 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 include/hw/acpi/wdat-ich9.h create mode 100644 hw/acpi/wdat-ich9-stub.c create mode 100644 hw/acpi/wdat-ich9.c diff --git a/include/hw/acpi/wdat-ich9.h b/include/hw/acpi/wdat-ich9.h new file mode 100644 index 0000000000..60a2a6a112 --- /dev/null +++ b/include/hw/acpi/wdat-ich9.h @@ -0,0 +1,15 @@ +/* + * Copyright Red Hat, Inc. 2026 + * Author(s): Igor Mammedov + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef QEMU_HW_ACPI_WDAT_ICH9_H +#define QEMU_HW_ACPI_WDAT_ICH9_H + +#include "hw/acpi/aml-build.h" + +void build_ich9_wdat(GArray *table_data, BIOSLinker *linker, const char *o= em_id, + const char *oem_table_id, uint64_t tco_base); + +#endif /* QEMU_HW_ACPI_WDAT_ICH9_H */ diff --git a/hw/acpi/meson.build b/hw/acpi/meson.build index 56b5d1ec96..ba974b2f0f 100644 --- a/hw/acpi/meson.build +++ b/hw/acpi/meson.build @@ -24,7 +24,7 @@ acpi_ss.add(when: 'CONFIG_ACPI_PCI_BRIDGE', if_true: file= s('pci-bridge.c')) acpi_ss.add(when: 'CONFIG_ACPI_PCIHP', if_true: files('pcihp.c')) acpi_ss.add(when: 'CONFIG_ACPI_PCIHP', if_false: files('acpi-pci-hotplug-s= tub.c')) acpi_ss.add(when: 'CONFIG_ACPI_VIOT', if_true: files('viot.c')) -acpi_ss.add(when: 'CONFIG_ACPI_ICH9', if_true: files('ich9.c', 'ich9_tco.c= ', 'ich9_timer.c')) +acpi_ss.add(when: 'CONFIG_ACPI_ICH9', if_true: files('ich9.c', 'ich9_tco.c= ', 'ich9_timer.c', 'wdat-ich9.c')) acpi_ss.add(when: 'CONFIG_ACPI_ERST', if_true: files('erst.c')) acpi_ss.add(when: 'CONFIG_IPMI', if_true: files('ipmi.c'), if_false: files= ('ipmi-stub.c')) acpi_ss.add(when: 'CONFIG_PC', if_false: files('acpi-x86-stub.c')) @@ -33,6 +33,7 @@ if have_tpm endif system_ss.add(when: 'CONFIG_ACPI', if_false: files('acpi-stub.c', 'aml-bui= ld-stub.c', 'ghes-stub.c', 'acpi_interface.c')) system_ss.add(when: 'CONFIG_ACPI_PCI_BRIDGE', if_false: files('pci-bridge-= stub.c')) +system_ss.add(when: 'CONFIG_ACPI_ICH9', if_false: files('wdat-ich9-stub.c'= )) system_ss.add_all(when: 'CONFIG_ACPI', if_true: acpi_ss) system_ss.add(when: 'CONFIG_GHES_CPER', if_true: files('ghes_cper.c')) system_ss.add(when: 'CONFIG_GHES_CPER', if_false: files('ghes_cper_stub.c'= )) diff --git a/hw/acpi/wdat-ich9-stub.c b/hw/acpi/wdat-ich9-stub.c new file mode 100644 index 0000000000..7c30ef3558 --- /dev/null +++ b/hw/acpi/wdat-ich9-stub.c @@ -0,0 +1,15 @@ +/* + * Copyright Red Hat, Inc. 2026 + * Author(s): Igor Mammedov + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/acpi/wdat-ich9.h" + +void build_ich9_wdat(GArray *table_data, BIOSLinker *linker, const char *o= em_id, + const char *oem_table_id, uint64_t tco_base) +{ + g_assert_not_reached(); +} diff --git a/hw/acpi/wdat-ich9.c b/hw/acpi/wdat-ich9.c new file mode 100644 index 0000000000..b1930dc71d --- /dev/null +++ b/hw/acpi/wdat-ich9.c @@ -0,0 +1,87 @@ +/* + * TCO Watchdog Action Table (WDAT) + * + * Copyright Red Hat, Inc. 2026 + * Author(s): Igor Mammedov + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/acpi/wdat.h" +#include "hw/acpi/wdat-ich9.h" +#include "hw/southbridge/ich9.h" + +#define TCO_REG(base, reg_offset, reg_width) { .space_id =3D AML_AS_SYSTEM= _IO, \ + .address =3D base + reg_offset, .bit_width =3D reg_width, \ + .access_width =3D AML_WORD_ACC, }; + +/* + * "Hardware Watchdog Timers Design=C2=A0Specification" + * https://uefi.org/acpi 'Watchdog Action Table (WDAT)' + * + * ICH9 specific implementation. + */ +void build_ich9_wdat(GArray *table_data, BIOSLinker *linker, const char *o= em_id, + const char *oem_table_id, uint64_t tco_base) +{ + AcpiTable table =3D { .sig =3D "WDAT", .rev =3D 1, .oem_id =3D oem_id, + .oem_table_id =3D oem_table_id }; + struct AcpiGenericAddress tco_rld =3D TCO_REG(tco_base, 0x0, 16); + struct AcpiGenericAddress tco2_sts =3D TCO_REG(tco_base, 0x6, 16); + struct AcpiGenericAddress tco1_cnt =3D TCO_REG(tco_base, 0x8, 16); + struct AcpiGenericAddress tco_tmr =3D TCO_REG(tco_base, 0x12, 16); + + acpi_table_begin(&table, table_data); + build_append_int_noprefix(table_data, 0x20, 4); /* Watchdog Header Len= gth */ + build_append_int_noprefix(table_data, 0xff, 2); /* PCI Segment */ + build_append_int_noprefix(table_data, 0xff, 1); /* PCI Bus Number */ + build_append_int_noprefix(table_data, 0xff, 1); /* PCI Device Number */ + build_append_int_noprefix(table_data, 0xff, 1); /* PCI Function Number= */ + build_append_int_noprefix(table_data, 0, 3); /* Reserved */ + build_append_int_noprefix(table_data, 0x258, 4);/* Timer Period, ms */ + build_append_int_noprefix(table_data, 0x3ff, 4);/* Maximum Count */ + build_append_int_noprefix(table_data, 0x4, 4); /* Minimum Count */ + /* + * WATCHDOG_ENABLED & WATCHDOG_STOPPED_IN_SLEEP_STATE + */ + build_append_int_noprefix(table_data, 0x81, 1); /* Watchdog Flags */ + build_append_int_noprefix(table_data, 0, 3); /* Reserved */ + /* + * watchdog instruction entries + */ + build_append_int_noprefix(table_data, 10, 4); + /* Action table */ + build_append_wdat_ins(table_data, WDAT_ACTION_RESET, + WDAT_INS_WRITE_VALUE, + tco_rld, 0x1, 0x1ff); + build_append_wdat_ins(table_data, WDAT_ACTION_QUERY_RUNNING_STATE, + WDAT_INS_READ_VALUE, + tco1_cnt, 0x0, 0x800); + build_append_wdat_ins(table_data, WDAT_ACTION_SET_RUNNING_STATE, + WDAT_INS_WRITE_VALUE | WDAT_INS_PRESERVE_REGISTER, + tco1_cnt, 0, 0x800); + build_append_wdat_ins(table_data, WDAT_ACTION_QUERY_STOPPED_STATE, + WDAT_INS_READ_VALUE, + tco1_cnt, 0x800, 0x800); + build_append_wdat_ins(table_data, WDAT_ACTION_SET_STOPPED_STATE, + WDAT_INS_WRITE_VALUE | WDAT_INS_PRESERVE_REGISTER, + tco1_cnt, 0x800, 0x800); + build_append_wdat_ins(table_data, WDAT_ACTION_SET_COUNTDOWN_PERIOD, + WDAT_INS_WRITE_COUNTDOWN, + tco_tmr, 0x0, 0x3FF); + build_append_wdat_ins(table_data, WDAT_ACTION_QUERY_COUNTDOWN_PERIOD, + WDAT_INS_READ_COUNTDOWN, + tco_tmr, 0x0, 0x3FF); + build_append_wdat_ins(table_data, WDAT_ACTION_QUERY_WATCHDOG_STATUS, + WDAT_INS_READ_VALUE, + tco2_sts, 0x2, 0x2); + build_append_wdat_ins(table_data, WDAT_ACTION_SET_WATCHDOG_STATUS, + WDAT_INS_WRITE_VALUE | WDAT_INS_PRESERVE_REGISTER, + tco2_sts, 0x2, 0x2); + build_append_wdat_ins(table_data, WDAT_ACTION_SET_WATCHDOG_STATUS, + WDAT_INS_WRITE_VALUE | WDAT_INS_PRESERVE_REGISTER, + tco2_sts, 0x4, 0x4); + + acpi_table_end(linker, &table); +} diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 19c62362e3..abb3e936fd 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -77,6 +77,7 @@ =20 #include "hw/acpi/hmat.h" #include "hw/acpi/viot.h" +#include "hw/acpi/wdat-ich9.h" =20 #include CONFIG_DEVICES =20 @@ -109,6 +110,7 @@ typedef struct AcpiPmInfo { uint16_t cpu_hp_io_base; uint16_t pcihp_io_base; uint16_t pcihp_io_len; + uint64_t tco_io_base; } AcpiPmInfo; =20 typedef struct AcpiMiscInfo { @@ -203,6 +205,7 @@ static void acpi_get_pm_info(MachineState *machine, Acp= iPmInfo *pm) pm->pcihp_io_len =3D 0; pm->smi_on_cpuhp =3D false; pm->smi_on_cpu_unplug =3D false; + pm->tco_io_base =3D 0; =20 assert(obj); init_common_fadt_data(machine, obj, &pm->fadt); @@ -224,6 +227,8 @@ static void acpi_get_pm_info(MachineState *machine, Acp= iPmInfo *pm) !!(smi_features & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT)); pm->smi_on_cpu_unplug =3D !!(smi_features & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT)); + pm->tco_io_base =3D object_property_get_uint(obj, ACPI_PM_PROP_PM_= IO_BASE, + NULL) + ICH9_PMIO_TCO_RLD; } pm->pcihp_io_base =3D object_property_get_uint(obj, ACPI_PCIHP_IO_BASE_PROP, NULL); @@ -2079,6 +2084,13 @@ void acpi_build(AcpiBuildTables *tables, MachineStat= e *machine) acpi_add_table(table_offsets, tables_blob); build_waet(tables_blob, tables->linker, x86ms->oem_id, x86ms->oem_tabl= e_id); =20 + if (machine->acpi_watchdog) { + g_assert(pm.tco_io_base); + acpi_add_table(table_offsets, tables_blob); + build_ich9_wdat(tables_blob, tables->linker, x86ms->oem_id, + x86ms->oem_table_id, pm.tco_io_base); + } + /* Add tables supplied by user (if any) */ for (u =3D acpi_table_first(); u; u =3D acpi_table_next(u)) { unsigned len =3D acpi_table_len(u); --=20 2.47.3