ia64/xen-unstable

view xen/common/kernel.c @ 9706:3c05406f5e0a

In some cases, say for instance for some bizzare reason
the tree was checked out of CVS, which doens't neccessarily
store file permissions, mkbuildtree may not be executable.
So run them explicitly via bash.

Signed-Off-By: Horms <horms@verge.net.au>
author kaf24@firebug.cl.cam.ac.uk
date Thu Apr 13 11:24:00 2006 +0100 (2006-04-13)
parents 4293d6760cef
children faad84c126e2
line source
1 /******************************************************************************
2 * kernel.c
3 *
4 * Copyright (c) 2002-2005 K A Fraser
5 */
7 #include <xen/config.h>
8 #include <xen/init.h>
9 #include <xen/lib.h>
10 #include <xen/errno.h>
11 #include <xen/compile.h>
12 #include <xen/sched.h>
13 #include <xen/shadow.h>
14 #include <xen/guest_access.h>
15 #include <asm/current.h>
16 #include <public/nmi.h>
17 #include <public/version.h>
19 int tainted;
21 void cmdline_parse(char *cmdline)
22 {
23 char opt[100], *optval, *p = cmdline, *q;
24 struct kernel_param *param;
26 if ( p == NULL )
27 return;
29 /* Skip whitespace and the image name. */
30 while ( *p == ' ' )
31 p++;
32 if ( (p = strchr(p, ' ')) == NULL )
33 return;
35 for ( ; ; )
36 {
37 /* Skip whitespace. */
38 while ( *p == ' ' )
39 p++;
40 if ( *p == '\0' )
41 break;
43 /* Grab the next whitespace-delimited option. */
44 q = opt;
45 while ( (*p != ' ') && (*p != '\0') )
46 *q++ = *p++;
47 *q = '\0';
49 /* Search for value part of a key=value option. */
50 optval = strchr(opt, '=');
51 if ( optval != NULL )
52 *optval++ = '\0';
54 for ( param = &__setup_start; param <= &__setup_end; param++ )
55 {
56 if ( strcmp(param->name, opt ) != 0 )
57 continue;
59 switch ( param->type )
60 {
61 case OPT_STR:
62 if ( optval != NULL )
63 {
64 strncpy(param->var, optval, param->len);
65 ((char *)param->var)[param->len-1] = '\0';
66 }
67 break;
68 case OPT_UINT:
69 if ( optval != NULL )
70 *(unsigned int *)param->var =
71 simple_strtol(optval, (char **)&optval, 0);
72 break;
73 case OPT_BOOL:
74 *(int *)param->var = 1;
75 break;
76 case OPT_CUSTOM:
77 if ( optval != NULL )
78 ((void (*)(char *))param->var)(optval);
79 break;
80 }
81 }
82 }
83 }
85 /**
86 * print_tainted - return a string to represent the kernel taint state.
87 *
88 * 'S' - SMP with CPUs not designed for SMP.
89 * 'M' - Machine had a machine check experience.
90 * 'B' - System has hit bad_page.
91 *
92 * The string is overwritten by the next call to print_taint().
93 */
94 char *print_tainted(char *str)
95 {
96 if ( tainted )
97 {
98 snprintf(str, TAINT_STRING_MAX_LEN, "Tainted: %c%c%c",
99 tainted & TAINT_UNSAFE_SMP ? 'S' : ' ',
100 tainted & TAINT_MACHINE_CHECK ? 'M' : ' ',
101 tainted & TAINT_BAD_PAGE ? 'B' : ' ');
102 }
103 else
104 {
105 snprintf(str, TAINT_STRING_MAX_LEN, "Not tainted");
106 }
108 return str;
109 }
111 void add_taint(unsigned flag)
112 {
113 tainted |= flag;
114 }
116 /*
117 * Simple hypercalls.
118 */
120 long do_xen_version(int cmd, GUEST_HANDLE(void) arg)
121 {
122 switch ( cmd )
123 {
124 case XENVER_version:
125 {
126 return (XEN_VERSION<<16) | (XEN_SUBVERSION);
127 }
129 case XENVER_extraversion:
130 {
131 xen_extraversion_t extraversion;
132 safe_strcpy(extraversion, XEN_EXTRAVERSION);
133 if ( copy_to_guest(arg, (char *)extraversion, sizeof(extraversion)) )
134 return -EFAULT;
135 return 0;
136 }
138 case XENVER_compile_info:
139 {
140 struct xen_compile_info info;
141 safe_strcpy(info.compiler, XEN_COMPILER);
142 safe_strcpy(info.compile_by, XEN_COMPILE_BY);
143 safe_strcpy(info.compile_domain, XEN_COMPILE_DOMAIN);
144 safe_strcpy(info.compile_date, XEN_COMPILE_DATE);
145 if ( copy_to_guest(arg, &info, 1) )
146 return -EFAULT;
147 return 0;
148 }
150 case XENVER_capabilities:
151 {
152 xen_capabilities_info_t info;
153 extern void arch_get_xen_caps(xen_capabilities_info_t info);
155 memset(info, 0, sizeof(info));
156 arch_get_xen_caps(info);
158 if ( copy_to_guest(arg, (char *)info, sizeof(info)) )
159 return -EFAULT;
160 return 0;
161 }
163 case XENVER_platform_parameters:
164 {
165 xen_platform_parameters_t params = {
166 .virt_start = HYPERVISOR_VIRT_START
167 };
168 if ( copy_to_guest(arg, &params, 1) )
169 return -EFAULT;
170 return 0;
172 }
174 case XENVER_changeset:
175 {
176 xen_changeset_info_t chgset;
177 safe_strcpy(chgset, XEN_CHANGESET);
178 if ( copy_to_guest(arg, (char *)chgset, sizeof(chgset)) )
179 return -EFAULT;
180 return 0;
181 }
183 case XENVER_get_features:
184 {
185 xen_feature_info_t fi;
187 if ( copy_from_guest(&fi, arg, 1) )
188 return -EFAULT;
190 switch ( fi.submap_idx )
191 {
192 case 0:
193 fi.submap = 0;
194 if ( shadow_mode_translate(current->domain) )
195 fi.submap |=
196 (1U << XENFEAT_writable_page_tables) |
197 (1U << XENFEAT_auto_translated_physmap) |
198 (1U << XENFEAT_pae_pgdir_above_4gb);
199 if ( supervisor_mode_kernel )
200 fi.submap |= 1U << XENFEAT_supervisor_mode_kernel;
201 break;
202 default:
203 return -EINVAL;
204 }
206 if ( copy_to_guest(arg, &fi, 1) )
207 return -EFAULT;
208 return 0;
209 }
211 }
213 return -ENOSYS;
214 }
216 long do_nmi_op(unsigned int cmd, GUEST_HANDLE(void) arg)
217 {
218 struct vcpu *v = current;
219 struct domain *d = current->domain;
220 struct xennmi_callback cb;
221 long rc = 0;
223 switch ( cmd )
224 {
225 case XENNMI_register_callback:
226 rc = -EINVAL;
227 if ( (d->domain_id != 0) || (v->vcpu_id != 0) )
228 break;
230 rc = -EFAULT;
231 if ( copy_from_guest(&cb, arg, 1) )
232 break;
234 v->nmi_addr = cb.handler_address;
235 #ifdef CONFIG_X86
236 /*
237 * If no handler was registered we can 'lose the NMI edge'. Re-assert
238 * it now.
239 */
240 if ( d->shared_info->arch.nmi_reason != 0 )
241 set_bit(_VCPUF_nmi_pending, &v->vcpu_flags);
242 #endif
243 rc = 0;
244 break;
245 case XENNMI_unregister_callback:
246 v->nmi_addr = 0;
247 break;
248 default:
249 rc = -ENOSYS;
250 break;
251 }
253 return rc;
254 }
256 long do_vm_assist(unsigned int cmd, unsigned int type)
257 {
258 return vm_assist(current->domain, cmd, type);
259 }
261 long do_ni_hypercall(void)
262 {
263 /* No-op hypercall. */
264 return -ENOSYS;
265 }
267 /*
268 * Local variables:
269 * mode: C
270 * c-set-style: "BSD"
271 * c-basic-offset: 4
272 * tab-width: 4
273 * indent-tabs-mode: nil
274 * End:
275 */