From owner-freebsd-hackers Tue Dec 10 8:22:50 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F2C2537B404; Tue, 10 Dec 2002 08:22:48 -0800 (PST) Received: from msgbas2x.cos.agilent.com (msgbas2x.cos.agilent.com [192.25.240.37]) by mx1.FreeBSD.org (Postfix) with ESMTP id 26D1F43ED4; Tue, 10 Dec 2002 08:22:48 -0800 (PST) (envelope-from ctuffli@rose.agilent.com) Received: from relcos2.cos.agilent.com (relcos2.cos.agilent.com [130.29.152.237]) by msgbas2x.cos.agilent.com (Postfix) with ESMTP id D4602D46; Tue, 10 Dec 2002 09:22:42 -0700 (MST) Received: from rtl.rose.agilent.com (rtl.rose.agilent.com [130.30.179.189]) by relcos2.cos.agilent.com (Postfix) with ESMTP id 5755A18; Tue, 10 Dec 2002 09:22:42 -0700 (MST) Received: from mail.rose.agilent.com (mailsrv@bellhop [130.30.179.19]) by rtl.rose.agilent.com (8.9.3 (PHNE_18979)/8.9.3 SMKit7.1.0) with ESMTP id IAA18644; Tue, 10 Dec 2002 08:22:41 -0800 (PST) Received: from thegrail (anu.rose.agilent.com [156.140.225.186]) by mail.rose.agilent.com (Netscape Messaging Server 3.6) with ESMTP id AAA24A8; Tue, 10 Dec 2002 08:22:39 -0800 Received: by thegrail (Postfix, from userid 1001) id 1BCA984659; Tue, 10 Dec 2002 08:18:20 -0800 (PST) Date: Tue, 10 Dec 2002 08:18:20 -0800 From: Chuck Tuffli To: phk@FreeBSD.ORG Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: registers not saved Message-ID: <20021210161813.GA681@thegrail.rose.agilent.com> References: <20021210154635.GC605@thegrail.rose.agilent.com> <99179.1039535914@critter.freebsd.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <99179.1039535914@critter.freebsd.dk> User-Agent: Mutt/1.4i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, Dec 10, 2002 at 04:58:34PM +0100, phk@FreeBSD.ORG wrote: > In message <20021210154635.GC605@thegrail.rose.agilent.com>, Chuck Tuffli write > s: > >I've been chasing down some weird panics in my CAM driver and have > >noticed that functions don't seem to save all register values before > >they modify them. > > > >For example, function A uses register ecx to hold the value of a > >pointer. Part way through, function A calls function B which uses > >ecx as a loop index. The bad part is function B never > >saves/restores the value of ecx and function A starts dereferencing > >garbage. > > > >An informal sampling of my driver seems to indicate that ebx gets > >pushed/poped at entry/exit but ecx and edx don't. Does any of this > >sound familiar? Thanks! > > There are strict rules for which registers should be saved and which not. The registers I see being saved are ebp, edi, esi, and ebx > You can modify these rules somewhat using weird compiler options, but > it should be consistent for all the code generated with the same > settings. These are the cc options I get when building the module (-I's removed) cc -O -pipe -I... -Werror -ggdb -DDBG -D_KERNEL -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -fformat-extensions -ansi -DKLD_MODULE -nostdinc -I- -I... -mpreferred-stack-boundary=2 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -fformat-extensions -ansi -c /usr/home/ctuffli/dev/tsdk/samples/bsd/tach/tach_pci.c > Which FreeBSD version (uname -a) and which compiler version (cc -v) > is this ? [522] cc -v Using builtin specs. gcc version 2.95.4 20020320 [FreeBSD] llama# uname -a FreeBSD llama.rose.agilent.com 4.7-STABLE FreeBSD 4.7-STABLE #3: Tue Dec 3 14:59:35 PST 2002 ctuffli@thegrail:/home/ctuffli/dev/bsd/sys/compile/THEGRAIL i386 This is 4.7-RELEASE GENERIC compiled with -g, using DDB and all the CAM debug options. The INET6 and XSERVER options are commented out as well as the cpu I{3,4,5}86_CPU definitions (i.e. only I686_CPU is used). -- Chuck Tuffli Agilent Technologies, Storage and Networking To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message