2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2014, The V3VEE Project <http://www.v3vee.org>
11 * All rights reserved.
13 * Author: Peter Dinda <pdinda@northwestern.edu>
15 * This is free software. You are permitted to use,
16 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
19 #ifndef __VMM_MEM_TRACK_H__
20 #define __VMM_MEM_TRACK_H__
26 // Currently, only V3_MEM_TRACK_ACCESS is supported. ..
27 #define V3_MEM_TRACK_NONE 0
28 #define V3_MEM_TRACK_READ 1
29 #define V3_MEM_TRACK_WRITE 2
30 #define V3_MEM_TRACK_EXEC 4
31 #define V3_MEM_TRACK_ACCESS (V3_MEM_TRACK_READ | V3_MEM_TRACK_WRITE | V3_MEM_TRACK_EXEC)
33 typedef uint32_t v3_mem_track_access_t;
34 typedef enum {V3_MEM_TRACK_ONESHOT, V3_MEM_TRACK_PERIODIC } v3_mem_track_reset_t;
37 // each VM contains this
38 struct v3_vm_mem_track {
40 v3_mem_track_access_t access_type;
41 v3_mem_track_reset_t reset_type;
43 uint64_t period; // or the interval for oneshot (in cycles) (0=continuous)
46 // each core contains this
47 struct v3_core_mem_track {
48 uint64_t start_time; // cycle count when we started
49 uint64_t end_time; // ... ended
51 uint64_t num_pages; // the GPA in 4K pages (size of bitmap in bits)
53 #define SET_BIT(x,pos) do { (x)[(pos)/8] |= 1 << ((pos)%8); } while (0)
54 #define CLR_BIT(x,pos) do { (x)[(pos)/8] &= ~(1 << ((pos)%8);) } while (0)
55 #define GET_BIT(x,pos) ((x)[(pos)/8] >> ((pos)%8) & 0x1)
57 uint8_t *access_bitmap; // the only one so far (1 bit per page)
61 // self-contained info
62 typedef struct mem_track_snapshot {
63 v3_mem_track_access_t access_type;
64 v3_mem_track_reset_t reset_type;
67 uint32_t num_cores; // how many cores
68 struct v3_core_mem_track core[0]; // one per core
69 } v3_mem_track_snapshot;
73 int v3_mem_track_init(struct v3_vm_info *vm);
74 int v3_mem_track_deinit(struct v3_vm_info *vm);
76 int v3_mem_track_start(struct v3_vm_info *vm, v3_mem_track_access_t access, v3_mem_track_reset_t reset, uint64_t period);
77 int v3_mem_track_stop(struct v3_vm_info *vm);
79 int v3_mem_track_get_sizes(struct v3_vm_info *vm, uint64_t *num_cores, uint64_t *num_pages);
82 v3_mem_track_snapshot *v3_mem_track_take_snapshot(struct v3_vm_info *vm);
83 void v3_mem_track_free_snapshot(v3_mem_track_snapshot *snapshot);
85 // call with interrupts on...
86 void v3_mem_track_entry(struct guest_info *core);
87 void v3_mem_track_exit(struct guest_info *core);