Linux Kernel Architecture

(Jacob Rumans) #1

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 address

Interrupt handler
or no context?

Usermode access Yes Segmentation Fault
No

Address > TASK_SIZE
and no protection fault
and kernel mode?

Yes vmalloc-Handler

No

vm_area_struct exists?

Stack?

No

unsuccesssful

erfolgreich

Allowed read access,
page not present

Alllowed write access
page not present

Not allowed
write access

Not allowed
read access

successsful

Yes

No

Yes

do_page_fault

find_vma

fixup_exception

expand_stack fixup_exception

handle_mm_fault

Figure 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.

Free download pdf