Skip to content

Introduce ACPI watchdog for Q35 and arm/virt boards

Igor Mammedov qemu-arm qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest21 patches 44 repliesIn review
  2. v111 patches 35 repliesSuperseded

Changes in v2 from the cover letter

* ditch generic '-machine acpi-watchdog' option in favor of board specific variants:
x86/q35: -machine wdat={on|off}
arm/virt: -device sbsa_gwdt,wdat={on|off}
* arm/virt: add FDT and GTDT ACPI entries for GWDT when it's present and hide GDTD one when WDAT is enabled.
* arm/virt: add test case for GTDT
* [18-21] optional GWDT cleanup/fixes in handling WCV register update, make QEMU behave according to spec (at least the way I read it and it appears MS also read it that way). It fixes Windows 11 reboots when GWDT is present (without WDAT). With that fixed it's up to MS to fix their driver to set sane timeout as with the current one wdatchdog will never trigger.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/21acpi: add API to build WDAT instructionshw/acpi/aml-build.c include/hw/acpi/wdat.h+132 -02 replies
2/21x86: q35: add 'wdat' propertyhw/i386/pc_q35.c include/hw/i386/pc.h+19 -02 replies
3/21x86: q35: generate WDAT ACPI tablehw/acpi/meson.build hw/acpi/wdat-ich9-stub.c hw/acpi/wdat-ich9.c +2 more+134 -13 replies
4/21tests: acpi: x86/q35: whitelist new WDAT tabletests/data/acpi/x86/q35/WDAT.wdat tests/qtest/bios-tables-test-allowed-diff.h+1 -01 reply
5/21tests: acpi: x86/q35: add WDAT table test casetests/qtest/bios-tables-test.c+13 -01 reply
6/21tests: acpi: x86/q35: update expected WDAT blobtests/data/acpi/x86/q35/WDAT.wdat tests/qtest/bios-tables-test-allowed-diff.h+0 -11 reply
7/21arm: sbsa_gwdt: fixup default "clock-frequency"hw/watchdog/sbsa_gwdt.c+2 -35 replies
8/21arm: add tracing events to sbsa_gwdthw/watchdog/sbsa_gwdt.c hw/watchdog/trace-events+17 -01 reply
9/21arm: virt: create sbsa_gwdt watchdoghw/arm/Kconfig hw/arm/virt-acpi-build.c hw/arm/virt.c +2 more+67 -210 replies
10/21arm: sbsa_gwdt: add 'wdat' optionhw/watchdog/sbsa_gwdt.c include/hw/watchdog/sbsa_gwdt.h+9 -03 replies
11/21arm: virt: add support for WDAT based watchdoghw/acpi/meson.build hw/acpi/wdat-gwdt-stub.c hw/acpi/wdat-gwdt.c +2 more+172 -152 replies
12/21tests: acpi: arm/virt: whitelist new WDAT tabletests/data/acpi/aarch64/virt/WDAT.wdat tests/qtest/bios-tables-test-allowed-diff.h+1 -01 reply
13/21tests: acpi: arm/virt: add WDAT table test casetests/qtest/bios-tables-test.c+21 -01 reply
14/21tests: acpi: arm/virt: update expected WDAT blobtests/data/acpi/aarch64/virt/WDAT.wdat tests/qtest/bios-tables-test-allowed-diff.h+0 -10 replies
15/21tests: acpi: arm/virt: whitelist GTDT tabletests/qtest/bios-tables-test-allowed-diff.h+1 -01 reply
16/21tests: acpi: arm/virt: add GTDT watchdog table test casetests/qtest/bios-tables-test.c+20 -03 replies
17/21tests: acpi: arm/virt: update expected GTDT blobtests/data/acpi/aarch64/virt/GTDT.gwdt tests/qtest/bios-tables-test-allowed-diff.h+0 -11 reply
18/21sbsa_gwdt: reduce code identhw/watchdog/sbsa_gwdt.c+20 -181 reply
19/21sbsa_gwdt: move all foo_REFRESH logic under REFRESH conditionhw/watchdog/sbsa_gwdt.c+9 -110 replies
20/21sbsa_gwdt: reschedule timer on direct WCV loadhw/watchdog/sbsa_gwdt.c+7 -20 replies
21/21sbsa_gwdt: limit compare_value to INT64_MAXhw/watchdog/sbsa_gwdt.c+2 -00 replies

Reviews trailers per patch

15 of 21 patches have a Reviewed-by or Acked-by.

PatchAni SinhaZhao LiuEric Auger
1/21R-b R-b R-b
2/21R-b R-b
3/21R-b R-b
4/21A-b R-b
5/21R-b R-b
6/21A-b R-b
7/21R-b
8/21R-b R-b
9/21
10/21R-b
11/21
12/21R-b
13/21R-b
14/21
15/21R-b
16/21R-b
17/21R-b
18/21R-b
19/21
20/21
21/21

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 00/21] Introduce ACPI watchdog for Q35 and arm/virt boards

Changelog:
v2:
* ditch generic '-machine acpi-watchdog' option in favor of board specific variants:
x86/q35: -machine wdat={on|off}
arm/virt: -device sbsa_gwdt,wdat={on|off}
* arm/virt: add FDT and GTDT ACPI entries for GWDT when it's present and hide GDTD one when WDAT is enabled.
* arm/virt: add test case for GTDT
* [18-21] optional GWDT cleanup/fixes in handling WCV register update, make QEMU behave according to spec (at least the way I read it and it appears MS also read it that way). It fixes Windows 11 reboots when GWDT is present (without WDAT). With that fixed it's up to MS to fix their driver to set sane timeout as with the current one wdatchdog will never trigger.

