ia64/xen-unstable

view linux-2.6-xen-sparse/arch/ia64/xen/xcom_mini.c @ 14026:409e94d0a35b

[IA64] Update xencommize_mini_grant_table_op for GNTTABOP_query_size

Signed-off-by: Alex Williamson <alex.williamson@hp.com>
author awilliam@xenbuild2.aw
date Tue Feb 20 15:12:11 2007 -0700 (2007-02-20)
parents 52e6bf6dc744
children 8af1a8250c13
line source
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 *
16 * Tristan Gingold <tristan.gingold@bull.net>
17 */
18 #include <linux/types.h>
19 #include <linux/errno.h>
20 #include <linux/kernel.h>
21 #include <linux/module.h>
22 #include <xen/interface/xen.h>
23 #include <xen/interface/dom0_ops.h>
24 #include <xen/interface/memory.h>
25 #include <xen/interface/xencomm.h>
26 #include <xen/interface/version.h>
27 #include <xen/interface/event_channel.h>
28 #include <xen/interface/physdev.h>
29 #include <xen/interface/grant_table.h>
30 #include <xen/interface/hvm/params.h>
31 #include <xen/interface/xenoprof.h>
32 #ifdef CONFIG_VMX_GUEST
33 #include <asm/hypervisor.h>
34 #else
35 #include <asm/hypercall.h>
36 #endif
37 #include <asm/xen/xencomm.h>
38 #include <asm/perfmon.h>
40 int
41 xencomm_mini_hypercall_event_channel_op(int cmd, void *op)
42 {
43 struct xencomm_mini xc_area[2];
44 int nbr_area = 2;
45 struct xencomm_handle *desc;
46 int rc;
48 rc = xencomm_create_mini(xc_area, &nbr_area,
49 op, sizeof(evtchn_op_t), &desc);
50 if (rc)
51 return rc;
53 return xencomm_arch_hypercall_event_channel_op(cmd, desc);
54 }
55 EXPORT_SYMBOL(xencomm_mini_hypercall_event_channel_op);
57 static int
58 xencommize_mini_grant_table_op(struct xencomm_mini *xc_area, int *nbr_area,
59 unsigned int cmd, void *op, unsigned int count,
60 struct xencomm_handle **desc)
61 {
62 struct xencomm_handle *desc1;
63 unsigned int argsize;
64 int rc;
66 switch (cmd) {
67 case GNTTABOP_map_grant_ref:
68 argsize = sizeof(struct gnttab_map_grant_ref);
69 break;
70 case GNTTABOP_unmap_grant_ref:
71 argsize = sizeof(struct gnttab_unmap_grant_ref);
72 break;
73 case GNTTABOP_setup_table:
74 {
75 struct gnttab_setup_table *setup = op;
77 argsize = sizeof(*setup);
79 if (count != 1)
80 return -EINVAL;
81 rc = xencomm_create_mini
82 (xc_area, nbr_area,
83 xen_guest_handle(setup->frame_list),
84 setup->nr_frames
85 * sizeof(*xen_guest_handle(setup->frame_list)),
86 &desc1);
87 if (rc)
88 return rc;
89 set_xen_guest_handle(setup->frame_list, (void *)desc1);
90 break;
91 }
92 case GNTTABOP_dump_table:
93 argsize = sizeof(struct gnttab_dump_table);
94 break;
95 case GNTTABOP_transfer:
96 argsize = sizeof(struct gnttab_transfer);
97 break;
98 case GNTTABOP_copy:
99 argsize = sizeof(struct gnttab_copy);
100 break;
101 case GNTTABOP_query_size:
102 argsize = sizeof(struct gnttab_query_size);
103 break;
104 default:
105 printk("%s: unknown mini grant table op %d\n", __func__, cmd);
106 BUG();
107 }
109 rc = xencomm_create_mini(xc_area, nbr_area, op, count * argsize, desc);
110 if (rc)
111 return rc;
113 return 0;
114 }
116 int
117 xencomm_mini_hypercall_grant_table_op(unsigned int cmd, void *op,
118 unsigned int count)
119 {
120 int rc;
121 struct xencomm_handle *desc;
122 int nbr_area = 2;
123 struct xencomm_mini xc_area[2];
125 rc = xencommize_mini_grant_table_op(xc_area, &nbr_area,
126 cmd, op, count, &desc);
127 if (rc)
128 return rc;
130 return xencomm_arch_hypercall_grant_table_op(cmd, desc, count);
131 }
132 EXPORT_SYMBOL(xencomm_mini_hypercall_grant_table_op);
134 int
135 xencomm_mini_hypercall_multicall(void *call_list, int nr_calls)
136 {
137 int i;
138 multicall_entry_t *mce;
139 int nbr_area = 2 + nr_calls * 3;
140 struct xencomm_mini xc_area[nbr_area];
141 struct xencomm_handle *desc;
142 int rc;
144 for (i = 0; i < nr_calls; i++) {
145 mce = (multicall_entry_t *)call_list + i;
147 switch (mce->op) {
148 case __HYPERVISOR_update_va_mapping:
149 case __HYPERVISOR_mmu_update:
150 /* No-op on ia64. */
151 break;
152 case __HYPERVISOR_grant_table_op:
153 rc = xencommize_mini_grant_table_op
154 (xc_area, &nbr_area,
155 mce->args[0], (void *)mce->args[1],
156 mce->args[2], &desc);
157 if (rc)
158 return rc;
159 mce->args[1] = (unsigned long)desc;
160 break;
161 case __HYPERVISOR_memory_op:
162 default:
163 printk("%s: unhandled multicall op entry op %lu\n",
164 __func__, mce->op);
165 return -ENOSYS;
166 }
167 }
169 rc = xencomm_create_mini(xc_area, &nbr_area, call_list,
170 nr_calls * sizeof(multicall_entry_t), &desc);
171 if (rc)
172 return rc;
174 return xencomm_arch_hypercall_multicall(desc, nr_calls);
175 }
176 EXPORT_SYMBOL(xencomm_mini_hypercall_multicall);
178 static int
179 xencommize_mini_memory_reservation(struct xencomm_mini *area, int *nbr_area,
180 xen_memory_reservation_t *mop)
181 {
182 struct xencomm_handle *desc;
183 int rc;
185 rc = xencomm_create_mini
186 (area, nbr_area,
187 xen_guest_handle(mop->extent_start),
188 mop->nr_extents
189 * sizeof(*xen_guest_handle(mop->extent_start)),
190 &desc);
191 if (rc)
192 return rc;
194 set_xen_guest_handle(mop->extent_start, (void *)desc);
196 return 0;
197 }
199 int
200 xencomm_mini_hypercall_memory_op(unsigned int cmd, void *arg)
201 {
202 int nbr_area = 4;
203 struct xencomm_mini xc_area[4];
204 struct xencomm_handle *desc;
205 int rc;
206 unsigned int argsize;
208 switch (cmd) {
209 case XENMEM_increase_reservation:
210 case XENMEM_decrease_reservation:
211 case XENMEM_populate_physmap:
212 argsize = sizeof(xen_memory_reservation_t);
213 rc = xencommize_mini_memory_reservation
214 (xc_area, &nbr_area, (xen_memory_reservation_t *)arg);
215 if (rc)
216 return rc;
217 break;
219 case XENMEM_maximum_ram_page:
220 argsize = 0;
221 break;
223 case XENMEM_exchange:
224 argsize = sizeof(xen_memory_exchange_t);
225 rc = xencommize_mini_memory_reservation
226 (xc_area, &nbr_area,
227 &((xen_memory_exchange_t *)arg)->in);
228 if (rc)
229 return rc;
230 rc = xencommize_mini_memory_reservation
231 (xc_area, &nbr_area,
232 &((xen_memory_exchange_t *)arg)->out);
233 if (rc)
234 return rc;
235 break;
237 case XENMEM_add_to_physmap:
238 argsize = sizeof (xen_add_to_physmap_t);
239 break;
241 default:
242 printk("%s: unknown mini memory op %d\n", __func__, cmd);
243 return -ENOSYS;
244 }
246 rc = xencomm_create_mini(xc_area, &nbr_area, arg, argsize, &desc);
247 if (rc)
248 return rc;
250 return xencomm_arch_hypercall_memory_op(cmd, desc);
251 }
252 EXPORT_SYMBOL(xencomm_mini_hypercall_memory_op);
254 unsigned long
255 xencomm_mini_hypercall_hvm_op(int cmd, void *arg)
256 {
257 struct xencomm_handle *desc;
258 int nbr_area = 2;
259 struct xencomm_mini xc_area[2];
260 unsigned int argsize;
261 int rc;
263 switch (cmd) {
264 case HVMOP_get_param:
265 case HVMOP_set_param:
266 argsize = sizeof(xen_hvm_param_t);
267 break;
268 default:
269 printk("%s: unknown HVMOP %d\n", __func__, cmd);
270 return -EINVAL;
271 }
273 rc = xencomm_create_mini(xc_area, &nbr_area, arg, argsize, &desc);
274 if (rc)
275 return rc;
277 return xencomm_arch_hypercall_hvm_op(cmd, desc);
278 }
279 EXPORT_SYMBOL(xencomm_mini_hypercall_hvm_op);
281 int
282 xencomm_mini_hypercall_xen_version(int cmd, void *arg)
283 {
284 struct xencomm_handle *desc;
285 int nbr_area = 2;
286 struct xencomm_mini xc_area[2];
287 unsigned int argsize;
288 int rc;
290 switch (cmd) {
291 case XENVER_version:
292 /* do not actually pass an argument */
293 return xencomm_arch_hypercall_xen_version(cmd, 0);
294 case XENVER_extraversion:
295 argsize = sizeof(xen_extraversion_t);
296 break;
297 case XENVER_compile_info:
298 argsize = sizeof(xen_compile_info_t);
299 break;
300 case XENVER_capabilities:
301 argsize = sizeof(xen_capabilities_info_t);
302 break;
303 case XENVER_changeset:
304 argsize = sizeof(xen_changeset_info_t);
305 break;
306 case XENVER_platform_parameters:
307 argsize = sizeof(xen_platform_parameters_t);
308 break;
309 case XENVER_pagesize:
310 argsize = (arg == NULL) ? 0 : sizeof(void *);
311 break;
312 case XENVER_get_features:
313 argsize = (arg == NULL) ? 0 : sizeof(xen_feature_info_t);
314 break;
316 default:
317 printk("%s: unknown version op %d\n", __func__, cmd);
318 return -ENOSYS;
319 }
321 rc = xencomm_create_mini(xc_area, &nbr_area, arg, argsize, &desc);
322 if (rc)
323 return rc;
325 return xencomm_arch_hypercall_xen_version(cmd, desc);
326 }
327 EXPORT_SYMBOL(xencomm_mini_hypercall_xen_version);
329 int
330 xencomm_mini_hypercall_xenoprof_op(int op, void *arg)
331 {
332 unsigned int argsize;
333 struct xencomm_mini xc_area[2];
334 int nbr_area = 2;
335 struct xencomm_handle *desc;
336 int rc;
338 switch (op) {
339 case XENOPROF_init:
340 argsize = sizeof(xenoprof_init_t);
341 break;
342 case XENOPROF_set_active:
343 argsize = sizeof(domid_t);
344 break;
345 case XENOPROF_set_passive:
346 argsize = sizeof(xenoprof_passive_t);
347 break;
348 case XENOPROF_counter:
349 argsize = sizeof(xenoprof_counter_t);
350 break;
351 case XENOPROF_get_buffer:
352 argsize = sizeof(xenoprof_get_buffer_t);
353 break;
355 case XENOPROF_reset_active_list:
356 case XENOPROF_reset_passive_list:
357 case XENOPROF_reserve_counters:
358 case XENOPROF_setup_events:
359 case XENOPROF_enable_virq:
360 case XENOPROF_start:
361 case XENOPROF_stop:
362 case XENOPROF_disable_virq:
363 case XENOPROF_release_counters:
364 case XENOPROF_shutdown:
365 return xencomm_arch_hypercall_xenoprof_op(op, arg);
367 default:
368 printk("%s: op %d isn't supported\n", __func__, op);
369 return -ENOSYS;
370 }
371 rc = xencomm_create_mini(xc_area, &nbr_area, arg, argsize, &desc);
372 if (rc)
373 return rc;
374 return xencomm_arch_hypercall_xenoprof_op(op, desc);
375 }
376 EXPORT_SYMBOL_GPL(xencomm_mini_hypercall_xenoprof_op);
378 int
379 xencomm_mini_hypercall_perfmon_op(unsigned long cmd, void* arg,
380 unsigned long count)
381 {
382 unsigned int argsize;
383 struct xencomm_mini xc_area[2];
384 int nbr_area = 2;
385 struct xencomm_handle *desc;
386 int rc;
388 switch (cmd) {
389 case PFM_GET_FEATURES:
390 argsize = sizeof(pfarg_features_t);
391 break;
392 case PFM_CREATE_CONTEXT:
393 argsize = sizeof(pfarg_context_t);
394 break;
395 case PFM_LOAD_CONTEXT:
396 argsize = sizeof(pfarg_load_t);
397 break;
398 case PFM_WRITE_PMCS:
399 case PFM_WRITE_PMDS:
400 argsize = sizeof(pfarg_reg_t) * count;
401 break;
403 case PFM_DESTROY_CONTEXT:
404 case PFM_UNLOAD_CONTEXT:
405 case PFM_START:
406 case PFM_STOP:
407 return xencomm_arch_hypercall_perfmon_op(cmd, arg, count);
409 default:
410 printk("%s:%d cmd %ld isn't supported\n",
411 __func__, __LINE__, cmd);
412 BUG();
413 }
415 rc = xencomm_create_mini(xc_area, &nbr_area, arg, argsize, &desc);
416 if (rc)
417 return rc;
418 return xencomm_arch_hypercall_perfmon_op(cmd, desc, count);
419 }
420 EXPORT_SYMBOL_GPL(xencomm_mini_hypercall_perfmon_op);