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 / syscall_hijack.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 __SYSCALL_HIJACK_H__
21 #define __SYSCALL_HIJACK_H__
22
23 #ifdef V3_CONFIG_EXT_SELECTIVE_SYSCALL_EXIT
24 int v3_syscall_on (void * ginfo, uint8_t syscall_nr);
25 int v3_syscall_off (void * ginfo, uint8_t syscall_nr);
26 int v3_syscall_stat (void * ginfo, uint8_t syscall_nr);
27
28 #endif
29 #ifdef __V3VEE__
30
31 #define STAR_MSR                 0xc0000081 /* Legacy mode SYSCALL target */
32 #define LSTAR_MSR                0xc0000082 /* Long mode SYSCALL target */
33 #define CSTAR_MSR                0xc0000083 /* compat mode SYSCALL target */
34 #define SF_MASK_MSR              0xc0000084 /* EFLAGS mask for syscall */
35 #define SYSENTER_CS_MSR          0x00000174 /* SYSENTER/EXIT are for legacy mode only on AMD */
36 #define SYSENTER_ESP_MSR         0x00000175
37 #define SYSENTER_EIP_MSR         0x00000176
38
39 /* Intel specific */
40 #define IA32_SYSENTER_CS_MSR     0x00000174
41 #define IA32_SYSENTER_ESP_MSR    0x00000175
42 #define IA32_SYSENTER_EIP_MSR    0x00000176
43
44 #define MAX_CHARS 256
45 #ifndef max
46     #define max(a, b) ( ((a) > (b)) ? (a) : (b) )
47 #endif
48
49 #define SYSCALL_INT_VECTOR   0x80
50 #define SYSCALL_CPUID_NUM    0x80000001
51 #define SYSENTER_CPUID_NUM   0x00000001
52
53 #define SYSCALL_MAGIC_ADDR       0xffffffffffffffff
54
55 #define KERNEL_PHYS_LOAD_ADDR    0x1000000
56
57 // hcall numbers for fast system call exiting utility
58 #define SYSCALL_HANDLE_HCALL   0x5CA11
59 #define SYSCALL_SETUP_HCALL    0x5CA12
60 #define SYSCALL_CLEANUP_HCALL  0x5CA13
61
62 struct v3_syscall_info {
63     uint64_t target_addr;
64     uint8_t  syscall_map_injected;
65     char * syscall_page_backup;
66     uint8_t * syscall_map;
67     addr_t syscall_stub;
68     // state save area
69     addr_t ssa;
70 };
71
72 int v3_hook_syscall (struct guest_info * core,
73     uint_t syscall_nr,
74     int (*handler)(struct guest_info * core, uint_t syscall_nr, void * priv_data), 
75     void * priv_data);
76
77 int v3_hook_passthrough_syscall (struct guest_info * core, uint_t syscall_nr);
78 int v3_syscall_handler (struct guest_info * core, uint8_t vector, void * priv_data);
79
80 #endif
81
82 #endif