ia64/xen-unstable

view xen/arch/x86/sysctl.c @ 18806:ed8524f4a044

x86: Re-initialise HPET on resume from S3

Signed-off-by: Guanqun Lu <guanqun.lu@intel.com>
Signed-off-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Nov 18 15:55:14 2008 +0000 (2008-11-18)
parents 0c8d2e44126d
children 821a4a8911f0
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;
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 switch ( sysctl->u.cpu_hotplug.op )
106 {
107 case XEN_SYSCTL_CPU_HOTPLUG_ONLINE:
108 ret = cpu_up(cpu);
109 break;
110 case XEN_SYSCTL_CPU_HOTPLUG_OFFLINE:
111 ret = continue_hypercall_on_cpu(
112 0, cpu_down_helper, (void *)(unsigned long)cpu);
113 break;
114 default:
115 ret = -EINVAL;
116 break;
117 }
118 }
119 break;
121 default:
122 ret = -ENOSYS;
123 break;
124 }
126 return ret;
127 }
129 /*
130 * Local variables:
131 * mode: C
132 * c-set-style: "BSD"
133 * c-basic-offset: 4
134 * tab-width: 4
135 * indent-tabs-mode: nil
136 * End:
137 */