ia64/xen-unstable

view xen/arch/ia64/xen/dom0_ops.c @ 9405:29dfadcc5029

[IA64] Followup to xen time cleanup

Clean up to xen time handler. Tristan #if 0 some code because it seems
redundant, which however is actually problematic logic as a reason for
an intermittent timer oops issue of dom0. So delete it now.

Also remove vcpu_wake, since wakeup current has nothing meaningful and
simply waste cpu cycle.

Signed-off-by: Kevin Tian <kevin.tian@intel.com>
author awilliam@xenbuild.aw
date Mon Mar 27 15:32:08 2006 -0700 (2006-03-27)
parents 695aa28b7cb1
children 827c65c06a66
line source
1 /******************************************************************************
2 * Arch-specific dom0_ops.c
3 *
4 * Process command requests from domain-0 guest OS.
5 *
6 * Copyright (c) 2002, K A Fraser
7 */
9 #include <xen/config.h>
10 #include <xen/types.h>
11 #include <xen/lib.h>
12 #include <xen/mm.h>
13 #include <public/dom0_ops.h>
14 #include <xen/sched.h>
15 #include <xen/event.h>
16 #include <asm/pdb.h>
17 #include <xen/trace.h>
18 #include <xen/console.h>
19 #include <xen/guest_access.h>
20 #include <public/sched_ctl.h>
21 #include <asm/vmx.h>
23 long arch_do_dom0_op(dom0_op_t *op, GUEST_HANDLE(dom0_op_t) u_dom0_op)
24 {
25 long ret = 0;
27 if ( !IS_PRIV(current->domain) )
28 return -EPERM;
30 switch ( op->cmd )
31 {
32 case DOM0_GETPAGEFRAMEINFO:
33 {
34 struct page_info *page;
35 unsigned long mfn = op->u.getpageframeinfo.mfn;
36 domid_t dom = op->u.getpageframeinfo.domain;
37 struct domain *d;
39 ret = -EINVAL;
41 if ( unlikely(!mfn_valid(mfn)) ||
42 unlikely((d = find_domain_by_id(dom)) == NULL) )
43 break;
45 page = &frame_table[mfn];
47 if ( likely(get_page(page, d)) )
48 {
49 ret = 0;
51 op->u.getpageframeinfo.type = NOTAB;
53 if ( (page->u.inuse.type_info & PGT_count_mask) != 0 )
54 {
55 switch ( page->u.inuse.type_info & PGT_type_mask )
56 {
57 default:
58 panic("No such page type\n");
59 break;
60 }
61 }
63 put_page(page);
64 }
66 put_domain(d);
68 copy_to_guest(u_dom0_op, op, 1);
69 }
70 break;
72 case DOM0_GETPAGEFRAMEINFO2:
73 {
74 #define GPF2_BATCH 128
75 int n,j;
76 int num = op->u.getpageframeinfo2.num;
77 domid_t dom = op->u.getpageframeinfo2.domain;
78 struct domain *d;
79 unsigned long *l_arr;
80 ret = -ESRCH;
82 if ( unlikely((d = find_domain_by_id(dom)) == NULL) )
83 break;
85 if ( unlikely(num > 1024) )
86 {
87 ret = -E2BIG;
88 break;
89 }
91 l_arr = (unsigned long *)alloc_xenheap_page();
93 ret = 0;
94 for( n = 0; n < num; )
95 {
96 int k = ((num-n)>GPF2_BATCH)?GPF2_BATCH:(num-n);
98 if ( copy_from_guest_offset(l_arr, op->u.getpageframeinfo2.array,
99 n, k) )
100 {
101 ret = -EINVAL;
102 break;
103 }
105 for( j = 0; j < k; j++ )
106 {
107 struct page_info *page;
108 unsigned long mfn = l_arr[j];
110 if ( unlikely(mfn >= max_page) )
111 goto e2_err;
113 page = &frame_table[mfn];
115 if ( likely(get_page(page, d)) )
116 {
117 unsigned long type = 0;
119 switch( page->u.inuse.type_info & PGT_type_mask )
120 {
121 default:
122 panic("No such page type\n");
123 break;
124 }
126 if ( page->u.inuse.type_info & PGT_pinned )
127 type |= LPINTAB;
128 l_arr[j] |= type;
129 put_page(page);
130 }
131 else
132 {
133 e2_err:
134 l_arr[j] |= XTAB;
135 }
137 }
139 if ( copy_to_guest_offset(op->u.getpageframeinfo2.array,
140 n, l_arr, k) )
141 {
142 ret = -EINVAL;
143 break;
144 }
146 n += j;
147 }
149 free_xenheap_page((void *) l_arr);
151 put_domain(d);
152 }
153 break;
154 /*
155 * NOTE: DOM0_GETMEMLIST has somewhat different semantics on IA64 -
156 * it actually allocates and maps pages.
157 */
158 case DOM0_GETMEMLIST:
159 {
160 unsigned long i;
161 struct domain *d = find_domain_by_id(op->u.getmemlist.domain);
162 unsigned long start_page = op->u.getmemlist.max_pfns >> 32;
163 unsigned long nr_pages = op->u.getmemlist.max_pfns & 0xffffffff;
164 unsigned long mfn;
166 ret = -EINVAL;
167 if ( d != NULL )
168 {
169 ret = 0;
171 /* A temp trick here. When max_pfns == -1, we assume
172 * the request is for machine contiguous pages, so request
173 * all pages at first query
174 */
175 if ( (op->u.getmemlist.max_pfns == -1UL) &&
176 !test_bit(ARCH_VMX_CONTIG_MEM,
177 &d->vcpu[0]->arch.arch_vmx.flags) ) {
178 ret = (long) vmx_alloc_contig_pages(d);
179 put_domain(d);
180 return ret ? (-ENOMEM) : 0;
181 }
183 for ( i = start_page; i < (start_page + nr_pages); i++ )
184 {
185 mfn = gmfn_to_mfn_foreign(d, i);
187 if ( copy_to_guest_offset(op->u.getmemlist.buffer,
188 i - start_page, &mfn, 1) )
189 {
190 ret = -EFAULT;
191 break;
192 }
193 }
195 op->u.getmemlist.num_pfns = i - start_page;
196 copy_to_guest(u_dom0_op, op, 1);
198 put_domain(d);
199 }
200 }
201 break;
203 case DOM0_PHYSINFO:
204 {
205 dom0_physinfo_t *pi = &op->u.physinfo;
207 pi->threads_per_core = smp_num_siblings;
208 pi->cores_per_socket = 1; // FIXME
209 pi->sockets_per_node =
210 num_online_cpus() / (pi->threads_per_core * pi->cores_per_socket);
211 pi->nr_nodes = 1;
212 pi->total_pages = 99; // FIXME
213 pi->free_pages = avail_domheap_pages();
214 pi->cpu_khz = 100; // FIXME cpu_khz;
215 memset(pi->hw_cap, 0, sizeof(pi->hw_cap));
216 //memcpy(pi->hw_cap, boot_cpu_data.x86_capability, NCAPINTS*4);
217 ret = 0;
218 if ( copy_to_guest(u_dom0_op, op, 1) )
219 ret = -EFAULT;
220 }
221 break;
223 default:
224 printf("arch_do_dom0_op: unrecognized dom0 op: %d!!!\n",op->cmd);
225 ret = -ENOSYS;
227 }
229 return ret;
230 }
232 /*
233 * Local variables:
234 * mode: C
235 * c-set-style: "BSD"
236 * c-basic-offset: 4
237 * tab-width: 4
238 * indent-tabs-mode: nil
239 * End:
240 */