Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
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?
Wouldn't that result in the page containing virtual_address being flushed from the TLB, not the page it points to? There's a warning about that specific problem here: http://wiki.osdev.org/Inline_Assembly/E ... PGFLUSHTLB.
Even reinterpret_cast doesn't work for me. I get the same error as trying to C-style cast it to char*, "Assembler messages: Error: operand size mismatch for `invlpg.'"
I compiled the code above to assembly (with -masm=intel) and the code in question is output as: "invlpg BYTE PTR [eax]."
It is a bug. I had been compiling with -masm=intel all the time, so I could use intel syntax in my inline assembly. I tried compiling without -masm=intel and it worked.
A workaround that allows -masm=intel to be used is to require va to be put into a general purpose register (using "r") and then dereferencing that register.