Invlpg operand errors.
Posted: Tue Jan 10, 2012 11:19 pm
I can't get GCC (or, more correctly, GAS) to take my inline invlpg. When I cast the address (which I store as a uintptr_t) to a void* and try to dereference it, I get "‘void*’ is not a pointer-to-object type." When I cast to it anything else (char, short, int, long long), I get "operand size mismatch for `invlpg.'"
Is this a GCC/GAS bug, or am I doing something wrong?
What should "type" be?
Is this a GCC/GAS bug, or am I doing something wrong?
Code: Select all
void page_table::map(uintptr_t virtual_address, uintptr_t physical_address, ptrdiff_t size, bool user, bool writable)
{
for(ptrdiff_t i = 0;i + PGSIZE <= size;i += PGSIZE)
{
auto &pte = _page_table[PTX(virtual_address + i)];
pte.set_page(physical_address + i);
pte.set_present(true);
pte.user(user);
pte.writable(writable);
asm volatile("invlpg %0" :: "m"(*((type*)virtual_address + i)));
}
}