The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
fault.h
Go to the documentation of this file.
1
#pragma once
2
3
/**
4
* user page faults: demand paging and killing processes that touch memory
5
* they have not mapped.
6
*
7
* user memory is only partly backed up front: the heap (sbrk), anonymous
8
* mmaps and the stack below its first pages get a physical frame the first
9
* time they are touched. the page-fault handler (and the kernel's user-copy
10
* helpers, before they touch user memory) ask mm_fault_in to back a page; an
11
* access no area allows kills the process instead of the kernel.
12
*
13
* after fork, parent and child share their RAM pages read-only
14
* (copy-on-write). the first write to such a page in a writable area also
15
* comes here: the process gets its own copy of the frame.
16
*/
17
18
#include "
common/stdint.h
"
19
#include "
kernel/process/process.h
"
20
21
/**
22
* back the page containing addr if the process's areas allow the access:
23
* allocate a zeroed frame and map it with the area's protection. a write to
24
* a copy-on-write page gives the process its own writable copy.
25
* @param proc the process (its own address space is the target).
26
* @param addr the user address being accessed.
27
* @param write true for a write access.
28
* @return true if the page is now mapped for that access; false if no area
29
* allows it (or memory ran out).
30
*/
31
bool
mm_fault_in
(
process_t
*proc,
uintptr_t
addr,
bool
write
);
32
33
/**
34
* handle a page fault raised by user code. if the page can be backed, the
35
* instruction runs again; otherwise the process gets SIGSEGV, acted on when
36
* the fault returns to user mode (by default a report and the end of the
37
* process).
38
* @param addr the faulting address (CR2).
39
* @param write true if the access was a write.
40
* @param present true if the page was present (a protection violation).
41
* @param pc the faulting instruction.
42
*/
43
void
mm_handle_user_fault
(
uintptr_t
addr,
bool
write
,
bool
present,
uintptr_t
pc);
stdint.h
mm_handle_user_fault
void mm_handle_user_fault(uintptr_t addr, bool write, bool present, uintptr_t pc)
handle a page fault raised by user code.
Definition
fault.c:133
mm_fault_in
bool mm_fault_in(process_t *proc, uintptr_t addr, bool write)
user page faults: demand paging and killing processes that touch memory they have not mapped.
Definition
fault.c:116
uintptr_t
__UINTPTR_TYPE__ uintptr_t
Definition
stdint.h:19
process.h
process_t
struct process process_t
process control block.
write
ssize_t write(int fd, const void *buf, size_t count)
write bytes to a file descriptor.
src
kernel
memory
fault.h
Generated by
1.18.0