I am an operating system hobbyist, and my kernel runs on 80486+, and already supports virtual memory.
Starting from 80386, the x86 processor family by
To your first question:
INVLPG
and you can do any change possible. Use of INVLPG
is always safe.CR3
does not invalidate global pages in the TLB. So sometimes you must use INVLPG
as reloading CR3
has no effect.INVLPG
must be used for every page involved. If you are changing multiple pages at a time then there comes a point where reloading CR3
is faster than a multitude of INVLPG
calls.To your second question:
A page that is not mapped can not be cached in the TLB (assuming you invalidated it correctly when you unmapped it previously). So any change from not-present does not need INVLPG
or CR3
reloading.