Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why kvminithart() has to be called after procinit() #134

Open
imabackstabber opened this issue Aug 25, 2022 · 0 comments
Open

Why kvminithart() has to be called after procinit() #134

imabackstabber opened this issue Aug 25, 2022 · 0 comments

Comments

@imabackstabber
Copy link

I notice that in procinit(),there is code like:

// 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant