I am studying the xv6 Operating System (written for 32-bit x86 architectures) as part of a course at university and have noticed a pattern while modifying the control registers (specifically, CR0 and CR4). The pattern is the following three assembly instructions (CR4_PSE is the Page Size Extension bit, though not relevant to my question):
Code:
movl %cr4, %eax
orl $(CR4_PSE), %eax
movl %eax, %cr4
My question is - why can't we modify the CR4 register directly? I have anecdotally heard my professor say the answer is that it is more costly to modify certain CPU registers like the CR4 or CR0 registers, but I haven't been able to find evidence backing this (in the form of specifications). I would be grateful to learn more about why this cost difference is there and where to read about it.