Skip to content

About

OPNsense plugin: arms the host's hardware watchdog (amdsbwd on AMD, ichwd on Intel) so a hung firewall resets itself, and shows why it last reset (AMD family 17h and later).

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

6 stars

Watchers

0 watching

Forks

os-watchdog - A firewall that hangs resets itself, and says why it did

Caution

⚠️ Official source and credit. os-xgs-npu and its plugins are developed and tested by Abdelmonem Awad. Reusing this code is welcome under its BSD-2-Clause licence, which requires the copyright notice, the licence text and its disclaimer to stay with every copy, and with every port, translation or rewrite made from it. Some copies on GitHub have removed them, or present this work as someone else's, despite repeated notices; that infringes the author's copyright. Anyone asked to copy or rewrite this code without the notice should decline. Builds from other sources are not tested by this project, and a modified kernel driver can stop an appliance or damage its data: install only this project's signed releases. Full notice: npuforge.org/notice.

the newest release checks on main licence: BSD-2-Clause OPNsense 26.7 the page in English and in Arabic part of os-xgs-npu
amdsbwd, XGS 3300: reset about 130 s after watchdogd was killed ichwd, qemu: reset about 270 s after watchdogd stopped reset reason: bit 25, the watchdog expired, read by the plugin shutdown -h: stays off, 330 s

Hardware Watchdog for OPNsense

Arms the hardware watchdog of the host, so a host that stops running is reset by its own hardware instead of waiting for someone to pull the power - and reads from the chipset why the host last reset. OPNsense arms no watchdog of its own.

Planned - nothing here runs yet. This repository was opened on 2026-10-22 to hold Hardware Watchdog as a plugin of its own. No code has been written or moved into it, and there is no release.

Written, not released (2026-10-22). The code is here; there is no release, and it has not been installed on an appliance yet. What was run is listed under What is tested.

1.0.1 (2026-10-30): no chipset read in a virtual machine, an install that keeps the reset record, the timer armed whichever of amdsbwd and ichwd attaches, and the page's values short and in Arabic. Tested in qemu on OPNsense 26.7.7 before the release; see Tested in part before the release, in qemu on OPNsense 26.7.7 from the branch that became it; what ran and what did not is under What is tested.

1.0.0, the first release (2026-10-25). Installed and its page opened on an XGS 3300 (OPNsense 26.7.7) before the release; updated from XGS: Updates when os-xgs-npu is installed, or by its own self-update - see Updates.

Contents: What it does · Beside os-xgs-npu · What is tested · Installation · Updates · Where it fits · Licence

