[PATCH v2] x86emu: Correctly handle 0x66 prefix for some instructions

Guillem Jover guillem at hadrons.org
Thu Mar 8 18:08:52 PST 2012

On Fri, 2012-03-09 at 00:02:55 +0000, Julian Pidancet wrote:
> Some instructions are not emulated correctly by x86emu when they
> are prefixed by the 0x66 opcode.
> I've identified problems in the emulation of these intructions: ret,
> enter, leave, iret and some forms of call.
> Most of the time, the problem is that these instructions should push or
> pop 32-bit values to/from the stack, instead of 16bit, when they are
> prefixed by the 0x66 special opcode.
> The SeaBIOS project aims to produce a complete legacy BIOS
> implementation as well as a VGA option ROM, entirely written in C and
> using the GCC compiler.
> In 16bit code produced by the GCC compiler, the 0x66 prefix is used
> almost everywhere. This patch is necessary to allow the SeaBIOS VGA
> option ROM to function with Xorg when using the vesa driver.
> v2: - Decrement BP instead of EBP in accordance with the Intel Manual
>     - Assign EIP instead of IP when poping the return address from the
>     stack in 32-bit operand size mode in ret_far_IMM, ret_far, and iret
>     - When poping EFLAGS from the stack in iret in 32-bit operand size
>     mode, apply some mask to preserve Read-only flags.
> Signed-off-by: Julian Pidancet <julian.pidancet at gmail.com>

Looks good to me:

Reviewed-by: Guillem Jover <guillem at hadrons.org>


More information about the xorg-devel mailing list