[Developer] what does L4_Copy_regs_to_mrs() actually return?

Iyad Q ikq2754 at yahoo.com
Wed Apr 25 03:48:56 EST 2007


Thanks Hal,

I am considering a different scenario from syscall, actually I working on crashing a process instead.  However, I inspected the 1.4.1.1 release you mentioned, and still have same observations:

1) The UTCB does not contain register information. Per vergs.h MR are the only registers stored within utcb.  Am I overlooking something?

2) The L4_Copy_regs_to_mrs() seems to retrieve incorrect information.  Here is how I reached this conclusion.   First listing is the user thread registers captured just before a simulated crash.  These are the registers I need to retrieve from L4.  The second and third listings are the returned register values from the L4_copy... call.  Clearly, these values are captured in totally different context from the target thread identified with thread id passed by L4_copy..()  Also, note that the values are always the same regardless of the user thread id passed to L4_copy..()  Finally, note the sp returned value, it is zero.

As for latest l4 software, i checked perform_exregs() and it seems to get the context in similar fashion as what I have at the moment.

Iyad

User Registers just be a crash
===============================
r0 = 00000000, r1 = 00000000, r2 = 00000000, r3 = 00000000

r4 = 40838800, r5 = 01FF7E84, r6 = 0081EE08, r7 = 000088D8 

r8 = 00000001, r9 = 00A311C4, r10= 00A2F000, fp = 01FF7E74
ip = 01A00000, sp = 01FF7E38, lr = 01FF7DF8, pc = 00008654

cpsr = 60000010

Thread 1 , L4_Copy_regs_to_mrs()
================================
r0 = 00000001, r1 = 00000000, r2 = 00000000, r3 = 095ffc1c
r4 = 094871a0, r5 = 09856760, r6 = 095ffbd4, r7 = 095ffbd4
r8 = 098571c8, r9 = 0900066c, r10= 00000000, fp = 095541e0 
ip = 098a5e98, sp = 00000000, lr = 095cdee0, pc = 09467920 
cpsr = 00000020, spsr = 09000660

Thread 2 , L4_Copy_regs_to_mrs()
================================
r0 = 00000001, r1 = 00000000, r2 = 00000000, r3 = 095ffc1c
r4 = 094871a0, r5 = 09856760, r6 = 095ffbd4, r7 = 095ffbd4
r8 = 098571c8, r9 = 0900066c, r10= 00000000, fp = 095541e0 
ip = 098a5e98, sp = 00000000, lr = 095cdee0, pc = 09467920 
cpsr = 00000020, spsr = 09000660


----- Original Message ----
From: Carl van Schaik <carl at ok-labs.com>
To: Iyad Q <ikq2754 at yahoo.com>
Cc: kenge-users at ertos.nicta.com.au
Sent: Monday, April 23, 2007 9:17:59 PM
Subject: Re: what does L4_Copy_regs_to_mrs() actually return?

Hi Iyad,

The L4_Copy_regs_to_mrs() calls returns the values of a thread stored in 
the threads L4 TCB. On uniprocessor, this should always contain the 
correct state. The only tine somthing different happens is when the 
thread is in the middle of a system call (eg Ipc).
Note that system calls don't save much state so many of the register 
values won't mean much.
Note, it seems you are running an old copy of L4/Iguana? In the old 
ertos release, kernel saving user state was very inconsistant. The 
latest OKL4 does much better. About your question re the PC value... it 
is possible for this to be a valid PC, especially if the thread is 
running in a shared library at the time. (eg libc).

Getting and setting the user registers has always been an interesting 
topic since there are many ways to do it. In Wombat, we try avoid doing 
this as much as possible, except for signal handling. We get the user to 
save their own state by jumping the thread to a special piece of code we 
map into the address space. Linux (other than for debug) does not really 
need access to thread registers so we have not had much need for direct 
thread register reading and setting.

So currently we can get user registers with L4_Copy_regs_to_mrs(), but 
not directly set user registers.
You may want to experiment with adding the equavalent function to set MRs.

regards,
Carl

Hal:

Oh yeah one other thing, this list is dead and will shortly be discontinued.
developer at okl4.org is where it's at now.
https://lists.okl4.org/mailman/listinfo/developer



Iyad Q wrote:
> Hi,
>
> I am trying to work on user thread debugging in linux, and need access to register content of the user space process.  I am using L4_Copy_regs_to_mrs(), but it seems to return incorrect information.  For example in the listing below note the return values for fp & lr.   As for the pc value, it seems that it does not reflect user thread the address range  which should be within 0x9000.
>
>   r0 = 00000000, r1 = 000008e1, r2 = 000008e1, r3 = 000008e1
>   r4 = 095f3da0, r5 = 095f3d6c, r6 = 07dc6274, r7 = 07dc605c
>   r8 = 00000001, r9 = fffff71f, r10= e0011200, fp = 00000000
>   ip = 07f95074, sp = 07ff2780, lr = 00000001, pc = 07f95060
>   cpsr = e0011200, spsr = 00000000
>
> My questions at the moment:
>
> 1) what is actually returned by the L4_Copy_regs_to_mrs() ?
> 2) How can I get user threads register values ?
> 3) How can I set user threads register values ?
>
> Thanks,
> Iyad
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
>
> _______________________________________________
> kenge-users mailing list
> kenge-users at ertos.nicta.com.au
> https://lists.ertos.nicta.com.au/mailman/listinfo/kenge-users
>   





__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Developer mailing list