ia64/xen-unstable

view xen/common/kernel.c @ 8609:85d693e6f61a

Arch-specific per-vcpu info should be initialised to zero
when allocating a new vcpu structure, not copied from
CPU0's idle VCPU. Especially now that the idle VCPU itself
is dynamically allocated.

This should fix assertions people have been seeing in
getdomain_info_ctxt() relation to IOPL in eflags.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Jan 14 21:26:40 2006 +0100 (2006-01-14)
parents 6ccee759e34f
children 31083f13ae47
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 <asm/current.h>
14 #include <public/nmi.h>
15 #include <public/version.h>
17 void cmdline_parse(char *cmdline)
18 {
19 char opt[100], *optval, *p = cmdline, *q;
20 struct kernel_param *param;
22 if ( p == NULL )
23 return;
25 /* Skip whitespace and the image name. */
26 while ( *p == ' ' )
27 p++;
28 if ( (p = strchr(p, ' ')) == NULL )
29 return;
31 for ( ; ; )
32 {
33 /* Skip whitespace. */
34 while ( *p == ' ' )
35 p++;
36 if ( *p == '\0' )
37 break;
39 /* Grab the next whitespace-delimited option. */
40 q = opt;
41 while ( (*p != ' ') && (*p != '\0') )
42 *q++ = *p++;
43 *q = '\0';
45 /* Search for value part of a key=value option. */
46 optval = strchr(opt, '=');
47 if ( optval != NULL )
48 *optval++ = '\0';
50 for ( param = &__setup_start; param <= &__setup_end; param++ )
51 {
52 if ( strcmp(param->name, opt ) != 0 )
53 continue;
55 switch ( param->type )
56 {
57 case OPT_STR:
58 if ( optval != NULL )
59 {
60 strncpy(param->var, optval, param->len);
61 ((char *)param->var)[param->len-1] = '\0';
62 }
63 break;
64 case OPT_UINT:
65 if ( optval != NULL )
66 *(unsigned int *)param->var =
67 simple_strtol(optval, (char **)&optval, 0);
68 break;
69 case OPT_BOOL:
70 *(int *)param->var = 1;
71 break;
72 case OPT_CUSTOM:
73 if ( optval != NULL )
74 ((void (*)(char *))param->var)(optval);
75 break;
76 }
77 }
78 }
79 }
81 /*
82 * Simple hypercalls.
83 */
85 long do_xen_version(int cmd, void *arg)
86 {
87 switch ( cmd )
88 {
89 case XENVER_version:
90 {
91 return (XEN_VERSION<<16) | (XEN_SUBVERSION);
92 }
94 case XENVER_extraversion:
95 {
96 xen_extraversion_t extraversion;
97 safe_strcpy(extraversion, XEN_EXTRAVERSION);
98 if ( copy_to_user(arg, extraversion, sizeof(extraversion)) )
99 return -EFAULT;
100 return 0;
101 }
103 case XENVER_compile_info:
104 {
105 struct xen_compile_info info;
106 safe_strcpy(info.compiler, XEN_COMPILER);
107 safe_strcpy(info.compile_by, XEN_COMPILE_BY);
108 safe_strcpy(info.compile_domain, XEN_COMPILE_DOMAIN);
109 safe_strcpy(info.compile_date, XEN_COMPILE_DATE);
110 if ( copy_to_user(arg, &info, sizeof(info)) )
111 return -EFAULT;
112 return 0;
113 }
115 case XENVER_capabilities:
116 {
117 xen_capabilities_info_t info;
118 extern void arch_get_xen_caps(xen_capabilities_info_t info);
120 memset(info, 0, sizeof(info));
121 arch_get_xen_caps(info);
123 if ( copy_to_user(arg, info, sizeof(info)) )
124 return -EFAULT;
125 return 0;
126 }
128 case XENVER_platform_parameters:
129 {
130 xen_platform_parameters_t params = {
131 .virt_start = HYPERVISOR_VIRT_START
132 };
133 if ( copy_to_user(arg, &params, sizeof(params)) )
134 return -EFAULT;
135 return 0;
137 }
139 case XENVER_changeset:
140 {
141 xen_changeset_info_t chgset;
142 safe_strcpy(chgset, XEN_CHANGESET);
143 if ( copy_to_user(arg, chgset, sizeof(chgset)) )
144 return -EFAULT;
145 return 0;
146 }
147 }
149 return -ENOSYS;
150 }
152 long do_nmi_op(unsigned int cmd, void *arg)
153 {
154 struct vcpu *v = current;
155 struct domain *d = current->domain;
156 long rc = 0;
158 switch ( cmd )
159 {
160 case XENNMI_register_callback:
161 if ( (d->domain_id != 0) || (v->vcpu_id != 0) )
162 {
163 rc = -EINVAL;
164 }
165 else
166 {
167 v->nmi_addr = (unsigned long)arg;
168 #ifdef CONFIG_X86
169 /*
170 * If no handler was registered we can 'lose the NMI edge'.
171 * Re-assert it now.
172 */
173 if ( d->shared_info->arch.nmi_reason != 0 )
174 set_bit(_VCPUF_nmi_pending, &v->vcpu_flags);
175 #endif
176 }
177 break;
178 case XENNMI_unregister_callback:
179 v->nmi_addr = 0;
180 break;
181 default:
182 rc = -ENOSYS;
183 break;
184 }
186 return rc;
187 }
189 long do_vm_assist(unsigned int cmd, unsigned int type)
190 {
191 return vm_assist(current->domain, cmd, type);
192 }
194 long do_ni_hypercall(void)
195 {
196 /* No-op hypercall. */
197 return -ENOSYS;
198 }
200 /*
201 * Local variables:
202 * mode: C
203 * c-set-style: "BSD"
204 * c-basic-offset: 4
205 * tab-width: 4
206 * indent-tabs-mode: nil
207 * End:
208 */