summaryrefslogtreecommitdiff
path: root/include/VBox/vmm/csam.h
blob: 99a68563739ebfc1284d4d3aa1dd581223ab24e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/** @file
 * CSAM - Guest OS Code Scanning and Analyis Manager.
 */

/*
 * 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;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 *
 * The contents of this file may alternatively be used under the terms
 * of the Common Development and Distribution License Version 1.0
 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
 * VirtualBox OSE distribution, in which case the provisions of the
 * CDDL are applicable instead of those of the GPL.
 *
 * You may elect to license modified versions of this file under the
 * terms and conditions of either the GPL or the CDDL or both.
 */

#ifndef ___VBox_vmm_csam_h
#define ___VBox_vmm_csam_h

#include <VBox/types.h>

#if defined(VBOX_WITH_RAW_MODE) || defined(DOXYGEN_RUNNING)

/** @defgroup grp_csam      The Code Scanning and Analysis API
 * @{
 */

/**
 * CSAM monitoring tag.
 * For use with CSAMR3MonitorPage
 */
typedef enum CSAMTAG
{
    CSAM_TAG_INVALID = 0,
    CSAM_TAG_REM,
    CSAM_TAG_PATM,
    CSAM_TAG_CSAM,
    CSAM_TAG_32BIT_HACK = 0x7fffffff
} CSAMTAG;


RT_C_DECLS_BEGIN


/**
 * Query CSAM state (enabled/disabled)
 *
 * @returns true / false.
 * @param   a_pVM         The shared VM handle.
 * @internal
 */
#define CSAMIsEnabled(a_pVM) ((a_pVM)->fCSAMEnabled && EMIsRawRing0Enabled(a_pVM))

VMM_INT_DECL(bool)      CSAMDoesPageNeedScanning(PVM pVM, RTRCUINTPTR GCPtr);
VMM_INT_DECL(bool)      CSAMIsPageScanned(PVM pVM, RTRCPTR pPage);
VMM_INT_DECL(int)       CSAMMarkPage(PVM pVM, RTRCUINTPTR pPage, bool fScanned);
VMM_INT_DECL(void)      CSAMMarkPossibleCodePage(PVM pVM, RTRCPTR GCPtr);
VMM_INT_DECL(int)       CSAMEnableScanning(PVM pVM);
VMM_INT_DECL(int)       CSAMDisableScanning(PVM pVM);
VMM_INT_DECL(int)       CSAMExecFault(PVM pVM, RTRCPTR pvFault);
VMM_INT_DECL(bool)      CSAMIsKnownDangerousInstr(PVM pVM, RTRCUINTPTR GCPtr);


#ifdef IN_RING3
/** @defgroup grp_csam_r3      The Code Scanning and Analysis API
 * @ingroup grp_csam
 * @{
 */

VMMR3DECL(bool)         CSAMR3IsEnabled(PUVM pUVM);
VMMR3DECL(int)          CSAMR3SetScanningEnabled(PUVM pUVM, bool fEnabled);

VMMR3_INT_DECL(int)     CSAMR3Init(PVM pVM);
VMMR3_INT_DECL(void)    CSAMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
VMMR3_INT_DECL(int)     CSAMR3Term(PVM pVM);
VMMR3_INT_DECL(int)     CSAMR3Reset(PVM pVM);

VMMR3_INT_DECL(int)     CSAMR3FlushPage(PVM pVM, RTRCPTR addr);
VMMR3_INT_DECL(int)     CSAMR3RemovePage(PVM pVM, RTRCPTR addr);
VMMR3_INT_DECL(int)     CSAMR3CheckCode(PVM pVM, RTRCPTR pInstrGC);
VMMR3_INT_DECL(int)     CSAMR3CheckCodeEx(PVM pVM, PCPUMCTXCORE pCtxCore, RTRCPTR pInstrGC);
VMMR3_INT_DECL(int)     CSAMR3MarkCode(PVM pVM, RTRCPTR pInstr, uint32_t cbInstr, bool fScanned);
VMMR3_INT_DECL(int)     CSAMR3DoPendingAction(PVM pVM, PVMCPU pVCpu);
VMMR3_INT_DECL(int)     CSAMR3CheckGates(PVM pVM, uint32_t iGate, uint32_t cGates);

VMMR3DECL(int)          CSAMR3MonitorPage(PVM pVM, RTRCPTR pPageAddrGC, CSAMTAG enmTag);
VMMR3DECL(int)          CSAMR3UnmonitorPage(PVM pVM, RTRCPTR pPageAddrGC, CSAMTAG enmTag);
VMMR3DECL(int)          CSAMR3RecordCallAddress(PVM pVM, RTRCPTR GCPtrCall);

/** @} */
#endif


/** @} */
RT_C_DECLS_END

#endif /* VBOX_WITH_RAW_MODE */

#endif