What is the function of the "mov eax, cr3; mov cr3, eax" in x86 assembly code?

assembly, x86

Solution

It is flushing the TLBs (Translation Lookaside Buffers) by loading cr3 with itself.

Intel even mentions the code in their "Intel 64 and IA-32 Architectures Software Develoment Manual Volume 3A - System Programming Guide".

mov EAX,CR3  ; invalidate the TLB
mov CR3,EAX  ; by copying CR3 to itself

You can find that and many more handy manuals at:

http://www.intel.com/products/processor/manuals/index.htm

Problem

I'm disassembling a bit of code and I came across: ``` mov eax, cr3 mov cr3, eax ``` What is the function of those lines? This is x86 low-level (bios/firmware/before boot loader) initialization code. We haven't even setup up caches yet.

Original source