ia64/xen-unstable

view xen/arch/powerpc/domctl.c @ 13608:30af6cfdb05c

Make domctl/sysctl interfaces 32-/64-bit invariant.
This kills off a fair amount of unpleasant CONFIG_COMPAT shimming and
avoids needing to keep the compat paths in sync as these interfaces
continue to develop.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Jan 24 16:33:19 2007 +0000 (2007-01-24)
parents 5442b2458e1b
children 271ffb1c12eb
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 * Copyright (C) IBM Corp. 2005
17 *
18 * Authors: Jimi Xenidis <jimix@watson.ibm.com>
19 */
21 #include <xen/config.h>
22 #include <xen/types.h>
23 #include <xen/lib.h>
24 #include <xen/sched.h>
25 #include <xen/domain.h>
26 #include <xen/guest_access.h>
27 #include <xen/shadow.h>
28 #include <public/xen.h>
29 #include <public/domctl.h>
30 #include <public/sysctl.h>
31 #include <asm/processor.h>
33 void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
34 {
35 memcpy(&c.nat->user_regs, &v->arch.ctxt, sizeof(struct cpu_user_regs));
36 /* XXX fill in rest of vcpu_guest_context_t */
37 }
39 long arch_do_domctl(struct xen_domctl *domctl,
40 XEN_GUEST_HANDLE(xen_domctl_t) u_domctl);
41 long arch_do_domctl(struct xen_domctl *domctl,
42 XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
43 {
44 long ret = 0;
46 switch (domctl->cmd) {
47 case XEN_DOMCTL_getmemlist:
48 {
49 int i;
50 struct domain *d = find_domain_by_id(domctl->domain);
51 unsigned long max_pfns = domctl->u.getmemlist.max_pfns;
52 uint64_t mfn;
53 struct list_head *list_ent;
55 ret = -EINVAL;
56 if ( d != NULL )
57 {
58 ret = 0;
60 spin_lock(&d->page_alloc_lock);
61 list_ent = d->page_list.next;
62 for ( i = 0; (i < max_pfns) && (list_ent != &d->page_list); i++ )
63 {
64 mfn = page_to_mfn(list_entry(
65 list_ent, struct page_info, list));
66 if ( copy_to_guest_offset(domctl->u.getmemlist.buffer,
67 i, &mfn, 1) )
68 {
69 ret = -EFAULT;
70 break;
71 }
72 list_ent = mfn_to_page(mfn)->list.next;
73 }
74 spin_unlock(&d->page_alloc_lock);
76 domctl->u.getmemlist.num_pfns = i;
77 copy_to_guest(u_domctl, domctl, 1);
79 put_domain(d);
80 }
81 }
82 break;
83 case XEN_DOMCTL_shadow_op:
84 {
85 struct domain *d;
86 ret = -ESRCH;
87 d = find_domain_by_id(domctl->domain);
88 if ( d != NULL )
89 {
90 ret = shadow_domctl(d, &domctl->u.shadow_op, u_domctl);
91 put_domain(d);
92 copy_to_guest(u_domctl, domctl, 1);
93 }
94 }
95 break;
96 case XEN_DOMCTL_real_mode_area:
97 {
98 struct domain *d;
99 unsigned int order = domctl->u.real_mode_area.log - PAGE_SHIFT;
101 ret = -ESRCH;
102 d = find_domain_by_id(domctl->domain);
103 if (d != NULL) {
104 ret = -EINVAL;
105 if (cpu_rma_valid(order))
106 ret = allocate_rma(d, order);
107 put_domain(d);
108 }
109 }
110 break;
112 default:
113 ret = -ENOSYS;
114 break;
115 }
117 return ret;
118 }