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.


Linux user-space tools for memory tracking functionality
[palacios.git] / palacios / include / extensions / tm_cache.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) 2012, NWU EECS 441 Transactional Memory Team
11  * Copyright (c) 2012, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Maciek Swiech <dotpyfe@u.northwestern.edu>
15  *         Kyle Hale <kh@u.northwestern.edu>
16  *
17  * This is free software.  You are permitted to use,
18  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
19  *
20  */
21
22 #ifndef __TM_CACHE_H__
23 #define __TM_CACHE_H__
24
25 #ifdef __V3VEE__
26
27 enum TM_ERR_E {
28     TM_OK  = 0,
29     TM_WAR = 1,
30     TM_WAW = 2,
31     TM_RAW = 3
32 };
33
34 enum TM_OP {
35     TM_READ  = 0,
36     TM_WRITE = 1,
37     TM_BEGIN = 2,
38     TM_ABORT = 3,
39     TM_END   = 4
40 };
41
42 // one record in the redo log linked list
43 struct rec {
44     enum TM_OP op;
45     addr_t vcorenum;
46     addr_t physaddr;
47     addr_t datalen;
48     struct list_head rec_node;
49 };
50
51 struct flag_bits {
52     uint8_t m : 1; // modified
53     uint8_t e : 1; // exclusive
54     uint8_t s : 1; // shared
55     uint8_t i : 1; // exclusive
56     uint8_t ws : 1;
57     uint8_t rs : 1;
58 } __attribute__((packed));
59
60 struct cache_line {
61     uint64_t tag;
62     struct flag_bits * flag;;
63 };
64
65 struct cache_spec {
66     uint64_t line_size;         // line size in bytes
67     uint64_t size;              // cache size in kb
68     uint64_t num_lines;
69     uint64_t associativity;
70     enum cache_policy policy;
71 };
72
73 // cache hardware we are emulating
74 struct cache_box {
75     int (*init) (struct cache_spec * spec, struct cache_box * self);
76     struct cache_spec * spec;
77     struct cache_line ** cache_table;
78
79     enum TM_ERR_E (*read)  (struct guest_info *core, addr_t hva, addr_t len, struct cache_box * self);
80     enum TM_ERR_E (*write) (struct guest_info *core, addr_t hva, addr_t len, struct cache_box * self);
81     uint64_t (*invalidate) (struct guest_info *core, addr_t hva, addr_t len, struct cache_box * self);
82 };
83
84 // redo logger
85 // TODO: dont need this anymore?
86 /*
87 struct logger {
88     // emulated cache
89     struct cache_box *model;
90     lock_t   global_lock;
91     uint64_t loglen;
92     uint64_t num_trans_active;
93
94     enum TM_ERR_E (*read) (struct guest_info *core, addr_t hva, addr_t len);
95     enum TM_ERR_E (*write) (struct guest_info *core, addr_t hva, addr_t len);
96
97     log_rec  *head;
98 };
99 */
100 /*
101  * error = handle_start_tx(logger,vcorenum);
102  * error = handle_abort(logger,vcorenum);
103  * error = handle_commit(logger,vcorenum);
104  *
105  * should_abort = handle_write(logger, vcorenum, physaddr, data, datalen);
106  * should_abort = handle_read(logger, vcorenum, physaddr, *data, datalen);
107  *
108  */
109
110 /* FN SKEL
111  *
112  * handle_start_tx(logger,vcorenum) {
113  *  logger.record(BEGIN,vcorenum)
114  * }
115  *
116  * handle_abort(logger,vcorenum) {
117  *  logger.record(ABORT,vcorenum)
118  * }
119  *
120  * handle_commit(logger,vcorenum) {
121  *  logger.record(END,vcorenum)
122  *  logger.commit(vcorenum)
123  * }
124  *
125  * record(head,type,vcorenum,physaddr,datalen,data) {
126  *  new rec = {type, vcorenum, physaddr, datalen, data,head}
127  *  head = new rec
128  *  err = conflict_check(head,vcorenum)
129  * }
130  *
131  * read(logger,core,addr,*data,datalen) {
132  *  logger.record(READ,vcorenum)
133  *
134  *  // hmm, we want the most recent entry, should we keep track of tail as
135  *  // well?? or just keep a seperate log of current values?
136  *  cur = head
137  *  while cur {
138  *    if cur->addr == addr
139  *      data = cur->data
140  *      return
141  *    cur = cur->next
142  *  }
143  *
144  *  read_mem(data)
145  *  return
146  * }
147  *
148  * write(logger,core,addr,data,datalen) {
149  *  logger.record(WRITE,vcorenum,data)
150  * }
151  *
152  */
153
154 #endif // ! __V3VEE__
155
156 #endif