INVLPG doesn't work but reloading CR3 does

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.
lexected
Posts: 23
Joined: Wed Aug 14, 2013 11:48 am

Re: INVLPG doesn't work but reloading CR3 does

Post by lexected »

iansjack wrote:From the Intel manual
Invalidates (flushes) the translation lookaside buffer (TLB) entry specified with the source operand. The source operand is a memory address. The processor determines the page that contains that address and flushes the TLB entry for that page.
So, sensible or not, it is the virtual address that the page maps to. (Well, you can use any virtual address within the page so it would be more accurate to say "a virtual address".)
So the address of a page to be invalidated is known at compile time? Really?
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: INVLPG doesn't work but reloading CR3 does

Post by iansjack »

I can't imagine why you'd think that, but it's a point that you'll have to argue with the Intel engineers.
stlw
Member
Member
Posts: 357
Joined: Fri Apr 04, 2008 6:43 am
Contact:

Re: INVLPG doesn't work but reloading CR3 does

Post by stlw »

So the address of a page to be invalidated is known at compile time? Really?
It is only means you don't understand what are yu talking about.
I'd like Intel notation so I'll give you example with Intel notation:

mov eax, [0x12345678] ; load value from address 0x12345678

mov eax, [esi] ; load value from address which is stored in esi register.

Same for INVLPG. So the address of a page to be invalidated is known at compile time ?
lexected
Posts: 23
Joined: Wed Aug 14, 2013 11:48 am

Re: INVLPG doesn't work but reloading CR3 does

Post by lexected »

stlw wrote:The virtual address you want to invalidate in the TLB
?

It's the address that specifies location where the address to be invalidated is stored. Not the address itself, that's what I was trying to say.

OK, so there's no need for additional brackets or '*' in my inline assembly. It works, just not in bochs.
stlw
Member
Member
Posts: 357
Joined: Fri Apr 04, 2008 6:43 am
Contact:

Re: INVLPG doesn't work but reloading CR3 does

Post by stlw »

filipadamer wrote:
stlw wrote:The virtual address you want to invalidate in the TLB
?

It's the address that specifies location where the address to be invalidated is stored. Not the address itself, that's what I was trying to say.

OK, so there's no need for additional brackets or '*' in my inline assembly. It works, just not in bochs.
I am trying to explain you but you don't listen :(
Now let's try to explain in C-language terms.

"It's the address that specifies location where the address to be invalidated is stored" in C-language means:

address 0x12345678
char *location = (char*) 0x12345678;
char **p = &location;
invlpg p;

It is over-indirection.

I suggest you to open Intel Software Developers Manual Volume 2, Chapter 2 )instruction format) and read how x86 instructions are encoded and what do they mean. You could see in Bochs (which provides also disasm) what you actually encoded in your sources. You could also use Bochs debugger functions to see what memory location yuor invlpg trying to invalidate. But looks like you don't care to debug, you here to complain ...
lexected
Posts: 23
Joined: Wed Aug 14, 2013 11:48 am

Re: INVLPG doesn't work but reloading CR3 does

Post by lexected »

I do understand how does it work. I was just confused by your post where you said that
What does the ModRM following the INVLPG contain?
The virtual address you want to invalidate in the TLB
but it doesn't contain the address itself, it only references on where is it stored.

It's solved about 17 posts ago.
User avatar
Griwes
Member
Member
Posts: 374
Joined: Sat Jul 30, 2011 10:07 am
Libera.chat IRC: Griwes
Location: Wrocław/Racibórz, Poland
Contact:

Re: INVLPG doesn't work but reloading CR3 does

Post by Griwes »

ModRM contains the address itself. Or, in other words, a way in which the processor can compute the address. invlpg [eax] - the address to invalidate is in eax, while you are saying that the address of the address is in eax...
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
lexected
Posts: 23
Joined: Wed Aug 14, 2013 11:48 am

Re: INVLPG doesn't work but reloading CR3 does

Post by lexected »

Griwes wrote:ModRM contains the address itself. Or, in other words, a way in which the processor can compute the address. invlpg [eax] - the address to invalidate is in eax, while you are saying that the address of the address is in eax...
](*,) I understand it in that correct way. No '()'/'*' are needed - that's the point.
User avatar
Griwes
Member
Member
Posts: 374
Joined: Sat Jul 30, 2011 10:07 am
Libera.chat IRC: Griwes
Location: Wrocław/Racibórz, Poland
Contact:

Re: INVLPG doesn't work but reloading CR3 does

Post by Griwes »

Then stop saying something different, please.
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
Post Reply