Intel® ISA Extensions
Use hardware-based isolation and memory encryption to provide more code protection in your solutions.

IRET Pseudo-code Bug

Philip_S_4
Beginner
931 Views

Hi,

I believe that there is a documentation bug in the pseudo-code for the IRET instruction in the current edition of Volume 2A of the Architectures Software Developers' Manual.

The case we're looking at is using IRET to switch from Ring-0 to Ring-3.

The prose for protected mode states:

If the return is to another privilege level, the IRET
instruction also pops the stack pointer and SS from the stack, before resuming program execution. If the return is
to virtual-8086 mode, the processor also pops the data segment registers from the stack.

However, the flow through the pseudo-code is:

  1. GOTO PROTECTED-MODE (because we're in protected mode, not in long mode, and not in virtual 8086 mode)
  2. GOTO PROTECTED-MODE-RETURN (because we're not in a nested task, and not switching to virtual 8086 mode)
  3. GOTO RETURN-OUTER-PRIVILEGE-LEVEL (because we're switching to a higher privilege level) - note, this appears to be a typo, it should be GOTO RETURN-TO-OUTER-PRIVILEGE-LEVEL

None of the code on this path restores SS or ESP, despite the prose indicating that it should.

I believe that the prose is correct in this case because that would mirror the behaviour of the INT instruction.

0 Kudos
7 Replies
MarkC_Intel
Moderator
931 Views

The IRET pseudo code changed in rev 54. Rev 55 is current. Can you take a quick look and see if your question / comment is still valid? The change log doc for rev 54 highlights the changes if that is helpful.

http://www.intel.com/sdm

 

0 Kudos
Philip_S_4
Beginner
931 Views

It is the Rev 55 (June 2015) manual that I've been reading.

Is the change log you are referring to the one at https://www-ssl.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developers-manual.pdf? Because I had a scan through that for IRET and can't see any updated pseudo code. So I assume I'm looking in the wrong place.

 

0 Kudos
MarkC_Intel
Moderator
931 Views

I was referring to the rev 54 change log. Not sure that is still available externally. I always download the changes doc when I get each revision.

Okay, now that I know you are referring to the latest doc, I'll try to discuss this with the relevant parties internally.  

0 Kudos
Philip_S_4
Beginner
931 Views

Hi Mark,

Was anyone internally able to look at this?

Kind regards,

Philip

0 Kudos
MarkC_Intel
Moderator
931 Views

yes. It should be fixed within the next revision or two. Not sure if it'll make the next update due to timing. Thanks for reporting this issue.

0 Kudos
Philip_S_4
Beginner
931 Views

Thanks!

0 Kudos
MarkC_Intel
Moderator
931 Views

revision 56 of the SDM is out with this change. http://www.intel.com/sdm

 

0 Kudos
Reply