[FAST486]

- Fix interrupts in V86 mode.
- CLI and STI should call Fast486GetCurrentPrivLevel in their IOPL check, since it
  always returns 3 if the VM flag is set.


svn path=/trunk/; revision=65447
This commit is contained in:
Aleksandar Andrejevic 2014-11-22 16:33:47 +00:00
parent e9b8b6f597
commit 9f8411bf3a
2 changed files with 31 additions and 4 deletions

View file

@ -294,8 +294,9 @@ Fast486InterruptInternal(PFAST486_STATE State,
State->PrefixFlags |= FAST486_PREFIX_OPSIZE;
}
/* Check if the interrupt handler is more privileged */
if (Fast486GetCurrentPrivLevel(State) > GET_SEGMENT_RPL(SegmentSelector))
/* Check if the interrupt handler is more privileged or if we're in V86 mode */
if ((Fast486GetCurrentPrivLevel(State) > GET_SEGMENT_RPL(SegmentSelector))
|| State->Flags.Vm)
{
/* Read the TSS */
if (!Fast486ReadLinearMemory(State,
@ -310,6 +311,24 @@ Fast486InterruptInternal(PFAST486_STATE State,
/* Switch to the new privilege level */
State->Cpl = GET_SEGMENT_RPL(SegmentSelector);
if (State->Flags.Vm)
{
/* Clear the VM flag */
State->Flags.Vm = FALSE;
/* Push GS, FS, DS and ES */
if (!Fast486StackPush(State, State->SegmentRegs[FAST486_REG_GS].Selector)) goto Cleanup;
if (!Fast486StackPush(State, State->SegmentRegs[FAST486_REG_FS].Selector)) goto Cleanup;
if (!Fast486StackPush(State, State->SegmentRegs[FAST486_REG_DS].Selector)) goto Cleanup;
if (!Fast486StackPush(State, State->SegmentRegs[FAST486_REG_ES].Selector)) goto Cleanup;
/* Now load them with NULL selectors, since they are useless in protected mode */
if (!Fast486LoadSegment(State, FAST486_REG_GS, 0)) goto Cleanup;
if (!Fast486LoadSegment(State, FAST486_REG_FS, 0)) goto Cleanup;
if (!Fast486LoadSegment(State, FAST486_REG_DS, 0)) goto Cleanup;
if (!Fast486LoadSegment(State, FAST486_REG_ES, 0)) goto Cleanup;
}
/* Check the new (higher) privilege level */
switch (State->Cpl)
{

View file

@ -754,7 +754,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeClearInt)
if (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PE)
{
/* Check IOPL */
if (State->Flags.Iopl >= State->SegmentRegs[FAST486_REG_CS].Dpl)
if (State->Flags.Iopl >= Fast486GetCurrentPrivLevel(State))
{
/* Clear the interrupt flag */
State->Flags.If = FALSE;
@ -789,7 +789,7 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeSetInt)
if (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PE)
{
/* Check IOPL */
if (State->Flags.Iopl >= State->SegmentRegs[FAST486_REG_CS].Dpl)
if (State->Flags.Iopl >= Fast486GetCurrentPrivLevel(State))
{
/* Set the interrupt flag */
State->Flags.If = TRUE;
@ -4548,6 +4548,14 @@ FAST486_OPCODE_HANDLER(Fast486OpcodeInt)
{
UCHAR IntNum;
/* Check for V86 mode */
if (State->Flags.Vm && (State->Flags.Iopl != 3))
{
/* Call the V86 monitor */
Fast486Exception(State, FAST486_EXCEPTION_GP);
return;
}
switch (Opcode)
{
case 0xCC: // INT 3