wangt13 wrote:
INVLPG needs a parameter, I think it should be virtual address.
Right. Did you know you could download CPU documentation for free? E.g.
here.
wangt13 wrote:
Now, I want to learn first is what is the virtual address?
It's explained in the documentation and other places, e.g.
Wikipedia.
wangt13 wrote:
It means, in which context the virtual address is, kernel space, or user space?
The context is the current address space. It may have only kernel-accessible pages or those and user-accessible ones. INVLPG doesn't care which of the two the address points to.
wangt13 wrote:
to flush the TLB for that PFN translation, what should do?
INVLPG is a privileged inst. so it needs to tell kernel to do that, so is it OK to pass the tmp directly to the kernel (to the INVLPG).
That's pretty much the only way to do it (reloading CR3 would flush the entire TLB (except the so-called
global pages), not just a single page; there's also INVPCID in newer CPUs, but to keep things simple let's not go there).
wangt13 wrote:
If so, I think it should be in the process context, that is the CR3 rooted tree.
When you switch the process context, you switch the address space (and change CR3). INVLPG affects the current address space.