Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Add memory tracking functionality to Palacios
[palacios.git] / palacios / include / palacios / vmm_mem_track.h
1 /*
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.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2014, The V3VEE Project <http://www.v3vee.org> 
11  * All rights reserved.
12  *
13  * Author: Peter Dinda <pdinda@northwestern.edu>
14  *
15  * This is free software.  You are permitted to use,
16  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
17  */
18
19 #ifndef __VMM_MEM_TRACK_H__
20 #define __VMM_MEM_TRACK_H__
21
22 struct guest_info;
23 struct v3_vm_info;
24
25
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)
32
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;
35
36
37 // each VM contains this
38 struct v3_vm_mem_track {
39     int                    started;
40     v3_mem_track_access_t  access_type;
41     v3_mem_track_reset_t   reset_type;
42     
43     uint64_t               period;  // or the interval for oneshot (in cycles) (0=continuous)
44 };
45
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
50
51     uint64_t               num_pages;      // the GPA in 4K pages (size of bitmap in bits)
52
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)
56
57     uint8_t                *access_bitmap; // the only one so far (1 bit per page)
58 };
59
60
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;
65     uint64_t               period;
66
67     uint32_t               num_cores;      // how many cores
68     struct v3_core_mem_track core[0];      // one per core
69 } v3_mem_track_snapshot;
70
71
72
73 int v3_mem_track_init(struct v3_vm_info *vm);
74 int v3_mem_track_deinit(struct v3_vm_info *vm);
75
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);
78
79 int v3_mem_track_get_sizes(struct v3_vm_info *vm, uint64_t *num_cores, uint64_t *num_pages);
80
81
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);
84
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);
88
89
90
91 #endif