]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/amd64/include/vmm_dev.h
IFC to head to catch up the bhyve branch
[FreeBSD/FreeBSD.git] / sys / amd64 / include / vmm_dev.h
1 /*-
2  * Copyright (c) 2011 NetApp, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD: vmm_dev.h 482 2011-05-09 21:22:43Z grehan $
27  */
28
29 #ifndef _VMM_DEV_H_
30 #define _VMM_DEV_H_
31
32 #ifdef _KERNEL
33 void    vmmdev_init(void);
34 void    vmmdev_cleanup(void);
35 #endif
36
37 struct vm_memory_segment {
38         vm_paddr_t      hpa;    /* out */
39         vm_paddr_t      gpa;    /* in */
40         size_t          len;    /* in */
41 };
42
43 struct vm_register {
44         int             cpuid;
45         int             regnum;         /* enum vm_reg_name */
46         uint64_t        regval;
47 };
48
49 struct vm_seg_desc {                    /* data or code segment */
50         int             cpuid;
51         int             regnum;         /* enum vm_reg_name */
52         struct seg_desc desc;
53 };
54
55 struct vm_pin {
56         int             vm_cpuid;
57         int             host_cpuid;     /* -1 to unpin */
58 };
59
60 struct vm_run {
61         int             cpuid;
62         uint64_t        rip;            /* start running here */
63         struct vm_exit  vm_exit;
64 };
65
66 struct vm_event {
67         int             cpuid;
68         enum vm_event_type type;
69         int             vector;
70         uint32_t        error_code;
71         int             error_code_valid;
72 };
73
74 struct vm_lapic_irq {
75         int             cpuid;
76         int             vector;
77 };
78
79 struct vm_capability {
80         int             cpuid;
81         enum vm_cap_type captype;
82         int             capval;
83         int             allcpus;
84 };
85
86 struct vm_pptdev {
87         int             bus;
88         int             slot;
89         int             func;
90 };
91
92 struct vm_pptdev_mmio {
93         int             bus;
94         int             slot;
95         int             func;
96         vm_paddr_t      gpa;
97         vm_paddr_t      hpa;
98         size_t          len;
99 };
100
101 struct vm_pptdev_msi {
102         int             vcpu;
103         int             bus;
104         int             slot;
105         int             func;
106         int             numvec;         /* 0 means disabled */
107         int             vector;
108         int             destcpu;
109 };
110
111 struct vm_nmi {
112         int             cpuid;
113 };
114
115 #define MAX_VM_STATS    64
116 struct vm_stats {
117         int             cpuid;                          /* in */
118         int             num_entries;                    /* out */
119         struct timeval  tv;
120         uint64_t        statbuf[MAX_VM_STATS];
121 };
122
123 struct vm_stat_desc {
124         int             index;                          /* in */
125         char            desc[128];                      /* out */
126 };
127
128 enum {
129         IOCNUM_RUN,
130         IOCNUM_SET_PINNING,
131         IOCNUM_GET_PINNING,
132         IOCNUM_MAP_MEMORY,
133         IOCNUM_GET_MEMORY_SEG,
134         IOCNUM_SET_REGISTER,
135         IOCNUM_GET_REGISTER,
136         IOCNUM_SET_SEGMENT_DESCRIPTOR,
137         IOCNUM_GET_SEGMENT_DESCRIPTOR,
138         IOCNUM_INJECT_EVENT,
139         IOCNUM_LAPIC_IRQ,
140         IOCNUM_SET_CAPABILITY,
141         IOCNUM_GET_CAPABILITY,
142         IOCNUM_BIND_PPTDEV,
143         IOCNUM_UNBIND_PPTDEV,
144         IOCNUM_MAP_PPTDEV_MMIO,
145         IOCNUM_PPTDEV_MSI,
146         IOCNUM_INJECT_NMI,
147         IOCNUM_VM_STATS,
148         IOCNUM_VM_STAT_DESC,
149 };
150
151 #define VM_RUN          \
152         _IOWR('v', IOCNUM_RUN, struct vm_run)
153 #define VM_SET_PINNING  \
154         _IOW('v', IOCNUM_SET_PINNING, struct vm_pin)
155 #define VM_GET_PINNING  \
156         _IOWR('v', IOCNUM_GET_PINNING, struct vm_pin)
157 #define VM_MAP_MEMORY   \
158         _IOWR('v', IOCNUM_MAP_MEMORY, struct vm_memory_segment)
159 #define VM_GET_MEMORY_SEG \
160         _IOWR('v', IOCNUM_GET_MEMORY_SEG, struct vm_memory_segment)
161 #define VM_SET_REGISTER \
162         _IOW('v', IOCNUM_SET_REGISTER, struct vm_register)
163 #define VM_GET_REGISTER \
164         _IOWR('v', IOCNUM_GET_REGISTER, struct vm_register)
165 #define VM_SET_SEGMENT_DESCRIPTOR \
166         _IOW('v', IOCNUM_SET_SEGMENT_DESCRIPTOR, struct vm_seg_desc)
167 #define VM_GET_SEGMENT_DESCRIPTOR \
168         _IOWR('v', IOCNUM_GET_SEGMENT_DESCRIPTOR, struct vm_seg_desc)
169 #define VM_INJECT_EVENT \
170         _IOW('v', IOCNUM_INJECT_EVENT, struct vm_event)
171 #define VM_LAPIC_IRQ            \
172         _IOW('v', IOCNUM_LAPIC_IRQ, struct vm_lapic_irq)
173 #define VM_SET_CAPABILITY \
174         _IOW('v', IOCNUM_SET_CAPABILITY, struct vm_capability)
175 #define VM_GET_CAPABILITY \
176         _IOWR('v', IOCNUM_GET_CAPABILITY, struct vm_capability)
177 #define VM_BIND_PPTDEV \
178         _IOW('v', IOCNUM_BIND_PPTDEV, struct vm_pptdev)
179 #define VM_UNBIND_PPTDEV \
180         _IOW('v', IOCNUM_UNBIND_PPTDEV, struct vm_pptdev)
181 #define VM_MAP_PPTDEV_MMIO \
182         _IOW('v', IOCNUM_MAP_PPTDEV_MMIO, struct vm_pptdev_mmio)
183 #define VM_PPTDEV_MSI \
184         _IOW('v', IOCNUM_PPTDEV_MSI, struct vm_pptdev_msi)
185 #define VM_INJECT_NMI \
186         _IOW('v', IOCNUM_INJECT_NMI, struct vm_nmi)
187 #define VM_STATS \
188         _IOWR('v', IOCNUM_VM_STATS, struct vm_stats)
189 #define VM_STAT_DESC \
190         _IOWR('v', IOCNUM_VM_STAT_DESC, struct vm_stat_desc)
191 #endif