Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

x86

assembly

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.

like image 457
monocasa Avatar asked Jul 07 '09 03:07

monocasa


1 Answers

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

like image 150
George Phillips Avatar answered Oct 12 '22 01:10

George Phillips