Is it possible to call a C function in transfer_to_handler(arch/ppc/kernel/entry.S)?
hi, list
I'm sorry to ask this topic in this mailling list. I've spend more than 2
days try to add a C function call in transfer_to_handler(in arch/ppc/kernel/entry.S) like this:
/* cut from arch/ppc/kernel/entry.S */transfer_to_handler:
stw r2,GPR2(r11)
stw r12,_NIP(r11)
stw r9,_MSR(r11)
andi. r2,r9,MSR_PR
mfctr r12
mfspr r2,SPRN_XER
stw r12,_CTR(r11)
stw r2,_XER(r11)
mfspr r12,SPRN_SPRG3
addi r2,r12,-THREAD
tovirt(r2,r2) /* set r2 to current */
beq 2f /* if from user, fix up THREAD.regs */
#if 1 /* this is add by me */
stwu r1, -16(r1)
mflr r0
stw r0, 20(r1)
bl emulate_iret
lwz r0, 20(r1)
mtlr r0
addi r1, r1, 16
#endif
addi r11,r1,STACK_FRAME_OVERHEAD
stw r11,PT_REGS(r12)The function prolog is taken from a userspace program. this code freeze the system after prints out `emulate_iret' (The only thing function emulate_iret do is print that message).
I read the source code from head_44x.S to entry.S, sounds like all registers (r0-r32, and even more such as _LINK, _CTR, etc..) are being saved, does that mean I shouldn't call any C function in transfer_to_handler()? Is there something tricky (or is it possible) to add a C function call?
Thanks in advance!
regards
Signature · 5 lines
Wang, Baojun Lanzhou University Distributed & Embedded System Lab http://dslab.lzu.edu.cn School of Information Science and Engeneering [email protected] Tianshui South Road 222. Lanzhou 730000 .P.R.China Tel:+86-931-8912025 Fax:+86-931-8912022
Quoted 3 lines · Baojun
I'm sorry to ask this topic in this mailling list. I've spend more than 2
days try to add a C function call intransfer_to_handler(in arch/ppc/kernel/entry.S)like this:
It's not going to work, because the MMU is off at this point. It will explode as soon as the C code tries to touch any external variable.
Paul.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 5 lines
I'm sorry to ask this topic in this mailling list. I've spend more than 2
days try to add a C function call intransfer_to_handler(in arch/ppc/kernel/entry.S)like this:
Why are you sorry ? This is what this list is for - and if nobody can answer it then its good you sent it - thanks !
<snip...>
Quoted 1 line
#if 1 /* this is add by me */
could you change this to use onle R3-R13 as these are caller safe - My suspicion i sthat you are using R0/1/2 and that is not healthy here.
Quoted 11 lines
stwu r1, -16(r1)
mflr r0
stw r0, 20(r1)
bl emulate_iret
lwz r0, 20(r1)
mtlr r0
addi r1, r1, 16
#endif
addi r11,r1,STACK_FRAME_OVERHEAD
stw r11,PT_REGS(r12)out of PPC too long - but will see if I can find something.
hofrat
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFGWvR4nU7rXZKfY2oRArQDAJ99xJOrUlqYpPPuJtoqH27lGeDJ9ACeIj97 1bPlGITc1bVMw1V5YmXnG34=
=hvub
-----END PGP SIGNATURE-----