From: Jan Kiszka <[email protected]>

Normally, the BIOS will reboot the system already on the first expiry,
when the related SMI triggered. On systems where this is disabled, e.g.
on QEMU, we will only get the reboot on the second timeout. Detect that
and adjust the timer programming accordingly.

Signed-off-by: Jan Kiszka <[email protected]>
---
 drivers/watchdog/itco.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/watchdog/itco.c b/drivers/watchdog/itco.c
index 835e081..a1ebb06 100644
--- a/drivers/watchdog/itco.c
+++ b/drivers/watchdog/itco.c
@@ -18,6 +18,10 @@
 #include <pci/header.h>
 #include <sys/io.h>
 
+#define SMI_EN_REG             0x30
+#define TCO_EN                 (1 << 13)
+#define GBL_SMI_EN             (1 << 0)
+
 #define TCO_RLD_REG            0x00
 #define TCO1_CNT_NO_REBOOT     (1 << 0)
 #define TCO1_CNT_REG           0x08
@@ -284,6 +288,15 @@ init(EFI_PCI_IO *pci_io, UINT16 pci_vendor_id, UINT16 
pci_device_id,
        Print(L"Detected Intel TCO %s watchdog\n", itco->name);
 
        pm_base = get_pm_base(pci_io, itco);
+       if (pm_base) {
+               /*
+                * If SMIs are not triggered, the reboot will only happen on
+                * the second timeout.
+                */
+               value = inl(pm_base + SMI_EN_REG);
+               if ((value & (TCO_EN | GBL_SMI_EN)) != (TCO_EN | GBL_SMI_EN))
+                       timeout /= 2;
+       }
 
        tco_base = get_tco_base(pm_base, itco);
        if (!tco_base) {
-- 
2.26.2

-- 
You received this message because you are subscribed to the Google Groups "EFI 
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/aa89fe3cbd883198c23eaec43c4448fe9e8ae148.1622447849.git.jan.kiszka%40siemens.com.

Reply via email to