From owner-freebsd-bugs@FreeBSD.ORG Thu Apr 17 16:40:15 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DD40337B401 for ; Thu, 17 Apr 2003 16:40:14 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E835F43FD7 for ; Thu, 17 Apr 2003 16:40:13 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h3HNeDUp055230 for ; Thu, 17 Apr 2003 16:40:13 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3HNeDA6055229; Thu, 17 Apr 2003 16:40:13 -0700 (PDT) Resent-Date: Thu, 17 Apr 2003 16:40:13 -0700 (PDT) Resent-Message-Id: <200304172340.h3HNeDA6055229@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, Alan Larson Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4F72C37B401 for ; Thu, 17 Apr 2003 16:31:23 -0700 (PDT) Received: from ground1.paix.net (ground1.paix.net [128.177.247.249]) by mx1.FreeBSD.org (Postfix) with ESMTP id C54E443FDD for ; Thu, 17 Apr 2003 16:31:22 -0700 (PDT) (envelope-from alarson@switchanddata.com) Received: (from larson@localhost) by ground1.paix.net (8.11.5/8.9.1) id h3HNVMx72167; Thu, 17 Apr 2003 16:31:22 -0700 (PDT) env-from (alarson@switchanddata.com) Message-Id: <200304172331.h3HNVMx72167@ground1.paix.net> Date: Thu, 17 Apr 2003 16:31:22 -0700 (PDT) From: Alan Larson To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/51110: halt -p doesn't if apm not enabled. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Alan Larson List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Apr 2003 23:40:15 -0000 >Number: 51110 >Category: kern >Synopsis: halt -p doesn't if apm not enabled. >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Apr 17 16:40:13 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Alan Larson >Release: FreeBSD 4.8-RELEASE i386 >Organization: >Environment: All distributed release versions, from 4.3 to 4.8, probably more. >Description: halt -p would halt the system, but not power down. Power down was known to work for windows 2k. Investigation revealed that apm_power_off() in apm.c was testing the softc to see if it was active. It appears to be unnecessary for the apm to be active to issue the bios call to power the machine down. A context diff of the correction is included. This is rather safe, since it calls apm_bioscall(), which calls apm_check_function_supported() right at the start. (Since the only requirement in the present code to get through to power off the system is that apm_softc.active be true, and that is set true by the ioctl to enable apm (without further testing), it seems quite safe to attempt the power off even if apm hasn't been enabled. The enabled state gives us no assurances that we can power the system off.) >How-To-Repeat: How to repeat the problem: su # many fun things start with this. apm -e 0 # only needed if it was already on. halt -p # you did save your work first, didn't you? >Fix: Fix to the problem: The following diff should do it just fine. *** apm.ccO Fri Mar 22 14:09:17 2002 --- apm.cc Fri Mar 22 14:15:10 2002 *************** *** 285,293 **** { struct apm_softc *sc = &apm_softc; ! /* Not halting powering off, or not active */ ! if (!(howto & RB_POWEROFF) || !apm_softc.active) ! return; sc->bios.r.eax = (APM_BIOS << 8) | APM_SETPWSTATE; sc->bios.r.ebx = PMDV_ALLDEV; sc->bios.r.ecx = PMST_OFF; --- 285,292 ---- { struct apm_softc *sc = &apm_softc; ! if (!(howto & RB_POWEROFF)) /* Powering off? */ ! return; /* no */ sc->bios.r.eax = (APM_BIOS << 8) | APM_SETPWSTATE; sc->bios.r.ebx = PMDV_ALLDEV; sc->bios.r.ecx = PMST_OFF; >Release-Note: >Audit-Trail: >Unformatted: