Accessing CR2/CR3 at CPL 1,2,3?

Emulation of old PCs, PC hardware, or PC peripherals.

Accessing CR2/CR3 at CPL 1,2,3?

Postby superfury » 2018-10-11 @ 12:22

Reading the 80486 manual, it lists the following control instructions as priveleged(CPL0 only, any other CPL levels(1,2,3) are illegal):
- CLTS
- HLT
- LGDT
- LIDT
- LLDT
- LMSW
- LTR
- MOV to/from CR0
- MOV to/from DRn
- MOV to/from TRn

Does that mean that MOV to/from CR2/CR3 is allowed always(CR1 being #UD always)? Or is that a documentation error?
superfury
l33t
 
Posts: 2680
Joined: 2014-3-08 @ 11:25
Location: Netherlands

Re: Accessing CR2/CR3 at CPL 1,2,3?

Postby Stenzek » 2018-10-13 @ 04:17

From the Pentium manual:
- PMode: #GP(0) if CPL != 0 for all control registers, #GP(0) if writing to reserved bits of CR4
- Real Mode: Interrupt 13 (which is #GP) if writing to reserved bits of CR4
- V8086 Mode: #GP(0) unconditionally

Which makes sense, you wouldn't want userspace to be able to change the page directory address, as that would render the protection useless.
Stenzek
Newbie
 
Posts: 16
Joined: 2017-12-08 @ 08:30


Return to PC Emulation

Who is online

Users browsing this forum: No registered users and 2 guests