I have been furiously searching on google for the correct use of INVLPG, but its still not clear.
From the intel manual, its used as
invlpg mem
But is the memory address, an address of a page table or is it just a normal memory address??
I have found articles on when to use invlpg, but not actual real-life usage.
INVLPG
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:INVLPG
the "mem" argument you will put is a memory location which will be resolved (just as when you perform some "mov mem,eax" instruction) into an effective address and further into a virtual address using the selector in DS (except if you specify a segment override with i.e. invlpg [cs:some_label]).
Instead of issuing a 'read cycle" for this address, the CPU will remove any entry in its page cache related to virtual address AND 0xFFFFF000.
Note that there might be a separate page cache for data and instructions ... so i don't know if the CS: override is needed or not ... better check back intel 's doc to know.
Instead of issuing a 'read cycle" for this address, the CPU will remove any entry in its page cache related to virtual address AND 0xFFFFF000.
Note that there might be a separate page cache for data and instructions ... so i don't know if the CS: override is needed or not ... better check back intel 's doc to know.
-
DarylD
Re:INVLPG
I understand all that, but one thing the intel docs don't seem to make clear (well to me anyhow!) is whether this is indirect or not.
I.e. the following instruction:
INVLPG (100000)
Will this read in the address to use in the page invalidation from 100000 and then invalidate that or will it try to invalidate address ds:100000 itself?
Just so I am clear on this.
Thanks Pype,
Daryl.
I.e. the following instruction:
INVLPG (100000)
Will this read in the address to use in the page invalidation from 100000 and then invalidate that or will it try to invalidate address ds:100000 itself?
Just so I am clear on this.
Thanks Pype,
Daryl.
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:INVLPG
invlpg [0x10000] will invalidate ds:0x10000
invlpg 0x10000 is invalid (this is a constant, not a memory location)
invlpg [eax+ecx*4] will invalidate ds:(result of effective address computation)
invlpg [es:0x0000] should be allowed as well.
invlpg 0x10000 is invalid (this is a constant, not a memory location)
invlpg [eax+ecx*4] will invalidate ds:(result of effective address computation)
invlpg [es:0x0000] should be allowed as well.
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:INVLPG
Code: Select all
#ifdef __PARANOIA__
#define invlpg(mem) asm("movl %%cr3,%%eax ; movl %%eax,%%cr3":::"memory")
#else
#define invlpg(mem) asm("invlpg %0"::"m"(mem):"memory")
#endif