Don't set oldcpl at the start of each instruction; instead, only set it following a successful CS load.
This commit is contained in:
parent
d461bc7cda
commit
c3250ca63e
4 changed files with 18 additions and 5 deletions
|
|
@ -238,7 +238,6 @@ void exec386(int cycs)
|
||||||
|
|
||||||
oldcs=CS;
|
oldcs=CS;
|
||||||
cpu_state.oldpc = cpu_state.pc;
|
cpu_state.oldpc = cpu_state.pc;
|
||||||
oldcpl=CPL;
|
|
||||||
cpu_state.op32 = use32;
|
cpu_state.op32 = use32;
|
||||||
|
|
||||||
dontprint=0;
|
dontprint=0;
|
||||||
|
|
|
||||||
|
|
@ -533,7 +533,6 @@ void exec386_dynarec(int cycs)
|
||||||
{
|
{
|
||||||
oldcs = CS;
|
oldcs = CS;
|
||||||
cpu_state.oldpc = cpu_state.pc;
|
cpu_state.oldpc = cpu_state.pc;
|
||||||
oldcpl = CPL;
|
|
||||||
cpu_state.op32 = use32;
|
cpu_state.op32 = use32;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -549,7 +548,6 @@ void exec386_dynarec(int cycs)
|
||||||
{
|
{
|
||||||
oldcs=CS;
|
oldcs=CS;
|
||||||
cpu_state.oldpc = cpu_state.pc;
|
cpu_state.oldpc = cpu_state.pc;
|
||||||
oldcpl=CPL;
|
|
||||||
cpu_state.op32 = use32;
|
cpu_state.op32 = use32;
|
||||||
|
|
||||||
cpu_state.ea_seg = &cpu_state.seg_ds;
|
cpu_state.ea_seg = &cpu_state.seg_ds;
|
||||||
|
|
@ -708,7 +706,6 @@ inrecomp=0;
|
||||||
{
|
{
|
||||||
oldcs=CS;
|
oldcs=CS;
|
||||||
cpu_state.oldpc = cpu_state.pc;
|
cpu_state.oldpc = cpu_state.pc;
|
||||||
oldcpl=CPL;
|
|
||||||
cpu_state.op32 = use32;
|
cpu_state.op32 = use32;
|
||||||
|
|
||||||
cpu_state.ea_seg = &cpu_state.seg_ds;
|
cpu_state.ea_seg = &cpu_state.seg_ds;
|
||||||
|
|
@ -790,7 +787,6 @@ inrecomp=0;
|
||||||
{
|
{
|
||||||
oldcs=CS;
|
oldcs=CS;
|
||||||
cpu_state.oldpc = cpu_state.pc;
|
cpu_state.oldpc = cpu_state.pc;
|
||||||
oldcpl=CPL;
|
|
||||||
cpu_state.op32 = use32;
|
cpu_state.op32 = use32;
|
||||||
|
|
||||||
cpu_state.ea_seg = &cpu_state.seg_ds;
|
cpu_state.ea_seg = &cpu_state.seg_ds;
|
||||||
|
|
|
||||||
|
|
@ -925,6 +925,7 @@ static int opLOADALL386(uint32_t fetchdat)
|
||||||
loadall_load_segment(la_addr + 0xc0, &cpu_state.seg_es);
|
loadall_load_segment(la_addr + 0xc0, &cpu_state.seg_es);
|
||||||
|
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
|
|
||||||
CLOCK_CYCLES(350);
|
CLOCK_CYCLES(350);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
17
src/x86seg.c
17
src/x86seg.c
|
|
@ -573,6 +573,7 @@ void loadcs(uint16_t seg)
|
||||||
do_seg_load(&cpu_state.seg_cs, segdat);
|
do_seg_load(&cpu_state.seg_cs, segdat);
|
||||||
use32=(segdat[3]&0x40)?0x300:0;
|
use32=(segdat[3]&0x40)?0x300:0;
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
|
|
||||||
#ifdef CS_ACCESSED
|
#ifdef CS_ACCESSED
|
||||||
cpl_override = 1;
|
cpl_override = 1;
|
||||||
|
|
@ -611,6 +612,7 @@ void loadcs(uint16_t seg)
|
||||||
if (cpu_state.eflags&VM_FLAG) cpu_state.seg_cs.access=(3<<5) | 2;
|
if (cpu_state.eflags&VM_FLAG) cpu_state.seg_cs.access=(3<<5) | 2;
|
||||||
else cpu_state.seg_cs.access=(0<<5) | 2;
|
else cpu_state.seg_cs.access=(0<<5) | 2;
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -697,6 +699,7 @@ void loadcsjmp(uint16_t seg, uint32_t oxpc)
|
||||||
|
|
||||||
do_seg_load(&cpu_state.seg_cs, segdat);
|
do_seg_load(&cpu_state.seg_cs, segdat);
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
/* if (segdat[3]&0x40)
|
/* if (segdat[3]&0x40)
|
||||||
{
|
{
|
||||||
use32=0x300;
|
use32=0x300;
|
||||||
|
|
@ -801,6 +804,7 @@ void loadcsjmp(uint16_t seg, uint32_t oxpc)
|
||||||
CS=seg2;
|
CS=seg2;
|
||||||
do_seg_load(&cpu_state.seg_cs, segdat);
|
do_seg_load(&cpu_state.seg_cs, segdat);
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
set_use32(segdat[3]&0x40);
|
set_use32(segdat[3]&0x40);
|
||||||
cpu_state.pc=newpc;
|
cpu_state.pc=newpc;
|
||||||
|
|
||||||
|
|
@ -856,6 +860,7 @@ void loadcsjmp(uint16_t seg, uint32_t oxpc)
|
||||||
if (cpu_state.eflags&VM_FLAG) cpu_state.seg_cs.access=(3<<5) | 2;
|
if (cpu_state.eflags&VM_FLAG) cpu_state.seg_cs.access=(3<<5) | 2;
|
||||||
else cpu_state.seg_cs.access=(0<<5) | 2;
|
else cpu_state.seg_cs.access=(0<<5) | 2;
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
cycles -= timing_jmp_rm;
|
cycles -= timing_jmp_rm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1032,6 +1037,7 @@ void loadcscall(uint16_t seg)
|
||||||
CS=seg;
|
CS=seg;
|
||||||
do_seg_load(&cpu_state.seg_cs, segdat);
|
do_seg_load(&cpu_state.seg_cs, segdat);
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
/* if (segdat[3]&0x40)
|
/* if (segdat[3]&0x40)
|
||||||
{
|
{
|
||||||
use32=0x300;
|
use32=0x300;
|
||||||
|
|
@ -1220,6 +1226,7 @@ void loadcscall(uint16_t seg)
|
||||||
CS=seg2;
|
CS=seg2;
|
||||||
do_seg_load(&cpu_state.seg_cs, segdat);
|
do_seg_load(&cpu_state.seg_cs, segdat);
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
set_use32(segdat[3]&0x40);
|
set_use32(segdat[3]&0x40);
|
||||||
cpu_state.pc=newpc;
|
cpu_state.pc=newpc;
|
||||||
|
|
||||||
|
|
@ -1324,6 +1331,7 @@ void loadcscall(uint16_t seg)
|
||||||
CS=seg2;
|
CS=seg2;
|
||||||
do_seg_load(&cpu_state.seg_cs, segdat);
|
do_seg_load(&cpu_state.seg_cs, segdat);
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
set_use32(segdat[3]&0x40);
|
set_use32(segdat[3]&0x40);
|
||||||
cpu_state.pc=newpc;
|
cpu_state.pc=newpc;
|
||||||
|
|
||||||
|
|
@ -1373,6 +1381,7 @@ void loadcscall(uint16_t seg)
|
||||||
if (cpu_state.eflags&VM_FLAG) cpu_state.seg_cs.access=(3<<5) | 2;
|
if (cpu_state.eflags&VM_FLAG) cpu_state.seg_cs.access=(3<<5) | 2;
|
||||||
else cpu_state.seg_cs.access=(0<<5) | 2;
|
else cpu_state.seg_cs.access=(0<<5) | 2;
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1500,6 +1509,7 @@ void pmoderetf(int is32, uint16_t off)
|
||||||
do_seg_load(&cpu_state.seg_cs, segdat);
|
do_seg_load(&cpu_state.seg_cs, segdat);
|
||||||
cpu_state.seg_cs.access = (cpu_state.seg_cs.access & ~(3 << 5)) | ((CS & 3) << 5);
|
cpu_state.seg_cs.access = (cpu_state.seg_cs.access & ~(3 << 5)) | ((CS & 3) << 5);
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
set_use32(segdat[3] & 0x40);
|
set_use32(segdat[3] & 0x40);
|
||||||
|
|
||||||
// pclog("CPL=RPL return to %04X:%08X\n",CS,pc);
|
// pclog("CPL=RPL return to %04X:%08X\n",CS,pc);
|
||||||
|
|
@ -1651,6 +1661,7 @@ void pmoderetf(int is32, uint16_t off)
|
||||||
CS=seg;
|
CS=seg;
|
||||||
do_seg_load(&cpu_state.seg_cs, segdat);
|
do_seg_load(&cpu_state.seg_cs, segdat);
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
set_use32(segdat[3] & 0x40);
|
set_use32(segdat[3] & 0x40);
|
||||||
|
|
||||||
if (stack32) ESP+=off;
|
if (stack32) ESP+=off;
|
||||||
|
|
@ -1982,6 +1993,7 @@ void pmodeint(int num, int soft)
|
||||||
cpu_state.seg_cs.access = (cpu_state.seg_cs.access & ~(3 << 5)) | (new_cpl << 5);
|
cpu_state.seg_cs.access = (cpu_state.seg_cs.access & ~(3 << 5)) | (new_cpl << 5);
|
||||||
// pclog("New CS = %04X\n",CS);
|
// pclog("New CS = %04X\n",CS);
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
if (type>0x800) cpu_state.pc=segdat[0]|(segdat[3]<<16);
|
if (type>0x800) cpu_state.pc=segdat[0]|(segdat[3]<<16);
|
||||||
else cpu_state.pc=segdat[0];
|
else cpu_state.pc=segdat[0];
|
||||||
set_use32(segdat2[3]&0x40);
|
set_use32(segdat2[3]&0x40);
|
||||||
|
|
@ -2178,6 +2190,7 @@ void pmodeiret(int is32)
|
||||||
CS=seg;
|
CS=seg;
|
||||||
cpu_state.seg_cs.access=(3<<5) | 2;
|
cpu_state.seg_cs.access=(3<<5) | 2;
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
|
|
||||||
ESP=newsp;
|
ESP=newsp;
|
||||||
loadseg(newss,&cpu_state.seg_ss);
|
loadseg(newss,&cpu_state.seg_ss);
|
||||||
|
|
@ -2297,6 +2310,7 @@ void pmodeiret(int is32)
|
||||||
do_seg_load(&cpu_state.seg_cs, segdat);
|
do_seg_load(&cpu_state.seg_cs, segdat);
|
||||||
cpu_state.seg_cs.access = (cpu_state.seg_cs.access & ~(3 << 5)) | ((CS & 3) << 5);
|
cpu_state.seg_cs.access = (cpu_state.seg_cs.access & ~(3 << 5)) | ((CS & 3) << 5);
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
set_use32(segdat[3]&0x40);
|
set_use32(segdat[3]&0x40);
|
||||||
|
|
||||||
#ifdef CS_ACCESSED
|
#ifdef CS_ACCESSED
|
||||||
|
|
@ -2413,6 +2427,7 @@ void pmodeiret(int is32)
|
||||||
do_seg_load(&cpu_state.seg_cs, segdat);
|
do_seg_load(&cpu_state.seg_cs, segdat);
|
||||||
cpu_state.seg_cs.access = (cpu_state.seg_cs.access & ~(3 << 5)) | ((CS & 3) << 5);
|
cpu_state.seg_cs.access = (cpu_state.seg_cs.access & ~(3 << 5)) | ((CS & 3) << 5);
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
set_use32(segdat[3] & 0x40);
|
set_use32(segdat[3] & 0x40);
|
||||||
|
|
||||||
check_seg_valid(&cpu_state.seg_ds);
|
check_seg_valid(&cpu_state.seg_ds);
|
||||||
|
|
@ -2647,6 +2662,7 @@ void taskswitch286(uint16_t seg, uint16_t *segdat, int is32)
|
||||||
CS=new_cs;
|
CS=new_cs;
|
||||||
do_seg_load(&cpu_state.seg_cs, segdat2);
|
do_seg_load(&cpu_state.seg_cs, segdat2);
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
set_use32(segdat2[3] & 0x40);
|
set_use32(segdat2[3] & 0x40);
|
||||||
cpu_cur_status &= ~CPU_STATUS_V86;
|
cpu_cur_status &= ~CPU_STATUS_V86;
|
||||||
}
|
}
|
||||||
|
|
@ -2847,6 +2863,7 @@ void taskswitch286(uint16_t seg, uint16_t *segdat, int is32)
|
||||||
CS=new_cs;
|
CS=new_cs;
|
||||||
do_seg_load(&cpu_state.seg_cs, segdat2);
|
do_seg_load(&cpu_state.seg_cs, segdat2);
|
||||||
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
if (CPL==3 && oldcpl!=3) flushmmucache_cr3();
|
||||||
|
oldcpl = CPL;
|
||||||
set_use32(0);
|
set_use32(0);
|
||||||
|
|
||||||
EAX=new_eax | 0xFFFF0000;
|
EAX=new_eax | 0xFFFF0000;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue