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.


Avoid strict-aliasing related issues when compiling with optimization
[palacios.git] / linux_module / iface-syscall.c
1 /*
2  * Linux interface for control of the fast system call
3  * exiting utility
4  *
5  * (c) Kyle C. Hale 2012
6  *
7  */
8
9 #include <linux/uaccess.h>
10 #include <linux/module.h>
11
12 #include <gears/syscall_hijack.h>
13
14 #include "palacios.h"
15 #include "vm.h"
16 #include "linux-exts.h"
17
18 #include "iface-syscall.h"
19
20
21 static int vm_syscall_ctrl (struct v3_guest * guest, unsigned int cmd, unsigned long arg, void * priv_data) {
22     struct v3_syscall_cmd syscall_cmd;
23     int ret;
24
25     if (copy_from_user(&syscall_cmd, (void __user *)arg, sizeof(struct v3_syscall_cmd))) {
26         ERROR("palacios: error copying syscall command from userspace\n");
27         return -EFAULT;
28     }
29     
30     switch (syscall_cmd.cmd) {
31
32         case SYSCALL_OFF: {
33             ret = v3_syscall_off(guest->v3_ctx, syscall_cmd.syscall_nr);
34             if (ret < 0) {
35                 ERROR("palacios: error deactivating syscall exiting for syscall nr: %d\n", syscall_cmd.syscall_nr);
36             }
37             break;
38         }
39         case SYSCALL_ON: {
40             ret = v3_syscall_on(guest->v3_ctx, syscall_cmd.syscall_nr);
41             if (ret < 0) {
42                 ERROR("palacios: error activating syscall exiting for syscall nr: %d\n", syscall_cmd.syscall_nr);
43             }
44             break;
45         }
46         case SYSCALL_STAT: {
47             ret = v3_syscall_stat(guest->v3_ctx, syscall_cmd.syscall_nr);  
48             if (ret == SYSCALL_OFF)
49                 INFO("palacios: exiting for syscall #%d is OFF\n", syscall_cmd.syscall_nr);
50             else if (ret == SYSCALL_ON) 
51                 INFO("palacios: exiting for syscall #%d is ON\n", syscall_cmd.syscall_nr);
52             else 
53                 INFO("palacios: error stating syscall nr: %d\n", syscall_cmd.syscall_nr);
54             break;
55         }
56         default:
57             ERROR("palacios: error - invalid syscall command\n");
58             return -1;
59     }
60       
61     return ret;
62 }
63
64
65 static int init_syscall_ctrl (void) {
66     return 0;
67 }
68
69
70 static int deinit_syscall_ctrl (void) { 
71     return 0;
72 }
73
74
75 static int guest_init_syscall_ctrl (struct v3_guest * guest, void ** vm_data) {
76     add_guest_ctrl(guest, V3_VM_SYSCALL_CTRL, vm_syscall_ctrl, NULL);
77     return 0;
78 }
79
80
81 static int guest_deinit_syscall_ctrl (struct v3_guest * guest, void * vm_data) {
82     remove_guest_ctrl(guest, V3_VM_SYSCALL_CTRL);
83     return 0;
84 }
85
86
87 static struct linux_ext syscall_ctrl_ext = {
88     .name = "SYSCALL_CTRL",
89     .init = init_syscall_ctrl,
90     .deinit = deinit_syscall_ctrl,
91     .guest_init = guest_init_syscall_ctrl,
92     .guest_deinit = guest_deinit_syscall_ctrl
93 };
94
95 register_extension(&syscall_ctrl_ext);