Chapter 4: Virtual Process Memory
same name is present in the architecture-specific sources of most CPUs.16,17)Figure4-18showsthecode
flow diagram of this extensive routine.
Save faulting addressInterrupt handler
or no context?Usermode access Yes Segmentation Fault
NoAddress > TASK_SIZE
and no protection fault
and kernel mode?Yes vmalloc-HandlerNovm_area_struct exists?Stack?NounsuccesssfulerfolgreichAllowed read access,
page not presentAlllowed write access
page not presentNot allowed
write accessNot allowed
read accesssuccesssfulYesNoYesdo_page_faultfind_vmafixup_exceptionexpand_stack fixup_exceptionhandle_mm_faultFigure 4-18: Code flow diagram fordo_page_faulton IA-32 processors.This situation is complex, so it is necessary to examine the implementation ofdo_page_faultvery
closely.
Two parameters are passed to the routine — the register set active at the time of the fault, and an error
code (long error_code) that supplies information on the cause of the fault. Currently, only the first three
bits(0,1,and2)oferror_codeare used; their meanings are given in Table 4-1.
arch/x86/mm/fault_32.c
fastcall void __kprobes do_page_fault(struct pt_regs *regs,
unsigned long error_code)
{
struct task_struct *tsk;
struct mm_struct *mm;(^16) As usual, Sparc processors are the odd man out. There the name of the function is do_sparc_fault(Sparc32),
do_sun4c_fault(Sparc32 sun4c), ordo_sparc64_fault(UltraSparc).ia64_do_page_faultis used on IA-64 systems.
(^17) Note that the code for IA-32 and AMD64 will be unified in kernel 2.6.25, which was still under development when this book was
written. The remarks given here also apply for the AMD64 architecture.
