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.


bug fix to check for illegal memory ranges
[palacios.git] / palacios / src / palacios / vmm_excp.c
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) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
11  * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Jack Lange <jarusl@cs.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 #include <palacios/vmm_excp.h>
21 #include <palacios/vmm.h>
22 #include <palacios/vmm_types.h>
23 #include <palacios/vm_guest.h>
24
25 void v3_init_exception_state(struct guest_info * info) {
26     info->excp_state.excp_pending = 0;
27     info->excp_state.excp_num = 0;
28     info->excp_state.excp_error_code = 0;
29
30 }
31
32
33
34 int v3_raise_exception_with_error(struct guest_info * info, uint_t excp, uint_t error_code) {
35     struct v3_excp_state * excp_state = &(info->excp_state);
36
37     if (excp_state->excp_pending == 0) {
38         excp_state->excp_pending = 1;
39         excp_state->excp_num = excp;
40         excp_state->excp_error_code = error_code;
41         excp_state->excp_error_code_valid = 1;
42         //      PrintDebug("[v3_raise_exception_with_error] error code: %x\n", error_code);
43     } else {
44         PrintError("Error injecting exception_w_error (excp=%d) (error=%d) -- Exception (%d) (error=%d) already pending\n",
45                    excp, error_code, excp_state->excp_num, excp_state->excp_error_code);
46         return -1;
47     }
48
49     return 0;
50 }
51
52 int v3_raise_exception(struct guest_info * info, uint_t excp) {
53     struct v3_excp_state * excp_state = &(info->excp_state);
54     //PrintDebug("[v3_raise_exception]\n");
55     if (excp_state->excp_pending == 0) {
56         excp_state->excp_pending = 1;
57         excp_state->excp_num = excp;
58         excp_state->excp_error_code = 0;
59         excp_state->excp_error_code_valid = 0;
60     } else {
61         PrintError("Error injecting exception (excp=%d) -- Exception (%d) (error=%d) already pending\n",
62                    excp, excp_state->excp_num, excp_state->excp_error_code);
63         return -1;
64     }
65
66     return 0;
67 }
68
69
70 int v3_excp_pending(struct guest_info * info) {
71     struct v3_excp_state * excp_state = &(info->excp_state);
72     
73     if (excp_state->excp_pending == 1) {
74         return 1;
75     }
76
77     return 0;
78 }
79
80
81 int v3_get_excp_number(struct guest_info * info) {
82     struct v3_excp_state * excp_state = &(info->excp_state);
83
84     if (excp_state->excp_pending == 1) {
85         return excp_state->excp_num;
86     }
87
88     return 0;
89 }
90
91
92 int v3_injecting_excp(struct guest_info * info, uint_t excp) {
93     struct v3_excp_state * excp_state = &(info->excp_state);
94     
95     excp_state->excp_pending = 0;
96     excp_state->excp_num = 0;
97     excp_state->excp_error_code = 0;
98     excp_state->excp_error_code_valid = 0;
99     
100     return 0;
101 }