linux内核分析之缺页中断(二)
来源:互联网 发布:如何防止java 内存泄露 编辑:程序博客网 时间:2024/05/17 02:21
对于缺页中断的非法访问由函数bad_area执行,该函数的执行情况分为:
1,如果在用户空间访问,直接发送SEGSEGV信号;
2,如果在内核空间访问分为两种情况:
1)地址是一个错误的系统调用参数,修正码(典型是发送SIGSEGV信号);
2)反之,杀死进程并显示内核的OOPS信息;
static void__bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, unsigned long address, int si_code){struct task_struct *tsk = current;/* User mode accesses just cause a SIGSEGV *//*如果用户态*/if (error_code & PF_USER) {/* * It's possible to have interrupts off here: */local_irq_enable();/* * Valid to do another page fault here because this one came * from user space: */if (is_prefetch(regs, error_code, address))return;if (is_errata100(regs, address))return;if (unlikely(show_unhandled_signals))show_signal_msg(regs, error_code, address, tsk);/* Kernel addresses are always protection faults: */tsk->thread.cr2= address;tsk->thread.error_code= error_code | (address >= TASK_SIZE);tsk->thread.trap_no= 14;/*发送SIGSEGV信号*/force_sig_info_fault(SIGSEGV, si_code, address, tsk);return;}if (is_f00f_bug(regs, address))return;/*内核态访问*/no_context(regs, error_code, address);}
内核访问时
static noinline voidno_context(struct pt_regs *regs, unsigned long error_code, unsigned long address){struct task_struct *tsk = current;unsigned long *stackend;unsigned long flags;int sig;/* Are we prepared to handle this kernel fault? *//*地址是一个系统调用参数,"修正码",典型情况是发送SIGSEGV信号*/if (fixup_exception(regs))return;/* * 32-bit: * * Valid to do another page fault here, because if this fault * had been triggered by is_prefetch fixup_exception would have * handled it. * * 64-bit: * * Hall of shame of CPU/BIOS bugs. */if (is_prefetch(regs, error_code, address))return;if (is_errata93(regs, address))return;/* * Oops. The kernel tried to access some bad page. We'll have to * terminate things with extreme prejudice: */ /*下面代码用于oops信息的显示和杀死当前 进程*/flags = oops_begin();show_fault_oops(regs, error_code, address);stackend = end_of_stack(tsk);if (*stackend != STACK_END_MAGIC)printk(KERN_ALERT "Thread overran stack, or stack corrupted\n");tsk->thread.cr2= address;tsk->thread.trap_no= 14;tsk->thread.error_code= error_code;sig = SIGKILL;if (__die("Oops", regs, error_code))sig = 0;/* Executive summary in case the body of the oops scrolled away */printk(KERN_EMERG "CR2: %016lx\n", address);oops_end(flags, regs, sig);}
- linux内核分析之缺页中断(二)
- linux内核分析之缺页中断
- Linux内核分析之缺页中断
- Linux内核修炼之软中断分析
- Linux开发心得总结1 - Linux内核分析之缺页中断
- Linux开发心得总结12 - Linux内核分析之缺页中断
- linux内核中断分析
- ARM-Linux s3c2440 之中断分析(二)
- linux内核分析--内核中的数据结构之队列(二)
- linux内核之中断
- Linux 内核之中断
- Linux内核之中断
- LINUX-内核-中断分析-中断向量表(1)-x86
- LINUX-内核-中断分析-中断向量表(2)-mips
- LINUX-内核-中断分析-中断向量表(3)-arm
- 【深入剖析Linux内核】Linux内核之旅——(二)内核抢占与中断返回
- Linux内核(二)中断基本概念
- Linux内核开发之中断与时钟(二)
- ubuntu下pdf文档显示不正常
- 潘安
- Android Bitmap和Drawable相互转换方法
- Linux中的文件特殊权限
- 乔布斯的名言
- linux内核分析之缺页中断(二)
- 怎样发现我们已经不再是Startup了
- VC 开机自动启动程序代码
- [转载/翻译]优化浏览器渲染
- 漫漫编程路--生活篇2011.12.28
- 动画效果的c#代码实现方式(非xaml代码)
- Nexus S 刷机教程注意事项
- 产品管理:用户访谈之道
- explicit