Skip to content

Commit

Permalink
pmm, pagetables: automatically map all PT frames (#67)
Browse files Browse the repository at this point in the history
* PMM
  - Add physical frame flag: mapped
  - map_used_memory() might be called multiple to map in newly
    allocated memory
    Use new mapped flag to skip already mapped ones.

* Pagetables:
  - Always map used physical frames when dumping pagetables

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>

Co-authored-by: Bjoern Doebel <[email protected]>
  • Loading branch information
wipawel and bjoernd authored Aug 24, 2020
1 parent 1ba70d0 commit a718cc2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions arch/x86/pagetables.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ static inline void dump_page_table(void *table, int level) {
void dump_pagetables(void) {
printk("\nPage Tables:\n");
printk("CR3: paddr: 0x%lx\n", cr3.paddr);
map_used_memory();
dump_page_table(get_l4_table(), 4);
}

Expand Down
2 changes: 1 addition & 1 deletion include/mm/pmm.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct frame {
struct list_head list;
mfn_t mfn;
uint32_t refcount;
uint32_t : 24, order : 6, uncachable : 1, free : 1;
uint32_t : 23, mapped : 1, order : 6, uncachable : 1, free : 1;
};
typedef struct frame frame_t;

Expand Down
8 changes: 6 additions & 2 deletions mm/pmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,11 @@ void map_used_memory(void) {
frame_t *frame;

for_each_order (order) {
list_for_each_entry (frame, &busy_frames[order], list)
kmap(frame->mfn, order, L1_PROT);
list_for_each_entry (frame, &busy_frames[order], list) {
if (!frame->mapped) {
kmap(frame->mfn, order, L1_PROT);
frame->mapped = true;
}
}
}
}

0 comments on commit a718cc2

Please sign in to comment.