Add watchdog support to arm/virt board
v4 cover Add watchdog support to arm/virt board
This series adds SBSA GWDT to the arm/virt machine with a WDAT table designed for it and necessary tweaks to make it usable with the WDAT driver.
In addition to WDAT, it also adds a native variant with GWDT described in FDT and GTDT.
One can test it launching VM with:
-device sbsa-gwdt,wdat=on
to trace access to GWDT registers add:
-trace "sbsa_gwdt*"
To verify the guest uses watchdog use following steps to trigger watchdog reboot:
* on Linux: enable watchdog service, check with wdctl, then:
echo c > /proc/sysrq-trigger
* on Windows: kill svchost in admin mode 'cmd' shell:
taskkill /f /im svchost.exe
Tested with Fedora 43 & Windows 11 (aarch64, KVM on Jetson)
git tree: https://gitlab.com/imammedo/qemu/-/commits/gwdt_v4
1) http://msdn.microsoft.com/en-us/windows/hardware/gg463320.aspx
Changelog:
v4:
* drop independed patches 14-17 for a separate spin-off (sbsa-gwdt fixes for WCV register writes)
* arm: sbsa_gwdt: rename device type to sbsa-gwdt (patch 3):
- collect Reviewed-by from Eric
* arm: virt: create sbsa-gwdt watchdog (patch 4):
(Eric)
- reorder [VIRT_GWDT_WS0] in irqmap after [VIRT_ACPI_GED]
- add missing blank line in pre_plug handler
- extract FDT node creation into create_gwdt_dt_bindings() helper
- add watchdog documentation to docs/system/arm/virt.rst
- add comment above dc->user_creatable about requiring machine-specific wiring
* acpi: introduce WDAT table for GWDT (patch 6):
(Eric)
- fix comment alignment
- collect Reviewed-by
* arm: virt: add support for WDAT based watchdog (patch 7):
(Eric)
- remove unused 'wdt' parameter from build_gtdt()
- add Native/WDAT modes documentation to docs/system/arm/virt.rst
- collect Reviewed-by
* tests: acpi: arm/virt: update expected WDAT blob (patch 10):
- collect Reviewed-by from Eric
* tests: acpi: arm/virt: add GTDT watchdog table test case (patch 12):
(Eric) fix whitespace in test command string (moved from patch 17)
v3:
* drop x86 patches (already merged)
* (Eric) rename device type from sbsa_gwdt to sbsa-gwdt (new patch 3)
* arm: virt: create sbsa-gwdt watchdog (patch 4):
- (Eric) assign MMIO/IRQ statically, drop dynamic sysbus machinery
- (Peter) set watchdog freq to system counter clock explicitly
* arm: sbsa-gwdt: add 'wdat' option (patch 5):
- split out from v2's monolithic patch 11
* acpi: introduce WDAT table for GWDT (patch 6):
- (Eric) split out from v2's patch 11
- add/improve comments
- use 'freq' argument passed down by caller
- simplify magic val on WRR write and add comment
- group table records by used register
* arm: virt: add support for WDAT based watchdog (patch 7):
- (Eric) split out from v2's patch 11
- skip FDT watchdog node creation in wdat mode
- skip setting cntfrq clock-frequency in wdat mode
* sbsa-gwdt: reschedule timer on direct WCV load (patch 16):
- improved commit message with spec references and description of Windows GTDT-mode behavior
* sbsa-gwdt: limit compare_value to INT64_MAX (patch 17):
- rewritten commit message: document QEMU timer API limitation vs spec, Windows write sequence, and
vCPU preemption fragility under virtualization
v2:
* ditch generic '-machine acpi-watchdog' option in favor of board specific: arm/virt: -device sbsa_gwdt,wdat={on|off}
* arm/virt: add FDT and GTDT ACPI entries for GWDT
* arm/virt: add test case for GTDT
* optional GWDT cleanup/fixes for WCV register update
previous revisions:
v3: https://patchew.org/QEMU/[email protected]/ v2: https://patchew.org/QEMU/[email protected]/ v1: https://patchew.org/QEMU/[email protected]/
Igor Mammedov (13):
arm: sbsa_gwdt: fixup default "clock-frequency"
arm: add tracing events to sbsa_gwdt
arm: sbsa_gwdt: rename device type to sbsa-gwdt
arm: virt: create sbsa-gwdt watchdog
arm: sbsa-gwdt: add 'wdat' option
acpi: introduce WDAT table for GWDT
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
include/hw/acpi/wdat-gwdt.h | 19 +++++ include/hw/arm/virt.h | 3 + include/hw/watchdog/sbsa_gwdt.h | 3 +- docs/system/arm/virt.rst | 24 ++++++ hw/acpi/meson.build | 2 + hw/acpi/wdat-gwdt-stub.c | 16 ++++ hw/acpi/wdat-gwdt.c | 99 +++++++++++++++++++++++++ hw/arm/Kconfig | 1 + hw/arm/virt-acpi-build.c | 51 ++++++++++++- hw/arm/virt.c | 48 ++++++++++++ hw/core/sysbus-fdt.c | 2 + hw/watchdog/sbsa_gwdt.c | 24 +++++- 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/qtest/bios-tables-test.c | 41 ++++++++++ 16 files changed, 334 insertions(+), 8 deletions(-) create mode 100644 include/hw/acpi/wdat-gwdt.h create mode 100644 hw/acpi/wdat-gwdt-stub.c create mode 100644 hw/acpi/wdat-gwdt.c create mode 100644 tests/data/acpi/aarch64/virt/GTDT.gwdt create mode 100644 tests/data/acpi/aarch64/virt/WDAT.wdat
Signature · 1 line
2.47.3
PATCH v4 1/13 arm: sbsa_gwdt: fixup default "clock-frequency"
Comment about keeping legacy freq, is wrong to begin with (should be 62.5MHz), but that value also doesn't make sense anymore as the watchdog is used only by un-versioned SBSA board and the later has hard-coded it to 1GHz.
Other potential user (arm/virt) also has system clock at 1GHz.
Drop misleading comment about legacy and set default to 1GHz to match both boards. (not that it does matter, since users are setting frequency to match CPU's one explicitly)
--- hw/watchdog/sbsa_gwdt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
hw/watchdog/sbsa_gwdt.c +2 -3
@@ -264,11 +264,10 @@ static void wdt_sbsa_gwdt_realize(DeviceState *dev, Error **errp)static const Property wdt_sbsa_gwdt_props[] = {/* * Timer frequency in Hz. This must match the frequency used by -* the CPU's generic timer. Default 62.5Hz matches QEMU's legacy -* CPU timer frequency default. +* the CPU's generic timer. */ DEFINE_PROP_UINT64("clock-frequency", struct SBSA_GWDTState, freq, -62500000 ), +1000000000 ), };static void wdt_sbsa_gwdt_class_init (ObjectClass *klass,const void *data)
Signature · 1 line
2.47.3
PATCH v4 2/13 arm: add tracing events to sbsa_gwdt
In reply to Igor Mammedov--- hw/watchdog/sbsa_gwdt.c | 8 ++++++++ hw/watchdog/trace-events | 9 +++++++++ 2 files changed, 17 insertions(+)
hw/watchdog/sbsa_gwdt.c +8 -0
@@ -24,6 +24,7 @@#include "migration/vmstate.h" #include "qemu/log.h" #include "qemu/module.h" +#include "trace.h" static const VMStateDescription vmstate_sbsa_gwdt = { .name ="sbsa-gwdt" ,
@@ -62,6 +63,7 @@ static uint64_t sbsa_gwdt_rread(void *opaque, hwaddr addr, unsigned int size)qemu_log_mask (LOG_GUEST_ERROR ,"bad address in refresh frame read :" " 0x%x\n" , (int )addr); } +trace_sbsa_gwdt_refresh_read (addr, ret);return ret; }
@@ -93,6 +95,7 @@ static uint64_t sbsa_gwdt_read(void *opaque, hwaddr addr, unsigned int size)qemu_log_mask (LOG_GUEST_ERROR ,"bad address in control frame read :" " 0x%x\n" , (int )addr); } +trace_sbsa_gwdt_control_read (addr, ret);return ret; }
@@ -127,6 +130,7 @@ static void sbsa_gwdt_rwrite(void *opaque, hwaddr offset, uint64_t data, unsigned size) {SBSA_GWDTState *s =SBSA_GWDT (opaque); +trace_sbsa_gwdt_refresh_write (offset, data);if (offset ==SBSA_GWDT_WRR ) { s->wcs &= ~(SBSA_GWDT_WCS_WS0 |SBSA_GWDT_WCS_WS1 );
@@ -141,6 +145,7 @@ static void sbsa_gwdt_write(void *opaque, hwaddr offset, uint64_t data, unsigned size) {SBSA_GWDTState *s =SBSA_GWDT (opaque); +trace_sbsa_gwdt_control_write (offset, data);switch (offset) {case SBSA_GWDT_WCS : s->wcs = data &SBSA_GWDT_WCS_EN ;
@@ -180,6 +185,7 @@ static void wdt_sbsa_gwdt_reset(DeviceState *dev) {SBSA_GWDTState *s =SBSA_GWDT (dev); +trace_sbsa_gwdt_reset ();timer_del (s->timer); s->wcs =0 ;
@@ -196,10 +202,12 @@ static void sbsa_gwdt_timer_sysinterrupt(void *opaque)if (!(s->wcs &SBSA_GWDT_WCS_WS0 )) { s->wcs |=SBSA_GWDT_WCS_WS0 ; +trace_sbsa_gwdt_ws0_asserted ();sbsa_gwdt_update_timer (s,TIMEOUT_REFRESH );qemu_set_irq (s->irq,1 ); }else { s->wcs |=SBSA_GWDT_WCS_WS1 ; +trace_sbsa_gwdt_ws1_asserted ();qemu_log_mask (CPU_LOG_RESET ,"Watchdog timer expired.\n" );/* * Reset the watchdog only if the guest gets notified about
hw/watchdog/trace-events +9 -0
@@ -42,3 +42,12 @@ k230_wdt_interrupt(void) "K230 WDT interrupt" k230_wdt_reset(void) "K230 WDT system reset" k230_wdt_restart(void) "K230 WDT restart" k230_wdt_reset_device(void) "K230 WDT device reset" + +#sbsa_gwdt.c +sbsa_gwdt_refresh_read(uint64_t addr, uint32_t value) "[0x%" PRIx64 "] -> 0x%" PRIx32 +sbsa_gwdt_refresh_write(uint64_t addr, uint64_t value) "[0x%" PRIx64 "] <- 0x%" PRIx64 +sbsa_gwdt_control_read(uint64_t addr, uint32_t value) "[0x%" PRIx64 "] -> 0x%" PRIx32 +sbsa_gwdt_control_write(uint64_t addr, uint64_t value) "[0x%" PRIx64 "] <- 0x%" PRIx64 +sbsa_gwdt_ws0_asserted(void) "WS0 signal is asserted" +sbsa_gwdt_ws1_asserted(void) "WS1 signal is asserted" +sbsa_gwdt_reset(void) "reset watchdog to default state"
Signature · 1 line
2.47.3
PATCH v4 3/13 arm: sbsa_gwdt: rename device type to sbsa-gwdt
In reply to Igor MammedovUse hyphenated name to follow QEMU device naming convention. Migration compatibility is preserved since the vmstate name is already "sbsa-gwdt".
--- include/hw/watchdog/sbsa_gwdt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/watchdog/sbsa_gwdt.h +1 -1
@@ -16,7 +16,7 @@#include "hw/core/sysbus.h" #include "hw/core/irq.h" -#define TYPE_WDT_SBSA "sbsa_gwdt" +#define TYPE_WDT_SBSA "sbsa-gwdt"#define SBSA_GWDT (obj) \ OBJECT_CHECK(SBSA_GWDTState, (obj), TYPE_WDT_SBSA)#define SBSA_GWDT_CLASS (klass) \
Signature · 1 line
2.47.3
PATCH v4 4/13 arm: virt: create sbsa-gwdt watchdog
In reply to Igor MammedovAllow to use SBSA generic watchdog with virt machine type. (includes conditional generation of corresponding FDT and ACPI GTDT descriptors)
Use '-device sbsa-gwdt' to command line to enable it.
Instead of using dynamic sysbus infra to wire up MMIO/IRQ/FDT, statically assign resources in machine's mem/irq maps and wire them up at device (pre_)plug handlers. It's similar to dynamic sysbus wiring, modulo resources are nailed down statically, and wiring is limited to virt machine only.
(Benefit is that tests don't break anymore on rebase due to address being stable)
Tested with Fedora 43:
FDT: -M virt,acpi=off -device sbsa-gwdt
ACPI: -M virt -device sbsa-gwdt
Note:
Windows sees GTDT, initializes watchdog but instead pinging WRR it sets/advances WOR to way too large value, so it's never going to trigger watchdog reboot (it's Windows driver issue though).
---
v4:
(Eric)
- reorder [VIRT_GWDT_WS0] in irqmap after [VIRT_ACPI_GED]
- add missing blank line in pre_plug handler
- extract FDT node creation into create_gwdt_dt_bindings() helper
- add watchdog documentation to docs/system/arm/virt.rst
- add comment above dc->user_creatable about requiring machine-specific wiring
v3:
- (Eric) assign MMIO/IRQ statically and abandon most of dynamic sysbus machinery.
- (Peter) set watchdog freq to system clock explicitly, machine version compat won't work in case host is not runing 1GHz clock. (Tested on Jetson machine)
--- include/hw/arm/virt.h | 3 +++ docs/system/arm/virt.rst | 9 ++++++++ hw/arm/Kconfig | 1 + hw/arm/virt-acpi-build.c | 29 ++++++++++++++++++++++++-- hw/arm/virt.c | 44 ++++++++++++++++++++++++++++++++++++++++ hw/core/sysbus-fdt.c | 2 ++ hw/watchdog/sbsa_gwdt.c | 2 ++ 7 files changed, 88 insertions(+), 2 deletions(-)
include/hw/arm/virt.h +3 -0
@@ -97,6 +97,9 @@ enum {VIRT_NVDIMM_ACPI ,VIRT_PVTIME ,VIRT_ACPI_PCIHP , +VIRT_GWDT_WS0 , +VIRT_GWDT_REFRESH , +VIRT_GWDT_CONTROL , VIRT_LOWMEMMAP_LAST, };
docs/system/arm/virt.rst +9 -0
@@ -39,6 +39,7 @@ The virt board supports: - A PL061 GPIO controller - An optional machine-wide SMMUv3 IOMMU - User-creatable SMMUv3 devices (see below for example) +- An optional SBSA Generic Watchdog Timer (see below) - hotpluggable DIMMs - hotpluggable NVDIMMs - An MSI controller (GICv2m or ITS).
@@ -314,6 +315,14 @@ User-creatable SMMUv3 devices bypassing QEMU and improving throughput for workloads that issue many invalidations. Without it, every invalidation command traps into QEMU. +SBSA Generic Watchdog +""""""""""""""""""""" + +The SBSA Generic Watchdog Timer (GWDT) can be added to the virt machine +using ``-device sbsa-gwdt``. It is only supported on the virt machine, +which wires up statically assigned MMIO regions and IRQs via +machine-specific plug handlers. + Linux guest kernel configuration """"""""""""""""""""""""""""""""
hw/arm/Kconfig +1 -0
@@ -36,6 +36,7 @@ config ARM_VIRT select VIRTIO_MEM_SUPPORTED select ACPI_CXL select ACPI_HMAT + select WDT_SBSA config CUBIEBOARD bool
hw/arm/virt-acpi-build.c +27 -2
@@ -64,6 +64,7 @@#include "hw/virtio/virtio-acpi.h" #include "target/arm/cpu.h" #include "target/arm/multiprocessing.h" +#include "hw/watchdog/sbsa_gwdt.h" #include "smmuv3-accel.h" #include "tegra241-cmdqv.h"
@@ -868,6 +869,8 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)const uint32_t irqflags =0 ;/* Interrupt is Level triggered */ AcpiTable table = { .sig ="GTDT" , .rev =3 , .oem_id = vms->oem_id, .oem_table_id = vms->oem_table_id }; +uint32_t gtdt_start = table_data->len; +Object *wdt =object_resolve_type_unambiguous (TYPE_WDT_SBSA ,NULL );acpi_table_begin (&table, table_data);
@@ -898,10 +901,15 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)build_append_int_noprefix (table_data, irqflags,4 );/* CntReadBase Physical address */ build_append_int_noprefix (table_data,0xFFFFFFFFFFFFFFFF ,8 ); +/* Platform Timer Count */ -build_append_int_noprefix (table_data,0 ,4 ); +build_append_int_noprefix (table_data, wdt ?1 :0 ,4 );/* Platform Timer Offset */ -build_append_int_noprefix (table_data,0 ,4 ); +build_append_int_noprefix (table_data, + wdt ? (table_data->len - gtdt_start) + +4 +4 +4 /* len of this & following 2 fields to skip */ + :0 ,4 ); +if (vms->ns_el2_virt_timer_irq) {/* Virtual EL2 Timer GSIV */ build_append_int_noprefix (table_data,ARCH_TIMER_NS_EL2_VIRT_IRQ ,4 );
@@ -911,6 +919,23 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)build_append_int_noprefix (table_data,0 ,4 );build_append_int_noprefix (table_data,0 ,4 ); } + +/* ACPI 6.5 spec: 5.2.25.2 ARM Generic Watchdog Structure (Table 5-124) */ +if (wdt) { +hwaddr rbase = vms->memmap[VIRT_GWDT_REFRESH ].base; +hwaddr cbase = vms->memmap[VIRT_GWDT_CONTROL ].base; +int irq =ARM_SPI_BASE + vms->irqmap[VIRT_GWDT_WS0 ]; + +build_append_int_noprefix (table_data,1 /* Type: Watchdog GT */ ,1 ); +build_append_int_noprefix (table_data,28 /* Length */ ,2 ); +build_append_int_noprefix (table_data,0 ,1 );/* Reserved */ +/* RefreshFrame Physical Address */ +build_append_int_noprefix (table_data, rbase,8 ); +/* WatchdogControlFrame Physical Address */ +build_append_int_noprefix (table_data, cbase,8 ); +build_append_int_noprefix (table_data, irq,4 );/* Watchdog Timer GSIV */ +build_append_int_noprefix (table_data,0 ,4 );/* Watchdog Timer Flags */ + }acpi_table_end (linker, &table); }
hw/arm/virt.c +44 -0
86 lines not on this page · raw message
hw/core/sysbus-fdt.c +2 -0
@@ -36,6 +36,7 @@#include "hw/display/ramfb.h" #include "hw/uefi/var-service-api.h" #include "hw/arm/fdt.h" +#include "hw/watchdog/sbsa_gwdt.h" /* * internal struct that contains the information to create dynamic
@@ -140,6 +141,7 @@ static const BindingEntry bindings[] = {TYPE_BINDING (TYPE_ARM_SMMUV3 , no_fdt_node),TYPE_BINDING (TYPE_RAMFB_DEVICE , no_fdt_node),TYPE_BINDING (TYPE_UEFI_VARS_SYSBUS , add_uefi_vars_node), +TYPE_BINDING (TYPE_WDT_SBSA , no_fdt_node), TYPE_BINDING("", NULL), /* last element */ };
hw/watchdog/sbsa_gwdt.c +2 -0
@@ -285,6 +285,8 @@ static void wdt_sbsa_gwdt_class_init(ObjectClass *klass, const void *data) dc->realize = wdt_sbsa_gwdt_realize;device_class_set_legacy_reset (dc, wdt_sbsa_gwdt_reset); dc->hotpluggable = false; +/* requires machine-specific wiring (MMIO/IRQ/FDT) at plug time */ + dc->user_creatable = true;set_bit (DEVICE_CATEGORY_WATCHDOG , dc->categories); dc->vmsd = &vmstate_sbsa_gwdt; dc->desc ="SBSA-compliant generic watchdog device" ;
Signature · 1 line
2.47.3
Re: [PATCH v4 04/13] arm: virt: create sbsa-gwdt watchdog
Hi Igor,
Quoted 18 lines · Igor Mammedov
Allow to use SBSA generic watchdog with virt machine type. (includes conditional generation of corresponding FDT and ACPI GTDT descriptors)
Use '-device sbsa-gwdt' to command line to enable it.
Instead of using dynamic sysbus infra to wire up MMIO/IRQ/FDT, statically assign resources in machine's mem/irq maps and wire them up at device (pre_)plug handlers. It's similar to dynamic sysbus wiring, modulo resources are nailed down statically, and wiring is limited to virt machine only.
(Benefit is that tests don't break anymore on rebase due to address being stable)Tested with Fedora 43:
FDT: -M virt,acpi=off -device sbsa-gwdt
ACPI: -M virt -device sbsa-gwdt
Quoted 6 lines
Note:
Windows sees GTDT, initializes watchdog but instead pinging WRR it sets/advances WOR to way too large value, so it's never going to trigger watchdog reboot (it's Windows driver issue though).Signed-off-by Igor Mammedov <[email protected]>
Thanks
Eric
Quoted 271 lines
---
v4:
(Eric)
- reorder [VIRT_GWDT_WS0] in irqmap after [VIRT_ACPI_GED]
- add missing blank line inpre_plughandler
- extract FDT node creation intocreate_gwdt_dt_bindings()helper
- add watchdog documentation todocs/system/arm/virt.rst
- add comment abovedc->user_creatableabout requiring machine-specific wiring
v3:
- (Eric) assign MMIO/IRQ statically and abandon most of dynamic sysbus machinery.
- (Peter) set watchdog freq to system clock explicitly, machine version compat won't work in case host is not runing 1GHz clock. (Tested on Jetson machine)--- include/hw/arm/virt.h | 3 +++ docs/system/arm/virt.rst | 9 ++++++++ hw/arm/Kconfig | 1 + hw/arm/virt-acpi-build.c | 29 ++++++++++++++++++++++++-- hw/arm/virt.c | 44 ++++++++++++++++++++++++++++++++++++++++ hw/core/sysbus-fdt.c | 2 ++ hw/watchdog/sbsa_gwdt.c | 2 ++ 7 files changed, 88 insertions(+), 2 deletions(-)include/hw/arm/virt.h +3
-0@@ -97,6 +97,9 @@ enum {VIRT_NVDIMM_ACPI ,VIRT_PVTIME ,VIRT_ACPI_PCIHP , +VIRT_GWDT_WS0 , +VIRT_GWDT_REFRESH , +VIRT_GWDT_CONTROL , VIRT_LOWMEMMAP_LAST, };docs/system/arm/virt.rst +9
-0@@ -39,6 +39,7 @@ The virt board supports: - A PL061 GPIO controller - An optional machine-wide SMMUv3 IOMMU - User-creatable SMMUv3 devices (see below for example) +- An optional SBSA Generic Watchdog Timer (see below) - hotpluggable DIMMs - hotpluggable NVDIMMs - An MSI controller (GICv2m or ITS).@@ -314,6 +315,14 @@ User-creatable SMMUv3 devices bypassing QEMU and improving throughput for workloads that issue many invalidations. Without it, every invalidation command traps into QEMU. +SBSA Generic Watchdog +""""""""""""""""""""" + +The SBSA Generic Watchdog Timer (GWDT) can be added to the virt machine +using ``-device sbsa-gwdt``. It is only supported on the virt machine, +which wires up statically assigned MMIO regions and IRQs via +machine-specific plug handlers. + Linux guest kernel configuration """"""""""""""""""""""""""""""""hw/arm/Kconfig +1
-0@@ -36,6 +36,7 @@ config ARM_VIRT select VIRTIO_MEM_SUPPORTED select ACPI_CXL select ACPI_HMAT + select WDT_SBSA config CUBIEBOARD boolhw/arm/virt-acpi-build.c +27
-2@@ -64,6 +64,7 @@#include "hw/virtio/virtio-acpi.h" #include "target/arm/cpu.h" #include "target/arm/multiprocessing.h" +#include "hw/watchdog/sbsa_gwdt.h" #include "smmuv3-accel.h" #include "tegra241-cmdqv.h" @@ -868,6 +869,8 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)const uint32_t irqflags =0 ;/* Interrupt is Level triggered */ AcpiTable table = { .sig ="GTDT" , .rev =3 , .oem_id = vms->oem_id, .oem_table_id = vms->oem_table_id }; +uint32_t gtdt_start = table_data->len; +Object *wdt =object_resolve_type_unambiguous (TYPE_WDT_SBSA ,NULL );acpi_table_begin (&table, table_data);@@ -898,10 +901,15 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)build_append_int_noprefix (table_data, irqflags,4 );/* CntReadBase Physical address */ build_append_int_noprefix (table_data,0xFFFFFFFFFFFFFFFF ,8 ); +/* Platform Timer Count */ -build_append_int_noprefix (table_data,0 ,4 ); +build_append_int_noprefix (table_data, wdt ?1 :0 ,4 );/* Platform Timer Offset */ -build_append_int_noprefix (table_data,0 ,4 ); +build_append_int_noprefix (table_data, + wdt ? (table_data->len - gtdt_start) + +4 +4 +4 /* len of this & following 2 fields to skip */ + :0 ,4 ); +if (vms->ns_el2_virt_timer_irq) {/* Virtual EL2 Timer GSIV */ build_append_int_noprefix (table_data,ARCH_TIMER_NS_EL2_VIRT_IRQ ,4 );@@ -911,6 +919,23 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)build_append_int_noprefix (table_data,0 ,4 );build_append_int_noprefix (table_data,0 ,4 ); } + +/* ACPI 6.5 spec: 5.2.25.2 ARM Generic Watchdog Structure (Table 5-124) */ +if (wdt) { +hwaddr rbase = vms->memmap[VIRT_GWDT_REFRESH ].base; +hwaddr cbase = vms->memmap[VIRT_GWDT_CONTROL ].base; +int irq =ARM_SPI_BASE + vms->irqmap[VIRT_GWDT_WS0 ]; + +build_append_int_noprefix (table_data,1 /* Type: Watchdog GT */ ,1 ); +build_append_int_noprefix (table_data,28 /* Length */ ,2 ); +build_append_int_noprefix (table_data,0 ,1 );/* Reserved */ +/* RefreshFrame Physical Address */ +build_append_int_noprefix (table_data, rbase,8 ); +/* WatchdogControlFrame Physical Address */ +build_append_int_noprefix (table_data, cbase,8 ); +build_append_int_noprefix (table_data, irq,4 );/* Watchdog Timer GSIV */ +build_append_int_noprefix (table_data,0 ,4 );/* Watchdog Timer Flags */ + }acpi_table_end (linker, &table); }hw/arm/virt.c +44
-0@@ -95,6 +95,7 @@#include "hw/cxl/cxl.h" #include "hw/cxl/cxl_host.h" #include "qemu/guest-random.h" +#include "hw/watchdog/sbsa_gwdt.h" static GlobalProperty arm_virt_compat_defaults[] = { {TYPE_VIRTIO_IOMMU_PCI ,"aw-bits" ,"48" },@@ -214,6 +215,8 @@ static const MemMapEntry base_memmap[] = { /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 }, [VIRT_SECURE_MEM] = { 0x0e000000, 0x01000000 }, + [VIRT_GWDT_REFRESH] = { 0x0f000000, 0x00001000 }, + [VIRT_GWDT_CONTROL] = { 0x0f001000, 0x00001000 }, [VIRT_PCIE_MMIO] = { 0x10000000, 0x2eff0000 }, [VIRT_PCIE_PIO] = { 0x3eff0000, 0x00010000 }, [VIRT_PCIE_ECAM] = { 0x3f000000, 0x01000000 },@@ -264,6 +267,7 @@ static const int a15irqmap[] = { [VIRT_GPIO] = 7, [VIRT_UART1] = 8, [VIRT_ACPI_GED] = 9, + [VIRT_GWDT_WS0] = 10, [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */ [VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */ [VIRT_SMMU] = 74, /* ...to 74 + NUM_SMMU_IRQS - 1 */@@ -2085,6 +2089,27 @@ static void create_smmu(const VirtMachineState *vms, PCIBus *bus)create_smmuv3_dt_bindings (vms, base, size, irq); } +static void create_gwdt_dt_bindings (VirtMachineState *vms) +{ +MachineState *ms =MACHINE (vms); +hwaddr rbase = vms->memmap[VIRT_GWDT_REFRESH ].base; +hwaddr cbase = vms->memmap[VIRT_GWDT_CONTROL ].base; +int irq = vms->irqmap[VIRT_GWDT_WS0 ]; +char *nodename =g_strdup_printf ("/watchdog@%" PRIx64, cbase); + +qemu_fdt_add_subnode (ms->fdt, nodename); +qemu_fdt_setprop_string (ms->fdt, nodename, +"compatible" ,"arm,sbsa-gwdt" ); +qemu_fdt_setprop_sized_cells (ms->fdt, nodename,"reg" , +2 , cbase,2 ,SBSA_GWDT_CMMIO_SIZE , +2 , rbase,2 ,SBSA_GWDT_RMMIO_SIZE ); +qemu_fdt_setprop_cells (ms->fdt, nodename,"interrupts" , +GIC_FDT_IRQ_TYPE_SPI , irq, +GIC_FDT_IRQ_FLAGS_LEVEL_HI ); +qemu_fdt_setprop_cell (ms->fdt, nodename,"timeout-sec" ,30 ); +g_free (nodename); +} +static void create_virtio_iommu_dt_bindings (VirtMachineState *vms) {const char compat[] ="virtio,pci-iommu\0pci1af4,1057" ;@@ -3820,6 +3845,11 @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,qlist_append_str (reserved_regions, resv_prop_str);qdev_prop_set_array (dev,"reserved-regions" , reserved_regions);g_free (resv_prop_str); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_WDT_SBSA )) { +uint64_t cntfrq =object_property_get_int (OBJECT (qemu_get_cpu (0 )), +"cntfrq" , &error_abort); + +qdev_prop_set_uint64 (dev,"clock-frequency" , cntfrq); }else if (object_dynamic_cast (OBJECT (dev),TYPE_ARM_SMMUV3 )) {if (vms->legacy_smmuv3_present || vms->iommu ==VIRT_IOMMU_VIRTIO ) { error_setg(errp, "virt machine already has %s set. "@@ -3871,6 +3901,19 @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, {VirtMachineState *vms =VIRT_MACHINE (hotplug_dev); +if (object_dynamic_cast (OBJECT (dev),TYPE_WDT_SBSA )) { +SysBusDevice *s =SYS_BUS_DEVICE (dev); +hwaddr rbase = vms->memmap[VIRT_GWDT_REFRESH ].base; +hwaddr cbase = vms->memmap[VIRT_GWDT_CONTROL ].base; +int irq = vms->irqmap[VIRT_GWDT_WS0 ]; + +sysbus_mmio_map (s,0 , rbase); +sysbus_mmio_map (s,1 , cbase); +sysbus_connect_irq (s,0 ,qdev_get_gpio_in (vms->gic, irq)); + +create_gwdt_dt_bindings (vms); + } +if (vms->platform_bus_dev) {MachineClass *mc =MACHINE_GET_CLASS (vms);@@ -4123,6 +4166,7 @@ static void virt_machine_class_init(ObjectClass *oc, const void *data)machine_class_allow_dynamic_sysbus_dev (mc,TYPE_RAMFB_DEVICE );machine_class_allow_dynamic_sysbus_dev (mc,TYPE_UEFI_VARS_SYSBUS );machine_class_allow_dynamic_sysbus_dev (mc,TYPE_ARM_SMMUV3 ); +machine_class_allow_dynamic_sysbus_dev (mc,TYPE_WDT_SBSA );#ifdef CONFIG_TPM machine_class_allow_dynamic_sysbus_dev (mc,TYPE_TPM_TIS_SYSBUS );#endif hw/core/sysbus-fdt.c +2
-0@@ -36,6 +36,7 @@#include "hw/display/ramfb.h" #include "hw/uefi/var-service-api.h" #include "hw/arm/fdt.h" +#include "hw/watchdog/sbsa_gwdt.h" /* * internal struct that contains the information to create dynamic @@ -140,6 +141,7 @@ static const BindingEntry bindings[] = {TYPE_BINDING (TYPE_ARM_SMMUV3 , no_fdt_node),TYPE_BINDING (TYPE_RAMFB_DEVICE , no_fdt_node),TYPE_BINDING (TYPE_UEFI_VARS_SYSBUS , add_uefi_vars_node), +TYPE_BINDING (TYPE_WDT_SBSA , no_fdt_node), TYPE_BINDING("", NULL), /* last element */ };hw/watchdog/sbsa_gwdt.c +2
-0@@ -285,6 +285,8 @@ static void wdt_sbsa_gwdt_class_init(ObjectClass *klass, const void *data) dc->realize = wdt_sbsa_gwdt_realize;device_class_set_legacy_reset (dc, wdt_sbsa_gwdt_reset); dc->hotpluggable = false; +/* requires machine-specific wiring (MMIO/IRQ/FDT) at plug time */ + dc->user_creatable = true;set_bit (DEVICE_CATEGORY_WATCHDOG , dc->categories); dc->vmsd = &vmstate_sbsa_gwdt; dc->desc ="SBSA-compliant generic watchdog device" ;
PATCH v4 5/13 arm: sbsa-gwdt: add 'wdat' option
In reply to Igor Mammedovit will be used by arm/virt board, to pick WDAT compatible watchdog impl. and act as switch over to WDAT ACPI table vesus default GTDT ACPI table.
--- include/hw/watchdog/sbsa_gwdt.h | 1 + hw/watchdog/sbsa_gwdt.c | 9 +++++++++ 2 files changed, 10 insertions(+)
include/hw/watchdog/sbsa_gwdt.h +1 -0
@@ -73,6 +73,7 @@ typedef struct SBSA_GWDTState {uint32_t woru;uint32_t wcvl;uint32_t wcvu; + bool wdat; } SBSA_GWDTState;#endif /* WDT_SBSA_GWDT_H */
hw/watchdog/sbsa_gwdt.c +9 -0
@@ -265,6 +265,14 @@ static void wdt_sbsa_gwdt_realize(DeviceState *dev, Error **errp)sysbus_init_irq (sbd, &s->irq); +/* +* WDAT spec: "The clock interval that the WDT uses must be +* greater than or equal to 1 millisecond." +*/ +if (s->wdat) { + s->freq =1000 ; + } + s->timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , sbsa_gwdt_timer_sysinterrupt, dev); }
@@ -276,6 +284,7 @@ static const Property wdt_sbsa_gwdt_props[] = {*/ DEFINE_PROP_UINT64("clock-frequency", struct SBSA_GWDTState, freq,1000000000 ), + DEFINE_PROP_BOOL("wdat", struct SBSA_GWDTState, wdat, false), };static void wdt_sbsa_gwdt_class_init (ObjectClass *klass,const void *data)
Signature · 1 line
2.47.3
PATCH v4 6/13 acpi: introduce WDAT table for GWDT
In reply to Igor MammedovAdd build_gwdt_wdat() to generate a Watchdog Action Table designed for SBSA Generic Watchdog Timer.
---
v4:
(Eric) fix comment alignment
v3:
(Eric)
- split '[PATCH v2 11/21] arm: virt: add support for WDAT based watchdog' on smaller chunks.
- add/improve comments where requested
- actualy use 'freq' argument passed down by caller
- simplify magic val on WRR write and add comment
- group table records by used register
--- include/hw/acpi/wdat-gwdt.h | 19 +++++++ hw/acpi/meson.build | 2 + hw/acpi/wdat-gwdt-stub.c | 16 ++++++ hw/acpi/wdat-gwdt.c | 99 +++++++++++++++++++++++++++++++++++++ 4 files changed, 136 insertions(+) create mode 100644 include/hw/acpi/wdat-gwdt.h create mode 100644 hw/acpi/wdat-gwdt-stub.c create mode 100644 hw/acpi/wdat-gwdt.c
include/hw/acpi/wdat-gwdt.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* GWDT Watchdog Action Table (WDAT) definition +* +* Copyright Red Hat, Inc. 2026 +* Author(s): Igor Mammedov <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef QEMU_HW_ACPI_WDAT_GWDT_H +#define QEMU_HW_ACPI_WDAT_GWDT_H + +#include "hw/acpi/aml-build.h" +#include "hw/watchdog/sbsa_gwdt.h" + +void build_gwdt_wdat (GArray *table_data,BIOSLinker *linker,const char *oem_id, +const char *oem_table_id,uint64_t rbase,uint64_t cbase, +uint64_t freq); + +#endif /* QEMU_HW_ACPI_WDAT_GWDT_H */
hw/acpi/meson.build +2 -0
@@ -31,11 +31,13 @@ acpi_ss.add(when: 'CONFIG_ACPI_ERST', if_true: files('erst.c')) acpi_ss.add(when: 'CONFIG_IPMI', if_true: files('ipmi.c')) stub_ss.add(files('ipmi-stub.c')) stub_ss.add(files('acpi-x86-stub.c')) +acpi_ss.add(when: 'CONFIG_WDT_SBSA', if_true: files('wdat-gwdt.c')) if have_tpm acpi_ss.add(files('tpm.c')) endif stub_ss.add(files('acpi-stub.c', 'aml-build-stub.c', 'ghes-stub.c')) stub_ss.add(files('pci-bridge-stub.c')) +stub_ss.add(files('wdat-gwdt-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')) stub_ss.add(files('ghes_cper_stub.c'))
hw/acpi/wdat-gwdt-stub.c new file +16 -0
@@ -0,0 +1,16 @@ +/* +* Copyright Red Hat, Inc. 2026 +* Author(s): Igor Mammedov <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "hw/acpi/wdat-gwdt.h" + +void build_gwdt_wdat (GArray *table_data,BIOSLinker *linker,const char *oem_id, +const char *oem_table_id,uint64_t rbase,uint64_t cbase, +uint64_t freq) +{ +g_assert_not_reached (); +}
hw/acpi/wdat-gwdt.c new file +99 -0
99 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH v4 7/13 arm: virt: add support for WDAT based watchdog
In reply to Igor MammedovAdd WDAT handling for sbsa-gwdt on arm/virt machine.
WDAT mode is enabled by 'wdat' option: ex: "-device sbsa-gwdt,wdat=on"
When WDAT is enabled:
- Build the WDAT ACPI table instead of the GTDT watchdog entry, since they are mutually exclusive due to different timer resolution (WDAT uses 1 kHz vs GTDT's system counter frequency).
- Skip FDT watchdog node creation, as the DT-based Linux driver would use the system counter frequency which doesn't match the WDAT-mode 1 kHz clock.
---
v4:
(Eric)
- remove unused 'wdt' parameter from build_gtdt()
- add Native/WDAT modes documentation to docs/system/arm/virt.rst
v3:
- Skip FDT watchdog node creation in wdat mode
(Eric)
- wiring part of larger '[PATCH v2 11/21] arm: virt: add support for WDAT based watchdog'
--- docs/system/arm/virt.rst | 15 +++++++++++++++ hw/arm/virt-acpi-build.c | 34 ++++++++++++++++++++++++++-------- hw/arm/virt.c | 12 ++++++++---- 3 files changed, 49 insertions(+), 12 deletions(-)
docs/system/arm/virt.rst +15 -0
@@ -323,6 +323,21 @@ using ``-device sbsa-gwdt``. It is only supported on the virt machine, which wires up statically assigned MMIO regions and IRQs via machine-specific plug handlers. +Two modes are available: + +Native mode (default) + The watchdog is described via the ACPI GTDT table and FDT, using + the system counter frequency. Example:: + + -device sbsa-gwdt + +WDAT mode + The watchdog is described via the ACPI WDAT table (no FDT node), + using a 1 kHz timer frequency. WDAT and GTDT watchdog entries are + mutually exclusive. Example:: + + -device sbsa-gwdt,wdat=on + Linux guest kernel configuration """"""""""""""""""""""""""""""""
hw/arm/virt-acpi-build.c +26 -8
@@ -65,6 +65,7 @@#include "target/arm/cpu.h" #include "target/arm/multiprocessing.h" #include "hw/watchdog/sbsa_gwdt.h" +#include "hw/acpi/wdat-gwdt.h" #include "smmuv3-accel.h" #include "tegra241-cmdqv.h"
@@ -859,7 +860,8 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)* 5.2.25 Generic Timer Description Table (GTDT) */ static void -build_gtdt (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) +build_gtdt (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms, +bool add_watchdog) {/* * Table 5-117 Flag Definitions
@@ -870,7 +872,6 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)AcpiTable table = { .sig ="GTDT" , .rev =3 , .oem_id = vms->oem_id, .oem_table_id = vms->oem_table_id };uint32_t gtdt_start = table_data->len; -Object *wdt =object_resolve_type_unambiguous (TYPE_WDT_SBSA ,NULL );acpi_table_begin (&table, table_data);
@@ -903,12 +904,12 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)build_append_int_noprefix (table_data,0xFFFFFFFFFFFFFFFF ,8 );/* Platform Timer Count */ -build_append_int_noprefix (table_data, wdt ?1 :0 ,4 ); +build_append_int_noprefix (table_data, add_watchdog ?1 :0 ,4 );/* Platform Timer Offset */ build_append_int_noprefix (table_data, - wdt ? (table_data->len - gtdt_start) + -4 +4 +4 /* len of this & following 2 fields to skip */ - :0 ,4 ); + add_watchdog ? (table_data->len - gtdt_start) + +4 +4 +4 /* len of this & following 2 fields to skip */ + :0 ,4 );if (vms->ns_el2_virt_timer_irq) {/* Virtual EL2 Timer GSIV */
@@ -921,7 +922,7 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) }/* ACPI 6.5 spec: 5.2.25.2 ARM Generic Watchdog Structure (Table 5-124) */ -if (wdt) { +if (add_watchdog) {hwaddr rbase = vms->memmap[VIRT_GWDT_REFRESH ].base;hwaddr cbase = vms->memmap[VIRT_GWDT_CONTROL ].base;int irq =ARM_SPI_BASE + vms->irqmap[VIRT_GWDT_WS0 ];
@@ -1332,13 +1333,19 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)VirtMachineClass *vmc =VIRT_MACHINE_GET_CLASS (vms);GArray *table_offsets;unsigned dsdt, xsdt; +bool has_wdat = false;GArray *tables_blob = tables->table_data;MachineState *ms =MACHINE (vms);CPUCoreCaches caches[CPU_MAX_CACHES ];unsigned int num_caches; +Object *wdt =object_resolve_type_unambiguous (TYPE_WDT_SBSA ,NULL ); num_caches =virt_get_caches (vms, caches); +if (wdt) { + has_wdat =object_property_get_bool (wdt,"wdat" , &error_abort); + } + table_offsets =g_array_new (false, true/* clear */ ,sizeof (uint32_t ));
@@ -1357,6 +1364,17 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)acpi_add_table (table_offsets, tables_blob);build_madt (tables_blob, tables->linker, vms); +acpi_add_table (table_offsets, tables_blob); +if (wdt && has_wdat) { +uint64_t freq =object_property_get_uint (wdt,"clock-frequency" , + &error_abort); +build_gwdt_wdat (tables_blob, tables->linker, + vms->oem_id, vms->oem_table_id, + vms->memmap[VIRT_GWDT_REFRESH ].base, + vms->memmap[VIRT_GWDT_CONTROL ].base, + freq); + } +if (!vmc->no_cpu_topology) {acpi_add_table (table_offsets, tables_blob); build_pptt(tables_blob, tables->linker, ms, vms->oem_id,
@@ -1364,7 +1382,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) }acpi_add_table (table_offsets, tables_blob); -build_gtdt (tables_blob, tables->linker, vms); +build_gtdt (tables_blob, tables->linker, vms, wdt && !has_wdat);acpi_add_table (table_offsets, tables_blob); {
hw/arm/virt.c +8 -4
@@ -3846,10 +3846,12 @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,qdev_prop_set_array (dev,"reserved-regions" , reserved_regions);g_free (resv_prop_str); }else if (object_dynamic_cast (OBJECT (dev),TYPE_WDT_SBSA )) { -uint64_t cntfrq =object_property_get_int (OBJECT (qemu_get_cpu (0 )), -"cntfrq" , &error_abort); +if (!object_property_get_bool (OBJECT (dev),"wdat" , &error_abort)) { +uint64_t cntfrq =object_property_get_int (OBJECT (qemu_get_cpu (0 )), +"cntfrq" , &error_abort); -qdev_prop_set_uint64 (dev,"clock-frequency" , cntfrq); +qdev_prop_set_uint64 (dev,"clock-frequency" , cntfrq); + } }else if (object_dynamic_cast (OBJECT (dev),TYPE_ARM_SMMUV3 )) {if (vms->legacy_smmuv3_present || vms->iommu ==VIRT_IOMMU_VIRTIO ) { error_setg(errp, "virt machine already has %s set. "
@@ -3911,7 +3913,9 @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev,sysbus_mmio_map (s,1 , cbase);sysbus_connect_irq (s,0 ,qdev_get_gpio_in (vms->gic, irq)); -create_gwdt_dt_bindings (vms); +if (!object_property_get_bool (OBJECT (dev),"wdat" , &error_abort)) { +create_gwdt_dt_bindings (vms); + } }if (vms->platform_bus_dev) {
Signature · 1 line
2.47.3
PATCH v4 8/13 tests: acpi: arm/virt: whitelist new WDAT table
In reply to Igor Mammedov--- tests/qtest/bios-tables-test-allowed-diff.h | 1 + tests/data/acpi/aarch64/virt/WDAT.wdat | 0 2 files changed, 1 insertion(+) create mode 100644 tests/data/acpi/aarch64/virt/WDAT.wdat
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
@@ -1 +1,2 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/aarch64/virt/WDAT.wdat",
tests/data/acpi/aarch64/virt/WDAT.wdat new file +0 -0
Signature · 1 line
2.47.3
PATCH v4 9/13 tests: acpi: arm/virt: add WDAT table test case
In reply to Igor Mammedov--- tests/qtest/bios-tables-test.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
tests/qtest/bios-tables-test.c +21 -0
@@ -2275,6 +2275,25 @@ static void test_acpi_aarch64_virt_tcg_msi_gicv2m(void)free_test_data (&data); } +static void test_acpi_aarch64_virt_tcg_wdat (void ) +{ +test_data data = { + .machine ="virt" , + .arch ="aarch64" , + .variant =".wdat" , + .tcg_only = true, + .uefi_fl1 ="pc-bios/edk2-aarch64-code.fd" , + .uefi_fl2 ="pc-bios/edk2-arm-vars.fd" , + .cd ="tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2" , + .ram_start =0x40000000ULL , + .scan_len =128ULL * MiB, + }; + +test_acpi_one ("-cpu cortex-a57 " +"-device sbsa-gwdt,wdat=on" , &data); +free_test_data (&data); +} +static void test_acpi_q35_viot (void ) {test_data data = {
@@ -2893,6 +2912,8 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/virt/smmuv3-dev" , test_acpi_aarch64_virt_smmuv3_dev); } +qtest_add_func ("acpi/virt/acpi-watchdog" , + test_acpi_aarch64_virt_tcg_wdat); } }else if (strcmp (arch,"riscv64" ) ==0 ) {if (has_tcg &&qtest_has_device ("virtio-blk-pci" )) {
Signature · 1 line
2.47.3
PATCH v4 10/13 tests: acpi: arm/virt: update expected WDAT blob
In reply to Igor Mammedovreplace blank table with a new one:
[000h 0000 004h] Signature : "WDAT" [Watchdog Action Table]
[004h 0004 004h] Table Length : 00000104
[008h 0008 001h] Revision : 01
[009h 0009 001h] Checksum : 3B
[00Ah 0010 006h] Oem ID : "BOCHS "
[010h 0016 008h] Oem Table ID : "BXPC "
[018h 0024 004h] Oem Revision : 00000001
[01Ch 0028 004h] Asl Compiler ID : "BXPC"
[020h 0032 004h] Asl Compiler Revision : 00000001
[024h 0036 004h] Header Length : 00000020
[028h 0040 002h] PCI Segment : 00FF
[02Ah 0042 001h] PCI Bus : FF
[02Bh 0043 001h] PCI Device : FF
[02Ch 0044 001h] PCI Function : FF
[02Dh 0045 003h] Reserved : 000000
[030h 0048 004h] Timer Period : 00000001
[034h 0052 004h] Max Count : 000927C0
[038h 0056 004h] Min Count : 00001388
[03Ch 0060 001h] Flags (decoded below) : 81
Enabled : 1
Stopped When Asleep : 1
[03Dh 0061 003h] Reserved : 000000
[040h 0064 004h] Watchdog Entry Count : 00000008
[044h 0068 001h] Watchdog Action : 08
[045h 0069 001h] Instruction : 00
[046h 0070 002h] Reserved : 0000
[048h 0072 00Ch] Register Region : [Generic Address Structure]
[048h 0072 001h] Space ID : 00 [SystemMemory]
[049h 0073 001h] Bit Width : 20
[04Ah 0074 001h] Bit Offset : 00
[04Bh 0075 001h] Encoded Access Width : 03 [DWord Access:32]
[04Ch 0076 008h] Address : 000000000C001000
[054h 0084 004h] Value : 00000001
[058h 0088 004h] Register Mask : 00000001
[05Ch 0092 001h] Watchdog Action : 01
[05Dh 0093 001h] Instruction : 02
[05Eh 0094 002h] Reserved : 0000
[060h 0096 00Ch] Register Region : [Generic Address Structure]
[060h 0096 001h] Space ID : 00 [SystemMemory]
[061h 0097 001h] Bit Width : 20
[062h 0098 001h] Bit Offset : 00
[063h 0099 001h] Encoded Access Width : 03 [DWord Access:32]
[064h 0100 008h] Address : 000000000C000000
[06Ch 0108 004h] Value : 00000001
[070h 0112 004h] Register Mask : 00000007
[074h 0116 001h] Watchdog Action : 06
[075h 0117 001h] Instruction : 03
[076h 0118 002h] Reserved : 0000
[078h 0120 00Ch] Register Region : [Generic Address Structure]
[078h 0120 001h] Space ID : 00 [SystemMemory]
[079h 0121 001h] Bit Width : 20
[07Ah 0122 001h] Bit Offset : 00
[07Bh 0123 001h] Encoded Access Width : 03 [DWord Access:32]
[07Ch 0124 008h] Address : 000000000C001008
[084h 0132 004h] Value : 00000000
[088h 0136 004h] Register Mask : FFFFFFFF
[08Ch 0140 001h] Watchdog Action : 09
[08Dh 0141 001h] Instruction : 82
[08Eh 0142 002h] Reserved : 0000
[090h 0144 00Ch] Register Region : [Generic Address Structure]
[090h 0144 001h] Space ID : 00 [SystemMemory]
[091h 0145 001h] Bit Width : 20
[092h 0146 001h] Bit Offset : 00
[093h 0147 001h] Encoded Access Width : 03 [DWord Access:32]
[094h 0148 008h] Address : 000000000C001000
[09Ch 0156 004h] Value : 00000001
[0A0h 0160 004h] Register Mask : 00000001
[0A4h 0164 001h] Watchdog Action : 0A
[0A5h 0165 001h] Instruction : 00
[0A6h 0166 002h] Reserved : 0000
[0A8h 0168 00Ch] Register Region : [Generic Address Structure]
[0A8h 0168 001h] Space ID : 00 [SystemMemory]
[0A9h 0169 001h] Bit Width : 20
[0AAh 0170 001h] Bit Offset : 00
[0ABh 0171 001h] Encoded Access Width : 03 [DWord Access:32]
[0ACh 0172 008h] Address : 000000000C001000
[0B4h 0180 004h] Value : 00000000
[0B8h 0184 004h] Register Mask : 00000001
[0BCh 0188 001h] Watchdog Action : 0B
[0BDh 0189 001h] Instruction : 82
[0BEh 0190 002h] Reserved : 0000
[0C0h 0192 00Ch] Register Region : [Generic Address Structure]
[0C0h 0192 001h] Space ID : 00 [SystemMemory]
[0C1h 0193 001h] Bit Width : 20
[0C2h 0194 001h] Bit Offset : 00
[0C3h 0195 001h] Encoded Access Width : 03 [DWord Access:32]
[0C4h 0196 008h] Address : 000000000C001000
[0CCh 0204 004h] Value : 00000000
[0D0h 0208 004h] Register Mask : 00000001
[0D4h 0212 001h] Watchdog Action : 20
[0D5h 0213 001h] Instruction : 00
[0D6h 0214 002h] Reserved : 0000
[0D8h 0216 00Ch] Register Region : [Generic Address Structure]
[0D8h 0216 001h] Space ID : 00 [SystemMemory]
[0D9h 0217 001h] Bit Width : 20
[0DAh 0218 001h] Bit Offset : 00
[0DBh 0219 001h] Encoded Access Width : 03 [DWord Access:32]
[0DCh 0220 008h] Address : 000000000C001000
[0E4h 0228 004h] Value : 00000004
[0E8h 0232 004h] Register Mask : 00000004
[0ECh 0236 001h] Watchdog Action : 21
[0EDh 0237 001h] Instruction : 82
[0EEh 0238 002h] Reserved : 0000
[0F0h 0240 00Ch] Register Region : [Generic Address Structure]
[0F0h 0240 001h] Space ID : 00 [SystemMemory]
[0F1h 0241 001h] Bit Width : 20
[0F2h 0242 001h] Bit Offset : 00
[0F3h 0243 001h] Encoded Access Width : 03 [DWord Access:32]
[0F4h 0244 008h] Address : 000000000C000000
[0FCh 0252 004h] Value : 00000004
[100h 0256 004h] Register Mask : 00000004
Raw Table Data: Length 260 (0x104)
--- tests/qtest/bios-tables-test-allowed-diff.h | 1 - tests/data/acpi/aarch64/virt/WDAT.wdat | Bin 0 -> 260 bytes 2 files changed, 1 deletion(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
@@ -1,2 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/aarch64/virt/WDAT.wdat",
tests/data/acpi/aarch64/virt/WDAT.wdat binary +0 -0
Signature · 1 line
2.47.3
PATCH v4 11/13 tests: acpi: arm/virt: whitelist GTDT table
In reply to Igor Mammedov--- tests/qtest/bios-tables-test-allowed-diff.h | 1 + 1 file changed, 1 insertion(+)
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
@@ -1 +1,2 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/aarch64/virt/GTDT",
Signature · 1 line
2.47.3
PATCH v4 12/13 tests: acpi: arm/virt: add GTDT watchdog table test case
In reply to Igor Mammedov---
v4:
(Eric) fix whitespace in test command string (moved from patch 17)
--- tests/qtest/bios-tables-test.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
tests/qtest/bios-tables-test.c +20 -0
@@ -2294,6 +2294,24 @@ static void test_acpi_aarch64_virt_tcg_wdat(void)free_test_data (&data); } +static void test_acpi_aarch64_virt_tcg_gtdt_wd (void ) +{ +test_data data = { + .machine ="virt" , + .arch ="aarch64" , + .variant =".gwdt" , + .tcg_only = true, + .uefi_fl1 ="pc-bios/edk2-aarch64-code.fd" , + .uefi_fl2 ="pc-bios/edk2-arm-vars.fd" , + .cd ="tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2" , + .ram_start =0x40000000ULL , + .scan_len =128ULL * MiB, + }; + +test_acpi_one ("-cpu cortex-a57 -device sbsa-gwdt" , &data); +free_test_data (&data); +} +static void test_acpi_q35_viot (void ) {test_data data = {
@@ -2914,6 +2932,8 @@ int main(int argc, char *argv[]) }qtest_add_func ("acpi/virt/acpi-watchdog" , test_acpi_aarch64_virt_tcg_wdat); +qtest_add_func ("acpi/virt/gwdt-watchdog" , + test_acpi_aarch64_virt_tcg_gtdt_wd); } }else if (strcmp (arch,"riscv64" ) ==0 ) {if (has_tcg &&qtest_has_device ("virtio-blk-pci" )) {
Signature · 1 line
2.47.3
PATCH v4 13/13 tests: acpi: arm/virt: update expected GTDT blob
In reply to Igor MammedovExpected diff from base GTDT is an addition of watchdog timer block:
[000h 0000 004h] Signature : "GTDT" [Generic Timer Description Table]
-[004h 0004 004h] Table Length : 00000068
+[004h 0004 004h] Table Length : 00000084
[008h 0008 001h] Revision : 03 -[009h 0009 001h] Checksum : 93 +[009h 0009 001h] Checksum : 39
[00Ah 0010 006h] Oem ID : "BOCHS "
[010h 0016 008h] Oem Table ID : "BXPC "
[018h 0024 004h] Oem Revision : 00000001
@@ -48,17 +48,30 @@
Always On : 0
[050h 0080 008h] Counter Read Block Address : FFFFFFFFFFFFFFFF
-[058h 0088 004h] Platform Timer Count : 00000000
-[05Ch 0092 004h] Platform Timer Offset : 00000000
+[058h 0088 004h] Platform Timer Count : 00000001
+[05Ch 0092 004h] Platform Timer Offset : 00000068
[060h 0096 004h] Virtual EL2 Timer GSIV : 00000000
[064h 0100 004h] Virtual EL2 Timer Flags : 00000000
-Raw Table Data: Length 104 (0x68)
+[068h 0104 001h] Subtable Type : 01 [Generic Watchdog Timer]
+[069h 0105 002h] Length : 001C
+[06Bh 0107 001h] Reserved : 00
+[06Ch 0108 008h] Refresh Frame Address : 000000000C000000
+[074h 0116 008h] Control Frame Address : 000000000C001000
+[07Ch 0124 004h] Timer Interrupt : 00000090
+[080h 0128 004h] Timer Flags (decoded below) : 00000000
+ Trigger Mode : 0
+ Polarity : 0
+ Security : 0
+
+Raw Table Data: Length 132 (0x84)
--- tests/qtest/bios-tables-test-allowed-diff.h | 1 - tests/data/acpi/aarch64/virt/GTDT.gwdt | Bin 0 -> 132 bytes 2 files changed, 1 deletion(-) create mode 100644 tests/data/acpi/aarch64/virt/GTDT.gwdt
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
@@ -1,2 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/aarch64/virt/GTDT",
tests/data/acpi/aarch64/virt/GTDT.gwdt new file binary +0 -0
Signature · 1 line
2.47.3