location of statcked registers after exception (superceeds previous email)
I think I've figured out my own question. However I still would like to understand some of this kernel code in
<linux src>/arch/ia64/kernel/entry.S
If my application takes an exception, what is the entry point in entry.S? I'd also like to verify that application stacked registers will be stored on kernel stack during a context switch. My understanding is that only the last procedure frame will be stored there. (Is this notion correct?)
I'm still very unsure if my intuition is correct, hence the questions. I only figured out the below through trial and error hacking.
Anyways the solution appears to be (again correct me if anything is brain damaged):
Quoted 6 lines · Weihaw CHUANG
int offset = cfm.sof - (regid-32)
unsigned long long = ptrace(PTRACED_PEEKUSER, pid, PT_AR_BSP, 0);
regvalue = ptrace(PTRACE_PEEKDATA, pid,
(long ) ia64_rse_skip_regs((long*) bsp, offset), 0);int offset = regid - 32;
unsigned long long bspstore = ptrace(PTRACED_PEEKUSER, pid,
PT_AR_BSPSTORE, 0);
unsigned long long regvalue = ptrace(PTRACE_PEEKDATA, pid,
(long) ia64_rse_skip_regs((long*) bspstore, offset),
0);I'd like to be pendantic, and make sure the following intuition is correct. Ptrace dumps seems to agree so far.
Quoted 9 lines
That is, does this diagram make sense?
alloc r35 = ar.pfs, 0, 3, 0, 0
reg stack
| r32 | r34 | r35 | (r35 is top of reg stack)
negative offset from bsp is:
3 2 1 bsp
offset from
^bspstore
0 1 2
Thanks!!
-Wei
Wei-
The file `arch/ia64/kernel/ivt.S' contains the interrupt vector table. This is where all exceptions go.
Quoted 59 lines · Weihaw CHUANG
I think I've figured out my own question. However I still would like to understand some of this kernel code in
<linux src>/arch/ia64/kernel/entry.SIf my application takes an exception, what is the entry point in
entry.S? I'd also like to verify that application stacked registers will be stored on kernel stack during a context switch. My understanding is that only the last procedure frame will be stored there. (Is this notion correct?)I'm still very unsure if my intuition is correct, hence the questions. I only figured out the below through trial and error hacking.
Anyways the solution appears to be (again correct me if anything is brain damaged):
Quoted 6 lines · Weihaw CHUANG
int offset = cfm.sof - (regid-32) unsigned long long = ptrace(PTRACED_PEEKUSER, pid, PT_AR_BSP, 0); regvalue = ptrace(PTRACE_PEEKDATA, pid, (long ) ia64_rse_skip_regs((long*) bsp, offset), 0);int offset = regid - 32;
unsigned long long bspstore = ptrace(PTRACED_PEEKUSER, pid,PT_AR_BSPSTORE, 0); unsigned long long regvalue = ptrace(PTRACE_PEEKDATA, pid, (long) ia64_rse_skip_regs((long*) bspstore, offset), 0);I'd like to be pendantic, and make sure the following intuition is correct. Ptrace dumps seems to agree so far.
Quoted 9 lines
That is, does this diagram make sense?
alloc r35 = ar.pfs, 0, 3, 0, 0
reg stack
| r32 | r34 | r35 | (r35 is top of reg stack)
negative offset from bsp is:
3 2 1 bspoffset from
^bspstore
0 1 2Thanks!!
-Wei_______________________________________________
Linux-IA64 mailing list
[email protected]
http://lists.linuxia64.org/lists/listinfo/linux-ia64
Signature · 4 lines
Don Dugger "Censeo Toto nos in Kansa esse decisse." - D. Gale [email protected] Ph: 303/938-9838
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Weihaw CHUANG
Weihaw> Anyways the solution appears to be (again correct me if Weihaw> anything is brain damaged):
Note that when using ptrace() to read PT_AR_BSP, you get a pointer to the _end_ of the backing store, i.e., you get the value of ar.bsp as if a "cover" instruction had been executed by the target task. Since the task is blocked at the time you call ptrace(), the stacked registers are indeed on the stack (they get written to the backingstore by the "flushrs" instruction in the context switch routine).
Thus, to read stacked register, you'd do something along the lines of:
unsigned long *rbs_end, *bsp;
rbs_end = ptrace(PTRACED_PEEKUSER, pid, PT_AR_BSP, 0);
bsp = ia64_rse_skip_regs(rbs_end, -cfm.sof);
regvalue = ptrace(PTRACE_PEEKDATA, pid,
ia64_rse_skip_regs(bsp, regid - 32), 0);(The code in utrace.c is outdated in this respect.)
--david