flat assembler
Message board for the users of flat assembler.

Index > DOS > INVD in DOS

Author
Thread Post new topic Reply to topic
MaoKo



Joined: 07 May 2019
Posts: 100
Location: Paris/French
MaoKo 24 Mar 2021, 17:11
Hello. I'm confused. When I try to execute invd instruction, the pc crash and reboot. It don't even go to an ISR. WBINVD work fine altough. Do you think my CPU is broken? I'm in real mode running on pentium-M.
Post 24 Mar 2021, 17:11
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20338
Location: In your JS exploiting you and your system
revolution 24 Mar 2021, 19:01
Yup. That will happen.
Quote:
Use this instruction with care. Data cached internally and not written back to main memory will be lost. Note that any data from an external device to main memory (for example, via a PCIWrite) can be temporarily stored in the caches; these data can be lost when an INVD instruction is executed. Unless there is a specific requirement or benefit to flushing caches without writing back modified cache lines (for example, temporary memory, testing, or fault recovery where cache coherency with main memory is not a concern), software should instead use the WBINVD instruction.
Your CPU isn't broken. It is doing exactly what you told it to do. And you told it to corrupt the memory state.
Post 24 Mar 2021, 19:01
View user's profile Send private message Visit poster's website Reply with quote
MaoKo



Joined: 07 May 2019
Posts: 100
Location: Paris/French
MaoKo 24 Mar 2021, 20:59
Ok thx. When I execute wbinvd followed by an invd my PC hang. Do you known a way to use invd without breaking the environement? Because I see some custom OS that use invd without disturb the execution. I want to test some caching policy (WB,WT,WP,WC,...). If I can't I can use clflush though but it writeback to memory.
Post 24 Mar 2021, 20:59
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20338
Location: In your JS exploiting you and your system
revolution 25 Mar 2021, 06:54
If you want to use invd then make sure that no other code has any data in the CPU caches.

This probably means you should:
  1. disable interrupts
  2. execute wbinvd
  3. run your code
  4. execute invd
  5. enable interrupts
Any other sequence is going to cause you trouble.
Post 25 Mar 2021, 06:54
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.