Date: Tue, 10 Dec 2002 08:18:20 -0800 From: Chuck Tuffli <chuck_tuffli@agilent.com> To: phk@FreeBSD.ORG Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: registers not saved Message-ID: <20021210161813.GA681@thegrail.rose.agilent.com> In-Reply-To: <99179.1039535914@critter.freebsd.dk> References: <20021210154635.GC605@thegrail.rose.agilent.com> <99179.1039535914@critter.freebsd.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <chuck_tuffli AT NO_SPAM agilent DOT com> Agilent Technologies, Storage and Networking To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021210161813.GA681>