diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-12-03 05:42:58 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-12-20 10:08:26 -0500 |
commit | bbc3d14e9aca023bb98e580aa1c9350af8effdb1 (patch) | |
tree | d4b70bc67c04d1cbe05948a9368f916198237dbc | |
parent | 28e18293cf0f8d23a0950d7b1d2212d11af494dc (diff) |
ARM: SMP: move CPU number sanity checks to smp_init_cpus()
Ensure that the number of CPUs is sanity checked before setting
the number of possible CPUs. This avoids any chance of overflowing
the cpu_possible bitmap.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | arch/arm/mach-omap2/omap-smp.c | 21 | ||||
-rw-r--r-- | arch/arm/mach-realview/platsmp.c | 20 | ||||
-rw-r--r-- | arch/arm/mach-ux500/platsmp.c | 26 |
3 files changed, 34 insertions, 33 deletions
diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c index 56a8bce247c8..3c87468ce9cb 100644 --- a/arch/arm/mach-omap2/omap-smp.c +++ b/arch/arm/mach-omap2/omap-smp.c | |||
@@ -120,16 +120,6 @@ void __init smp_init_cpus(void) | |||
120 | 120 | ||
121 | ncores = get_core_count(); | 121 | ncores = get_core_count(); |
122 | 122 | ||
123 | for (i = 0; i < ncores; i++) | ||
124 | set_cpu_possible(i, true); | ||
125 | } | ||
126 | |||
127 | void __init smp_prepare_cpus(unsigned int max_cpus) | ||
128 | { | ||
129 | unsigned int ncores = get_core_count(); | ||
130 | unsigned int cpu = smp_processor_id(); | ||
131 | int i; | ||
132 | |||
133 | /* sanity check */ | 123 | /* sanity check */ |
134 | if (ncores == 0) { | 124 | if (ncores == 0) { |
135 | printk(KERN_ERR | 125 | printk(KERN_ERR |
@@ -144,6 +134,17 @@ void __init smp_prepare_cpus(unsigned int max_cpus) | |||
144 | ncores, NR_CPUS); | 134 | ncores, NR_CPUS); |
145 | ncores = NR_CPUS; | 135 | ncores = NR_CPUS; |
146 | } | 136 | } |
137 | |||
138 | for (i = 0; i < ncores; i++) | ||
139 | set_cpu_possible(i, true); | ||
140 | } | ||
141 | |||
142 | void __init smp_prepare_cpus(unsigned int max_cpus) | ||
143 | { | ||
144 | unsigned int ncores = num_possible_cpus(); | ||
145 | unsigned int cpu = smp_processor_id(); | ||
146 | int i; | ||
147 | |||
147 | smp_store_cpu_info(cpu); | 148 | smp_store_cpu_info(cpu); |
148 | 149 | ||
149 | /* | 150 | /* |
diff --git a/arch/arm/mach-realview/platsmp.c b/arch/arm/mach-realview/platsmp.c index af3d9093390b..108e92f9746b 100644 --- a/arch/arm/mach-realview/platsmp.c +++ b/arch/arm/mach-realview/platsmp.c | |||
@@ -160,16 +160,6 @@ void __init smp_init_cpus(void) | |||
160 | { | 160 | { |
161 | unsigned int i, ncores = get_core_count(); | 161 | unsigned int i, ncores = get_core_count(); |
162 | 162 | ||
163 | for (i = 0; i < ncores; i++) | ||
164 | set_cpu_possible(i, true); | ||
165 | } | ||
166 | |||
167 | void __init smp_prepare_cpus(unsigned int max_cpus) | ||
168 | { | ||
169 | unsigned int ncores = get_core_count(); | ||
170 | unsigned int cpu = smp_processor_id(); | ||
171 | int i; | ||
172 | |||
173 | /* sanity check */ | 163 | /* sanity check */ |
174 | if (ncores == 0) { | 164 | if (ncores == 0) { |
175 | printk(KERN_ERR | 165 | printk(KERN_ERR |
@@ -186,6 +176,16 @@ void __init smp_prepare_cpus(unsigned int max_cpus) | |||
186 | ncores = NR_CPUS; | 176 | ncores = NR_CPUS; |
187 | } | 177 | } |
188 | 178 | ||
179 | for (i = 0; i < ncores; i++) | ||
180 | set_cpu_possible(i, true); | ||
181 | } | ||
182 | |||
183 | void __init smp_prepare_cpus(unsigned int max_cpus) | ||
184 | { | ||
185 | unsigned int ncores = num_possible_cpus(); | ||
186 | unsigned int cpu = smp_processor_id(); | ||
187 | int i; | ||
188 | |||
189 | smp_store_cpu_info(cpu); | 189 | smp_store_cpu_info(cpu); |
190 | 190 | ||
191 | /* | 191 | /* |
diff --git a/arch/arm/mach-ux500/platsmp.c b/arch/arm/mach-ux500/platsmp.c index b8987bd21249..a51962b7579b 100644 --- a/arch/arm/mach-ux500/platsmp.c +++ b/arch/arm/mach-ux500/platsmp.c | |||
@@ -128,16 +128,6 @@ void __init smp_init_cpus(void) | |||
128 | { | 128 | { |
129 | unsigned int i, ncores = get_core_count(); | 129 | unsigned int i, ncores = get_core_count(); |
130 | 130 | ||
131 | for (i = 0; i < ncores; i++) | ||
132 | set_cpu_possible(i, true); | ||
133 | } | ||
134 | |||
135 | void __init smp_prepare_cpus(unsigned int max_cpus) | ||
136 | { | ||
137 | unsigned int ncores = get_core_count(); | ||
138 | unsigned int cpu = smp_processor_id(); | ||
139 | int i; | ||
140 | |||
141 | /* sanity check */ | 131 | /* sanity check */ |
142 | if (ncores == 0) { | 132 | if (ncores == 0) { |
143 | printk(KERN_ERR | 133 | printk(KERN_ERR |
@@ -145,14 +135,24 @@ void __init smp_prepare_cpus(unsigned int max_cpus) | |||
145 | ncores = 1; | 135 | ncores = 1; |
146 | } | 136 | } |
147 | 137 | ||
148 | if (ncores > num_possible_cpus()) { | 138 | if (ncores > NR_CPUS) { |
149 | printk(KERN_WARNING | 139 | printk(KERN_WARNING |
150 | "U8500: no. of cores (%d) greater than configured " | 140 | "U8500: no. of cores (%d) greater than configured " |
151 | "maximum of %d - clipping\n", | 141 | "maximum of %d - clipping\n", |
152 | ncores, num_possible_cpus()); | 142 | ncores, NR_CPUS); |
153 | ncores = num_possible_cpus(); | 143 | ncores = NR_CPUS; |
154 | } | 144 | } |
155 | 145 | ||
146 | for (i = 0; i < ncores; i++) | ||
147 | set_cpu_possible(i, true); | ||
148 | } | ||
149 | |||
150 | void __init smp_prepare_cpus(unsigned int max_cpus) | ||
151 | { | ||
152 | unsigned int ncores = num_possible_cpus(); | ||
153 | unsigned int cpu = smp_processor_id(); | ||
154 | int i; | ||
155 | |||
156 | smp_store_cpu_info(cpu); | 156 | smp_store_cpu_info(cpu); |
157 | 157 | ||
158 | /* | 158 | /* |