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) 2008, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
21 #include <palacios/vmm_msr.h>
22 #include <palacios/vmm.h>
23 #include <palacios/vm_guest.h>
26 void v3_init_msr_map(struct guest_info * info) {
27 struct v3_msr_map * msr_map = &(info->msr_map);
29 INIT_LIST_HEAD(&(msr_map->hook_list));
30 msr_map->num_hooks = 0;
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),
39 struct v3_msr_map * msr_map = &(info->msr_map);
40 struct v3_msr_hook * hook = NULL;
42 hook = (struct v3_msr_hook *)V3_Malloc(sizeof(struct v3_msr_hook));
44 PrintError("Could not allocate msr hook for MSR %d\n", msr);
51 hook->priv_data = priv_data;
55 list_add(&(hook->link), &(msr_map->hook_list));
61 int v3_unhook_msr(struct guest_info * info, uint_t msr) {
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;
71 list_for_each_entry(hook, &(msr_map->hook_list), link) {
72 if (hook->msr == msr) {
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;
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);