ia64/xen-unstable

view xen/arch/x86/sysctl.c @ 19835:edfdeb150f27

Fix buildsystem to detect udev > version 124

udev removed the udevinfo symlink from versions higher than 123 and
xen's build-system could not detect if udev is in place and has the
required version.

Signed-off-by: Marc-A. Dahlhaus <mad@wol.de>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 25 13:02:37 2009 +0100 (2009-06-25)
parents 821a4a8911f0
children
line source
1 /******************************************************************************
2 * Arch-specific sysctl.c
3 *
4 * System management operations. For use by node control stack.
5 *
6 * Copyright (c) 2002-2006, K Fraser
7 */
9 #include <xen/config.h>
10 #include <xen/types.h>
11 #include <xen/lib.h>
12 #include <xen/mm.h>
13 #include <xen/guest_access.h>
14 #include <public/sysctl.h>
15 #include <xen/sched.h>
16 #include <xen/event.h>
17 #include <xen/domain_page.h>
18 #include <asm/msr.h>
19 #include <xen/trace.h>
20 #include <xen/console.h>
21 #include <xen/iocap.h>
22 #include <asm/irq.h>
23 #include <asm/hvm/hvm.h>
24 #include <asm/hvm/support.h>
25 #include <asm/processor.h>
26 #include <asm/numa.h>
27 #include <xen/nodemask.h>
28 #include <xsm/xsm.h>
30 #define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0)
32 static long cpu_down_helper(void *data)
33 {
34 int cpu = (unsigned long)data;
35 return cpu_down(cpu);
36 }
38 long arch_do_sysctl(
39 struct xen_sysctl *sysctl, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
40 {
41 long ret = 0, status;
43 switch ( sysctl->cmd )
44 {
46 case XEN_SYSCTL_physinfo:
47 {
48 uint32_t i, max_array_ent;
49 XEN_GUEST_HANDLE_64(uint32) cpu_to_node_arr;
51 xen_sysctl_physinfo_t *pi = &sysctl->u.physinfo;
53 ret = xsm_physinfo();
54 if ( ret )
55 break;
57 max_array_ent = pi->max_cpu_id;
58 cpu_to_node_arr = pi->cpu_to_node;
60 memset(pi, 0, sizeof(*pi));
61 pi->cpu_to_node = cpu_to_node_arr;
62 pi->threads_per_core =
63 cpus_weight(cpu_sibling_map[0]);
64 pi->cores_per_socket =
65 cpus_weight(cpu_core_map[0]) / pi->threads_per_core;
66 pi->nr_cpus = (u32)num_online_cpus();
67 pi->nr_nodes = num_online_nodes();
68 pi->total_pages = total_pages;
69 pi->free_pages = avail_domheap_pages();
70 pi->scrub_pages = avail_scrub_pages();
71 pi->cpu_khz = cpu_khz;
72 memcpy(pi->hw_cap, boot_cpu_data.x86_capability, NCAPINTS*4);
73 if ( hvm_enabled )
74 pi->capabilities |= XEN_SYSCTL_PHYSCAP_hvm;
75 if ( iommu_enabled )
76 pi->capabilities |= XEN_SYSCTL_PHYSCAP_hvm_directio;
78 pi->max_cpu_id = last_cpu(cpu_online_map);
79 max_array_ent = min_t(uint32_t, max_array_ent, pi->max_cpu_id);
81 ret = 0;
83 if ( !guest_handle_is_null(cpu_to_node_arr) )
84 {
85 for ( i = 0; i <= max_array_ent; i++ )
86 {
87 uint32_t node = cpu_online(i) ? cpu_to_node(i) : ~0u;
88 if ( copy_to_guest_offset(cpu_to_node_arr, i, &node, 1) )
89 {
90 ret = -EFAULT;
91 break;
92 }
93 }
94 }
96 if ( copy_to_guest(u_sysctl, sysctl, 1) )
97 ret = -EFAULT;
98 }
99 break;
101 case XEN_SYSCTL_cpu_hotplug:
102 {
103 unsigned int cpu = sysctl->u.cpu_hotplug.cpu;
105 if (cpu_present(cpu)) {
106 status = cpu_online(cpu) ? XEN_CPU_HOTPLUG_STATUS_ONLINE :
107 XEN_CPU_HOTPLUG_STATUS_OFFLINE;
108 } else {
109 status = -EINVAL;
110 }
112 switch ( sysctl->u.cpu_hotplug.op )
113 {
114 case XEN_SYSCTL_CPU_HOTPLUG_ONLINE:
115 ret = cpu_up(cpu);
116 /*
117 * In the case of a true hotplug, this CPU wasn't present
118 * before, so return the 'new' status for it.
119 */
120 if (ret == 0 && status == -EINVAL)
121 status = XEN_CPU_HOTPLUG_STATUS_NEW;
122 break;
123 case XEN_SYSCTL_CPU_HOTPLUG_OFFLINE:
124 ret = continue_hypercall_on_cpu(
125 0, cpu_down_helper, (void *)(unsigned long)cpu);
126 break;
127 case XEN_SYSCTL_CPU_HOTPLUG_STATUS:
128 ret = 0;
129 break;
130 default:
131 ret = -EINVAL;
132 break;
133 }
135 /*
136 * If the operation was successful, return the old status.
137 */
138 if (ret >= 0)
139 ret = status;
140 }
141 break;
143 default:
144 ret = -ENOSYS;
145 break;
146 }
148 return ret;
149 }
151 /*
152 * Local variables:
153 * mode: C
154 * c-set-style: "BSD"
155 * c-basic-offset: 4
156 * tab-width: 4
157 * indent-tabs-mode: nil
158 * End:
159 */