Windows doesn't ship built-in TCO watchdog driver, and users are forced to install vendor specific driver(s) if such exists. However the OS provides a generic watchdog driver that uses ACPI WDAT table [1] to abstract actual hardware behind it. The same applies to ARM version of Windows.

This series adds
* WDAT table tailored for TCO watchdog that Q35 already has as part of ICH9 chipset and a knob to enable it.
* SBSA GWDT to arm/virt machine with WDAT table tailored for it and necessary tweaks to GWDT to make usable with WDAT driver.
* in addition to WDAT, it also adds native variant with GWDT described in FDT and DTDT
(broken on Windows/works on linux).

Guest OS WDAT support is present since Windows Vista and Linux since 2016[2].

One can test it launching VM with following options:
* x86:
-machine q35,wdat=on
* arm/virt:
-device sbsa_gwdt,wdat=on

to trace access to TCO registers one can add to CLI:

    -trace "tco_*"
to trace access to GWDT registers one can add to CLI:
    -trace "sbsa_gwdt*"

To verify that guest uses WDAT (both Windows and Linux would use it if present),
* on linux make sure that watchdog service is configured/enabled (use wdctl to check what watchdog device is in use) and then trigger kernel panic with command:
echo c > /proc/sysrq-trigger
* on Windows kill svchost process, running cmd in admin mode:
taskkill /f /im svchost.exe

Tested with WS2025 & RHEL9.6 & Fedora 43 (aarch64)

git tree at: https://gitlab.com/imammedo/qemu/-/commits/gwdt_v2

1) http://msdn.microsoft.com/en-us/windows/hardware/gg463320.aspx
2) https://lwn.net/Articles/700524/

PS:
previous revision:
https://patchew.org/QEMU/[email protected]/

Igor Mammedov (21):
acpi: add API to build WDAT instructions
x86: q35: add 'wdat' property
x86: q35: generate WDAT ACPI table
tests: acpi: x86/q35: whitelist new WDAT table
tests: acpi: x86/q35: add WDAT table test case
tests: acpi: x86/q35: update expected WDAT blob
arm: sbsa_gwdt: fixup default "clock-frequency"
arm: add tracing events to sbsa_gwdt
arm: virt: create sbsa_gwdt watchdog
arm: sbsa_gwdt: add 'wdat' option
arm: virt: add support for WDAT based watchdog
tests: acpi: arm/virt: whitelist new WDAT table
tests: acpi: arm/virt: add WDAT table test case
tests: acpi: arm/virt: update expected WDAT blob
tests: acpi: arm/virt: whitelist GTDT table
tests: acpi: arm/virt: add GTDT watchdog table test case
tests: acpi: arm/virt: update expected GTDT blob
sbsa_gwdt: reduce code ident
sbsa_gwdt: move all foo_REFRESH logic under REFRESH condition
sbsa_gwdt: reschedule timer on direct WCV load
sbsa_gwdt: limit compare_value to INT64_MAX

 include/hw/acpi/wdat-gwdt.h            |  19 ++++
 include/hw/acpi/wdat-ich9.h            |  15 ++++
 include/hw/acpi/wdat.h                 | 118 +++++++++++++++++++++++++
 include/hw/i386/pc.h                   |   1 +
 include/hw/watchdog/sbsa_gwdt.h        |   1 +
 hw/acpi/aml-build.c                    |  14 +++
 hw/acpi/meson.build                    |   5 +-
 hw/acpi/wdat-gwdt-stub.c               |  16 ++++
 hw/acpi/wdat-gwdt.c                    |  92 +++++++++++++++++++
 hw/acpi/wdat-ich9-stub.c               |  15 ++++
 hw/acpi/wdat-ich9.c                    |  90 +++++++++++++++++++
 hw/arm/Kconfig                         |   1 +
 hw/arm/virt-acpi-build.c               |  65 +++++++++++++-
 hw/arm/virt.c                          |   2 +
 hw/core/sysbus-fdt.c                   |  32 +++++++
 hw/i386/acpi-build.c                   |  12 +++
 hw/i386/pc_q35.c                       |  18 ++++
 hw/watchdog/sbsa_gwdt.c                |  65 +++++++++-----
 hw/watchdog/trace-events               |   9 ++
 tests/data/acpi/aarch64/virt/GTDT.gwdt | Bin 0 -> 132 bytes
 tests/data/acpi/aarch64/virt/WDAT.wdat | Bin 0 -> 260 bytes
 tests/data/acpi/x86/q35/WDAT.wdat      | Bin 0 -> 308 bytes
 tests/qtest/bios-tables-test.c         |  54 +++++++++++
 23 files changed, 618 insertions(+), 26 deletions(-)
 create mode 100644 include/hw/acpi/wdat-gwdt.h
 create mode 100644 include/hw/acpi/wdat-ich9.h
 create mode 100644 include/hw/acpi/wdat.h
 create mode 100644 hw/acpi/wdat-gwdt-stub.c
 create mode 100644 hw/acpi/wdat-gwdt.c
 create mode 100644 hw/acpi/wdat-ich9-stub.c
 create mode 100644 hw/acpi/wdat-ich9.c
 create mode 100644 tests/data/acpi/aarch64/virt/GTDT.gwdt
 create mode 100644 tests/data/acpi/aarch64/virt/WDAT.wdat
 create mode 100644 tests/data/acpi/x86/q35/WDAT.wdat
Signature · 1 line
2.47.3