First post, by vladstamate
So I am trying to write a piece of code that enters VM86. This is done from protected mode with paging enabled. What I do is push the CS, IP and FLAGS (which have VM bit set) and then execute an IRET.
I think some emulators(*) (including mine) treat that whole IRET as an atomic unit, but I think that might not be the case with all of them.
What I see is while the IRET is popping and setting up CS it somehow has not popped EFLAGS, and therefore not realized that VM86 is now turned on and instead of using segmentation it looks for the CS descriptor number. Since VM86 is using segmentation CS should be treated as a segment not as a descriptor ID.
What would be the correct behavior in this case?
(*) I've noticed this behavior with both QEMU and Bochs
YouTube channel: https://www.youtube.com/channel/UC7HbC_ ... l7qGYL0mTA