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.


Have unregistered hypercalls fail to guest
[palacios.git] / palacios / include / gears / code_inject.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) 2011, Kyle C. Hale <kh@u.northwestern.edu> 
11  * Copyright (c) 2011, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Kyle C. Hale <kh@u.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 #ifndef __CODE_INJECT_H__
21 #define __CODE_INJECT_H__
22
23 int v3_insert_code_inject (void *ginfo, void *code, int size, char *bin_file, 
24                            int is_dyn, int is_exec_hooked, int func_offset);
25
26 #ifdef __V3VEE__
27
28 #define E_NEED_PF -2
29
30 #define MMAP_SIZE 86
31 #define MUNMAP_SIZE 22
32 #define VMMCALL_SIZE 10
33
34 #define PAGES_BACK 50
35 #define ELF_MAG_SIZE 4
36 #define NO_MMAP 0
37 #define MMAP_COMPLETE 1
38
39 struct v3_code_injects {
40     struct list_head code_inject_list;
41     struct list_head hooked_code_injects;
42     int active;
43 };
44
45
46 // TODO: adjust size of boolean members
47 struct v3_code_inject_info {
48
49     // pointer to ELF and its size
50     void *code;
51     int code_size;
52
53
54     // indicates this is a hooked inject
55     int is_exec_hooked;
56     char * bin_file;
57
58     // important offsets to ELF sections
59     // for the injected code
60     int func_offset;
61     int got_offset;
62     int plt_offset;
63
64
65     int is_dyn;
66     addr_t code_region_gva;
67     // continuation-style function for
68     // page fault handling
69     struct v3_cont *cont;
70
71
72     // the following are for saving context
73     char *old_code;
74     struct v3_gprs regs;
75     struct v3_ctrl_regs ctrl_regs;
76     uint64_t rip;
77
78     struct list_head inject_node;
79
80     int in_progress;
81 };
82
83 struct v3_cont {
84     addr_t check_addr;
85     int (*cont_func)(struct guest_info * core, struct v3_code_inject_info * inject,
86                      addr_t check);
87 };
88
89 int v3_remove_code_inject(struct v3_vm_info * vm, struct v3_code_inject_info * inject);
90 int v3_do_inject(struct guest_info * core, struct v3_code_inject_info * inject, int mmap_state);
91 int v3_do_static_inject(struct guest_info * core, struct v3_code_inject_info * inject, 
92                         int mmap_state, addr_t region_gva);
93 int v3_handle_guest_inject(struct guest_info * core, void * priv_data);
94
95 #endif  /* ! __V3VEE__ */
96
97 #endif