0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** @file
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * CSAM - Guest OS Code Scanning and Analyis Manager.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/*
c1d279fc0865b91a40b30eda02ed14f6533fe1a4vboxsync * Copyright (C) 2006-2015 Oracle Corporation
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync *
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * available from http://www.virtualbox.org. This file is free software;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * you can redistribute it and/or modify it under the terms of the GNU
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * General Public License (GPL) as published by the Free Software
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync *
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * The contents of this file may alternatively be used under the terms
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * of the Common Development and Distribution License Version 1.0
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * VirtualBox OSE distribution, in which case the provisions of the
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * CDDL are applicable instead of those of the GPL.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync *
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * You may elect to license modified versions of this file under the
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * terms and conditions of either the GPL or the CDDL or both.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#ifndef ___VBox_vmm_csam_h
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#define ___VBox_vmm_csam_h
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#include <VBox/types.h>
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
7220367ea1944fa8a7694534401321ad86eb70c6vboxsync#if defined(VBOX_WITH_RAW_MODE) || defined(DOXYGEN_RUNNING)
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** @defgroup grp_csam The Code Scanning and Analysis API
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @{
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/**
30f237f6ee470d86afe123226be6d049f3dd9467vboxsync * CSAM monitoring tag.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * For use with CSAMR3MonitorPage
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctypedef enum CSAMTAG
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync{
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync CSAM_TAG_INVALID = 0,
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync CSAM_TAG_REM,
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync CSAM_TAG_PATM,
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync CSAM_TAG_CSAM,
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync CSAM_TAG_32BIT_HACK = 0x7fffffff
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync} CSAMTAG;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncRT_C_DECLS_BEGIN
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/**
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * Query CSAM state (enabled/disabled)
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync *
30f237f6ee470d86afe123226be6d049f3dd9467vboxsync * @returns true / false.
30f237f6ee470d86afe123226be6d049f3dd9467vboxsync * @param a_pVM The shared VM handle.
30f237f6ee470d86afe123226be6d049f3dd9467vboxsync * @internal
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync */
30f237f6ee470d86afe123226be6d049f3dd9467vboxsync#define CSAMIsEnabled(a_pVM) ((a_pVM)->fCSAMEnabled && EMIsRawRing0Enabled(a_pVM))
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMM_INT_DECL(bool) CSAMDoesPageNeedScanning(PVM pVM, RTRCUINTPTR GCPtr);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMM_INT_DECL(bool) CSAMIsPageScanned(PVM pVM, RTRCPTR pPage);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMM_INT_DECL(int) CSAMMarkPage(PVM pVM, RTRCUINTPTR pPage, bool fScanned);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMM_INT_DECL(void) CSAMMarkPossibleCodePage(PVM pVM, RTRCPTR GCPtr);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMM_INT_DECL(int) CSAMEnableScanning(PVM pVM);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMM_INT_DECL(int) CSAMDisableScanning(PVM pVM);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMM_INT_DECL(int) CSAMExecFault(PVM pVM, RTRCPTR pvFault);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMM_INT_DECL(bool) CSAMIsKnownDangerousInstr(PVM pVM, RTRCUINTPTR GCPtr);
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#ifdef IN_RING3
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** @defgroup grp_csam_r3 The Code Scanning and Analysis API
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @{
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMMR3DECL(bool) CSAMR3IsEnabled(PUVM pUVM);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMMR3DECL(int) CSAMR3SetScanningEnabled(PUVM pUVM, bool fEnabled);
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMMR3_INT_DECL(int) CSAMR3Init(PVM pVM);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMMR3_INT_DECL(void) CSAMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMMR3_INT_DECL(int) CSAMR3Term(PVM pVM);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMMR3_INT_DECL(int) CSAMR3Reset(PVM pVM);
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMMR3_INT_DECL(int) CSAMR3FlushPage(PVM pVM, RTRCPTR addr);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMMR3_INT_DECL(int) CSAMR3RemovePage(PVM pVM, RTRCPTR addr);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMMR3_INT_DECL(int) CSAMR3CheckCode(PVM pVM, RTRCPTR pInstrGC);
4ef1cd1012e75ff26e27b27d319ecfdf470b2190vboxsyncVMMR3_INT_DECL(int) CSAMR3CheckCodeEx(PVM pVM, PCPUMCTX pCtx, RTRCPTR pInstrGC);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMMR3_INT_DECL(int) CSAMR3MarkCode(PVM pVM, RTRCPTR pInstr, uint32_t cbInstr, bool fScanned);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMMR3_INT_DECL(int) CSAMR3DoPendingAction(PVM pVM, PVMCPU pVCpu);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMMR3_INT_DECL(int) CSAMR3CheckGates(PVM pVM, uint32_t iGate, uint32_t cGates);
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMMR3DECL(int) CSAMR3MonitorPage(PVM pVM, RTRCPTR pPageAddrGC, CSAMTAG enmTag);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMMR3DECL(int) CSAMR3UnmonitorPage(PVM pVM, RTRCPTR pPageAddrGC, CSAMTAG enmTag);
30f237f6ee470d86afe123226be6d049f3dd9467vboxsyncVMMR3DECL(int) CSAMR3RecordCallAddress(PVM pVM, RTRCPTR GCPtrCall);
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** @} */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#endif
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** @} */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncRT_C_DECLS_END
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
7220367ea1944fa8a7694534401321ad86eb70c6vboxsync#endif /* VBOX_WITH_RAW_MODE */
7220367ea1944fa8a7694534401321ad86eb70c6vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#endif
30f237f6ee470d86afe123226be6d049f3dd9467vboxsync