From owner-freebsd-bugs@FreeBSD.ORG Tue Jan 13 18:40:01 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 162AA1065677 for ; Tue, 13 Jan 2009 18:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E2E458FC1D for ; Tue, 13 Jan 2009 18:40:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n0DIe0Xo073914 for ; Tue, 13 Jan 2009 18:40:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n0DIe0VY073913; Tue, 13 Jan 2009 18:40:00 GMT (envelope-from gnats) Resent-Date: Tue, 13 Jan 2009 18:40:00 GMT Resent-Message-Id: <200901131840.n0DIe0VY073913@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dmitrij Tejblum Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 43247106564A for ; Tue, 13 Jan 2009 18:35:32 +0000 (UTC) (envelope-from tejblum@tejblum.yandex.ru) Received: from tejblum.yandex.ru (dhcp250-161.yandex.ru [87.250.250.161]) by mx1.freebsd.org (Postfix) with ESMTP id BF3B38FC21 for ; Tue, 13 Jan 2009 18:35:31 +0000 (UTC) (envelope-from tejblum@tejblum.yandex.ru) Received: from tejblum.yandex.ru (localhost [127.0.0.1]) by tejblum.yandex.ru (8.14.1/8.13.4) with ESMTP id n0DILhmH002433 for ; Tue, 13 Jan 2009 21:21:43 +0300 (MSK) (envelope-from tejblum@tejblum.yandex.ru) Received: (from tejblum@localhost) by tejblum.yandex.ru (8.14.1/8.13.4/Submit) id n0DILhf6002432; Tue, 13 Jan 2009 21:21:43 +0300 (MSK) (envelope-from tejblum) Message-Id: <200901131821.n0DILhf6002432@tejblum.yandex.ru> Date: Tue, 13 Jan 2009 21:21:43 +0300 (MSK) From: Dmitrij Tejblum To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: kern/130512: [patch] Various mistakes in IPMI watchdog handling X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Dmitrij Tejblum List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jan 2009 18:40:01 -0000 >Number: 130512 >Category: kern >Synopsis: [patch] Various mistakes in IPMI watchdog handling >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Jan 13 18:40:00 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Dmitrij Tejblum >Release: FreeBSD 7.1-PRERELEASE i386 >Organization: OOO Yandex >Environment: >Description: Watchdog handling in the ipmi driver has several problems. 1. Incorrect timeout setting: To get the most significant byte of a 2-byte number (i.e. sec*10) you should divide the number by 256, not 2550. Also, a second contains 1000000000 nanoseconds, not 1800000000 nanoseconds. (This change is verified by the "ipmitool" program and by testing when the watchdog actually fire.) 2. Due to rounding error, setting watchdog to a really small timeout (< 1 sec) was turning the watchdog off. It should set the watchdog to a small timeout instead. 3. The error checking was missed. >How-To-Repeat: Use ipmitool program from ports/sysutils/ipmitool (ipmitool bmc watchdog get) to see actual watchdog settings. Use different values of '-s' option to watchdogd to see when the timeout actually fires. >Fix: --- dev/ipmi/ipmi.c 2008-10-13 18:43:46.000000000 +0400 +++ dev/ipmi/ipmi.c 2009-01-13 21:15:49.000000000 +0300 @@ -588,7 +588,7 @@ * Watchdog event handler. */ -static void +static int ipmi_set_watchdog(struct ipmi_softc *sc, int sec) { struct ipmi_request *req; @@ -604,7 +604,7 @@ req->ir_request[2] = 0; req->ir_request[3] = 0; /* Timer use */ req->ir_request[4] = (sec * 10) & 0xff; - req->ir_request[5] = (sec * 10) / 2550; + req->ir_request[5] = (sec * 10) / 256; } else { req->ir_request[0] = IPMI_SET_WD_TIMER_SMS_OS; req->ir_request[1] = 0; @@ -631,6 +631,7 @@ } ipmi_free_request(req); + return error; /* dump_watchdog(sc); */ @@ -641,14 +642,22 @@ { struct ipmi_softc *sc = arg; unsigned int timeout; + int e; cmd &= WD_INTERVAL; if (cmd > 0 && cmd <= 63) { - timeout = ((uint64_t)1 << cmd) / 1800000000; - ipmi_set_watchdog(sc, timeout); - *error = 0; + timeout = ((uint64_t)1 << cmd) / 1000000000; + if (timeout == 0) + timeout = 1; + e = ipmi_set_watchdog(sc, timeout); + if (e == 0) + *error = 0; + else + ipmi_set_watchdog(sc, 0); } else { - ipmi_set_watchdog(sc, 0); + e = ipmi_set_watchdog(sc, 0); + if (e != 0) + *error = EOPNOTSUPP; } } >Release-Note: >Audit-Trail: >Unformatted: