From 74dfcd6a84222ac4a601abf5f06ace300627f62d Mon Sep 17 00:00:00 2001 From: cracyc Date: Sun, 14 Feb 2016 19:45:23 -0600 Subject: [PATCH] i386: don't change IF when IOPL < CPL (nw) --- src/devices/cpu/i386/i386.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/devices/cpu/i386/i386.cpp b/src/devices/cpu/i386/i386.cpp index 62a65155a59..be65518f57b 100644 --- a/src/devices/cpu/i386/i386.cpp +++ b/src/devices/cpu/i386/i386.cpp @@ -2364,6 +2364,7 @@ void i386_device::i386_protected_mode_iret(int operand32) I386_SREG desc,stack; UINT8 CPL, RPL, DPL; UINT32 newflags; + UINT8 IOPL = m_IOP1 | (m_IOP2 << 1); CPL = m_CPL; UINT32 ea = i386_translate(SS, (STACK_32BIT)?REG32(ESP):REG16(SP), 0); @@ -2383,7 +2384,7 @@ void i386_device::i386_protected_mode_iret(int operand32) if(V8086_MODE) { UINT32 oldflags = get_flags(); - if(!m_IOP1 || !m_IOP2) + if(IOPL != 3) { logerror("IRET (%08x): Is in Virtual 8086 mode and IOPL != 3.\n",m_pc); FAULT(FAULT_GP,0) @@ -2455,6 +2456,8 @@ void i386_device::i386_protected_mode_iret(int operand32) { UINT32 oldflags = get_flags(); newflags = (newflags & ~0x00003000) | (oldflags & 0x00003000); + if(CPL > IOPL) + newflags = (newflags & ~0x200 ) | (oldflags & 0x200); } set_flags(newflags); m_eip = POP32() & 0xffff; // high 16 bits are ignored @@ -2584,6 +2587,8 @@ void i386_device::i386_protected_mode_iret(int operand32) { UINT32 oldflags = get_flags(); newflags = (newflags & ~0x00003000) | (oldflags & 0x00003000); + if(CPL > IOPL) + newflags = (newflags & ~0x200 ) | (oldflags & 0x200); } if(operand32 == 0) @@ -2753,6 +2758,8 @@ void i386_device::i386_protected_mode_iret(int operand32) { UINT32 oldflags = get_flags(); newflags = (newflags & ~0x00003000) | (oldflags & 0x00003000); + if(CPL > IOPL) + newflags = (newflags & ~0x200 ) | (oldflags & 0x200); } if(operand32 == 0)