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.


HVM synchronous operation facility
[palacios.git] / palacios / include / palacios / vmm_hvm.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) 2015, The V3VEE Project <http://www.v3vee.org> 
11  * All rights reserved.
12  *
13  * Author: Peter Dinda <pdinda@northwestern.edu>
14  *
15  * This is free software.  You are permitted to use,
16  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
17  */
18
19
20 #ifndef __VMM_HVM_H
21 #define __VMM_HVM_H
22
23
24 #ifdef __V3VEE__ 
25
26 #include <palacios/vmm_types.h>
27 #include <palacios/vmm_multiboot.h>
28
29 struct v3_vm_hvm {
30     uint8_t   is_hvm;
31     uint32_t  first_hrt_core;
32     uint64_t  first_hrt_gpa;
33     struct v3_cfg_file *hrt_file;
34     uint64_t  hrt_entry_addr;
35     enum { HRT_BLOB, HRT_ELF64, HRT_MBOOT2, HRT_MBOOT64 } hrt_type;
36
37     // The following parallel the content of mb_info_hrt_t in
38     // the extended multiboot header.   They reflect how the 
39     // HRT has actually been mapped, as opposed to the requested
40     // mapping/flags from the mb_mb64_hrt_t
41     uint64_t  hrt_flags; 
42     uint64_t  max_mem_mapped;
43     uint64_t  gva_offset;
44     uint64_t  gva_entry;
45     uint64_t  comm_page_gpa;
46     uint8_t   hrt_int_vector;
47
48     void     *comm_page_hpa;
49     void     *comm_page_hva;
50
51     enum {HRT_IDLE=0, HRT_CALL=1, HRT_PARCALL=2, HRT_SYNCSETUP=3, HRT_SYNC=4, HRT_SYNCTEARDOWN=5, HRT_MERGE=6} trans_state;
52     uint64_t  trans_count;
53 };
54
55 struct v3_core_hvm {
56     uint8_t   is_hrt;
57     uint64_t  last_boot_start;
58 };
59
60
61
62 struct v3_xml;
63
64 int v3_init_hvm();
65 int v3_deinit_hvm();
66
67 int v3_init_hvm_vm(struct v3_vm_info *vm, struct v3_xml *config);
68 int v3_deinit_hvm_vm(struct v3_vm_info *vm);
69
70
71 int v3_init_hvm_core(struct guest_info *core);
72 int v3_deinit_hvm_core(struct guest_info *core);
73
74
75 uint64_t v3_get_hvm_ros_memsize(struct v3_vm_info *vm);
76 uint64_t v3_get_hvm_hrt_memsize(struct v3_vm_info *vm);
77 int      v3_is_hvm_ros_mem_gpa(struct v3_vm_info *vm, addr_t gpa);
78 int      v3_is_hvm_hrt_mem_gpa(struct v3_vm_info *vm, addr_t gpa);
79
80 uint32_t v3_get_hvm_ros_cores(struct v3_vm_info *vm);
81 uint32_t v3_get_hvm_hrt_cores(struct v3_vm_info *vm);
82 int      v3_is_hvm_ros_core(struct guest_info *core);
83 int      v3_is_hvm_hrt_core(struct guest_info *core);
84
85
86 int      v3_hvm_should_deliver_ipi(struct guest_info *src, struct guest_info *dest);
87 void     v3_hvm_find_apics_seen_by_core(struct guest_info *core, struct v3_vm_info *vm, 
88                                         uint32_t *start_apic, uint32_t *num_apics);
89
90
91 int v3_build_hrt_multiboot_tag(struct guest_info *core, mb_info_hrt_t *hrt);
92
93 int v3_setup_hvm_vm_for_boot(struct v3_vm_info *vm);
94 int v3_setup_hvm_hrt_core_for_boot(struct guest_info *core);
95
96 int v3_handle_hvm_reset(struct guest_info *core);
97
98 /*
99   HVM/HRT interaction is as follows:
100
101   1. MB_TAG_MB64_HRT tag in the HRT multiboot kernel signifies it
102      is handled by the HVM.
103   2. The flags and other info in the the tag indicate the properties of the HRT
104      to the HVM.  (see vmm_multiboot.h), in particular:
105          - position independence
106          - ability to be initially mapped with an offset
107            between virtual and physical addresses, for example  
108            to hoist it into the same position that the ROS kernel
109            will occupy in the virtual address space of a ROS
110            process
111          - how much physical address space we will intiially map
112            and what kind of page tables are used to map it
113          - what physical page (4KB) should we reserve for use
114            in HVM/HRT communication (particularly upcalls)
115          - the interrupt vector used to upcall from the HVM to the HRT
116   3. The MB_INFO_HRT_TAG within the multiboot info structures the
117      HRT sees on boot indicates that HRT functionality is established and
118      gives details of operation to the HRT, including the following.
119      See vmm_multiboot.c for more info
120          - apics and ioapic ids, and indications of which apics
121            and which entries on ioapics are exclusively for HRT use
122          - physical address range that is exclusively for HRT use
123          - where the the physical address range exclusively for HRT use 
124            is mapped into the virtual address space (offset).  The
125            ROS part of the physical address space is always identity mapped 
126            initially.
127          - the amount of physical memory that has been mapped
128          - the physical address of the page the HVM will use to 
129            communicate with the HRT
130          - the interrupt vector the HVM will use to upcall the HRT
131          - flags copied from the HRT's HRT tag (position independence, 
132            page table model, offset, etc)
133   4. Downcalls:
134          hypercall 0xf00df00d with arguments depending on operation
135          with examples described below.
136   5. Upcalls
137          interrupt injected by VMM or a magic #PF
138          communication via a shared memory page, contents below
139
140   Upcalls
141
142    Type of upcall is determined by the first 64 bits in the commm page
143
144    0x0  =>  Null (test)
145    0x20 =>  Invoke function in HRT 
146             Next 64 bits contains address of structure
147             describing function call.   This is typically the ROS
148             trying to get the HRT to run a function for it. 
149             ROS is resposible for assuring that this address
150             (and other addresses) are correct with respect to
151             mappings.   That is, for a non-merged address space,
152             the ROS needs to supply physical addresses so that
153             they can be used (with the identity-mapped ROS physical
154             memory.)  If it wants to use virtual addresses, it
155             needs to first merge the address spaces. 
156    0x21 =>  Invoke function in HRT in parallel
157             Exactly like previos, but the upcall is happening 
158             simultaneously on all HRT cores. 
159    0x30 =>  Merge address space
160             Next 64 bits contains the ROS CR3 that we will use
161             to map the user portion of ROS address space into
162             the HRT address space
163    0x31 =>  Unmerge address space
164             return the ROS memory mapping to normal (physical/virtual identity)
165
166   Downcalls
167
168    HVM_HCALL is the general hypercall number used to talk to the HVM
169      The first argument is the request number (below).   The other arguments
170      depend on the first.
171
172    0x0  =>  Null, just for timing
173    0x1  =>  Reboot ROS
174    0x2  =>  Reboot HRT
175    0x3  =>  Reboot Both
176    0xf  =>  Get HRT transaction state
177
178    0x20 =>  Invoke function (ROS->HRT)
179             first argument is pointer to structure describing call
180    0x21 =>  Invoke function in parallel (ROS->HRT)
181             same as above, but simultaneously on all HRT cores
182    0x2f =>  Function execution complete (HRT->ROS, once per core)
183    0x30 =>  Merge address space (ROS->HRT)
184             no arguments (CR3 implicit).   Merge the current
185             address space in the ROS with the address space on 
186             the HRT
187    0x31 =>  Unmerge address apce (ROS->HRT)
188             release any address space merger and restore identity mapping
189    0x3f =>  Merge request complete (HRT->ROS)
190
191 */     
192      
193
194
195 #endif /* ! __V3VEE__ */
196
197
198 #endif