lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b3849bea-2a4d-079e-e9df-8a1d6c13c0c7@ti.com>
Date:   Thu, 25 Jun 2020 11:32:07 +0300
From:   Tero Kristo <t-kristo@...com>
To:     Jan Kiszka <jan.kiszka@...mens.com>, <wim@...ux-watchdog.org>,
        <linux@...ck-us.net>, <linux-watchdog@...r.kernel.org>
CC:     <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] watchdog: rti: tweak min_hw_heartbeat_ms to match
 initial allowed window

On 24/06/2020 18:24, Jan Kiszka wrote:
> On 24.06.20 13:45, Tero Kristo wrote:
>> If the RTI watchdog has been started by someone (like bootloader) when
>> the driver probes, we must adjust the initial ping timeout to match the
>> currently running watchdog window to avoid generating watchdog reset.
>>
>> Signed-off-by: Tero Kristo <t-kristo@...com>
>> ---
>>   drivers/watchdog/rti_wdt.c | 25 +++++++++++++++++++++++++
>>   1 file changed, 25 insertions(+)
>>
>> diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
>> index d456dd72d99a..02ea2b2435f5 100644
>> --- a/drivers/watchdog/rti_wdt.c
>> +++ b/drivers/watchdog/rti_wdt.c
>> @@ -55,11 +55,13 @@ static int heartbeat;
>>    * @base - base io address of WD device
>>    * @freq - source clock frequency of WDT
>>    * @wdd  - hold watchdog device as is in WDT core
>> + * @min_hw_heartbeat_save - save of the min hw heartbeat value
>>    */
>>   struct rti_wdt_device {
>>       void __iomem        *base;
>>       unsigned long        freq;
>>       struct watchdog_device    wdd;
>> +    unsigned int        min_hw_heartbeat_save;
>>   };
>>   static int rti_wdt_start(struct watchdog_device *wdd)
>> @@ -107,6 +109,11 @@ static int rti_wdt_ping(struct watchdog_device *wdd)
>>       /* put watchdog in active state */
>>       writel_relaxed(WDKEY_SEQ1, wdt->base + RTIWDKEY);
>> +    if (wdt->min_hw_heartbeat_save) {
>> +        wdd->min_hw_heartbeat_ms = wdt->min_hw_heartbeat_save;
>> +        wdt->min_hw_heartbeat_save = 0;
>> +    }
>> +
>>       return 0;
>>   }
>> @@ -201,6 +208,24 @@ static int rti_wdt_probe(struct platform_device 
>> *pdev)
>>           goto err_iomap;
>>       }
>> +    if (readl(wdt->base + RTIDWDCTRL) == WDENABLE_KEY) {
>> +        u32 time_left;
>> +        u32 heartbeat;
>> +
>> +        set_bit(WDOG_HW_RUNNING, &wdd->status);
>> +        time_left = rti_wdt_get_timeleft(wdd);
>> +        heartbeat = readl(wdt->base + RTIDWDPRLD);
>> +        heartbeat <<= WDT_PRELOAD_SHIFT;
>> +        heartbeat /= wdt->freq;
>> +        if (time_left < heartbeat / 2)
>> +            wdd->min_hw_heartbeat_ms = 0;
>> +        else
>> +            wdd->min_hw_heartbeat_ms =
>> +                (time_left - heartbeat / 2 + 1) * 1000;
>> +
>> +        wdt->min_hw_heartbeat_save = 11 * heartbeat * 1000 / 20;
>> +    }
>> +
>>       ret = watchdog_register_device(wdd);
>>       if (ret) {
>>           dev_err(dev, "cannot register watchdog device\n");
>>
> 
> This assumes that the bootloader also programmed a 50% window, right? 
> The pending U-Boot patch will do that, but what if that may chance or 
> someone uses a different setup?

Yes, we assume 50%. I think based on the hw design, 50% is the only sane 
value to be used, otherwise you just shrink the open window too much and 
for no apparent reason.

-Tero
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