diff options
Diffstat (limited to 'src/VBox/VMM/VMMAll/CSAMAll.cpp')
| -rw-r--r-- | src/VBox/VMM/VMMAll/CSAMAll.cpp | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/VBox/VMM/VMMAll/CSAMAll.cpp b/src/VBox/VMM/VMMAll/CSAMAll.cpp index db9143d9..d2281a1c 100644 --- a/src/VBox/VMM/VMMAll/CSAMAll.cpp +++ b/src/VBox/VMM/VMMAll/CSAMAll.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2007 Oracle Corporation + * Copyright (C) 2006-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -26,6 +26,7 @@ #include <VBox/vmm/csam.h> #include <VBox/vmm/pgm.h> #include <VBox/vmm/em.h> +#include <VBox/vmm/hm.h> #include <VBox/vmm/mm.h> #include <VBox/sup.h> #include <VBox/vmm/mm.h> @@ -37,11 +38,11 @@ #include <VBox/dbg.h> #include <VBox/err.h> #include <VBox/log.h> -#include <iprt/assert.h> #include <VBox/dis.h> #include <VBox/disopcode.h> -#include <iprt/string.h> +#include <iprt/assert.h> #include <iprt/asm.h> +#include <iprt/string.h> /** * Check if this page needs to be analysed by CSAM @@ -50,14 +51,15 @@ * @param pVM Pointer to the VM. * @param pvFault Fault address */ -VMMDECL(int) CSAMExecFault(PVM pVM, RTRCPTR pvFault) +VMM_INT_DECL(int) CSAMExecFault(PVM pVM, RTRCPTR pvFault) { - if(!CSAMIsEnabled(pVM)) + Assert(!HMIsEnabled(pVM)); + if (!CSAMIsEnabled(pVM)) return VINF_SUCCESS; LogFlow(("CSAMGCExecFault: for page %08X scanned=%d\n", pvFault, CSAMIsPageScanned(pVM, pvFault))); - if(CSAMIsPageScanned(pVM, pvFault)) + if (CSAMIsPageScanned(pVM, pvFault)) { // Already checked! STAM_COUNTER_ADD(&pVM->csam.s.StatNrKnownPagesGC, 1); @@ -77,10 +79,11 @@ VMMDECL(int) CSAMExecFault(PVM pVM, RTRCPTR pvFault) * @param pVM Pointer to the VM. * @param pPage GC page address */ -VMMDECL(bool) CSAMIsPageScanned(PVM pVM, RTRCPTR pPage) +VMM_INT_DECL(bool) CSAMIsPageScanned(PVM pVM, RTRCPTR pPage) { int pgdir, bit; uintptr_t page; + Assert(!HMIsEnabled(pVM)); page = (uintptr_t)pPage; pgdir = page >> X86_PAGE_4M_SHIFT; @@ -105,7 +108,7 @@ VMMDECL(bool) CSAMIsPageScanned(PVM pVM, RTRCPTR pPage) * @param fScanned Mark as scanned or not scanned * */ -VMMDECL(int) CSAMMarkPage(PVM pVM, RTRCUINTPTR pPage, bool fScanned) +VMM_INT_DECL(int) CSAMMarkPage(PVM pVM, RTRCUINTPTR pPage, bool fScanned) { int pgdir, bit; uintptr_t page; @@ -115,8 +118,9 @@ VMMDECL(int) CSAMMarkPage(PVM pVM, RTRCUINTPTR pPage, bool fScanned) Log(("CSAMMarkPage %RRv\n", pPage)); #endif - if(!CSAMIsEnabled(pVM)) + if (!CSAMIsEnabled(pVM)) return VINF_SUCCESS; + Assert(!HMIsEnabled(pVM)); page = (uintptr_t)pPage; pgdir = page >> X86_PAGE_4M_SHIFT; @@ -174,10 +178,11 @@ VMMDECL(int) CSAMMarkPage(PVM pVM, RTRCUINTPTR pPage, bool fScanned) * @param pVM Pointer to the VM. * @param GCPtr GC pointer of page */ -VMMDECL(bool) CSAMDoesPageNeedScanning(PVM pVM, RTRCUINTPTR GCPtr) +VMM_INT_DECL(bool) CSAMDoesPageNeedScanning(PVM pVM, RTRCUINTPTR GCPtr) { - if(!CSAMIsEnabled(pVM)) + if (!CSAMIsEnabled(pVM)) return false; + Assert(!HMIsEnabled(pVM)); if(CSAMIsPageScanned(pVM, (RTRCPTR)GCPtr)) { @@ -197,8 +202,9 @@ VMMDECL(bool) CSAMDoesPageNeedScanning(PVM pVM, RTRCUINTPTR GCPtr) * @param pVM Pointer to the VM. * @param GCPtr GC pointer of page */ -VMMDECL(void) CSAMMarkPossibleCodePage(PVM pVM, RTRCPTR GCPtr) +VMM_INT_DECL(void) CSAMMarkPossibleCodePage(PVM pVM, RTRCPTR GCPtr) { + Assert(!HMIsEnabled(pVM)); if (pVM->csam.s.cPossibleCodePages < RT_ELEMENTS(pVM->csam.s.pvPossibleCodePage)) { pVM->csam.s.pvPossibleCodePage[pVM->csam.s.cPossibleCodePages++] = (RTRCPTR)GCPtr; @@ -214,8 +220,9 @@ VMMDECL(void) CSAMMarkPossibleCodePage(PVM pVM, RTRCPTR GCPtr) * @returns VBox status code. * @param pVM Pointer to the VM. */ -VMMDECL(int) CSAMEnableScanning(PVM pVM) +VMM_INT_DECL(int) CSAMEnableScanning(PVM pVM) { + AssertReturn(!HMIsEnabled(pVM), VERR_CSAM_HM_IPE); pVM->fCSAMEnabled = true; return VINF_SUCCESS; } @@ -226,7 +233,7 @@ VMMDECL(int) CSAMEnableScanning(PVM pVM) * @returns VBox status code. * @param pVM Pointer to the VM. */ -VMMDECL(int) CSAMDisableScanning(PVM pVM) +VMM_INT_DECL(int) CSAMDisableScanning(PVM pVM) { pVM->fCSAMEnabled = false; return VINF_SUCCESS; @@ -244,8 +251,10 @@ VMMDECL(int) CSAMDisableScanning(PVM pVM) * @param pVM Pointer to the VM. * @param GCPtr GC pointer of page table entry */ -VMMDECL(bool) CSAMIsKnownDangerousInstr(PVM pVM, RTRCUINTPTR GCPtr) +VMM_INT_DECL(bool) CSAMIsKnownDangerousInstr(PVM pVM, RTRCUINTPTR GCPtr) { + Assert(!HMIsEnabled(pVM)); + for (uint32_t i=0;i<pVM->csam.s.cDangerousInstr;i++) { if (pVM->csam.s.aDangerousInstr[i] == (RTRCPTR)GCPtr) |
