xref: /freebsd/sys/amd64/vmm/amd/amdv.c (revision 7ce04d0ad9c662c473b9c57aa3dcf824cb3d0179)
1366f6083SPeter Grehan /*-
2366f6083SPeter Grehan  * Copyright (c) 2011 NetApp, Inc.
3366f6083SPeter Grehan  * All rights reserved.
4366f6083SPeter Grehan  *
5366f6083SPeter Grehan  * Redistribution and use in source and binary forms, with or without
6366f6083SPeter Grehan  * modification, are permitted provided that the following conditions
7366f6083SPeter Grehan  * are met:
8366f6083SPeter Grehan  * 1. Redistributions of source code must retain the above copyright
9366f6083SPeter Grehan  *    notice, this list of conditions and the following disclaimer.
10366f6083SPeter Grehan  * 2. Redistributions in binary form must reproduce the above copyright
11366f6083SPeter Grehan  *    notice, this list of conditions and the following disclaimer in the
12366f6083SPeter Grehan  *    documentation and/or other materials provided with the distribution.
13366f6083SPeter Grehan  *
14366f6083SPeter Grehan  * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
15366f6083SPeter Grehan  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16366f6083SPeter Grehan  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17366f6083SPeter Grehan  * ARE DISCLAIMED.  IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
18366f6083SPeter Grehan  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19366f6083SPeter Grehan  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20366f6083SPeter Grehan  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21366f6083SPeter Grehan  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22366f6083SPeter Grehan  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23366f6083SPeter Grehan  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24366f6083SPeter Grehan  * SUCH DAMAGE.
25366f6083SPeter Grehan  *
26366f6083SPeter Grehan  * $FreeBSD$
27366f6083SPeter Grehan  */
28366f6083SPeter Grehan 
29366f6083SPeter Grehan #include <sys/cdefs.h>
30366f6083SPeter Grehan __FBSDID("$FreeBSD$");
31366f6083SPeter Grehan 
32366f6083SPeter Grehan #include <sys/param.h>
33366f6083SPeter Grehan #include <sys/systm.h>
34366f6083SPeter Grehan #include <sys/errno.h>
35a5615c90SPeter Grehan #include <sys/smp.h>
36366f6083SPeter Grehan 
37366f6083SPeter Grehan #include <machine/vmm.h>
38366f6083SPeter Grehan #include "io/iommu.h"
39366f6083SPeter Grehan 
40366f6083SPeter Grehan static int
41366f6083SPeter Grehan amdv_init(void)
42366f6083SPeter Grehan {
43366f6083SPeter Grehan 
44366f6083SPeter Grehan 	printf("amdv_init: not implemented\n");
45366f6083SPeter Grehan 	return (ENXIO);
46366f6083SPeter Grehan }
47366f6083SPeter Grehan 
48366f6083SPeter Grehan static int
49366f6083SPeter Grehan amdv_cleanup(void)
50366f6083SPeter Grehan {
51366f6083SPeter Grehan 
52366f6083SPeter Grehan 	printf("amdv_cleanup: not implemented\n");
53366f6083SPeter Grehan 	return (ENXIO);
54366f6083SPeter Grehan }
55366f6083SPeter Grehan 
56366f6083SPeter Grehan static void *
57366f6083SPeter Grehan amdv_vminit(struct vm *vm)
58366f6083SPeter Grehan {
59366f6083SPeter Grehan 
60366f6083SPeter Grehan 	printf("amdv_vminit: not implemented\n");
61366f6083SPeter Grehan 	return (NULL);
62366f6083SPeter Grehan }
63366f6083SPeter Grehan 
64366f6083SPeter Grehan static int
6598ed632cSNeel Natu amdv_vmrun(void *arg, int vcpu, register_t rip)
66366f6083SPeter Grehan {
67366f6083SPeter Grehan 
68366f6083SPeter Grehan 	printf("amdv_vmrun: not implemented\n");
69366f6083SPeter Grehan 	return (ENXIO);
70366f6083SPeter Grehan }
71366f6083SPeter Grehan 
72366f6083SPeter Grehan static void
73366f6083SPeter Grehan amdv_vmcleanup(void *arg)
74366f6083SPeter Grehan {
75366f6083SPeter Grehan 
76366f6083SPeter Grehan 	printf("amdv_vmcleanup: not implemented\n");
77366f6083SPeter Grehan 	return;
78366f6083SPeter Grehan }
79366f6083SPeter Grehan 
80366f6083SPeter Grehan static int
81bda273f2SNeel Natu amdv_vmmmap_set(void *arg, vm_paddr_t gpa, vm_paddr_t hpa, size_t length,
82366f6083SPeter Grehan 	    vm_memattr_t attr, int prot, boolean_t spok)
83366f6083SPeter Grehan {
84366f6083SPeter Grehan 
85bda273f2SNeel Natu 	printf("amdv_vmmmap_set: not implemented\n");
86bda273f2SNeel Natu 	return (EINVAL);
87bda273f2SNeel Natu }
88bda273f2SNeel Natu 
89bda273f2SNeel Natu static vm_paddr_t
90bda273f2SNeel Natu amdv_vmmmap_get(void *arg, vm_paddr_t gpa)
91bda273f2SNeel Natu {
92bda273f2SNeel Natu 
93bda273f2SNeel Natu 	printf("amdv_vmmmap_get: not implemented\n");
94366f6083SPeter Grehan 	return (EINVAL);
95366f6083SPeter Grehan }
96366f6083SPeter Grehan 
97366f6083SPeter Grehan static int
98366f6083SPeter Grehan amdv_getreg(void *arg, int vcpu, int regnum, uint64_t *retval)
99366f6083SPeter Grehan {
100366f6083SPeter Grehan 
101366f6083SPeter Grehan 	printf("amdv_getreg: not implemented\n");
102366f6083SPeter Grehan 	return (EINVAL);
103366f6083SPeter Grehan }
104366f6083SPeter Grehan 
105366f6083SPeter Grehan static int
106366f6083SPeter Grehan amdv_setreg(void *arg, int vcpu, int regnum, uint64_t val)
107366f6083SPeter Grehan {
108366f6083SPeter Grehan 
109366f6083SPeter Grehan 	printf("amdv_setreg: not implemented\n");
110366f6083SPeter Grehan 	return (EINVAL);
111366f6083SPeter Grehan }
112366f6083SPeter Grehan 
113366f6083SPeter Grehan static int
114366f6083SPeter Grehan amdv_getdesc(void *vmi, int vcpu, int num, struct seg_desc *desc)
115366f6083SPeter Grehan {
116366f6083SPeter Grehan 
117366f6083SPeter Grehan 	printf("amdv_get_desc: not implemented\n");
118366f6083SPeter Grehan 	return (EINVAL);
119366f6083SPeter Grehan }
120366f6083SPeter Grehan 
121366f6083SPeter Grehan static int
122366f6083SPeter Grehan amdv_setdesc(void *vmi, int vcpu, int num, struct seg_desc *desc)
123366f6083SPeter Grehan {
124366f6083SPeter Grehan 
125366f6083SPeter Grehan 	printf("amdv_get_desc: not implemented\n");
126366f6083SPeter Grehan 	return (EINVAL);
127366f6083SPeter Grehan }
128366f6083SPeter Grehan 
129366f6083SPeter Grehan static int
130366f6083SPeter Grehan amdv_inject_event(void *vmi, int vcpu, int type, int vector,
131366f6083SPeter Grehan 		  uint32_t error_code, int error_code_valid)
132366f6083SPeter Grehan {
133366f6083SPeter Grehan 
134366f6083SPeter Grehan 	printf("amdv_inject_event: not implemented\n");
135366f6083SPeter Grehan 	return (EINVAL);
136366f6083SPeter Grehan }
137366f6083SPeter Grehan 
138366f6083SPeter Grehan static int
139366f6083SPeter Grehan amdv_nmi(void *arg, int vcpu)
140366f6083SPeter Grehan {
141366f6083SPeter Grehan 
142366f6083SPeter Grehan 	printf("amdv_nmi: not implemented\n");
143366f6083SPeter Grehan         return (EINVAL);
144366f6083SPeter Grehan }
145366f6083SPeter Grehan 
146366f6083SPeter Grehan static int
147366f6083SPeter Grehan amdv_getcap(void *arg, int vcpu, int type, int *retval)
148366f6083SPeter Grehan {
149366f6083SPeter Grehan 
150366f6083SPeter Grehan 	printf("amdv_getcap: not implemented\n");
151366f6083SPeter Grehan 	return (EINVAL);
152366f6083SPeter Grehan }
153366f6083SPeter Grehan 
154366f6083SPeter Grehan static int
155366f6083SPeter Grehan amdv_setcap(void *arg, int vcpu, int type, int val)
156366f6083SPeter Grehan {
157366f6083SPeter Grehan 
158366f6083SPeter Grehan 	printf("amdv_setcap: not implemented\n");
159366f6083SPeter Grehan 	return (EINVAL);
160366f6083SPeter Grehan }
161366f6083SPeter Grehan 
162366f6083SPeter Grehan struct vmm_ops vmm_ops_amd = {
163366f6083SPeter Grehan 	amdv_init,
164366f6083SPeter Grehan 	amdv_cleanup,
165366f6083SPeter Grehan 	amdv_vminit,
166366f6083SPeter Grehan 	amdv_vmrun,
167366f6083SPeter Grehan 	amdv_vmcleanup,
168bda273f2SNeel Natu 	amdv_vmmmap_set,
169bda273f2SNeel Natu 	amdv_vmmmap_get,
170366f6083SPeter Grehan 	amdv_getreg,
171366f6083SPeter Grehan 	amdv_setreg,
172366f6083SPeter Grehan 	amdv_getdesc,
173366f6083SPeter Grehan 	amdv_setdesc,
174366f6083SPeter Grehan 	amdv_inject_event,
175366f6083SPeter Grehan 	amdv_nmi,
176366f6083SPeter Grehan 	amdv_getcap,
177366f6083SPeter Grehan 	amdv_setcap
178366f6083SPeter Grehan };
179366f6083SPeter Grehan 
180366f6083SPeter Grehan static int
181366f6083SPeter Grehan amd_iommu_init(void)
182366f6083SPeter Grehan {
183366f6083SPeter Grehan 
184366f6083SPeter Grehan 	printf("amd_iommu_init: not implemented\n");
185366f6083SPeter Grehan 	return (ENXIO);
186366f6083SPeter Grehan }
187366f6083SPeter Grehan 
188366f6083SPeter Grehan static void
189366f6083SPeter Grehan amd_iommu_cleanup(void)
190366f6083SPeter Grehan {
191366f6083SPeter Grehan 
192366f6083SPeter Grehan 	printf("amd_iommu_cleanup: not implemented\n");
193366f6083SPeter Grehan }
194366f6083SPeter Grehan 
195366f6083SPeter Grehan static void
196366f6083SPeter Grehan amd_iommu_enable(void)
197366f6083SPeter Grehan {
198366f6083SPeter Grehan 
199366f6083SPeter Grehan 	printf("amd_iommu_enable: not implemented\n");
200366f6083SPeter Grehan }
201366f6083SPeter Grehan 
202366f6083SPeter Grehan static void
203366f6083SPeter Grehan amd_iommu_disable(void)
204366f6083SPeter Grehan {
205366f6083SPeter Grehan 
206366f6083SPeter Grehan 	printf("amd_iommu_disable: not implemented\n");
207366f6083SPeter Grehan }
208366f6083SPeter Grehan 
209366f6083SPeter Grehan static void *
210366f6083SPeter Grehan amd_iommu_create_domain(vm_paddr_t maxaddr)
211366f6083SPeter Grehan {
212366f6083SPeter Grehan 
213366f6083SPeter Grehan 	printf("amd_iommu_create_domain: not implemented\n");
214366f6083SPeter Grehan 	return (NULL);
215366f6083SPeter Grehan }
216366f6083SPeter Grehan 
217366f6083SPeter Grehan static void
218366f6083SPeter Grehan amd_iommu_destroy_domain(void *domain)
219366f6083SPeter Grehan {
220366f6083SPeter Grehan 
221366f6083SPeter Grehan 	printf("amd_iommu_destroy_domain: not implemented\n");
222366f6083SPeter Grehan }
223366f6083SPeter Grehan 
224366f6083SPeter Grehan static uint64_t
225366f6083SPeter Grehan amd_iommu_create_mapping(void *domain, vm_paddr_t gpa, vm_paddr_t hpa,
226366f6083SPeter Grehan 			 uint64_t len)
227366f6083SPeter Grehan {
228366f6083SPeter Grehan 
229366f6083SPeter Grehan 	printf("amd_iommu_create_mapping: not implemented\n");
230366f6083SPeter Grehan 	return (0);
231366f6083SPeter Grehan }
232366f6083SPeter Grehan 
233*7ce04d0aSNeel Natu static uint64_t
234*7ce04d0aSNeel Natu amd_iommu_remove_mapping(void *domain, vm_paddr_t gpa, uint64_t len)
235*7ce04d0aSNeel Natu {
236*7ce04d0aSNeel Natu 
237*7ce04d0aSNeel Natu 	printf("amd_iommu_remove_mapping: not implemented\n");
238*7ce04d0aSNeel Natu 	return (0);
239*7ce04d0aSNeel Natu }
240*7ce04d0aSNeel Natu 
241366f6083SPeter Grehan static void
242366f6083SPeter Grehan amd_iommu_add_device(void *domain, int bus, int slot, int func)
243366f6083SPeter Grehan {
244366f6083SPeter Grehan 
245366f6083SPeter Grehan 	printf("amd_iommu_add_device: not implemented\n");
246366f6083SPeter Grehan }
247366f6083SPeter Grehan 
248366f6083SPeter Grehan static void
249366f6083SPeter Grehan amd_iommu_remove_device(void *domain, int bus, int slot, int func)
250366f6083SPeter Grehan {
251366f6083SPeter Grehan 
252366f6083SPeter Grehan 	printf("amd_iommu_remove_device: not implemented\n");
253366f6083SPeter Grehan }
254366f6083SPeter Grehan 
255*7ce04d0aSNeel Natu static void
256*7ce04d0aSNeel Natu amd_iommu_invalidate_tlb(void *domain)
257*7ce04d0aSNeel Natu {
258*7ce04d0aSNeel Natu 
259*7ce04d0aSNeel Natu 	printf("amd_iommu_invalidate_tlb: not implemented\n");
260*7ce04d0aSNeel Natu }
261*7ce04d0aSNeel Natu 
262366f6083SPeter Grehan struct iommu_ops iommu_ops_amd = {
263366f6083SPeter Grehan 	amd_iommu_init,
264366f6083SPeter Grehan 	amd_iommu_cleanup,
265366f6083SPeter Grehan 	amd_iommu_enable,
266366f6083SPeter Grehan 	amd_iommu_disable,
267366f6083SPeter Grehan 	amd_iommu_create_domain,
268366f6083SPeter Grehan 	amd_iommu_destroy_domain,
269366f6083SPeter Grehan 	amd_iommu_create_mapping,
270*7ce04d0aSNeel Natu 	amd_iommu_remove_mapping,
271366f6083SPeter Grehan 	amd_iommu_add_device,
272366f6083SPeter Grehan 	amd_iommu_remove_device,
273*7ce04d0aSNeel Natu 	amd_iommu_invalidate_tlb,
274366f6083SPeter Grehan };
275