direct-io.hg

view xen/arch/powerpc/dom0_ops.c @ 11509:2e6c10dc7c0b

[POWERPC][XEN] make sure put_domain() is called in case of allocate_rma() failuer

Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Tue Sep 12 10:53:46 2006 -0400 (2006-09-12)
parents 4fdf5151b187
children
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/guest_access.h>
26 #include <xen/shadow.h>
27 #include <public/xen.h>
28 #include <public/domctl.h>
29 #include <public/sysctl.h>
30 #include <asm/processor.h>
32 void arch_getdomaininfo_ctxt(struct vcpu *, vcpu_guest_context_t *);
33 void arch_getdomaininfo_ctxt(struct vcpu *v, vcpu_guest_context_t *c)
34 {
35 memcpy(&c->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 xen_pfn_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 log = domctl->u.real_mode_area.log;
101 ret = -ESRCH;
102 d = find_domain_by_id(domctl->domain);
103 if (d != NULL) {
104 ret = -EINVAL;
105 if (cpu_rma_valid(log))
106 ret = allocate_rma(d, log - PAGE_SHIFT);
107 put_domain(d);
108 }
109 }
110 break;
112 default:
113 ret = -ENOSYS;
114 break;
115 }
117 return ret;
118 }
120 long arch_do_sysctl(struct xen_sysctl *sysctl,
121 XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl);
122 long arch_do_sysctl(struct xen_sysctl *sysctl,
123 XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
124 {
125 long ret = 0;
127 switch (sysctl->cmd) {
128 case XEN_SYSCTL_physinfo:
129 {
130 xen_sysctl_physinfo_t *pi = &sysctl->u.physinfo;
132 pi->threads_per_core = 1;
133 pi->cores_per_socket = 1;
134 pi->sockets_per_node = 1;
135 pi->nr_nodes = 1;
136 pi->total_pages = total_pages;
137 pi->free_pages = avail_domheap_pages();
138 pi->cpu_khz = cpu_khz;
139 memset(pi->hw_cap, 0, sizeof(pi->hw_cap));
140 ret = 0;
141 if ( copy_to_guest(u_sysctl, sysctl, 1) )
142 ret = -EFAULT;
143 }
144 break;
146 default:
147 printk("%s: unsupported sysctl: 0x%x\n", __func__, (sysctl->cmd));
148 ret = -ENOSYS;
149 break;
150 }
152 return ret;
153 }