Bitdefender Hypervisor Memory Introspection
gpacache.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Bitdefender
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #ifndef _GPACACHE_H_
6 #define _GPACACHE_H_
7 
8 #include "introtypes.h"
9 
10 
14 typedef struct _GPA_CACHE_ENTRY
15 {
17  void *Hva;
22 
23 
27 typedef struct _GPA_CACHE_LINE
28 {
31 
32 
37 typedef struct _GPA_CACHE_VICTIM
38 {
42 
43 
48 typedef struct _GPA_CACHE
49 {
52 
54 
57 
58 
59 void
61  _In_ PGPA_CACHE Cache
62  );
63 
66  _Inout_ PGPA_CACHE *Cache,
67  _In_ DWORD LinesCount,
68  _In_ DWORD EntriesCount
69  );
70 
73  _In_ PGPA_CACHE *Cache
74  );
75 
78  _In_ PGPA_CACHE Cache,
79  _In_ QWORD Gpa
80  );
81 
84  _In_ PGPA_CACHE Cache,
85  _In_ QWORD Gpa,
86  _Out_ void **Hva
87  );
88 
91  _In_ PGPA_CACHE Cache,
92  _In_ QWORD Gpa,
93  _In_ DWORD Size,
94  _Out_ PBYTE Buffer
95  );
96 
99  _In_ PGPA_CACHE Cache,
100  _In_ QWORD Gpa,
101  _In_ DWORD Size,
102  _In_ PBYTE Buffer
103  );
104 
105 INTSTATUS
107  _In_ PGPA_CACHE Cache
108  );
109 
110 #endif // _GPACACHE_H_
struct _GPA_CACHE_ENTRY GPA_CACHE_ENTRY
#define _Out_
Definition: intro_sal.h:22
_Bool BOOLEAN
Definition: intro_types.h:58
#define _In_
Definition: intro_sal.h:21
struct _GPA_CACHE_ENTRY * PGPA_CACHE_ENTRY
GPA_CACHE_ENTRY Entry
The actual cache entry.
Definition: gpacache.h:40
struct _GPA_CACHE_VICTIM * PGPA_CACHE_VICTIM
DWORD UseCount
Reference count, incremented by calls to IntGpaCacheFindAndAdd.
Definition: gpacache.h:19
INTSTATUS IntGpaCacheInit(PGPA_CACHE *Cache, DWORD LinesCount, DWORD EntriesCount)
Initialize a GPA cache.
Definition: gpacache.c:115
int INTSTATUS
The status data type.
Definition: introstatus.h:24
struct _GPA_CACHE_LINE GPA_CACHE_LINE
LIST_ENTRY Victims
List of victim entries evicted from the cache while UseCount is not 0.
Definition: gpacache.h:55
struct _GPA_CACHE * PGPA_CACHE
INTSTATUS IntGpaCacheFlush(PGPA_CACHE Cache)
Flush the entire GPA cache.
Definition: gpacache.c:776
INTSTATUS IntGpaCacheRelease(PGPA_CACHE Cache, QWORD Gpa)
Release a previously used cached entry.
Definition: gpacache.c:678
#define _Inout_
Definition: intro_sal.h:20
QWORD Gpa
Gpa this entry maps to.
Definition: gpacache.h:16
uint8_t * PBYTE
Definition: intro_types.h:47
INTSTATUS IntGpaCacheFetchAndAdd(PGPA_CACHE Cache, QWORD Gpa, DWORD Size, PBYTE Buffer)
Fetch data from a cached entry, or add it to the cache, of not already present.
Definition: gpacache.c:508
unsigned long long QWORD
Definition: intro_types.h:53
struct _GPA_CACHE_LINE * PGPA_CACHE_LINE
GPA_CACHE_LINE * Lines
Actual array of cache lines.
Definition: gpacache.h:53
LIST_ENTRY Link
Linked list entry.
Definition: gpacache.h:39
uint32_t DWORD
Definition: intro_types.h:49
INTSTATUS IntGpaCacheUnInit(PGPA_CACHE *Cache)
Uninit a GPA cache.
Definition: gpacache.c:209
void * Hva
Host pointer which maps to Gpa.
Definition: gpacache.h:17
DWORD HitCount
Number of times this entry was accessed.
Definition: gpacache.h:18
void IntGpaCacheDump(PGPA_CACHE Cache)
Dumps the entire contents of the GPA cache.
Definition: gpacache.c:65
INTSTATUS IntGpaCacheFindAndAdd(PGPA_CACHE Cache, QWORD Gpa, void **Hva)
Search for an entry in the GPA cache, and add it, if it wasn't found.
Definition: gpacache.c:451
struct _GPA_CACHE GPA_CACHE
struct _GPA_CACHE_VICTIM GPA_CACHE_VICTIM
INTSTATUS IntGpaCachePatchAndAdd(PGPA_CACHE Cache, QWORD Gpa, DWORD Size, PBYTE Buffer)
Patch data in a cached entry, or add it to the cache, of not already present.
Definition: gpacache.c:593
DWORD LinesCount
Number of lines.
Definition: gpacache.h:50
GPA_CACHE_ENTRY * Entries
An array of cache entries.
Definition: gpacache.h:29
DWORD EntriesCount
Number of entries per line.
Definition: gpacache.h:51
BOOLEAN Valid
True if the entry is valid, false otherwise.
Definition: gpacache.h:20