144 if (!aref_node || !aref_node->
entry)
150 panic(
"aref has no page");
168 if (aref->
ref == 1) {
209 aref_node->
entry = new_aref;
216 return err ? err : 1;
235 printk(
"vm: an object with no pager, page %p missing\n", (
void *)
off);
317 return err ? err : 1;
450 printk(
"[%d:%d] %s: page fault at %p not resolved: error %d\n",
static int pf_anon(struct pf *pf)
Handles a fault on a page that the process's anon has (a page it wrote to before).
static struct vm_page * vm_object_page(struct vm_object *vm_object, hash_t hash, size_t off)
Returns an object's page at offset off, reading it in with the object's pager if the object doesn't h...
static int pf_zero(struct pf *pf)
Handles a fault on a page that nothing has yet: a new page, zeroed, in the process's anon.
static int pf_object(struct pf *pf)
Handles a fault on a page of the object the mapping is of (a file's page).
static int check_violation(int flags, int vm_flags)
Returns whether an access of kind flags (PF_*) is one the mapping's permissions vm_flags don't allow.
static int pf_present(struct pf *pf)
Handles a fault on a page that is mapped, but not with the permission the access needed: a write to a...
void mm_page_decref(paddr_t paddr)
Drops a reference to a page of RAM.
struct vm_page * mm_page_alloc(void)
Allocates a free page of physical memory.
int mm_page_fault(vaddr_t vaddr, int flags)
Handles a page fault in the current process's address space.
int mm_page_map(struct pmap *pmap, vaddr_t vaddr, paddr_t paddr, int flags)
Maps a page into an address space.
void mm_page_dealloc(paddr_t paddr)
Frees a page of physical memory, back to the zone it came from.
void mm_page_incref(paddr_t paddr)
Adds a reference to a page of RAM.
void * kmalloc(size_t size, struct malloc_type *type, int flags)
Allocates memory for one of the kernel's structures.
void kfree(void *)
Frees an object that kmalloc() gave.
void * memset(void *dst, int c, size_t n)
Sets n bytes to c.
void pmap_page_copy(paddr_t src, paddr_t dst)
Copies a page of physical memory to another.
void pmap_protect(struct pmap *pmap, vaddr_t sva, vaddr_t eva, uint32_t prot)
Changes the permissions of the mapped pages of a range of an address space.
void pmap_remove(struct pmap *pmap, vaddr_t sva, vaddr_t eva)
Unmaps the pages of a range of an address space, and flushes them from the TLBs that may have them.
int printk(const char *fmt,...)
Writes a kernel message, to the message buffer and the consoles.
int signal_proc_send(struct proc *proc, int signal)
Sends a signal to a process.
A hash table's node: an entry, with its key's hash.
What a page fault is about, passed to each of the steps below.
struct vm_entry * vm_entry
struct vm_space * vm_space
An address space's page tables, on x86.
An anon: a mapping's private pages, those the process wrote to.
struct hashmap * arefs
its arefs, by the offset of their page in the mapping
int flags
its flags (VM_COPY: to be copied before it's written to)
size_t ref
how many mappings share the anon
An anon's reference to a page (an aref).
uint32_t flags
its flags (VM_COPY)
size_t ref
how many anons have the aref
struct vm_page * vm_page
the page
A mapping (map entry): a range of an address space, its permissions, and where its pages come from.
struct vm_anon * vm_anon
its anon: the pages the process wrote to
uint32_t flags
its permissions and flags (VM_*)
size_t off
where the mapping starts in its object
vaddr_t base
where the mapping starts in its address space
struct vm_object * vm_object
its object: what its other pages come from (a file)
A vm object: what a mapping's pages come from (a file), and its pages that have been read in.
struct vm_pager * pager
its pager
struct hashmap * pages
its pages that have been read in, by their offset
A page of physical memory (pages[] has one for every page of RAM).
size_t off
its offset in its object or anon
size_t ref
how many references it has
struct vm_object * vm_object
the object it belongs to, or NULL
paddr_t paddr
its physical address
An address space: its mappings, and its page tables.
struct pmap * pmap
its page tables (the architecture's)
#define VM_KW
kernel write
#define VM_COPY
to be copied before it's written to
#define VM_PERM
permissions mask
struct vm_anon * vm_anon_new(void)
Makes a new, empty anon.
#define VM_UX
user execute
struct vm_anon * vm_anon_copy(struct vm_anon *vm_anon)
Makes a copy of an anon that shares its arefs, and so its pages, when a mapping's shared anon is writ...
void vm_anon_decref(struct vm_anon *vm_anon)
Drops a reference to an anon, and frees it with the last one.
struct vm_entry * vm_space_find(struct vm_space *vm_space, vaddr_t vaddr)
Finds the map entry that an address is in.