Linux下的数据结构是非常重要的,其中`struct pt_regs`是一个用于存储处理器寄存器状态的结构体,它在Linux内核中被广泛使用。在操作系统内核中,这种结构体通常用于保存进程执行时CPU寄存器的状态,以便能够在中断或异常发生时正确地恢复现场。 `struct pt_regs`结构体的定义通常在`asm/ptrace.h`头文件中,它包含了各个...
* unless syscall needs a complete, fully filled "struct pt_regs". */unsignedlongr15;unsignedlongr14;unsignedlongr13;unsignedlongr12;unsignedlongrbp;unsignedlongrbx;/* These regs are callee-clobbered. Always saved on kernel entry. */unsignedlongr11;unsignedlongr10;unsignedlongr9;unsignedlongr8;unsign...
offsetof(struct pt_regs, ax), offsetof(struct pt_regs, dx), offsetof(struct pt_regs, cx), #define NR_REG_ARGUMENTS3 #else offsetof(struct pt_regs, di), offsetof(struct pt_regs, si), offsetof(struct pt_regs, dx), offsetof(struct pt_regs, cx), offsetof(struct pt_regs, r8), offset...
我们可以通过下面的函数,先从 task_struct找到内核栈的开始位置。然后这个位置加上 THREAD_SIZE 就到了最后的位置,然后转换为 struct pt_regs,再减一,就相当于减少了一个 pt_regs 的位置,就到了这个结构的首地址。 /* * TOP_OF_KERNEL_STACK_PADDING reserves 8 bytes on top of the ring0 stack. * This...
offsetof(struct pt_regs, r8), offsetof(struct pt_regs, r9), #define NR_REG_ARGUMENTS6 #endif }; if(n >= NR_REG_ARGUMENTS) { n -= NR_REG_ARGUMENTS -1; returnregs_get_kernel_stack_nth(regs, n); }else returnregs_get_register(regs, argument_offs[n]); ...
从task_struct 如何得到相应的 pt_regs 呢?我们可以通过下面的函数,先从 task_struct找到内核栈的开始位置。然后这个位置加上 THREAD_SIZE 就到了最后的位置,然后转换为 struct pt_regs,再减一,就相当于减少了一个 pt_regs 的位置,就到了这个结构的首地址。 /* * TOP_OF_KERNEL_STACK_PADDING reserves 8 ...
比如说每一次的系统调用、中断、陷阱、故障时,pt_regs结构中保存了最少的状态信息。该结构 中主要保存了必要的scratch类型的寄存器。(在现代IA64架构中还有3类寄存器:scratch寄存器、保持寄存器、专用寄存器)。在每一次的系 统调用、中断、陷阱、故障发生时,依次会发生下列事件:1、在内核堆栈上为pt_...
来说,比重视的多。 和都是斜体,但是是逻辑元素,是物理元素。
*/ #define task_pt_regs(task) \ ({ \ unsigned long __ptr = (unsigned long)task_stack_page(task); \ __ptr += THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING; \ ((struct pt_regs *)__ptr) - 1; \ }) 这里面有一个TOP_OF_KERNEL_STACK_PADDING,这个的定义如下: #ifdef CONFIG_X86_32...
struct pt_regs *regs, unsigned long stack_size, int __user *child_tidptr, struct pid *pid) { ... retval = copy_thread(0, clone_flags, stack_start, stack_size, p, regs); ... } int copy_thread(int nr, unsigned long clone_flags, unsigned long sp, ...