Porting setjmp/longjmp to mips64 kernel issue

From: Fawad Lateef
Date: Wed Aug 08 2007 - 10:07:50 EST


Hello,

I am trying to implement/port the functionality of "setjmp" and
"longjmp" provided by glibc in a kernel module for mips64 based
embedded system; running debian with modified smp kernel 2.6.16 on
2-cores.

I removed all the floating-point registers save and restore
functionality from setjmp/longjmp functions as they are not
used/accessable from kernel.

Now the issue is:

Kernel hangs at instruction "j $31" in __longjmp function whenever I
try to do longjmp; the value loaded in registers (in longjmp function
especially PC in $31) are the same as I got in setjmp so it should
jump to correct location but I think its jmping to some other place
and simply stuck there.

The prints from my module before the kernel hangs is:

# insmod jmptest.ko
JMP test module loaded. Starting tests...
1:
pj_setjmp: 14 ....
calling first
calling second
pj_longjmp: 21 ....
__longjmp: 64 .... pc = [c00000000009d11c]

Can someone tell me if there is something wrong in my
porting/implementation __or__ give some hints ? I am attaching the
code in tar.gz (I am doing cross-compilation with embedded tool chain
so please adjust paths in Makefile when compiling)

Thanks in Advance.

--
Fawad Lateef

Attachment: setjmp_mips64_kern.tar.gz
Description: GNU Zip compressed data