From a647c7e55192b4030040a1de92df049f47c2d41d Mon Sep 17 00:00:00 2001 From: Stanislav Shwartsman Date: Fri, 25 Apr 2008 11:39:51 +0000 Subject: [PATCH] Check for old TSS limits in task switching logic MSR_GSKERNELBASE should be canonical - added WRMSR check --- bochs/cpu/proc_ctrl.cc | 6 +++++- bochs/cpu/tasking.cc | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bochs/cpu/proc_ctrl.cc b/bochs/cpu/proc_ctrl.cc index 2547c3d11..a25623519 100644 --- a/bochs/cpu/proc_ctrl.cc +++ b/bochs/cpu/proc_ctrl.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: proc_ctrl.cc,v 1.218 2008-04-20 21:44:13 sshwarts Exp $ +// $Id: proc_ctrl.cc,v 1.219 2008-04-25 11:39:51 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -1896,6 +1896,10 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::WRMSR(bxInstruction_c *i) return; case BX_MSR_KERNELGSBASE: + if (! IsCanonical(val64)) { + BX_ERROR(("WRMSR: attempt to write non-canonical value to MSR_KERNELGSBASE !")); + exception(BX_GP_EXCEPTION, 0, 0); + } MSR_KERNELGSBASE = val64; return; diff --git a/bochs/cpu/tasking.cc b/bochs/cpu/tasking.cc index 6a5619b3f..122c382d0 100644 --- a/bochs/cpu/tasking.cc +++ b/bochs/cpu/tasking.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: tasking.cc,v 1.54 2008-04-22 22:05:38 sshwarts Exp $ +// $Id: tasking.cc,v 1.55 2008-04-25 11:39:51 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -186,6 +186,11 @@ void BX_CPU_C::task_switch(bx_selector_t *tss_selector, exception(BX_TS_EXCEPTION, tss_selector->value & 0xfffc, 0); } + if (old_TSS_limit < old_TSS_max) { + BX_ERROR(("task_switch(): old TSS limit < %d", old_TSS_max)); + exception(BX_TS_EXCEPTION, BX_CPU_THIS_PTR tr.selector.value & 0xfffc, 0); + } + if (obase32 == nbase32) { BX_INFO(("TASK SWITCH: switching to the same TSS !")); }