From 19955c36e87cdf400672f63b646e3764c5500650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Strohh=C3=A4cker?= Date: Thu, 27 Apr 2006 13:22:27 +0000 Subject: [PATCH] use inverted stack mask in normal/full core; issue exception when calling type zero descriptor; add INVLPG opcode Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2617 --- src/cpu/core_full/load.h | 4 ++-- src/cpu/core_full/op.h | 5 +++++ src/cpu/core_normal.cpp | 1 + src/cpu/core_normal/prefix_0f.h | 4 ++++ src/cpu/core_normal/prefix_66.h | 2 +- src/cpu/core_normal/prefix_66_0f.h | 4 ++++ src/cpu/core_normal/prefix_none.h | 2 +- src/cpu/cpu.cpp | 7 +++++-- 8 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/cpu/core_full/load.h b/src/cpu/core_full/load.h index 73ced332..1f47b886 100644 --- a/src/cpu/core_full/load.h +++ b/src/cpu/core_full/load.h @@ -447,12 +447,12 @@ l_M_Ed: goto nextopcode; } case D_LEAVEw: - reg_esp&=~cpu.stack.mask; + reg_esp&=cpu.stack.notmask; reg_esp|=(reg_ebp&cpu.stack.mask); reg_bp=Pop_16(); goto nextopcode; case D_LEAVEd: - reg_esp&=~cpu.stack.mask; + reg_esp&=cpu.stack.notmask; reg_esp|=(reg_ebp&cpu.stack.mask); reg_ebp=Pop_32(); goto nextopcode; diff --git a/src/cpu/core_full/op.h b/src/cpu/core_full/op.h index 8f25a72d..97f85756 100644 --- a/src/cpu/core_full/op.h +++ b/src/cpu/core_full/op.h @@ -450,6 +450,11 @@ switch (inst.code.op) { FillFlags(); if (CPU_LMSW(inst_op1_w)) RunException(); goto nextopcode; + case 7: /* INVLPG */ + if (cpu.pmode && cpu.cpl) EXCEPTION(EXCEPTION_GP); + FillFlags(); + PAGING_ClearTLB(); + goto nextopcode; default: LOG(LOG_CPU,LOG_ERROR)("Group 7 Illegal subfunction %X",inst.rm_index); goto illegalopcode; diff --git a/src/cpu/core_normal.cpp b/src/cpu/core_normal.cpp index 5ff39eeb..f71a6f1f 100644 --- a/src/cpu/core_normal.cpp +++ b/src/cpu/core_normal.cpp @@ -26,6 +26,7 @@ #include "callback.h" #include "pic.h" #include "fpu.h" +#include "paging.h" #if C_DEBUG #include "debug.h" diff --git a/src/cpu/core_normal/prefix_0f.h b/src/cpu/core_normal/prefix_0f.h index cb24f83f..cefd09ea 100644 --- a/src/cpu/core_normal/prefix_0f.h +++ b/src/cpu/core_normal/prefix_0f.h @@ -92,6 +92,10 @@ limit=LoadMw(eaa); if (CPU_LMSW(limit)) RUNEXCEPTION(); break; + case 0x07: /* INVLPG */ + if (cpu.pmode && cpu.cpl) EXCEPTION(EXCEPTION_GP); + PAGING_ClearTLB(); + break; } } else { GetEArw;Bitu limit; diff --git a/src/cpu/core_normal/prefix_66.h b/src/cpu/core_normal/prefix_66.h index a839c42b..8742716a 100644 --- a/src/cpu/core_normal/prefix_66.h +++ b/src/cpu/core_normal/prefix_66.h @@ -492,7 +492,7 @@ } break; CASE_D(0xc9) /* LEAVE */ - reg_esp&=~cpu.stack.mask; + reg_esp&=cpu.stack.notmask; reg_esp|=(reg_ebp&cpu.stack.mask); reg_ebp=Pop_32(); break; diff --git a/src/cpu/core_normal/prefix_66_0f.h b/src/cpu/core_normal/prefix_66_0f.h index d9cc9901..b034b783 100644 --- a/src/cpu/core_normal/prefix_66_0f.h +++ b/src/cpu/core_normal/prefix_66_0f.h @@ -94,6 +94,10 @@ limit=LoadMw(eaa); if (CPU_LMSW((Bit16u)limit)) RUNEXCEPTION(); break; + case 0x07: /* INVLPG */ + if (cpu.pmode && cpu.cpl) EXCEPTION(EXCEPTION_GP); + PAGING_ClearTLB(); + break; } } else { GetEArd;Bitu limit; diff --git a/src/cpu/core_normal/prefix_none.h b/src/cpu/core_normal/prefix_none.h index 44a9a941..c2d8113a 100644 --- a/src/cpu/core_normal/prefix_none.h +++ b/src/cpu/core_normal/prefix_none.h @@ -712,7 +712,7 @@ } break; CASE_W(0xc9) /* LEAVE */ - reg_esp&=~cpu.stack.mask; + reg_esp&=cpu.stack.notmask; reg_esp|=(reg_ebp&cpu.stack.mask); reg_bp=Pop_16(); break; diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp index abe57759..6e687e41 100644 --- a/src/cpu/cpu.cpp +++ b/src/cpu/cpu.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: cpu.cpp,v 1.80 2006-04-18 17:44:25 c2woody Exp $ */ +/* $Id: cpu.cpp,v 1.81 2006-04-27 13:22:27 c2woody Exp $ */ #include #include "dosbox.h" @@ -1147,9 +1147,12 @@ call_code: LOG(LOG_CPU,LOG_NORMAL)("CALL:TSS to %X",selector); CPU_SwitchTask(selector,TSwitch_CALL_INT,oldeip); break; + case DESC_INVALID: + // used by some installers + CPU_Exception(EXCEPTION_GP,selector & 0xfffc); + return; default: E_Exit("CALL:Descriptor type %x unsupported",call.Type()); - } } assert(1);