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) 2011, Kyle C. Hale <kh@u.northwestern.edu>
11 * Copyright (c) 2011, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Kyle C. Hale <kh@u.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
20 #ifndef __SYSCALL_HIJACK_H__
21 #define __SYSCALL_HIJACK_H__
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);
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
40 #define IA32_SYSENTER_CS_MSR 0x00000174
41 #define IA32_SYSENTER_ESP_MSR 0x00000175
42 #define IA32_SYSENTER_EIP_MSR 0x00000176
46 #define max(a, b) ( ((a) > (b)) ? (a) : (b) )
49 #define SYSCALL_INT_VECTOR 0x80
50 #define SYSCALL_CPUID_NUM 0x80000001
51 #define SYSENTER_CPUID_NUM 0x00000001
53 #define SYSCALL_MAGIC_ADDR 0xffffffffffffffff
55 #define KERNEL_PHYS_LOAD_ADDR 0x1000000
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
62 struct v3_syscall_info {
64 uint8_t syscall_map_injected;
65 char * syscall_page_backup;
66 uint8_t * syscall_map;
72 int v3_hook_syscall (struct guest_info * core,
74 int (*handler)(struct guest_info * core, uint_t syscall_nr, void * priv_data),
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);