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.


105bfe6b1fcc1437c6a2b563718fa278452c07bf
[palacios.releases.git] / palacios / src / palacios / vmm_msr.c
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) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
11  * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Jack Lange <jarusl@cs.northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20
21 #include <palacios/vmm_msr.h>
22 #include <palacios/vmm.h>
23 #include <palacios/vm_guest.h>
24
25
26 void v3_init_msr_map(struct guest_info * info) {
27     struct v3_msr_map * msr_map  = &(info->msr_map);
28
29     INIT_LIST_HEAD(&(msr_map->hook_list));
30     msr_map->num_hooks = 0;
31 }
32
33
34 int v3_hook_msr(struct guest_info * info, uint_t msr, 
35                 int (*read)(uint_t msr, struct v3_msr * dst, void * priv_data),
36                 int (*write)(uint_t msr, struct v3_msr src, void * priv_data),
37                 void * priv_data) {
38
39     struct v3_msr_map * msr_map = &(info->msr_map);
40     struct v3_msr_hook * hook = NULL;
41
42     hook = (struct v3_msr_hook *)V3_Malloc(sizeof(struct v3_msr_hook));
43     if (hook == NULL) {
44         PrintError("Could not allocate msr hook for MSR %d\n", msr);
45         return -1;
46     }
47
48     hook->read = read;
49     hook->write = write;
50     hook->msr = msr;
51     hook->priv_data = priv_data;
52
53     msr_map->num_hooks++;
54
55     list_add(&(hook->link), &(msr_map->hook_list));
56
57     return 0;
58 }
59
60
61 int v3_unhook_msr(struct guest_info * info, uint_t msr) {
62     return -1;
63 }
64
65
66
67 struct v3_msr_hook * v3_get_msr_hook(struct guest_info * info, uint_t msr) {
68     struct v3_msr_map * msr_map = &(info->msr_map);
69     struct v3_msr_hook * hook = NULL;
70
71     list_for_each_entry(hook, &(msr_map->hook_list), link) {
72         if (hook->msr == msr) {
73             return hook;
74         }
75     }
76
77     return NULL;
78 }
79
80
81 void v3_print_msr_map(struct guest_info * info) {
82     struct v3_msr_map * msr_map = &(info->msr_map);
83     struct v3_msr_hook * hook = NULL;
84
85     list_for_each_entry(hook, &(msr_map->hook_list), link) {
86         PrintDebug("MSR HOOK (MSR=%d) (read=0x%p) (write=0x%p)\n",
87                    hook->msr, hook->read, hook->write);
88     }
89 }