MOS Source Code
Loading...
Searching...
No Matches
dump.c
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
4
6#include "mos/syslog/printk.h"
8
9static void pagetable_do_dump(ptr_t vaddr, ptr_t vaddr_end, vm_flags flags, pfn_t pfn, pfn_t pfn_end, ptr_t *prev_end_vaddr)
10{
11 if (vaddr - *prev_end_vaddr > MOS_PAGE_SIZE)
12 pr_info(" VGROUP: " PTR_FMT, vaddr);
13
14 pr_info2(" " PTR_RANGE " -> " PFN_RANGE ", %5zd pages, %pvf, %c%c, %s", //
15 vaddr, //
16 vaddr_end, //
17 pfn, //
18 pfn_end, //
19 (ALIGN_UP_TO_PAGE(vaddr_end) - vaddr) / MOS_PAGE_SIZE, //
20 (void *) &flags, //
21 flags & VM_CACHE_DISABLED ? 'C' : '-', //
22 flags & VM_GLOBAL ? 'G' : '-', //
23 flags & VM_USER ? "user" : "kernel" //
24 );
25
26 *prev_end_vaddr = vaddr_end;
27}
28
30{
31 pr_info("Page Table:");
32 ptr_t tmp = 0;
34
35 pagetable_iter_t iter = { 0 };
37
39 while ((range = pagetable_iter_next(&iter)))
40 if (range->present)
41 pagetable_do_dump(range->vaddr, range->vaddr_end, range->flags, range->pfn, range->pfn_end, &tmp);
42
43 pagetable_iter_init(&iter, mmctx->pgd, MOS_KERNEL_START_VADDR, 0xffffffffffffffff);
44 while ((range = pagetable_iter_next(&iter)))
45 if (range->present)
46 pagetable_do_dump(range->vaddr, range->vaddr_end, range->flags, range->pfn, range->pfn_end, &tmp);
47
49}
50
52{
53 const char *cpu_pagetable_source = current_cpu->mm_context == platform_info->kernel_mm ? "Kernel" : NULL;
54
56 {
57 pr_emph("Current task: thread %pt, process %pp", (void *) current_thread, (void *) current_process);
58 pr_emph("Task Page Table:");
60 if (current_cpu->mm_context == current_process->mm)
61 cpu_pagetable_source = "Current Process";
62 }
63 else
64 {
65 pr_emph("Kernel Page Table:");
67 }
68
69 if (cpu_pagetable_source)
70 {
71 pr_emph("CPU Page Table: %s", cpu_pagetable_source);
72 }
73 else
74 {
75 pr_emph("CPU Page Table:");
76 mm_dump_pagetable(current_cpu->mm_context);
77 }
78}
79
80MOS_PANIC_HOOK_FEAT(vmm, mm_dump_current_pagetable, "dump current pagetable");
#define MOS_PAGE_SIZE
Definition autoconf.h:6
void mm_dump_current_pagetable()
Definition dump.c:51
static void pagetable_do_dump(ptr_t vaddr, ptr_t vaddr_end, vm_flags flags, pfn_t pfn, pfn_t pfn_end, ptr_t *prev_end_vaddr)
Definition dump.c:9
void mm_dump_pagetable(mm_context_t *mmctx)
Definition dump.c:29
void pagetable_iter_init(pagetable_iter_t *it, pgd_t pgd, ptr_t vaddr, ptr_t end)
Initialize a pagetable iterator.
Definition iterator.c:82
pagetable_iter_range_t * pagetable_iter_next(pagetable_iter_t *it)
Get the next page table range.
Definition iterator.c:97
#define ALIGN_UP_TO_PAGE(addr)
Definition mos_global.h:75
#define MOS_PANIC_HOOK_FEAT(_feat, _f, _n)
Definition panic.h:32
#define NULL
Definition pb_syshdr.h:46
#define current_thread
Definition platform.h:30
vm_flags
Definition platform.h:40
@ VM_GLOBAL
Definition platform.h:48
@ VM_CACHE_DISABLED
Definition platform.h:47
@ VM_USER
Definition platform.h:45
#define current_cpu
Definition platform.h:29
#define current_process
Definition platform.h:31
#define pr_info2(fmt,...)
Definition printk.h:36
#define pr_info(fmt,...)
Definition printk.h:35
#define pr_emph(fmt,...)
Definition printk.h:37
#define MOS_KERNEL_START_VADDR
#define MOS_USER_END_VADDR
mos_platform_info_t *const platform_info
#define spinlock_acquire(lock)
Definition spinlock.h:61
#define spinlock_release(lock)
Definition spinlock.h:62
spinlock_t mm_lock
protects [pgd] and the [mmaps] list (the list itself, not the vmap_t objects)
Definition platform.h:81
pgd_t pgd
Definition platform.h:82
mm_context_t * kernel_mm
Definition platform.h:118
unsigned long long pfn_t
Definition types.h:41
#define PTR_RANGE
Definition types.h:36
#define PTR_FMT
Definition types.h:33
#define PFN_RANGE
Definition types.h:43
unsigned long ptr_t
Definition types.h:25