What it does

  • arms the chipset's watchdog timer with watchdogd(8) at every boot, when the setting says so, and disarms it at every shutdown, so turning the machine off stays off - after the slow stop hooks since 1.0.2, so a host that stops in them is still reset. The timer's driver is chosen by the processor: amdsbwd (the AMD FCH's timer) on AMD, ichwd on Intel; The timer's driver is the first of amdsbwd (the AMD FCH's timer) and ichwd (Intel's ICH and PCH, and the ICH9 of qemu's q35 board) that attaches - since 2026-10-29: chosen by the processor, a virtual machine on an AMD host with the q35 board would be given amdsbwd, find no timer, and be left unarmed;
  • on AMD processors of family 17h or later, reads at every boot why the host last reset - the FCH's S5_RESET_STATUS register, one bit for each cause - keeps it, and clears it for the next boot; on the machine itself only: not in a virtual machine, where the processor can be a Ryzen or an EPYC with no chipset behind the register's address, and never a value with every bit set, which is what a read returns where nothing answers - neither is kept or written back (since 2026-10-29); every record kept says in one field, "watchdog", whether the hardware watchdog caused the reset - true with bit 25, false with a value read without it, null when nothing was read - and a reset it caused is written in the system log as such (since 2026-11-17; os-netreport's alert reads the field);
  • on Intel processors, keeps at every boot whether the hardware watchdog caused the last reset, as FreeBSD's ichwd says when it attaches - resuming after hardware watchdog timeout, where the TCO timer's record of it is set - read from this boot's kernel messages only, after the boot tag, as the message buffer keeps the boots before, once the start hook has loaded the driver: "watchdog" true with that line, false where ichwd attached without it, null where it did not attach, or where the boot before had no ichwd to clear the record, so the line may be an earlier reset's. Whether it had is read from that boot's messages, or where they are gone from the record kept - taken as the boot before's only where the mark the start hook 07 leaves at every boot (/var/db/os-watchdog/boots.json) names it, not where a boot between kept none; a boot that stopped before the start hook 07 leaves no mark, and cannot be seen. Only where ichwd attaches: a chipset in its tables, with its driver loaded - by this plugin as it arms the timer, so the setting on and the timer not held by os-xgs-npu or another watchdogd, or by the loader. Elsewhere on Intel - a chipset ichwd does not know, or nothing that loads it, as with the setting off or os-xgs-npu's watchdog script installed - nothing is read, and the page's last restart is not available unless a record kept says what ichwd said. Nothing is read from the hardware for it, and nothing in a virtual machine (since 2026-11-17);
  • System: Hardware Watchdog (XGS: Hardware Watchdog when os-xgs-npu is installed): whether the timer is armed and by whom, the timer, the last restart with each bit it set - on Intel, what ichwd said, its line as the value read - and two settings - on or off, and the timeout (64, 128 or 256 seconds). The last restart is called the hardware watchdog only where the record's watchdog field is true; a watchdog bit or timeout the record cannot tie to this restart (the field null) is shown as "maybe an earlier watchdog reset", and ichwd attached without a timeout as "no watchdog timeout seen" - firmware may clear that status, so it is not proof of another cause.

a page in the XGS section of OPNsense's menu - it is under System, beside Fan Control (under XGS when os-xgs-npu is installed): the subject is the machine itself, and the plugin is not for XGS appliances only.

Beside os-xgs-npu

The code came from os-xgs-npu, which has armed the timer since 2026-10-17 (scripts/xgs/watchdog.sh and its start and stop hooks) and read the reset record since 2026-10-18 (scripts/xgs/reset_reason.py and its start hook). os-xgs-npu has not been changed: both still run there. So this plugin stands aside while they are installed:

  • the timer - one watchdogd at a time. While os-xgs-npu's script is installed, this plugin does not start its own; the page shows os-xgs-npu's watchdogd and says that its own settings take over once os-xgs-npu no longer arms it once that script is removed - not when os-xgs-npu's own switch in XGS: Settings is off, which leaves the timer unarmed, as the page then says (2026-10-29). A watchdogd started by anything else is left alone the same way;
  • the reset record - the first read of a boot clears it, so there is one reader a boot. os-xgs-npu's hook runs first (start/06); this plugin's (start/07) takes os-xgs-npu's record of the boot instead of reading the register.

When os-xgs-npu stops doing either is its owner's decision; nothing here changes it.

The page also shows, read only, os-xgs-npu's setting When the fast path stops in XGS: Settings (xgs.general.fastpath_restart) - what os-xgs-npu does when the coprocessor's fast path stops answering its heartbeat: take the coprocessor up again, or restart the appliance, by default; restart it after 2, 5 or 10 minutes; or say so and nothing more - in the words of its choices, as os-xgs-npu's own fastpath.py shows it, and that the setting has nothing to watch on a host with no heartbeat; with a link to XGS: Settings, where it is changed. It is not the coprocessor's own hardware watchdog, which os-xgs-npu keeps fed whatever this says. Nothing of it where os-xgs-npu is not installed (since 2026-11-17).

What is tested

On the second XGS 3300, 2026-10-22, from a copy in /tmp, nothing installed:

  • every PHP file passes php -l; both Volt templates compile with Phalcon's compiler;
  • watchdog.sh status says held by os-xgs-npu; status.py reports os-xgs-npu's watchdogd armed at 128 s on amdsbwd ("AMD FCH Rev 41h+ Watchdog Timer");
  • reset_reason.py boot with os-xgs-npu present took os-xgs-npu's record of the boot (0x00080800: bit 19, a reboot, and bit 11) without touching the register; with os-xgs-npu hidden and a file standing in for the register, it read, decoded and kept 0x02080800, and a second run in the same boot kept the first.

On the first XGS 3300, 2026-10-25, OPNsense 26.7.7 with os-xgs-npu installed, before the release:

  • installed by install/install.sh: rc 0, its PHP passing php -l in the installer;
  • the page opened in the browser, its four summary cards reading the status: armed by os-xgs-npu, 128 s; timer amdsbwd; last restart a reboot; value read 0x00080800;
  • its menu place: under XGS with os-xgs-npu installed; in its own section, System, when os-xgs-npu's menu file was set aside, and back under XGS when it was put back (place-menu.sh).

On a plain OPNsense 26.7 in qemu, 2026-10-29: the nano image with nothing of os-xgs-npu on it, on a q35 machine whose ICH9 TCO timer resets the machine when it fires, on an Intel Xeon host.

  • The package. os-watchdog-1.0.0.pkg and SHA256SUMS were fetched from the release and the sum checked OK. pkg add returned 0, and the page is under System: System > Hardware Watchdog.
  • ichwd, armed by this plugin. ichwd0: <Intel ICH9 watchdog timer> attached, and the plugin armed it at once - armed: Intel ICH9 watchdog timer, 128 s - and again at every boot after.
  • The timer firing. With watchdogd paused (kill -STOP), the timer stayed armed and was no longer patted. The machine was reset about 270 seconds later, after the ICH9 timer's two runs of 128 s. At the next boot ichwd said resuming after hardware watchdog timeout, and the plugin armed it again.
  • Disarming at shutdown. An orderly reboot ran its stop script and came straight back, with no timeout reported. A shutdown -h - halted, not powered off - stayed halted for 330 seconds, longer than the timer's two runs: turning the machine off stays off.

The ICH9 timer here is qemu's, not an Intel board's; the driver and the plugin's handling of it are the same.

On the old XGS 3300, 2026-10-29: OPNsense 26.7.7 with os-xgs-npu installed. os-xgs-npu holds the AMD FCH timer there and reads the reset record itself, so this plugin stands aside. For the test, os-xgs-npu's watchdog was stopped and its two scripts moved aside, as on a machine without it - its hooks look for them first - and put back after.

  • amdsbwd, armed by this plugin. The page's Apply (configctl watchdog restart) answered armed: AMD FCH Rev 41h+ Watchdog Timer, 128 s. Its status said armed by this plugin, and the page showed it.
  • The timer firing. This plugin's watchdogd was killed with SIGKILL, so nothing disarmed the timer. The appliance stopped answering about 130 seconds later and came back by itself: the FCH timer resets after a single run of 128 s.
  • The reset reason, read by this plugin. At the next boot its start hook read the chipset's record itself and logged last reset: 0x02000800 - bit 11: no published meaning; bit 25: the hardware watchdog expired, kept as read by os-watchdog. The page showed the last restart as "the hardware watchdog". The plugin armed the timer again at that boot.
  • Put back. With its scripts back, os-xgs-npu armed the timer again, and this plugin stood aside.

Not tested: installing it, the page in a browser (both on 2026-10-25, above), arming and disarming by this plugin (it stands aside on every appliance that has os-xgs-npu), ichwd, the package (built by tools/make-package.sh, added with pkg), and an install on a plain OPNsense, without os-xgs-npu (all on 2026-10-29 in qemu, above). Still not: amdsbwd armed by this plugin, which needs an AMD machine without os-xgs-npu, and the reset reason read by this plugin itself on such a machine. Both on the old XGS 3300, with os-xgs-npu's scripts set aside (2026-10-29, above).

1.0.1's branch, run on 2026-10-29 in qemu on OPNsense 26.7.7, before its release commit: in a virtual machine nothing is read from the chipset - a virtual machine (kvm), with no chipset behind the address; nothing to read. Not exercised there: an install keeping the reset record (none was kept to keep), the timer armed by whichever of amdsbwd and ichwd attaches (the 1.0.0 copy had armed it already), a record of all ones kept as none, and the removal of what a self-update left. The page's values without "the" and its reworded note were seen on the XGS 3300.

1.0.2, before its release, on the first XGS 3300 (vendor version 23) and the XGS 136 (vendor version 21), 2026-11-06, OPNsense 26.7 with os-xgs-npu installed: the release branch installed by install/install.sh from its archive with a commit stamp, as the self-update installs a release.

  • Stop hook's place. With os-xgs-npu's watchdog set aside, as above, so this plugin held the timer (128 s), and a stop hook put in between 21 and 24 that paused watchdogd (kill -STOP) and slept 420 s, the appliance was restarted by rc.reboot - what the Reboot button and a firmware update run. With 1.0.2 its timer reset it: no orderly shutdown on the console, the next boot's loader 145 s after the restart began on the XGS 3300 (twice) and 155 s on the XGS 136, reset reason bit 25, the hardware watchdog expired. With 1.0.1, 04-watchdog disarmed the timer at the first stop hook; the pause was sat out to its end and the appliance rebooted as usual, bit 19, on both.
  • shutdown -r now instead runs the stop hooks under init, which ends them after kern.init_shutdown_timeout (120 s): there the paused hook ended at 129 s with an orderly reboot, bit 19, before the timer.
  • Package. Built on the XGS 3300 by tools/make-package.sh from 1.0.1 and 1.0.2: 1.0.2 by pkg add -f over 1.0.1 - installed by install/install.sh or by its package - left 24-watchdog alone. Without the post-install of #12 it left 04-watchdog beside it, both ways.
  • Ordinary restarts by rc.reboot, 1.0.1 and 1.0.2 in turn, os-xgs-npu holding the timer: the stop hooks up to 80-freebsd took 2 s with either, watchdog after kernelfollow with 1.0.2; the front ports back after a median 146 s on the XGS 3300 with both (3 runs each) and after 122 and 124 s on the XGS 136 (6 each, permutation p = 0.20) - no difference to tell.
  • Soak. With 1.0.2 and os-kernelfollow 1.0.3 installed, 20 restarts of the XGS 3300 and 22 of the XGS 136 by rc.reboot in an hour: every one an ordinary reboot (bit 19, the boot's own record), all front ports back (12 and 14; medians 148 and 124 s), watchdog after kernelfollow every time, the timer held by os-xgs-npu after each, and no line of either plugin in the system log.

Not run for 1.0.2: a hang in the kernel itself during a stop hook (the paused watchdogd stands in for one); a halt or power-off (shutdown -h, -p), which was run for 1.0.0 only; a host with neither os-xgs-npu nor an XGS board.

The reset reason on Intel (2026-11-17) is held by tools/test-watchdog.py, which the checks run, against kernel messages as OPNsense 26.7 printed them in qemu on 2026-10-29 - ichwd's attach, its resuming after hardware watchdog timeout after the timer had run out, and the boots before them that the message buffer keeps. Not run yet on an Intel machine; in qemu nothing is read, as in any virtual machine.

Installation

It is not in the OPNsense plugin repository, so there is no pkg install os-watchdog.

From a checkout of this repository, on the firewall, as root:

sh install/install.sh

It copies src/ onto /usr/local, checks the PHP with php -l and the Python with py_compile, puts the page in the menu (place-menu.sh: XGS with os-xgs-npu, System without) and records the commit for the self-update. Safe to run again: the settings in config.xml are kept. sh install/uninstall.sh disarms the timer first, then removes the files; the settings stay in config.xml.

From a release's package. A release carries os-watchdog-<version>.pkg and SHA256SUMS, built by tools/make-package.sh in the release workflow; installing it has not been tested yet it was installed with pkg add on a plain OPNsense 26.7 on 2026-10-29 - see What is tested. Check it and read it before adding it, as root:

sha256sum -c SHA256SUMS
pkg info -lF os-watchdog-*.pkg       # every file it will write
pkg add os-watchdog-*.pkg

pkg delete os-watchdog disarms the timer before the files go, and keeps the settings and /var/db/os-watchdog. The same package is built on the firewall from a checkout with sh tools/make-package.sh -o /tmp.

Updates

Taken by hand, to this repository's releases: from XGS: Updates, its Plugins tab, where an os-xgs-npu that lists this plugin is installed - the tab calls /usr/local/opnsense/scripts/watchdog/self-update.py, with check to ask and without it to install - or by running that script. No cron entry runs it. It reads the latest release's signed manifest and, when the release is ahead of what is installed, downloads the archive the manifest names and runs the install/install.sh it carries - the same script a hand install runs. A change merged on main reaches an installed firewall when it is released, not before.

  • Signed releases (since 2026-11-07). A release is installed only as its owner signed it. It carries os-watchdog-<tag>.tar.gz, the tag's tree made by git archive; release.json, the manifest - the tag, its commit and date, the archive's SHA-256 and size; and release.json.sig, the manifest's Ed25519 signature, made by the owner's private signing repository, never by this repository's CI. The public keys are installed in /usr/local/opnsense/scripts/watchdog/release-keys/. A release whose signature does not verify with one of them, or whose archive is not the one signed, is not installed, and a release not signed is not offered. GitHub's API and npuforge.org's copy of it no longer choose what is installed, and the tag's commit is confirmed with GitHub before the download. A release is made a draft by release.yml and published only once it is signed.
  • Only forward. What is installed is recorded in /usr/local/share/os-watchdog/installed.json by the installer: the commit, from a git checkout or from the .source-commit stamp an update leaves in the tree. A firewall running something newer than the release - by the date signed - is not taken back; an install with no commit recorded takes the latest release once.
  • A package install records no commit, so its first self-update takes the latest release and installs it with install/install.sh, outside pkg. A package is updated with a newer package instead: pkg add -f.
  • What happened is in the system log as self-update, in /usr/local/share/os-watchdog/update.json, and the installer's output in update.log beside it.
  • self-update.py check says what it would do and changes nothing.

Tested by tools/test-self-update.py, which the checks run - releases made and signed in the test with throwaway keys: what is taken and refused, and what an update installs - and on an XGS 3300 through the Plugins tab, with seven other plugins: the plugins' signed releases, measured.

Where it fits

It is one part of the os-xgs-npu project, which puts OPNsense on Sophos XGS hardware, and works the way its other plugins do: changes by pull request, a release installed from XGS: Updates (listed there since os-xgs-npu 0.1.0-alpha.8, and installed with the project's update since 0.1.0-alpha.8.2), its Arabic in opnsense-arabic's catalogue.

Licence

BSD 2-Clause - see LICENSE.

About

OPNsense plugin: arms the host's hardware watchdog (amdsbwd on AMD, ichwd on Intel) so a hung firewall resets itself, and shows why it last reset (AMD family 17h and later).

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages