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.


b367cd38ecf868d9a69b9881987da4e626ed8f2b
[palacios.git] / palacios / include / palacios / vmx_assist.h
1 /*
2  * vmx_assist.h: Context definitions for the VMXASSIST world switch.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to
6  * deal in the Software without restriction, including without limitation the
7  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8  * sell copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  *
22  * Leendert van Doorn, leendert@watson.ibm.com
23  * Copyright (c) 2005, International Business Machines Corporation.
24  */
25
26 #ifndef _VMX_ASSIST_H_
27 #define _VMX_ASSIST_H_
28
29 #ifdef __V3VEE__
30
31 #include <palacios/vm_guest.h>
32
33 #define VMXASSIST_BASE         0xD0000
34 #define VMXASSIST_MAGIC        0x17101966
35
36
37 struct vmx_assist_header {
38     uint64_t rsvd; // 8 bytes of nothing
39     uint32_t magic;
40     uint32_t new_ctx_gpa;
41     uint32_t old_ctx_gpa;
42 } __attribute__((packed));
43
44
45 union vmcs_arbytes {
46     struct arbyte_fields {
47         unsigned int seg_type : 4,
48             s         : 1,
49             dpl       : 2,
50             p         : 1,
51             reserved0 : 4,
52             avl       : 1,
53             reserved1 : 1,
54             default_ops_size: 1,
55             g         : 1,
56             null_bit  : 1,
57             reserved2 : 15;
58     } fields;
59     unsigned int bytes;
60 };
61
62 /*
63  * World switch state
64  */
65 struct vmx_assist_context {
66     uint32_t  eip;        /* execution pointer */
67     uint32_t  esp;        /* stack pointer */
68     uint32_t  eflags;     /* flags register */
69     uint32_t  cr0;
70     uint32_t  cr3;        /* page table directory */
71     uint32_t  cr4;
72     uint32_t  idtr_limit; /* idt */
73     uint32_t  idtr_base;
74     uint32_t  gdtr_limit; /* gdt */
75     uint32_t  gdtr_base;
76     uint32_t  cs_sel;     /* cs selector */
77     uint32_t  cs_limit;
78     uint32_t  cs_base;
79     union vmcs_arbytes cs_arbytes;
80     uint32_t  ds_sel;     /* ds selector */
81     uint32_t  ds_limit;
82     uint32_t  ds_base;
83     union vmcs_arbytes ds_arbytes;
84     uint32_t  es_sel;     /* es selector */
85     uint32_t  es_limit;
86     uint32_t  es_base;
87     union vmcs_arbytes es_arbytes;
88     uint32_t  ss_sel;     /* ss selector */
89     uint32_t  ss_limit;
90     uint32_t  ss_base;
91     union vmcs_arbytes ss_arbytes;
92     uint32_t  fs_sel;     /* fs selector */
93     uint32_t  fs_limit;
94     uint32_t  fs_base;
95     union vmcs_arbytes fs_arbytes;
96     uint32_t  gs_sel;     /* gs selector */
97     uint32_t  gs_limit;
98     uint32_t  gs_base;
99     union vmcs_arbytes gs_arbytes;
100     uint32_t  tr_sel;     /* task selector */
101     uint32_t  tr_limit;
102     uint32_t  tr_base;
103     union vmcs_arbytes tr_arbytes;
104     uint32_t  ldtr_sel;   /* ldtr selector */
105     uint32_t  ldtr_limit;
106     uint32_t  ldtr_base;
107     union vmcs_arbytes ldtr_arbytes;
108
109     unsigned char rm_irqbase[2];
110 };
111
112 typedef struct vmx_assist_context vmx_assist_context_t;
113
114 int v3_vmxassist_ctx_switch(struct guest_info * info);
115
116
117 #endif
118
119 #endif /* _VMX_ASSIST_H_ */
120
121 /*
122  * Local variables:
123  * mode: C
124  * c-set-style: "BSD"
125  * c-basic-offset: 4
126  * tab-width: 4
127  * indent-tabs-mode: nil
128  * End:
129  */