// initialize the proc table at boot time.
void
procinit(void)
{
struct proc *p;
initlock(&pid_lock, "nextpid");
for(p = proc; p < &proc[NPROC]; p++) {
initlock(&p->lock, "proc");
// Allocate a page for the process's kernel stack.
// Map it high in memory, followed by an invalid
// guard page.
char *pa = kalloc();
if(pa == 0)
panic("kalloc");
uint64 va = KSTACK((int) (p - proc));
kvmmap(va, (uint64)pa, PGSIZE, PTE_R | PTE_W);
p->kstack = va;
}
kvminithart();
}
It will call kvminithart(), which will call w_satp() and flush TLB.
I'm wondering why kvminithart() is needed.It seems that procinit() just add PTEs to kernel pagetable but didn't change the physical address of it.So why call kvminithart() again here?
I notice that in
procinit()
,there is code like:It will call
kvminithart()
, which will callw_satp()
and flush TLB. I'm wondering whykvminithart()
is needed.It seems thatprocinit()
just add PTEs to kernel pagetable but didn't change the physical address of it.So why callkvminithart()
again here?