您可能无法获得响应,因为您对事物的理解不是很好,并且linux-arm-kernel列表上的任何人都需要一些时间来响应.阅读
kprobes.txt并详细研究ARM体系结构.
If kprobe is handled undefined instruction exception(bcos kprobe only created), then why __und_svc() is invoked. what is the role of __und_svc() handler with respect to kprobes?
在ARM上,模式0b11011是未定义的指令模式.未定义指令发生时的流程是,
> lr_und = pc的undef指令4
> SPSR_und =指令发生的模式的CPSR.
>在禁用中断的情况下将模式更改为ARM.
> PC =矢量基数4
第四步的主矢量表位于__vectors_start,这只是分支到
vector_und.代码是一个名为vector_stub的宏,它决定调用__und_svc或__und_usr.堆栈是每个进程保留的4 / 8k页面.它是包含任务结构和内核堆栈的内核页面.
kprobe的工作原理是将未定义的指令放在您想要探测的代码地址上.即,它涉及未定义的指令处理程序.这应该是非常明显的.它调用两个例程,call_fpe或do_undefinstr().您对第二种情况感兴趣,它获取操作码并调用call_undef_hook().添加register_undef_hook()的钩子;您可以看到arch_init_kprobes().使用struct pt_regs * regs调用主回调kprobe_handler,这恰好是__und_svc中保留的额外内存.请注意,例如,kretprobe_trampoline(),它正在使用当前正在执行的堆栈进行技巧.
If 64 bytes memory is compulsory, then how to allocate without compiling the kernel. i.e How to do it dynamically.?
不它不是.您可以使用其他机制,但可能必须修改kprobes代码.您很可能必须限制功能.也可以完全重写堆栈帧并在事后保留额外的64字节.它不是kmalloc()中的分配.它只是从管理程序堆栈指针中添加/减去一个数字.我猜测代码会从未定义的处理程序重写返回地址,以在kprobed地址的上下文(ISR,下半部分/线程IRQ,work_queue,内核任务)中执行.但是,您可能还有其他问题尚未遇到.如果永远不会调用arch_init_kprobes(),那么您可以随时在__und_svc中进行预留;它只占用64个字节的堆栈,这将使内核堆栈更有可能溢出.即,改变,
__und_svc:
@ Always reserve 64 bytes, even if kprobe is not active.
svc_entry 64
arch_init_kprobes()实际上是安装该功能的.