1 Reply Latest reply on Dec 30, 2007 5:25 AM by alexey_khosh@rambler.ru

    Can't read control registers

      Hi there
      I'm trying to read and write to the control registers mainly CR4 with the intrinsics __readcr4 and the write equivalent. The code compiles without any warnings or errors but when I run it the program crashes.

      Even the most basic code fails, like:
      ULONG Cr4;
      CR4 = __readcr4();

      I'm running the AMD 64 X2 with XP, I would really appreciate any help.

        • Can't read control registers
          Here is quotation from the AMD document #24594.pdf: "MOV(CRn) is a privileged instruction and must always be executed at CPL = 0." As you can see, usual applications cannot execute these two instructions (read and write CRx), because ones are working on CPL = 3 (not 0, as required). In other words, it is allowed only for OS and drivers, because ones are working on CPL = 0.