Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
target_xen_vm.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2014 The University of Utah
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef __TARGET_XEN_VM_H__
20 #define __TARGET_XEN_VM_H__
21 
22 #include "config.h"
23 
24 #include <xenctrl.h>
25 #include <xen/xen.h>
26 #ifdef __x86_64__
27 #include <xen/hvm/save.h>
28 #endif
29 
30 #include "target_arch_x86.h"
31 #include "evloop.h"
32 
33 extern struct target_ops xen_vm_ops;
34 
35 typedef enum {
38 
39 /*
40  * target-specific state for xen vms.
41  */
42 
43 /*
44  * Platform-specific registers for Xen VMs.
45  */
46 #define XV_TSREG_START_INDEX 126
47 #define XV_TSREG_COUNT 14
48 #define XV_TSREG_END_INDEX (XV_TSREG_START_INDEX - XV_TSREG_COUNT + 1)
49 typedef enum {
56 
66 
67 struct xen_vm_spec {
68  char *domain;
70  char *config_file;
71  char *replay_dir;
73 
74  /* Max memcache limit, in bytes. Backends must honor this! */
75  unsigned long int memcache_mmap_size;
76 
77  unsigned int no_hw_debug_reg_clear:1,
80  use_libvmi:1,
81  use_xenaccess:1,
84 };
85 
87  /*
88  * This is invalidated after each exception and resolved again.
89  */
91 
92  /*
93  * Either this came directly from the CPU for the currently-running
94  * thread; or we populated it based on the last saved CPU state for
95  * the thread.
96  *
97  * Now, this gets tricky: if CONFIG_PREEMPT is supported, the
98  * context will be the kernel thread's context -- not the user
99  * context -- if the thread is in the kernel when it was preempted!
100  *
101  * Otherwise, it will be the state of the user thread (because
102  * ifndef CONFIG_PREEMPT, kernel threads only stop on the
103  * user-kernel boundary).
104  */
105  vcpu_guest_context_t context;
106 
107  //vcpu_guest_context_t alt_context;
108 
109  /* XXX: can we debug a 32-bit target on a 64-bit host? If yes, how
110  * we use this might have to change.
111  */
112  unsigned long dr[8];
113 };
114 
115 struct xen_vm_state {
116  domid_t id;
117  char *name;
118 
119  unsigned int hvm:1,
121 
122  char *vmpath;
123  char *ostype;
125 
126  /* If we have an OS personality, try to load this from it. */
128 
130 
131  shared_info_t *live_shinfo;
132  xc_dominfo_t dominfo;
133  vcpu_info_t vcpuinfo; /* Also part of loading dominfo. */
135 
136  /* The most recent set of paging flags. */
138 
139  /* Which memops are we using? */
141  void *memops_priv;
142 
143 #ifdef __x86_64__
144  uint8_t *hvm_context_buf;
145  uint32_t hvm_context_bufsiz;
146  HVM_SAVE_TYPE(CPU) *hvm_cpu;
147 #endif
148 
150 
153 };
154 
155 struct target *xen_vm_instantiate(struct target_spec *spec,
156  struct evloop *evloop);
157 struct xen_vm_spec *xen_vm_build_spec(void);
158 void xen_vm_free_spec(struct xen_vm_spec *xspec);
159 int xen_vm_spec_to_argv(struct target_spec *spec,int *argc,char ***argv);
160 
161 unsigned char *xen_vm_read_pid(struct target *target,int pid,ADDR addr,
162  unsigned long target_length,unsigned char *buf);
163 unsigned long xen_vm_write_pid(struct target *target,int pid,ADDR addr,
164  unsigned long length,unsigned char *buf);
165 
166 /*
167  * We support several different memory backends for Xen VMs.
168  */
170  int (*init)(struct target *target);
171  int (*attach)(struct target *target);
174  int (*handle_pause)(struct target *target);
175  int (*addr_v2p)(struct target *target,tid_t tid,ADDR pgd,
176  ADDR vaddr,ADDR *paddr);
177  unsigned char *(*read_phys)(struct target *target,ADDR paddr,
178  unsigned long length,unsigned char *buf);
179  unsigned long (*write_phys)(struct target *target,ADDR paddr,
180  unsigned long length,unsigned char *buf);
181  unsigned char *(*read_tid)(struct target *target,tid_t tid,ADDR pgd,ADDR addr,
182  unsigned long target_length,unsigned char *buf);
183  unsigned long (*write_tid)(struct target *target,tid_t tid,ADDR pgd,ADDR addr,
184  unsigned long length,unsigned char *buf);
185  int (*fini)(struct target *target);
186 };
187 
188 #endif /* __TARGET_XEN_VM_H__ */
char * domain
Definition: target_xen_vm.h:68
ADDR kernel_start_addr
shared_info_t * live_shinfo
unsigned int use_xenaccess
Definition: target_xen_vm.h:77
int32_t tid_t
Definition: common.h:36
int(* handle_exception_any)(struct target *target)
char * kernel_filename
Definition: target_xen_vm.h:69
char * replay_dir
Definition: target_xen_vm.h:71
int(* init)(struct target *target)
char * kernel_filename
unsigned char * xen_vm_read_pid(struct target *target, int pid, ADDR addr, unsigned long target_length, unsigned char *buf)
int(* fini)(struct target *target)
unsigned int hvm
arch_x86_v2p_flags_t
Definition: evloop.h:66
unsigned int use_libvmi
Definition: target_xen_vm.h:77
unsigned int clear_mem_caches_each_exception
Definition: target_xen_vm.h:77
xen_vm_feature_t
Definition: target_xen_vm.h:35
unsigned int no_hvm_setcontext
Definition: target_xen_vm.h:77
xen_vm_tsreg_t
Definition: target_xen_vm.h:49
unsigned int no_hw_debug_reg_clear
Definition: target_xen_vm.h:77
void * memops_priv
unsigned int no_use_multiplexer
Definition: target_xen_vm.h:77
int xen_vm_vmp_client_fd
unsigned int hvm_monitor_trap_flag_set
int(* handle_exception_ours)(struct target *target)
char * config_file
Definition: target_xen_vm.h:70
unsigned long dr[8]
int(* addr_v2p)(struct target *target, tid_t tid, ADDR pgd, ADDR vaddr, ADDR *paddr)
#define XV_TSREG_START_INDEX
Definition: target_xen_vm.h:46
struct xen_vm_spec * xen_vm_build_spec(void)
struct xen_vm_mem_ops * memops
unsigned int hypervisor_ignores_userspace_exceptions
Definition: target_xen_vm.h:77
vcpu_guest_context_t context
unsigned long xen_vm_write_pid(struct target *target, int pid, ADDR addr, unsigned long length, unsigned char *buf)
char * xen_vm_vmp_client_path
int dominfo_timeout
Definition: target_xen_vm.h:72
int(* attach)(struct target *target)
int(* handle_pause)(struct target *target)
unsigned long int memcache_mmap_size
Definition: target_xen_vm.h:75
uint32_t ADDR
Definition: common.h:64
arch_x86_v2p_flags_t v2p_flags
unsigned long(* write_tid)(struct target *target, tid_t tid, ADDR pgd, ADDR addr, unsigned long length, unsigned char *buf)
struct target_spec * spec
Definition: target_api.h:2605
int xen_vm_spec_to_argv(struct target_spec *spec, int *argc, char ***argv)
unsigned long(* write_phys)(struct target *target, ADDR paddr, unsigned long length, unsigned char *buf)
vcpu_info_t vcpuinfo
xc_dominfo_t dominfo
void xen_vm_free_spec(struct xen_vm_spec *xspec)
struct target * xen_vm_instantiate(struct target_spec *spec, struct evloop *evloop)
struct target_ops xen_vm_ops