From b8dfe6d9b199bc503c976745887034a1d1fa9146 Mon Sep 17 00:00:00 2001 From: Stanislav Shwartsman Date: Mon, 15 Mar 2010 22:58:41 +0000 Subject: [PATCH] assert check --- bochs/cpu/smm.cc | 14 ++++++++++---- bochs/cpu/vmx.cc | 7 +++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/bochs/cpu/smm.cc b/bochs/cpu/smm.cc index 9bee12116..52a7bfb38 100755 --- a/bochs/cpu/smm.cc +++ b/bochs/cpu/smm.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: smm.cc,v 1.63 2010-03-14 15:51:26 sshwarts Exp $ +// $Id: smm.cc,v 1.64 2010-03-15 22:58:41 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (c) 2006-2009 Stanislav Shwartsman @@ -73,9 +73,15 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::RSM(bxInstruction_c *i) } #if BX_SUPPORT_VMX - if (BX_CPU_THIS_PTR in_vmx_guest) { - BX_ERROR(("VMEXIT: RSM in VMX non-root operation")); - VMexit(i, VMX_VMEXIT_RSM, 0); + if (BX_CPU_THIS_PTR in_vmx) { + if (BX_CPU_THIS_PTR in_vmx_guest) { + BX_ERROR(("VMEXIT: RSM in VMX non-root operation")); + VMexit(i, VMX_VMEXIT_RSM, 0); + } + else { + BX_ERROR(("RSM in VMX root operation !")); + exception(BX_UD_EXCEPTION, 0); + } } #endif diff --git a/bochs/cpu/vmx.cc b/bochs/cpu/vmx.cc index da476ccc6..52b4a9f1b 100755 --- a/bochs/cpu/vmx.cc +++ b/bochs/cpu/vmx.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: vmx.cc,v 1.38 2010-03-15 16:34:03 sshwarts Exp $ +// $Id: vmx.cc,v 1.39 2010-03-15 22:58:41 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (c) 2009 Stanislav Shwartsman @@ -1758,6 +1758,10 @@ void BX_CPU_C::VMexit(bxInstruction_c *i, Bit32u reason, Bit64u qualification) { VMCS_CACHE *vm = &BX_CPU_THIS_PTR vmcs; + if (!BX_CPU_THIS_PTR in_vmx || !BX_CPU_THIS_PTR in_vmx_guest) { + BX_PANIC(("PANIC: VMEXIT not in VMX guest mode !")); + } + // VMEXITs are FAULT-like: restore RIP/RSP to value before VMEXIT occurred RIP = BX_CPU_THIS_PTR prev_rip; if (BX_CPU_THIS_PTR speculative_rsp) @@ -2162,7 +2166,6 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::VMLAUNCH(bxInstruction_c *i) /////////////////////////////////////////////////////// VMenterInjectEvents(); - #else BX_INFO(("VMLAUNCH/VMRESUME: required VMX support, use --enable-vmx option")); exception(BX_UD_EXCEPTION, 0);