Commit a776878d6cf8a81fa65b29aa9bd6a10a5131e71c

Authored by Linus Torvalds

Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86, efi: Calling __pa() with an ioremap()ed address is invalid
  x86, hpet: Immediately disable HPET timer 1 if rtc irq is masked
  x86/intel_mid: Kconfig select fix
  x86/intel_mid: Fix the Kconfig for MID selection

Showing 8 changed files Inline Diff

1 # Select 32 or 64 bit 1 # Select 32 or 64 bit
2 config 64BIT 2 config 64BIT
3 bool "64-bit kernel" if ARCH = "x86" 3 bool "64-bit kernel" if ARCH = "x86"
4 default ARCH = "x86_64" 4 default ARCH = "x86_64"
5 ---help--- 5 ---help---
6 Say yes to build a 64-bit kernel - formerly known as x86_64 6 Say yes to build a 64-bit kernel - formerly known as x86_64
7 Say no to build a 32-bit kernel - formerly known as i386 7 Say no to build a 32-bit kernel - formerly known as i386
8 8
9 config X86_32 9 config X86_32
10 def_bool !64BIT 10 def_bool !64BIT
11 select CLKSRC_I8253 11 select CLKSRC_I8253
12 12
13 config X86_64 13 config X86_64
14 def_bool 64BIT 14 def_bool 64BIT
15 15
16 ### Arch settings 16 ### Arch settings
17 config X86 17 config X86
18 def_bool y 18 def_bool y
19 select HAVE_AOUT if X86_32 19 select HAVE_AOUT if X86_32
20 select HAVE_UNSTABLE_SCHED_CLOCK 20 select HAVE_UNSTABLE_SCHED_CLOCK
21 select HAVE_IDE 21 select HAVE_IDE
22 select HAVE_OPROFILE 22 select HAVE_OPROFILE
23 select HAVE_PCSPKR_PLATFORM 23 select HAVE_PCSPKR_PLATFORM
24 select HAVE_PERF_EVENTS 24 select HAVE_PERF_EVENTS
25 select HAVE_IRQ_WORK 25 select HAVE_IRQ_WORK
26 select HAVE_IOREMAP_PROT 26 select HAVE_IOREMAP_PROT
27 select HAVE_KPROBES 27 select HAVE_KPROBES
28 select HAVE_MEMBLOCK 28 select HAVE_MEMBLOCK
29 select ARCH_WANT_OPTIONAL_GPIOLIB 29 select ARCH_WANT_OPTIONAL_GPIOLIB
30 select ARCH_WANT_FRAME_POINTERS 30 select ARCH_WANT_FRAME_POINTERS
31 select HAVE_DMA_ATTRS 31 select HAVE_DMA_ATTRS
32 select HAVE_KRETPROBES 32 select HAVE_KRETPROBES
33 select HAVE_OPTPROBES 33 select HAVE_OPTPROBES
34 select HAVE_FTRACE_MCOUNT_RECORD 34 select HAVE_FTRACE_MCOUNT_RECORD
35 select HAVE_C_RECORDMCOUNT 35 select HAVE_C_RECORDMCOUNT
36 select HAVE_DYNAMIC_FTRACE 36 select HAVE_DYNAMIC_FTRACE
37 select HAVE_FUNCTION_TRACER 37 select HAVE_FUNCTION_TRACER
38 select HAVE_FUNCTION_GRAPH_TRACER 38 select HAVE_FUNCTION_GRAPH_TRACER
39 select HAVE_FUNCTION_GRAPH_FP_TEST 39 select HAVE_FUNCTION_GRAPH_FP_TEST
40 select HAVE_FUNCTION_TRACE_MCOUNT_TEST 40 select HAVE_FUNCTION_TRACE_MCOUNT_TEST
41 select HAVE_FTRACE_NMI_ENTER if DYNAMIC_FTRACE 41 select HAVE_FTRACE_NMI_ENTER if DYNAMIC_FTRACE
42 select HAVE_SYSCALL_TRACEPOINTS 42 select HAVE_SYSCALL_TRACEPOINTS
43 select HAVE_KVM 43 select HAVE_KVM
44 select HAVE_ARCH_KGDB 44 select HAVE_ARCH_KGDB
45 select HAVE_ARCH_TRACEHOOK 45 select HAVE_ARCH_TRACEHOOK
46 select HAVE_GENERIC_DMA_COHERENT if X86_32 46 select HAVE_GENERIC_DMA_COHERENT if X86_32
47 select HAVE_EFFICIENT_UNALIGNED_ACCESS 47 select HAVE_EFFICIENT_UNALIGNED_ACCESS
48 select USER_STACKTRACE_SUPPORT 48 select USER_STACKTRACE_SUPPORT
49 select HAVE_REGS_AND_STACK_ACCESS_API 49 select HAVE_REGS_AND_STACK_ACCESS_API
50 select HAVE_DMA_API_DEBUG 50 select HAVE_DMA_API_DEBUG
51 select HAVE_KERNEL_GZIP 51 select HAVE_KERNEL_GZIP
52 select HAVE_KERNEL_BZIP2 52 select HAVE_KERNEL_BZIP2
53 select HAVE_KERNEL_LZMA 53 select HAVE_KERNEL_LZMA
54 select HAVE_KERNEL_XZ 54 select HAVE_KERNEL_XZ
55 select HAVE_KERNEL_LZO 55 select HAVE_KERNEL_LZO
56 select HAVE_HW_BREAKPOINT 56 select HAVE_HW_BREAKPOINT
57 select HAVE_MIXED_BREAKPOINTS_REGS 57 select HAVE_MIXED_BREAKPOINTS_REGS
58 select PERF_EVENTS 58 select PERF_EVENTS
59 select HAVE_PERF_EVENTS_NMI 59 select HAVE_PERF_EVENTS_NMI
60 select ANON_INODES 60 select ANON_INODES
61 select HAVE_ARCH_KMEMCHECK 61 select HAVE_ARCH_KMEMCHECK
62 select HAVE_USER_RETURN_NOTIFIER 62 select HAVE_USER_RETURN_NOTIFIER
63 select HAVE_ARCH_JUMP_LABEL 63 select HAVE_ARCH_JUMP_LABEL
64 select HAVE_TEXT_POKE_SMP 64 select HAVE_TEXT_POKE_SMP
65 select HAVE_GENERIC_HARDIRQS 65 select HAVE_GENERIC_HARDIRQS
66 select HAVE_SPARSE_IRQ 66 select HAVE_SPARSE_IRQ
67 select SPARSE_IRQ 67 select SPARSE_IRQ
68 select GENERIC_FIND_FIRST_BIT 68 select GENERIC_FIND_FIRST_BIT
69 select GENERIC_IRQ_PROBE 69 select GENERIC_IRQ_PROBE
70 select GENERIC_PENDING_IRQ if SMP 70 select GENERIC_PENDING_IRQ if SMP
71 select GENERIC_IRQ_SHOW 71 select GENERIC_IRQ_SHOW
72 select GENERIC_CLOCKEVENTS_MIN_ADJUST 72 select GENERIC_CLOCKEVENTS_MIN_ADJUST
73 select IRQ_FORCED_THREADING 73 select IRQ_FORCED_THREADING
74 select USE_GENERIC_SMP_HELPERS if SMP 74 select USE_GENERIC_SMP_HELPERS if SMP
75 select HAVE_BPF_JIT if (X86_64 && NET) 75 select HAVE_BPF_JIT if (X86_64 && NET)
76 select CLKEVT_I8253 76 select CLKEVT_I8253
77 select ARCH_HAVE_NMI_SAFE_CMPXCHG 77 select ARCH_HAVE_NMI_SAFE_CMPXCHG
78 78
79 config INSTRUCTION_DECODER 79 config INSTRUCTION_DECODER
80 def_bool (KPROBES || PERF_EVENTS) 80 def_bool (KPROBES || PERF_EVENTS)
81 81
82 config OUTPUT_FORMAT 82 config OUTPUT_FORMAT
83 string 83 string
84 default "elf32-i386" if X86_32 84 default "elf32-i386" if X86_32
85 default "elf64-x86-64" if X86_64 85 default "elf64-x86-64" if X86_64
86 86
87 config ARCH_DEFCONFIG 87 config ARCH_DEFCONFIG
88 string 88 string
89 default "arch/x86/configs/i386_defconfig" if X86_32 89 default "arch/x86/configs/i386_defconfig" if X86_32
90 default "arch/x86/configs/x86_64_defconfig" if X86_64 90 default "arch/x86/configs/x86_64_defconfig" if X86_64
91 91
92 config GENERIC_CMOS_UPDATE 92 config GENERIC_CMOS_UPDATE
93 def_bool y 93 def_bool y
94 94
95 config CLOCKSOURCE_WATCHDOG 95 config CLOCKSOURCE_WATCHDOG
96 def_bool y 96 def_bool y
97 97
98 config GENERIC_CLOCKEVENTS 98 config GENERIC_CLOCKEVENTS
99 def_bool y 99 def_bool y
100 100
101 config ARCH_CLOCKSOURCE_DATA 101 config ARCH_CLOCKSOURCE_DATA
102 def_bool y 102 def_bool y
103 depends on X86_64 103 depends on X86_64
104 104
105 config GENERIC_CLOCKEVENTS_BROADCAST 105 config GENERIC_CLOCKEVENTS_BROADCAST
106 def_bool y 106 def_bool y
107 depends on X86_64 || (X86_32 && X86_LOCAL_APIC) 107 depends on X86_64 || (X86_32 && X86_LOCAL_APIC)
108 108
109 config LOCKDEP_SUPPORT 109 config LOCKDEP_SUPPORT
110 def_bool y 110 def_bool y
111 111
112 config STACKTRACE_SUPPORT 112 config STACKTRACE_SUPPORT
113 def_bool y 113 def_bool y
114 114
115 config HAVE_LATENCYTOP_SUPPORT 115 config HAVE_LATENCYTOP_SUPPORT
116 def_bool y 116 def_bool y
117 117
118 config MMU 118 config MMU
119 def_bool y 119 def_bool y
120 120
121 config ZONE_DMA 121 config ZONE_DMA
122 bool "DMA memory allocation support" if EXPERT 122 bool "DMA memory allocation support" if EXPERT
123 default y 123 default y
124 help 124 help
125 DMA memory allocation support allows devices with less than 32-bit 125 DMA memory allocation support allows devices with less than 32-bit
126 addressing to allocate within the first 16MB of address space. 126 addressing to allocate within the first 16MB of address space.
127 Disable if no such devices will be used. 127 Disable if no such devices will be used.
128 128
129 If unsure, say Y. 129 If unsure, say Y.
130 130
131 config SBUS 131 config SBUS
132 bool 132 bool
133 133
134 config NEED_DMA_MAP_STATE 134 config NEED_DMA_MAP_STATE
135 def_bool (X86_64 || INTEL_IOMMU || DMA_API_DEBUG) 135 def_bool (X86_64 || INTEL_IOMMU || DMA_API_DEBUG)
136 136
137 config NEED_SG_DMA_LENGTH 137 config NEED_SG_DMA_LENGTH
138 def_bool y 138 def_bool y
139 139
140 config GENERIC_ISA_DMA 140 config GENERIC_ISA_DMA
141 def_bool ISA_DMA_API 141 def_bool ISA_DMA_API
142 142
143 config GENERIC_IOMAP 143 config GENERIC_IOMAP
144 def_bool y 144 def_bool y
145 145
146 config GENERIC_BUG 146 config GENERIC_BUG
147 def_bool y 147 def_bool y
148 depends on BUG 148 depends on BUG
149 select GENERIC_BUG_RELATIVE_POINTERS if X86_64 149 select GENERIC_BUG_RELATIVE_POINTERS if X86_64
150 150
151 config GENERIC_BUG_RELATIVE_POINTERS 151 config GENERIC_BUG_RELATIVE_POINTERS
152 bool 152 bool
153 153
154 config GENERIC_HWEIGHT 154 config GENERIC_HWEIGHT
155 def_bool y 155 def_bool y
156 156
157 config GENERIC_GPIO 157 config GENERIC_GPIO
158 bool 158 bool
159 159
160 config ARCH_MAY_HAVE_PC_FDC 160 config ARCH_MAY_HAVE_PC_FDC
161 def_bool ISA_DMA_API 161 def_bool ISA_DMA_API
162 162
163 config RWSEM_GENERIC_SPINLOCK 163 config RWSEM_GENERIC_SPINLOCK
164 def_bool !X86_XADD 164 def_bool !X86_XADD
165 165
166 config RWSEM_XCHGADD_ALGORITHM 166 config RWSEM_XCHGADD_ALGORITHM
167 def_bool X86_XADD 167 def_bool X86_XADD
168 168
169 config ARCH_HAS_CPU_IDLE_WAIT 169 config ARCH_HAS_CPU_IDLE_WAIT
170 def_bool y 170 def_bool y
171 171
172 config GENERIC_CALIBRATE_DELAY 172 config GENERIC_CALIBRATE_DELAY
173 def_bool y 173 def_bool y
174 174
175 config GENERIC_TIME_VSYSCALL 175 config GENERIC_TIME_VSYSCALL
176 bool 176 bool
177 default X86_64 177 default X86_64
178 178
179 config ARCH_HAS_CPU_RELAX 179 config ARCH_HAS_CPU_RELAX
180 def_bool y 180 def_bool y
181 181
182 config ARCH_HAS_DEFAULT_IDLE 182 config ARCH_HAS_DEFAULT_IDLE
183 def_bool y 183 def_bool y
184 184
185 config ARCH_HAS_CACHE_LINE_SIZE 185 config ARCH_HAS_CACHE_LINE_SIZE
186 def_bool y 186 def_bool y
187 187
188 config HAVE_SETUP_PER_CPU_AREA 188 config HAVE_SETUP_PER_CPU_AREA
189 def_bool y 189 def_bool y
190 190
191 config NEED_PER_CPU_EMBED_FIRST_CHUNK 191 config NEED_PER_CPU_EMBED_FIRST_CHUNK
192 def_bool y 192 def_bool y
193 193
194 config NEED_PER_CPU_PAGE_FIRST_CHUNK 194 config NEED_PER_CPU_PAGE_FIRST_CHUNK
195 def_bool y 195 def_bool y
196 196
197 config ARCH_HIBERNATION_POSSIBLE 197 config ARCH_HIBERNATION_POSSIBLE
198 def_bool y 198 def_bool y
199 199
200 config ARCH_SUSPEND_POSSIBLE 200 config ARCH_SUSPEND_POSSIBLE
201 def_bool y 201 def_bool y
202 202
203 config ZONE_DMA32 203 config ZONE_DMA32
204 bool 204 bool
205 default X86_64 205 default X86_64
206 206
207 config ARCH_POPULATES_NODE_MAP 207 config ARCH_POPULATES_NODE_MAP
208 def_bool y 208 def_bool y
209 209
210 config AUDIT_ARCH 210 config AUDIT_ARCH
211 bool 211 bool
212 default X86_64 212 default X86_64
213 213
214 config ARCH_SUPPORTS_OPTIMIZED_INLINING 214 config ARCH_SUPPORTS_OPTIMIZED_INLINING
215 def_bool y 215 def_bool y
216 216
217 config ARCH_SUPPORTS_DEBUG_PAGEALLOC 217 config ARCH_SUPPORTS_DEBUG_PAGEALLOC
218 def_bool y 218 def_bool y
219 219
220 config HAVE_INTEL_TXT 220 config HAVE_INTEL_TXT
221 def_bool y 221 def_bool y
222 depends on EXPERIMENTAL && INTEL_IOMMU && ACPI 222 depends on EXPERIMENTAL && INTEL_IOMMU && ACPI
223 223
224 config X86_32_SMP 224 config X86_32_SMP
225 def_bool y 225 def_bool y
226 depends on X86_32 && SMP 226 depends on X86_32 && SMP
227 227
228 config X86_64_SMP 228 config X86_64_SMP
229 def_bool y 229 def_bool y
230 depends on X86_64 && SMP 230 depends on X86_64 && SMP
231 231
232 config X86_HT 232 config X86_HT
233 def_bool y 233 def_bool y
234 depends on SMP 234 depends on SMP
235 235
236 config X86_32_LAZY_GS 236 config X86_32_LAZY_GS
237 def_bool y 237 def_bool y
238 depends on X86_32 && !CC_STACKPROTECTOR 238 depends on X86_32 && !CC_STACKPROTECTOR
239 239
240 config ARCH_HWEIGHT_CFLAGS 240 config ARCH_HWEIGHT_CFLAGS
241 string 241 string
242 default "-fcall-saved-ecx -fcall-saved-edx" if X86_32 242 default "-fcall-saved-ecx -fcall-saved-edx" if X86_32
243 default "-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx -fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10 -fcall-saved-r11" if X86_64 243 default "-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx -fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10 -fcall-saved-r11" if X86_64
244 244
245 config KTIME_SCALAR 245 config KTIME_SCALAR
246 def_bool X86_32 246 def_bool X86_32
247 247
248 config ARCH_CPU_PROBE_RELEASE 248 config ARCH_CPU_PROBE_RELEASE
249 def_bool y 249 def_bool y
250 depends on HOTPLUG_CPU 250 depends on HOTPLUG_CPU
251 251
252 source "init/Kconfig" 252 source "init/Kconfig"
253 source "kernel/Kconfig.freezer" 253 source "kernel/Kconfig.freezer"
254 254
255 menu "Processor type and features" 255 menu "Processor type and features"
256 256
257 source "kernel/time/Kconfig" 257 source "kernel/time/Kconfig"
258 258
259 config SMP 259 config SMP
260 bool "Symmetric multi-processing support" 260 bool "Symmetric multi-processing support"
261 ---help--- 261 ---help---
262 This enables support for systems with more than one CPU. If you have 262 This enables support for systems with more than one CPU. If you have
263 a system with only one CPU, like most personal computers, say N. If 263 a system with only one CPU, like most personal computers, say N. If
264 you have a system with more than one CPU, say Y. 264 you have a system with more than one CPU, say Y.
265 265
266 If you say N here, the kernel will run on single and multiprocessor 266 If you say N here, the kernel will run on single and multiprocessor
267 machines, but will use only one CPU of a multiprocessor machine. If 267 machines, but will use only one CPU of a multiprocessor machine. If
268 you say Y here, the kernel will run on many, but not all, 268 you say Y here, the kernel will run on many, but not all,
269 singleprocessor machines. On a singleprocessor machine, the kernel 269 singleprocessor machines. On a singleprocessor machine, the kernel
270 will run faster if you say N here. 270 will run faster if you say N here.
271 271
272 Note that if you say Y here and choose architecture "586" or 272 Note that if you say Y here and choose architecture "586" or
273 "Pentium" under "Processor family", the kernel will not work on 486 273 "Pentium" under "Processor family", the kernel will not work on 486
274 architectures. Similarly, multiprocessor kernels for the "PPro" 274 architectures. Similarly, multiprocessor kernels for the "PPro"
275 architecture may not work on all Pentium based boards. 275 architecture may not work on all Pentium based boards.
276 276
277 People using multiprocessor machines who say Y here should also say 277 People using multiprocessor machines who say Y here should also say
278 Y to "Enhanced Real Time Clock Support", below. The "Advanced Power 278 Y to "Enhanced Real Time Clock Support", below. The "Advanced Power
279 Management" code will be disabled if you say Y here. 279 Management" code will be disabled if you say Y here.
280 280
281 See also <file:Documentation/x86/i386/IO-APIC.txt>, 281 See also <file:Documentation/x86/i386/IO-APIC.txt>,
282 <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at 282 <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
283 <http://www.tldp.org/docs.html#howto>. 283 <http://www.tldp.org/docs.html#howto>.
284 284
285 If you don't know what to do here, say N. 285 If you don't know what to do here, say N.
286 286
287 config X86_X2APIC 287 config X86_X2APIC
288 bool "Support x2apic" 288 bool "Support x2apic"
289 depends on X86_LOCAL_APIC && X86_64 && IRQ_REMAP 289 depends on X86_LOCAL_APIC && X86_64 && IRQ_REMAP
290 ---help--- 290 ---help---
291 This enables x2apic support on CPUs that have this feature. 291 This enables x2apic support on CPUs that have this feature.
292 292
293 This allows 32-bit apic IDs (so it can support very large systems), 293 This allows 32-bit apic IDs (so it can support very large systems),
294 and accesses the local apic via MSRs not via mmio. 294 and accesses the local apic via MSRs not via mmio.
295 295
296 If you don't know what to do here, say N. 296 If you don't know what to do here, say N.
297 297
298 config X86_MPPARSE 298 config X86_MPPARSE
299 bool "Enable MPS table" if ACPI 299 bool "Enable MPS table" if ACPI
300 default y 300 default y
301 depends on X86_LOCAL_APIC 301 depends on X86_LOCAL_APIC
302 ---help--- 302 ---help---
303 For old smp systems that do not have proper acpi support. Newer systems 303 For old smp systems that do not have proper acpi support. Newer systems
304 (esp with 64bit cpus) with acpi support, MADT and DSDT will override it 304 (esp with 64bit cpus) with acpi support, MADT and DSDT will override it
305 305
306 config X86_BIGSMP 306 config X86_BIGSMP
307 bool "Support for big SMP systems with more than 8 CPUs" 307 bool "Support for big SMP systems with more than 8 CPUs"
308 depends on X86_32 && SMP 308 depends on X86_32 && SMP
309 ---help--- 309 ---help---
310 This option is needed for the systems that have more than 8 CPUs 310 This option is needed for the systems that have more than 8 CPUs
311 311
312 if X86_32 312 if X86_32
313 config X86_EXTENDED_PLATFORM 313 config X86_EXTENDED_PLATFORM
314 bool "Support for extended (non-PC) x86 platforms" 314 bool "Support for extended (non-PC) x86 platforms"
315 default y 315 default y
316 ---help--- 316 ---help---
317 If you disable this option then the kernel will only support 317 If you disable this option then the kernel will only support
318 standard PC platforms. (which covers the vast majority of 318 standard PC platforms. (which covers the vast majority of
319 systems out there.) 319 systems out there.)
320 320
321 If you enable this option then you'll be able to select support 321 If you enable this option then you'll be able to select support
322 for the following (non-PC) 32 bit x86 platforms: 322 for the following (non-PC) 32 bit x86 platforms:
323 AMD Elan 323 AMD Elan
324 NUMAQ (IBM/Sequent) 324 NUMAQ (IBM/Sequent)
325 RDC R-321x SoC 325 RDC R-321x SoC
326 SGI 320/540 (Visual Workstation) 326 SGI 320/540 (Visual Workstation)
327 Summit/EXA (IBM x440) 327 Summit/EXA (IBM x440)
328 Unisys ES7000 IA32 series 328 Unisys ES7000 IA32 series
329 Moorestown MID devices 329 Moorestown MID devices
330 330
331 If you have one of these systems, or if you want to build a 331 If you have one of these systems, or if you want to build a
332 generic distribution kernel, say Y here - otherwise say N. 332 generic distribution kernel, say Y here - otherwise say N.
333 endif 333 endif
334 334
335 if X86_64 335 if X86_64
336 config X86_EXTENDED_PLATFORM 336 config X86_EXTENDED_PLATFORM
337 bool "Support for extended (non-PC) x86 platforms" 337 bool "Support for extended (non-PC) x86 platforms"
338 default y 338 default y
339 ---help--- 339 ---help---
340 If you disable this option then the kernel will only support 340 If you disable this option then the kernel will only support
341 standard PC platforms. (which covers the vast majority of 341 standard PC platforms. (which covers the vast majority of
342 systems out there.) 342 systems out there.)
343 343
344 If you enable this option then you'll be able to select support 344 If you enable this option then you'll be able to select support
345 for the following (non-PC) 64 bit x86 platforms: 345 for the following (non-PC) 64 bit x86 platforms:
346 ScaleMP vSMP 346 ScaleMP vSMP
347 SGI Ultraviolet 347 SGI Ultraviolet
348 348
349 If you have one of these systems, or if you want to build a 349 If you have one of these systems, or if you want to build a
350 generic distribution kernel, say Y here - otherwise say N. 350 generic distribution kernel, say Y here - otherwise say N.
351 endif 351 endif
352 # This is an alphabetically sorted list of 64 bit extended platforms 352 # This is an alphabetically sorted list of 64 bit extended platforms
353 # Please maintain the alphabetic order if and when there are additions 353 # Please maintain the alphabetic order if and when there are additions
354 354
355 config X86_VSMP 355 config X86_VSMP
356 bool "ScaleMP vSMP" 356 bool "ScaleMP vSMP"
357 select PARAVIRT_GUEST 357 select PARAVIRT_GUEST
358 select PARAVIRT 358 select PARAVIRT
359 depends on X86_64 && PCI 359 depends on X86_64 && PCI
360 depends on X86_EXTENDED_PLATFORM 360 depends on X86_EXTENDED_PLATFORM
361 ---help--- 361 ---help---
362 Support for ScaleMP vSMP systems. Say 'Y' here if this kernel is 362 Support for ScaleMP vSMP systems. Say 'Y' here if this kernel is
363 supposed to run on these EM64T-based machines. Only choose this option 363 supposed to run on these EM64T-based machines. Only choose this option
364 if you have one of these machines. 364 if you have one of these machines.
365 365
366 config X86_UV 366 config X86_UV
367 bool "SGI Ultraviolet" 367 bool "SGI Ultraviolet"
368 depends on X86_64 368 depends on X86_64
369 depends on X86_EXTENDED_PLATFORM 369 depends on X86_EXTENDED_PLATFORM
370 depends on NUMA 370 depends on NUMA
371 depends on X86_X2APIC 371 depends on X86_X2APIC
372 ---help--- 372 ---help---
373 This option is needed in order to support SGI Ultraviolet systems. 373 This option is needed in order to support SGI Ultraviolet systems.
374 If you don't have one of these, you should say N here. 374 If you don't have one of these, you should say N here.
375 375
376 # Following is an alphabetically sorted list of 32 bit extended platforms 376 # Following is an alphabetically sorted list of 32 bit extended platforms
377 # Please maintain the alphabetic order if and when there are additions 377 # Please maintain the alphabetic order if and when there are additions
378 378
379 config X86_INTEL_CE 379 config X86_INTEL_CE
380 bool "CE4100 TV platform" 380 bool "CE4100 TV platform"
381 depends on PCI 381 depends on PCI
382 depends on PCI_GODIRECT 382 depends on PCI_GODIRECT
383 depends on X86_32 383 depends on X86_32
384 depends on X86_EXTENDED_PLATFORM 384 depends on X86_EXTENDED_PLATFORM
385 select X86_REBOOTFIXUPS 385 select X86_REBOOTFIXUPS
386 select OF 386 select OF
387 select OF_EARLY_FLATTREE 387 select OF_EARLY_FLATTREE
388 ---help--- 388 ---help---
389 Select for the Intel CE media processor (CE4100) SOC. 389 Select for the Intel CE media processor (CE4100) SOC.
390 This option compiles in support for the CE4100 SOC for settop 390 This option compiles in support for the CE4100 SOC for settop
391 boxes and media devices. 391 boxes and media devices.
392 392
393 config X86_INTEL_MID 393 config X86_WANT_INTEL_MID
394 bool "Intel MID platform support" 394 bool "Intel MID platform support"
395 depends on X86_32 395 depends on X86_32
396 depends on X86_EXTENDED_PLATFORM 396 depends on X86_EXTENDED_PLATFORM
397 ---help--- 397 ---help---
398 Select to build a kernel capable of supporting Intel MID platform 398 Select to build a kernel capable of supporting Intel MID platform
399 systems which do not have the PCI legacy interfaces (Moorestown, 399 systems which do not have the PCI legacy interfaces (Moorestown,
400 Medfield). If you are building for a PC class system say N here. 400 Medfield). If you are building for a PC class system say N here.
401 401
402 if X86_INTEL_MID 402 if X86_WANT_INTEL_MID
403 403
404 config X86_INTEL_MID
405 bool
406
404 config X86_MRST 407 config X86_MRST
405 bool "Moorestown MID platform" 408 bool "Moorestown MID platform"
406 depends on PCI 409 depends on PCI
407 depends on PCI_GOANY 410 depends on PCI_GOANY
408 depends on X86_IO_APIC 411 depends on X86_IO_APIC
409 select APB_TIMER 412 select APB_TIMER
410 select I2C 413 select I2C
411 select SPI 414 select SPI
412 select INTEL_SCU_IPC 415 select INTEL_SCU_IPC
413 select X86_PLATFORM_DEVICES 416 select X86_PLATFORM_DEVICES
417 select X86_INTEL_MID
414 ---help--- 418 ---help---
415 Moorestown is Intel's Low Power Intel Architecture (LPIA) based Moblin 419 Moorestown is Intel's Low Power Intel Architecture (LPIA) based Moblin
416 Internet Device(MID) platform. Moorestown consists of two chips: 420 Internet Device(MID) platform. Moorestown consists of two chips:
417 Lincroft (CPU core, graphics, and memory controller) and Langwell IOH. 421 Lincroft (CPU core, graphics, and memory controller) and Langwell IOH.
418 Unlike standard x86 PCs, Moorestown does not have many legacy devices 422 Unlike standard x86 PCs, Moorestown does not have many legacy devices
419 nor standard legacy replacement devices/features. e.g. Moorestown does 423 nor standard legacy replacement devices/features. e.g. Moorestown does
420 not contain i8259, i8254, HPET, legacy BIOS, most of the io ports. 424 not contain i8259, i8254, HPET, legacy BIOS, most of the io ports.
421 425
422 endif 426 endif
423 427
424 config X86_RDC321X 428 config X86_RDC321X
425 bool "RDC R-321x SoC" 429 bool "RDC R-321x SoC"
426 depends on X86_32 430 depends on X86_32
427 depends on X86_EXTENDED_PLATFORM 431 depends on X86_EXTENDED_PLATFORM
428 select M486 432 select M486
429 select X86_REBOOTFIXUPS 433 select X86_REBOOTFIXUPS
430 ---help--- 434 ---help---
431 This option is needed for RDC R-321x system-on-chip, also known 435 This option is needed for RDC R-321x system-on-chip, also known
432 as R-8610-(G). 436 as R-8610-(G).
433 If you don't have one of these chips, you should say N here. 437 If you don't have one of these chips, you should say N here.
434 438
435 config X86_32_NON_STANDARD 439 config X86_32_NON_STANDARD
436 bool "Support non-standard 32-bit SMP architectures" 440 bool "Support non-standard 32-bit SMP architectures"
437 depends on X86_32 && SMP 441 depends on X86_32 && SMP
438 depends on X86_EXTENDED_PLATFORM 442 depends on X86_EXTENDED_PLATFORM
439 ---help--- 443 ---help---
440 This option compiles in the NUMAQ, Summit, bigsmp, ES7000, default 444 This option compiles in the NUMAQ, Summit, bigsmp, ES7000, default
441 subarchitectures. It is intended for a generic binary kernel. 445 subarchitectures. It is intended for a generic binary kernel.
442 if you select them all, kernel will probe it one by one. and will 446 if you select them all, kernel will probe it one by one. and will
443 fallback to default. 447 fallback to default.
444 448
445 # Alphabetically sorted list of Non standard 32 bit platforms 449 # Alphabetically sorted list of Non standard 32 bit platforms
446 450
447 config X86_NUMAQ 451 config X86_NUMAQ
448 bool "NUMAQ (IBM/Sequent)" 452 bool "NUMAQ (IBM/Sequent)"
449 depends on X86_32_NON_STANDARD 453 depends on X86_32_NON_STANDARD
450 depends on PCI 454 depends on PCI
451 select NUMA 455 select NUMA
452 select X86_MPPARSE 456 select X86_MPPARSE
453 ---help--- 457 ---help---
454 This option is used for getting Linux to run on a NUMAQ (IBM/Sequent) 458 This option is used for getting Linux to run on a NUMAQ (IBM/Sequent)
455 NUMA multiquad box. This changes the way that processors are 459 NUMA multiquad box. This changes the way that processors are
456 bootstrapped, and uses Clustered Logical APIC addressing mode instead 460 bootstrapped, and uses Clustered Logical APIC addressing mode instead
457 of Flat Logical. You will need a new lynxer.elf file to flash your 461 of Flat Logical. You will need a new lynxer.elf file to flash your
458 firmware with - send email to <Martin.Bligh@us.ibm.com>. 462 firmware with - send email to <Martin.Bligh@us.ibm.com>.
459 463
460 config X86_SUPPORTS_MEMORY_FAILURE 464 config X86_SUPPORTS_MEMORY_FAILURE
461 def_bool y 465 def_bool y
462 # MCE code calls memory_failure(): 466 # MCE code calls memory_failure():
463 depends on X86_MCE 467 depends on X86_MCE
464 # On 32-bit this adds too big of NODES_SHIFT and we run out of page flags: 468 # On 32-bit this adds too big of NODES_SHIFT and we run out of page flags:
465 depends on !X86_NUMAQ 469 depends on !X86_NUMAQ
466 # On 32-bit SPARSEMEM adds too big of SECTIONS_WIDTH: 470 # On 32-bit SPARSEMEM adds too big of SECTIONS_WIDTH:
467 depends on X86_64 || !SPARSEMEM 471 depends on X86_64 || !SPARSEMEM
468 select ARCH_SUPPORTS_MEMORY_FAILURE 472 select ARCH_SUPPORTS_MEMORY_FAILURE
469 473
470 config X86_VISWS 474 config X86_VISWS
471 bool "SGI 320/540 (Visual Workstation)" 475 bool "SGI 320/540 (Visual Workstation)"
472 depends on X86_32 && PCI && X86_MPPARSE && PCI_GODIRECT 476 depends on X86_32 && PCI && X86_MPPARSE && PCI_GODIRECT
473 depends on X86_32_NON_STANDARD 477 depends on X86_32_NON_STANDARD
474 ---help--- 478 ---help---
475 The SGI Visual Workstation series is an IA32-based workstation 479 The SGI Visual Workstation series is an IA32-based workstation
476 based on SGI systems chips with some legacy PC hardware attached. 480 based on SGI systems chips with some legacy PC hardware attached.
477 481
478 Say Y here to create a kernel to run on the SGI 320 or 540. 482 Say Y here to create a kernel to run on the SGI 320 or 540.
479 483
480 A kernel compiled for the Visual Workstation will run on general 484 A kernel compiled for the Visual Workstation will run on general
481 PCs as well. See <file:Documentation/sgi-visws.txt> for details. 485 PCs as well. See <file:Documentation/sgi-visws.txt> for details.
482 486
483 config X86_SUMMIT 487 config X86_SUMMIT
484 bool "Summit/EXA (IBM x440)" 488 bool "Summit/EXA (IBM x440)"
485 depends on X86_32_NON_STANDARD 489 depends on X86_32_NON_STANDARD
486 ---help--- 490 ---help---
487 This option is needed for IBM systems that use the Summit/EXA chipset. 491 This option is needed for IBM systems that use the Summit/EXA chipset.
488 In particular, it is needed for the x440. 492 In particular, it is needed for the x440.
489 493
490 config X86_ES7000 494 config X86_ES7000
491 bool "Unisys ES7000 IA32 series" 495 bool "Unisys ES7000 IA32 series"
492 depends on X86_32_NON_STANDARD && X86_BIGSMP 496 depends on X86_32_NON_STANDARD && X86_BIGSMP
493 ---help--- 497 ---help---
494 Support for Unisys ES7000 systems. Say 'Y' here if this kernel is 498 Support for Unisys ES7000 systems. Say 'Y' here if this kernel is
495 supposed to run on an IA32-based Unisys ES7000 system. 499 supposed to run on an IA32-based Unisys ES7000 system.
496 500
497 config X86_32_IRIS 501 config X86_32_IRIS
498 tristate "Eurobraille/Iris poweroff module" 502 tristate "Eurobraille/Iris poweroff module"
499 depends on X86_32 503 depends on X86_32
500 ---help--- 504 ---help---
501 The Iris machines from EuroBraille do not have APM or ACPI support 505 The Iris machines from EuroBraille do not have APM or ACPI support
502 to shut themselves down properly. A special I/O sequence is 506 to shut themselves down properly. A special I/O sequence is
503 needed to do so, which is what this module does at 507 needed to do so, which is what this module does at
504 kernel shutdown. 508 kernel shutdown.
505 509
506 This is only for Iris machines from EuroBraille. 510 This is only for Iris machines from EuroBraille.
507 511
508 If unused, say N. 512 If unused, say N.
509 513
510 config SCHED_OMIT_FRAME_POINTER 514 config SCHED_OMIT_FRAME_POINTER
511 def_bool y 515 def_bool y
512 prompt "Single-depth WCHAN output" 516 prompt "Single-depth WCHAN output"
513 depends on X86 517 depends on X86
514 ---help--- 518 ---help---
515 Calculate simpler /proc/<PID>/wchan values. If this option 519 Calculate simpler /proc/<PID>/wchan values. If this option
516 is disabled then wchan values will recurse back to the 520 is disabled then wchan values will recurse back to the
517 caller function. This provides more accurate wchan values, 521 caller function. This provides more accurate wchan values,
518 at the expense of slightly more scheduling overhead. 522 at the expense of slightly more scheduling overhead.
519 523
520 If in doubt, say "Y". 524 If in doubt, say "Y".
521 525
522 menuconfig PARAVIRT_GUEST 526 menuconfig PARAVIRT_GUEST
523 bool "Paravirtualized guest support" 527 bool "Paravirtualized guest support"
524 ---help--- 528 ---help---
525 Say Y here to get to see options related to running Linux under 529 Say Y here to get to see options related to running Linux under
526 various hypervisors. This option alone does not add any kernel code. 530 various hypervisors. This option alone does not add any kernel code.
527 531
528 If you say N, all options in this submenu will be skipped and disabled. 532 If you say N, all options in this submenu will be skipped and disabled.
529 533
530 if PARAVIRT_GUEST 534 if PARAVIRT_GUEST
531 535
532 config PARAVIRT_TIME_ACCOUNTING 536 config PARAVIRT_TIME_ACCOUNTING
533 bool "Paravirtual steal time accounting" 537 bool "Paravirtual steal time accounting"
534 select PARAVIRT 538 select PARAVIRT
535 default n 539 default n
536 ---help--- 540 ---help---
537 Select this option to enable fine granularity task steal time 541 Select this option to enable fine granularity task steal time
538 accounting. Time spent executing other tasks in parallel with 542 accounting. Time spent executing other tasks in parallel with
539 the current vCPU is discounted from the vCPU power. To account for 543 the current vCPU is discounted from the vCPU power. To account for
540 that, there can be a small performance impact. 544 that, there can be a small performance impact.
541 545
542 If in doubt, say N here. 546 If in doubt, say N here.
543 547
544 source "arch/x86/xen/Kconfig" 548 source "arch/x86/xen/Kconfig"
545 549
546 config KVM_CLOCK 550 config KVM_CLOCK
547 bool "KVM paravirtualized clock" 551 bool "KVM paravirtualized clock"
548 select PARAVIRT 552 select PARAVIRT
549 select PARAVIRT_CLOCK 553 select PARAVIRT_CLOCK
550 ---help--- 554 ---help---
551 Turning on this option will allow you to run a paravirtualized clock 555 Turning on this option will allow you to run a paravirtualized clock
552 when running over the KVM hypervisor. Instead of relying on a PIT 556 when running over the KVM hypervisor. Instead of relying on a PIT
553 (or probably other) emulation by the underlying device model, the host 557 (or probably other) emulation by the underlying device model, the host
554 provides the guest with timing infrastructure such as time of day, and 558 provides the guest with timing infrastructure such as time of day, and
555 system time 559 system time
556 560
557 config KVM_GUEST 561 config KVM_GUEST
558 bool "KVM Guest support" 562 bool "KVM Guest support"
559 select PARAVIRT 563 select PARAVIRT
560 ---help--- 564 ---help---
561 This option enables various optimizations for running under the KVM 565 This option enables various optimizations for running under the KVM
562 hypervisor. 566 hypervisor.
563 567
564 source "arch/x86/lguest/Kconfig" 568 source "arch/x86/lguest/Kconfig"
565 569
566 config PARAVIRT 570 config PARAVIRT
567 bool "Enable paravirtualization code" 571 bool "Enable paravirtualization code"
568 ---help--- 572 ---help---
569 This changes the kernel so it can modify itself when it is run 573 This changes the kernel so it can modify itself when it is run
570 under a hypervisor, potentially improving performance significantly 574 under a hypervisor, potentially improving performance significantly
571 over full virtualization. However, when run without a hypervisor 575 over full virtualization. However, when run without a hypervisor
572 the kernel is theoretically slower and slightly larger. 576 the kernel is theoretically slower and slightly larger.
573 577
574 config PARAVIRT_SPINLOCKS 578 config PARAVIRT_SPINLOCKS
575 bool "Paravirtualization layer for spinlocks" 579 bool "Paravirtualization layer for spinlocks"
576 depends on PARAVIRT && SMP && EXPERIMENTAL 580 depends on PARAVIRT && SMP && EXPERIMENTAL
577 ---help--- 581 ---help---
578 Paravirtualized spinlocks allow a pvops backend to replace the 582 Paravirtualized spinlocks allow a pvops backend to replace the
579 spinlock implementation with something virtualization-friendly 583 spinlock implementation with something virtualization-friendly
580 (for example, block the virtual CPU rather than spinning). 584 (for example, block the virtual CPU rather than spinning).
581 585
582 Unfortunately the downside is an up to 5% performance hit on 586 Unfortunately the downside is an up to 5% performance hit on
583 native kernels, with various workloads. 587 native kernels, with various workloads.
584 588
585 If you are unsure how to answer this question, answer N. 589 If you are unsure how to answer this question, answer N.
586 590
587 config PARAVIRT_CLOCK 591 config PARAVIRT_CLOCK
588 bool 592 bool
589 593
590 endif 594 endif
591 595
592 config PARAVIRT_DEBUG 596 config PARAVIRT_DEBUG
593 bool "paravirt-ops debugging" 597 bool "paravirt-ops debugging"
594 depends on PARAVIRT && DEBUG_KERNEL 598 depends on PARAVIRT && DEBUG_KERNEL
595 ---help--- 599 ---help---
596 Enable to debug paravirt_ops internals. Specifically, BUG if 600 Enable to debug paravirt_ops internals. Specifically, BUG if
597 a paravirt_op is missing when it is called. 601 a paravirt_op is missing when it is called.
598 602
599 config NO_BOOTMEM 603 config NO_BOOTMEM
600 def_bool y 604 def_bool y
601 605
602 config MEMTEST 606 config MEMTEST
603 bool "Memtest" 607 bool "Memtest"
604 ---help--- 608 ---help---
605 This option adds a kernel parameter 'memtest', which allows memtest 609 This option adds a kernel parameter 'memtest', which allows memtest
606 to be set. 610 to be set.
607 memtest=0, mean disabled; -- default 611 memtest=0, mean disabled; -- default
608 memtest=1, mean do 1 test pattern; 612 memtest=1, mean do 1 test pattern;
609 ... 613 ...
610 memtest=4, mean do 4 test patterns. 614 memtest=4, mean do 4 test patterns.
611 If you are unsure how to answer this question, answer N. 615 If you are unsure how to answer this question, answer N.
612 616
613 config X86_SUMMIT_NUMA 617 config X86_SUMMIT_NUMA
614 def_bool y 618 def_bool y
615 depends on X86_32 && NUMA && X86_32_NON_STANDARD 619 depends on X86_32 && NUMA && X86_32_NON_STANDARD
616 620
617 config X86_CYCLONE_TIMER 621 config X86_CYCLONE_TIMER
618 def_bool y 622 def_bool y
619 depends on X86_32_NON_STANDARD 623 depends on X86_32_NON_STANDARD
620 624
621 source "arch/x86/Kconfig.cpu" 625 source "arch/x86/Kconfig.cpu"
622 626
623 config HPET_TIMER 627 config HPET_TIMER
624 def_bool X86_64 628 def_bool X86_64
625 prompt "HPET Timer Support" if X86_32 629 prompt "HPET Timer Support" if X86_32
626 ---help--- 630 ---help---
627 Use the IA-PC HPET (High Precision Event Timer) to manage 631 Use the IA-PC HPET (High Precision Event Timer) to manage
628 time in preference to the PIT and RTC, if a HPET is 632 time in preference to the PIT and RTC, if a HPET is
629 present. 633 present.
630 HPET is the next generation timer replacing legacy 8254s. 634 HPET is the next generation timer replacing legacy 8254s.
631 The HPET provides a stable time base on SMP 635 The HPET provides a stable time base on SMP
632 systems, unlike the TSC, but it is more expensive to access, 636 systems, unlike the TSC, but it is more expensive to access,
633 as it is off-chip. You can find the HPET spec at 637 as it is off-chip. You can find the HPET spec at
634 <http://www.intel.com/hardwaredesign/hpetspec_1.pdf>. 638 <http://www.intel.com/hardwaredesign/hpetspec_1.pdf>.
635 639
636 You can safely choose Y here. However, HPET will only be 640 You can safely choose Y here. However, HPET will only be
637 activated if the platform and the BIOS support this feature. 641 activated if the platform and the BIOS support this feature.
638 Otherwise the 8254 will be used for timing services. 642 Otherwise the 8254 will be used for timing services.
639 643
640 Choose N to continue using the legacy 8254 timer. 644 Choose N to continue using the legacy 8254 timer.
641 645
642 config HPET_EMULATE_RTC 646 config HPET_EMULATE_RTC
643 def_bool y 647 def_bool y
644 depends on HPET_TIMER && (RTC=y || RTC=m || RTC_DRV_CMOS=m || RTC_DRV_CMOS=y) 648 depends on HPET_TIMER && (RTC=y || RTC=m || RTC_DRV_CMOS=m || RTC_DRV_CMOS=y)
645 649
646 config APB_TIMER 650 config APB_TIMER
647 def_bool y if MRST 651 def_bool y if MRST
648 prompt "Langwell APB Timer Support" if X86_MRST 652 prompt "Langwell APB Timer Support" if X86_MRST
649 select DW_APB_TIMER 653 select DW_APB_TIMER
650 help 654 help
651 APB timer is the replacement for 8254, HPET on X86 MID platforms. 655 APB timer is the replacement for 8254, HPET on X86 MID platforms.
652 The APBT provides a stable time base on SMP 656 The APBT provides a stable time base on SMP
653 systems, unlike the TSC, but it is more expensive to access, 657 systems, unlike the TSC, but it is more expensive to access,
654 as it is off-chip. APB timers are always running regardless of CPU 658 as it is off-chip. APB timers are always running regardless of CPU
655 C states, they are used as per CPU clockevent device when possible. 659 C states, they are used as per CPU clockevent device when possible.
656 660
657 # Mark as expert because too many people got it wrong. 661 # Mark as expert because too many people got it wrong.
658 # The code disables itself when not needed. 662 # The code disables itself when not needed.
659 config DMI 663 config DMI
660 default y 664 default y
661 bool "Enable DMI scanning" if EXPERT 665 bool "Enable DMI scanning" if EXPERT
662 ---help--- 666 ---help---
663 Enabled scanning of DMI to identify machine quirks. Say Y 667 Enabled scanning of DMI to identify machine quirks. Say Y
664 here unless you have verified that your setup is not 668 here unless you have verified that your setup is not
665 affected by entries in the DMI blacklist. Required by PNP 669 affected by entries in the DMI blacklist. Required by PNP
666 BIOS code. 670 BIOS code.
667 671
668 config GART_IOMMU 672 config GART_IOMMU
669 bool "GART IOMMU support" if EXPERT 673 bool "GART IOMMU support" if EXPERT
670 default y 674 default y
671 select SWIOTLB 675 select SWIOTLB
672 depends on X86_64 && PCI && AMD_NB 676 depends on X86_64 && PCI && AMD_NB
673 ---help--- 677 ---help---
674 Support for full DMA access of devices with 32bit memory access only 678 Support for full DMA access of devices with 32bit memory access only
675 on systems with more than 3GB. This is usually needed for USB, 679 on systems with more than 3GB. This is usually needed for USB,
676 sound, many IDE/SATA chipsets and some other devices. 680 sound, many IDE/SATA chipsets and some other devices.
677 Provides a driver for the AMD Athlon64/Opteron/Turion/Sempron GART 681 Provides a driver for the AMD Athlon64/Opteron/Turion/Sempron GART
678 based hardware IOMMU and a software bounce buffer based IOMMU used 682 based hardware IOMMU and a software bounce buffer based IOMMU used
679 on Intel systems and as fallback. 683 on Intel systems and as fallback.
680 The code is only active when needed (enough memory and limited 684 The code is only active when needed (enough memory and limited
681 device) unless CONFIG_IOMMU_DEBUG or iommu=force is specified 685 device) unless CONFIG_IOMMU_DEBUG or iommu=force is specified
682 too. 686 too.
683 687
684 config CALGARY_IOMMU 688 config CALGARY_IOMMU
685 bool "IBM Calgary IOMMU support" 689 bool "IBM Calgary IOMMU support"
686 select SWIOTLB 690 select SWIOTLB
687 depends on X86_64 && PCI && EXPERIMENTAL 691 depends on X86_64 && PCI && EXPERIMENTAL
688 ---help--- 692 ---help---
689 Support for hardware IOMMUs in IBM's xSeries x366 and x460 693 Support for hardware IOMMUs in IBM's xSeries x366 and x460
690 systems. Needed to run systems with more than 3GB of memory 694 systems. Needed to run systems with more than 3GB of memory
691 properly with 32-bit PCI devices that do not support DAC 695 properly with 32-bit PCI devices that do not support DAC
692 (Double Address Cycle). Calgary also supports bus level 696 (Double Address Cycle). Calgary also supports bus level
693 isolation, where all DMAs pass through the IOMMU. This 697 isolation, where all DMAs pass through the IOMMU. This
694 prevents them from going anywhere except their intended 698 prevents them from going anywhere except their intended
695 destination. This catches hard-to-find kernel bugs and 699 destination. This catches hard-to-find kernel bugs and
696 mis-behaving drivers and devices that do not use the DMA-API 700 mis-behaving drivers and devices that do not use the DMA-API
697 properly to set up their DMA buffers. The IOMMU can be 701 properly to set up their DMA buffers. The IOMMU can be
698 turned off at boot time with the iommu=off parameter. 702 turned off at boot time with the iommu=off parameter.
699 Normally the kernel will make the right choice by itself. 703 Normally the kernel will make the right choice by itself.
700 If unsure, say Y. 704 If unsure, say Y.
701 705
702 config CALGARY_IOMMU_ENABLED_BY_DEFAULT 706 config CALGARY_IOMMU_ENABLED_BY_DEFAULT
703 def_bool y 707 def_bool y
704 prompt "Should Calgary be enabled by default?" 708 prompt "Should Calgary be enabled by default?"
705 depends on CALGARY_IOMMU 709 depends on CALGARY_IOMMU
706 ---help--- 710 ---help---
707 Should Calgary be enabled by default? if you choose 'y', Calgary 711 Should Calgary be enabled by default? if you choose 'y', Calgary
708 will be used (if it exists). If you choose 'n', Calgary will not be 712 will be used (if it exists). If you choose 'n', Calgary will not be
709 used even if it exists. If you choose 'n' and would like to use 713 used even if it exists. If you choose 'n' and would like to use
710 Calgary anyway, pass 'iommu=calgary' on the kernel command line. 714 Calgary anyway, pass 'iommu=calgary' on the kernel command line.
711 If unsure, say Y. 715 If unsure, say Y.
712 716
713 # need this always selected by IOMMU for the VIA workaround 717 # need this always selected by IOMMU for the VIA workaround
714 config SWIOTLB 718 config SWIOTLB
715 def_bool y if X86_64 719 def_bool y if X86_64
716 ---help--- 720 ---help---
717 Support for software bounce buffers used on x86-64 systems 721 Support for software bounce buffers used on x86-64 systems
718 which don't have a hardware IOMMU (e.g. the current generation 722 which don't have a hardware IOMMU (e.g. the current generation
719 of Intel's x86-64 CPUs). Using this PCI devices which can only 723 of Intel's x86-64 CPUs). Using this PCI devices which can only
720 access 32-bits of memory can be used on systems with more than 724 access 32-bits of memory can be used on systems with more than
721 3 GB of memory. If unsure, say Y. 725 3 GB of memory. If unsure, say Y.
722 726
723 config IOMMU_HELPER 727 config IOMMU_HELPER
724 def_bool (CALGARY_IOMMU || GART_IOMMU || SWIOTLB || AMD_IOMMU) 728 def_bool (CALGARY_IOMMU || GART_IOMMU || SWIOTLB || AMD_IOMMU)
725 729
726 config MAXSMP 730 config MAXSMP
727 bool "Enable Maximum number of SMP Processors and NUMA Nodes" 731 bool "Enable Maximum number of SMP Processors and NUMA Nodes"
728 depends on X86_64 && SMP && DEBUG_KERNEL && EXPERIMENTAL 732 depends on X86_64 && SMP && DEBUG_KERNEL && EXPERIMENTAL
729 select CPUMASK_OFFSTACK 733 select CPUMASK_OFFSTACK
730 ---help--- 734 ---help---
731 Enable maximum number of CPUS and NUMA Nodes for this architecture. 735 Enable maximum number of CPUS and NUMA Nodes for this architecture.
732 If unsure, say N. 736 If unsure, say N.
733 737
734 config NR_CPUS 738 config NR_CPUS
735 int "Maximum number of CPUs" if SMP && !MAXSMP 739 int "Maximum number of CPUs" if SMP && !MAXSMP
736 range 2 8 if SMP && X86_32 && !X86_BIGSMP 740 range 2 8 if SMP && X86_32 && !X86_BIGSMP
737 range 2 512 if SMP && !MAXSMP 741 range 2 512 if SMP && !MAXSMP
738 default "1" if !SMP 742 default "1" if !SMP
739 default "4096" if MAXSMP 743 default "4096" if MAXSMP
740 default "32" if SMP && (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000) 744 default "32" if SMP && (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000)
741 default "8" if SMP 745 default "8" if SMP
742 ---help--- 746 ---help---
743 This allows you to specify the maximum number of CPUs which this 747 This allows you to specify the maximum number of CPUs which this
744 kernel will support. The maximum supported value is 512 and the 748 kernel will support. The maximum supported value is 512 and the
745 minimum value which makes sense is 2. 749 minimum value which makes sense is 2.
746 750
747 This is purely to save memory - each supported CPU adds 751 This is purely to save memory - each supported CPU adds
748 approximately eight kilobytes to the kernel image. 752 approximately eight kilobytes to the kernel image.
749 753
750 config SCHED_SMT 754 config SCHED_SMT
751 bool "SMT (Hyperthreading) scheduler support" 755 bool "SMT (Hyperthreading) scheduler support"
752 depends on X86_HT 756 depends on X86_HT
753 ---help--- 757 ---help---
754 SMT scheduler support improves the CPU scheduler's decision making 758 SMT scheduler support improves the CPU scheduler's decision making
755 when dealing with Intel Pentium 4 chips with HyperThreading at a 759 when dealing with Intel Pentium 4 chips with HyperThreading at a
756 cost of slightly increased overhead in some places. If unsure say 760 cost of slightly increased overhead in some places. If unsure say
757 N here. 761 N here.
758 762
759 config SCHED_MC 763 config SCHED_MC
760 def_bool y 764 def_bool y
761 prompt "Multi-core scheduler support" 765 prompt "Multi-core scheduler support"
762 depends on X86_HT 766 depends on X86_HT
763 ---help--- 767 ---help---
764 Multi-core scheduler support improves the CPU scheduler's decision 768 Multi-core scheduler support improves the CPU scheduler's decision
765 making when dealing with multi-core CPU chips at a cost of slightly 769 making when dealing with multi-core CPU chips at a cost of slightly
766 increased overhead in some places. If unsure say N here. 770 increased overhead in some places. If unsure say N here.
767 771
768 config IRQ_TIME_ACCOUNTING 772 config IRQ_TIME_ACCOUNTING
769 bool "Fine granularity task level IRQ time accounting" 773 bool "Fine granularity task level IRQ time accounting"
770 default n 774 default n
771 ---help--- 775 ---help---
772 Select this option to enable fine granularity task irq time 776 Select this option to enable fine granularity task irq time
773 accounting. This is done by reading a timestamp on each 777 accounting. This is done by reading a timestamp on each
774 transitions between softirq and hardirq state, so there can be a 778 transitions between softirq and hardirq state, so there can be a
775 small performance impact. 779 small performance impact.
776 780
777 If in doubt, say N here. 781 If in doubt, say N here.
778 782
779 source "kernel/Kconfig.preempt" 783 source "kernel/Kconfig.preempt"
780 784
781 config X86_UP_APIC 785 config X86_UP_APIC
782 bool "Local APIC support on uniprocessors" 786 bool "Local APIC support on uniprocessors"
783 depends on X86_32 && !SMP && !X86_32_NON_STANDARD 787 depends on X86_32 && !SMP && !X86_32_NON_STANDARD
784 ---help--- 788 ---help---
785 A local APIC (Advanced Programmable Interrupt Controller) is an 789 A local APIC (Advanced Programmable Interrupt Controller) is an
786 integrated interrupt controller in the CPU. If you have a single-CPU 790 integrated interrupt controller in the CPU. If you have a single-CPU
787 system which has a processor with a local APIC, you can say Y here to 791 system which has a processor with a local APIC, you can say Y here to
788 enable and use it. If you say Y here even though your machine doesn't 792 enable and use it. If you say Y here even though your machine doesn't
789 have a local APIC, then the kernel will still run with no slowdown at 793 have a local APIC, then the kernel will still run with no slowdown at
790 all. The local APIC supports CPU-generated self-interrupts (timer, 794 all. The local APIC supports CPU-generated self-interrupts (timer,
791 performance counters), and the NMI watchdog which detects hard 795 performance counters), and the NMI watchdog which detects hard
792 lockups. 796 lockups.
793 797
794 config X86_UP_IOAPIC 798 config X86_UP_IOAPIC
795 bool "IO-APIC support on uniprocessors" 799 bool "IO-APIC support on uniprocessors"
796 depends on X86_UP_APIC 800 depends on X86_UP_APIC
797 ---help--- 801 ---help---
798 An IO-APIC (I/O Advanced Programmable Interrupt Controller) is an 802 An IO-APIC (I/O Advanced Programmable Interrupt Controller) is an
799 SMP-capable replacement for PC-style interrupt controllers. Most 803 SMP-capable replacement for PC-style interrupt controllers. Most
800 SMP systems and many recent uniprocessor systems have one. 804 SMP systems and many recent uniprocessor systems have one.
801 805
802 If you have a single-CPU system with an IO-APIC, you can say Y here 806 If you have a single-CPU system with an IO-APIC, you can say Y here
803 to use it. If you say Y here even though your machine doesn't have 807 to use it. If you say Y here even though your machine doesn't have
804 an IO-APIC, then the kernel will still run with no slowdown at all. 808 an IO-APIC, then the kernel will still run with no slowdown at all.
805 809
806 config X86_LOCAL_APIC 810 config X86_LOCAL_APIC
807 def_bool y 811 def_bool y
808 depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_APIC 812 depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_APIC
809 813
810 config X86_IO_APIC 814 config X86_IO_APIC
811 def_bool y 815 def_bool y
812 depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_IOAPIC 816 depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_IOAPIC
813 817
814 config X86_VISWS_APIC 818 config X86_VISWS_APIC
815 def_bool y 819 def_bool y
816 depends on X86_32 && X86_VISWS 820 depends on X86_32 && X86_VISWS
817 821
818 config X86_REROUTE_FOR_BROKEN_BOOT_IRQS 822 config X86_REROUTE_FOR_BROKEN_BOOT_IRQS
819 bool "Reroute for broken boot IRQs" 823 bool "Reroute for broken boot IRQs"
820 depends on X86_IO_APIC 824 depends on X86_IO_APIC
821 ---help--- 825 ---help---
822 This option enables a workaround that fixes a source of 826 This option enables a workaround that fixes a source of
823 spurious interrupts. This is recommended when threaded 827 spurious interrupts. This is recommended when threaded
824 interrupt handling is used on systems where the generation of 828 interrupt handling is used on systems where the generation of
825 superfluous "boot interrupts" cannot be disabled. 829 superfluous "boot interrupts" cannot be disabled.
826 830
827 Some chipsets generate a legacy INTx "boot IRQ" when the IRQ 831 Some chipsets generate a legacy INTx "boot IRQ" when the IRQ
828 entry in the chipset's IO-APIC is masked (as, e.g. the RT 832 entry in the chipset's IO-APIC is masked (as, e.g. the RT
829 kernel does during interrupt handling). On chipsets where this 833 kernel does during interrupt handling). On chipsets where this
830 boot IRQ generation cannot be disabled, this workaround keeps 834 boot IRQ generation cannot be disabled, this workaround keeps
831 the original IRQ line masked so that only the equivalent "boot 835 the original IRQ line masked so that only the equivalent "boot
832 IRQ" is delivered to the CPUs. The workaround also tells the 836 IRQ" is delivered to the CPUs. The workaround also tells the
833 kernel to set up the IRQ handler on the boot IRQ line. In this 837 kernel to set up the IRQ handler on the boot IRQ line. In this
834 way only one interrupt is delivered to the kernel. Otherwise 838 way only one interrupt is delivered to the kernel. Otherwise
835 the spurious second interrupt may cause the kernel to bring 839 the spurious second interrupt may cause the kernel to bring
836 down (vital) interrupt lines. 840 down (vital) interrupt lines.
837 841
838 Only affects "broken" chipsets. Interrupt sharing may be 842 Only affects "broken" chipsets. Interrupt sharing may be
839 increased on these systems. 843 increased on these systems.
840 844
841 config X86_MCE 845 config X86_MCE
842 bool "Machine Check / overheating reporting" 846 bool "Machine Check / overheating reporting"
843 ---help--- 847 ---help---
844 Machine Check support allows the processor to notify the 848 Machine Check support allows the processor to notify the
845 kernel if it detects a problem (e.g. overheating, data corruption). 849 kernel if it detects a problem (e.g. overheating, data corruption).
846 The action the kernel takes depends on the severity of the problem, 850 The action the kernel takes depends on the severity of the problem,
847 ranging from warning messages to halting the machine. 851 ranging from warning messages to halting the machine.
848 852
849 config X86_MCE_INTEL 853 config X86_MCE_INTEL
850 def_bool y 854 def_bool y
851 prompt "Intel MCE features" 855 prompt "Intel MCE features"
852 depends on X86_MCE && X86_LOCAL_APIC 856 depends on X86_MCE && X86_LOCAL_APIC
853 ---help--- 857 ---help---
854 Additional support for intel specific MCE features such as 858 Additional support for intel specific MCE features such as
855 the thermal monitor. 859 the thermal monitor.
856 860
857 config X86_MCE_AMD 861 config X86_MCE_AMD
858 def_bool y 862 def_bool y
859 prompt "AMD MCE features" 863 prompt "AMD MCE features"
860 depends on X86_MCE && X86_LOCAL_APIC 864 depends on X86_MCE && X86_LOCAL_APIC
861 ---help--- 865 ---help---
862 Additional support for AMD specific MCE features such as 866 Additional support for AMD specific MCE features such as
863 the DRAM Error Threshold. 867 the DRAM Error Threshold.
864 868
865 config X86_ANCIENT_MCE 869 config X86_ANCIENT_MCE
866 bool "Support for old Pentium 5 / WinChip machine checks" 870 bool "Support for old Pentium 5 / WinChip machine checks"
867 depends on X86_32 && X86_MCE 871 depends on X86_32 && X86_MCE
868 ---help--- 872 ---help---
869 Include support for machine check handling on old Pentium 5 or WinChip 873 Include support for machine check handling on old Pentium 5 or WinChip
870 systems. These typically need to be enabled explicitely on the command 874 systems. These typically need to be enabled explicitely on the command
871 line. 875 line.
872 876
873 config X86_MCE_THRESHOLD 877 config X86_MCE_THRESHOLD
874 depends on X86_MCE_AMD || X86_MCE_INTEL 878 depends on X86_MCE_AMD || X86_MCE_INTEL
875 def_bool y 879 def_bool y
876 880
877 config X86_MCE_INJECT 881 config X86_MCE_INJECT
878 depends on X86_MCE 882 depends on X86_MCE
879 tristate "Machine check injector support" 883 tristate "Machine check injector support"
880 ---help--- 884 ---help---
881 Provide support for injecting machine checks for testing purposes. 885 Provide support for injecting machine checks for testing purposes.
882 If you don't know what a machine check is and you don't do kernel 886 If you don't know what a machine check is and you don't do kernel
883 QA it is safe to say n. 887 QA it is safe to say n.
884 888
885 config X86_THERMAL_VECTOR 889 config X86_THERMAL_VECTOR
886 def_bool y 890 def_bool y
887 depends on X86_MCE_INTEL 891 depends on X86_MCE_INTEL
888 892
889 config VM86 893 config VM86
890 bool "Enable VM86 support" if EXPERT 894 bool "Enable VM86 support" if EXPERT
891 default y 895 default y
892 depends on X86_32 896 depends on X86_32
893 ---help--- 897 ---help---
894 This option is required by programs like DOSEMU to run 16-bit legacy 898 This option is required by programs like DOSEMU to run 16-bit legacy
895 code on X86 processors. It also may be needed by software like 899 code on X86 processors. It also may be needed by software like
896 XFree86 to initialize some video cards via BIOS. Disabling this 900 XFree86 to initialize some video cards via BIOS. Disabling this
897 option saves about 6k. 901 option saves about 6k.
898 902
899 config TOSHIBA 903 config TOSHIBA
900 tristate "Toshiba Laptop support" 904 tristate "Toshiba Laptop support"
901 depends on X86_32 905 depends on X86_32
902 ---help--- 906 ---help---
903 This adds a driver to safely access the System Management Mode of 907 This adds a driver to safely access the System Management Mode of
904 the CPU on Toshiba portables with a genuine Toshiba BIOS. It does 908 the CPU on Toshiba portables with a genuine Toshiba BIOS. It does
905 not work on models with a Phoenix BIOS. The System Management Mode 909 not work on models with a Phoenix BIOS. The System Management Mode
906 is used to set the BIOS and power saving options on Toshiba portables. 910 is used to set the BIOS and power saving options on Toshiba portables.
907 911
908 For information on utilities to make use of this driver see the 912 For information on utilities to make use of this driver see the
909 Toshiba Linux utilities web site at: 913 Toshiba Linux utilities web site at:
910 <http://www.buzzard.org.uk/toshiba/>. 914 <http://www.buzzard.org.uk/toshiba/>.
911 915
912 Say Y if you intend to run this kernel on a Toshiba portable. 916 Say Y if you intend to run this kernel on a Toshiba portable.
913 Say N otherwise. 917 Say N otherwise.
914 918
915 config I8K 919 config I8K
916 tristate "Dell laptop support" 920 tristate "Dell laptop support"
917 select HWMON 921 select HWMON
918 ---help--- 922 ---help---
919 This adds a driver to safely access the System Management Mode 923 This adds a driver to safely access the System Management Mode
920 of the CPU on the Dell Inspiron 8000. The System Management Mode 924 of the CPU on the Dell Inspiron 8000. The System Management Mode
921 is used to read cpu temperature and cooling fan status and to 925 is used to read cpu temperature and cooling fan status and to
922 control the fans on the I8K portables. 926 control the fans on the I8K portables.
923 927
924 This driver has been tested only on the Inspiron 8000 but it may 928 This driver has been tested only on the Inspiron 8000 but it may
925 also work with other Dell laptops. You can force loading on other 929 also work with other Dell laptops. You can force loading on other
926 models by passing the parameter `force=1' to the module. Use at 930 models by passing the parameter `force=1' to the module. Use at
927 your own risk. 931 your own risk.
928 932
929 For information on utilities to make use of this driver see the 933 For information on utilities to make use of this driver see the
930 I8K Linux utilities web site at: 934 I8K Linux utilities web site at:
931 <http://people.debian.org/~dz/i8k/> 935 <http://people.debian.org/~dz/i8k/>
932 936
933 Say Y if you intend to run this kernel on a Dell Inspiron 8000. 937 Say Y if you intend to run this kernel on a Dell Inspiron 8000.
934 Say N otherwise. 938 Say N otherwise.
935 939
936 config X86_REBOOTFIXUPS 940 config X86_REBOOTFIXUPS
937 bool "Enable X86 board specific fixups for reboot" 941 bool "Enable X86 board specific fixups for reboot"
938 depends on X86_32 942 depends on X86_32
939 ---help--- 943 ---help---
940 This enables chipset and/or board specific fixups to be done 944 This enables chipset and/or board specific fixups to be done
941 in order to get reboot to work correctly. This is only needed on 945 in order to get reboot to work correctly. This is only needed on
942 some combinations of hardware and BIOS. The symptom, for which 946 some combinations of hardware and BIOS. The symptom, for which
943 this config is intended, is when reboot ends with a stalled/hung 947 this config is intended, is when reboot ends with a stalled/hung
944 system. 948 system.
945 949
946 Currently, the only fixup is for the Geode machines using 950 Currently, the only fixup is for the Geode machines using
947 CS5530A and CS5536 chipsets and the RDC R-321x SoC. 951 CS5530A and CS5536 chipsets and the RDC R-321x SoC.
948 952
949 Say Y if you want to enable the fixup. Currently, it's safe to 953 Say Y if you want to enable the fixup. Currently, it's safe to
950 enable this option even if you don't need it. 954 enable this option even if you don't need it.
951 Say N otherwise. 955 Say N otherwise.
952 956
953 config MICROCODE 957 config MICROCODE
954 tristate "/dev/cpu/microcode - microcode support" 958 tristate "/dev/cpu/microcode - microcode support"
955 select FW_LOADER 959 select FW_LOADER
956 ---help--- 960 ---help---
957 If you say Y here, you will be able to update the microcode on 961 If you say Y here, you will be able to update the microcode on
958 certain Intel and AMD processors. The Intel support is for the 962 certain Intel and AMD processors. The Intel support is for the
959 IA32 family, e.g. Pentium Pro, Pentium II, Pentium III, 963 IA32 family, e.g. Pentium Pro, Pentium II, Pentium III,
960 Pentium 4, Xeon etc. The AMD support is for family 0x10 and 964 Pentium 4, Xeon etc. The AMD support is for family 0x10 and
961 0x11 processors, e.g. Opteron, Phenom and Turion 64 Ultra. 965 0x11 processors, e.g. Opteron, Phenom and Turion 64 Ultra.
962 You will obviously need the actual microcode binary data itself 966 You will obviously need the actual microcode binary data itself
963 which is not shipped with the Linux kernel. 967 which is not shipped with the Linux kernel.
964 968
965 This option selects the general module only, you need to select 969 This option selects the general module only, you need to select
966 at least one vendor specific module as well. 970 at least one vendor specific module as well.
967 971
968 To compile this driver as a module, choose M here: the 972 To compile this driver as a module, choose M here: the
969 module will be called microcode. 973 module will be called microcode.
970 974
971 config MICROCODE_INTEL 975 config MICROCODE_INTEL
972 bool "Intel microcode patch loading support" 976 bool "Intel microcode patch loading support"
973 depends on MICROCODE 977 depends on MICROCODE
974 default MICROCODE 978 default MICROCODE
975 select FW_LOADER 979 select FW_LOADER
976 ---help--- 980 ---help---
977 This options enables microcode patch loading support for Intel 981 This options enables microcode patch loading support for Intel
978 processors. 982 processors.
979 983
980 For latest news and information on obtaining all the required 984 For latest news and information on obtaining all the required
981 Intel ingredients for this driver, check: 985 Intel ingredients for this driver, check:
982 <http://www.urbanmyth.org/microcode/>. 986 <http://www.urbanmyth.org/microcode/>.
983 987
984 config MICROCODE_AMD 988 config MICROCODE_AMD
985 bool "AMD microcode patch loading support" 989 bool "AMD microcode patch loading support"
986 depends on MICROCODE 990 depends on MICROCODE
987 select FW_LOADER 991 select FW_LOADER
988 ---help--- 992 ---help---
989 If you select this option, microcode patch loading support for AMD 993 If you select this option, microcode patch loading support for AMD
990 processors will be enabled. 994 processors will be enabled.
991 995
992 config MICROCODE_OLD_INTERFACE 996 config MICROCODE_OLD_INTERFACE
993 def_bool y 997 def_bool y
994 depends on MICROCODE 998 depends on MICROCODE
995 999
996 config X86_MSR 1000 config X86_MSR
997 tristate "/dev/cpu/*/msr - Model-specific register support" 1001 tristate "/dev/cpu/*/msr - Model-specific register support"
998 ---help--- 1002 ---help---
999 This device gives privileged processes access to the x86 1003 This device gives privileged processes access to the x86
1000 Model-Specific Registers (MSRs). It is a character device with 1004 Model-Specific Registers (MSRs). It is a character device with
1001 major 202 and minors 0 to 31 for /dev/cpu/0/msr to /dev/cpu/31/msr. 1005 major 202 and minors 0 to 31 for /dev/cpu/0/msr to /dev/cpu/31/msr.
1002 MSR accesses are directed to a specific CPU on multi-processor 1006 MSR accesses are directed to a specific CPU on multi-processor
1003 systems. 1007 systems.
1004 1008
1005 config X86_CPUID 1009 config X86_CPUID
1006 tristate "/dev/cpu/*/cpuid - CPU information support" 1010 tristate "/dev/cpu/*/cpuid - CPU information support"
1007 ---help--- 1011 ---help---
1008 This device gives processes access to the x86 CPUID instruction to 1012 This device gives processes access to the x86 CPUID instruction to
1009 be executed on a specific processor. It is a character device 1013 be executed on a specific processor. It is a character device
1010 with major 203 and minors 0 to 31 for /dev/cpu/0/cpuid to 1014 with major 203 and minors 0 to 31 for /dev/cpu/0/cpuid to
1011 /dev/cpu/31/cpuid. 1015 /dev/cpu/31/cpuid.
1012 1016
1013 choice 1017 choice
1014 prompt "High Memory Support" 1018 prompt "High Memory Support"
1015 default HIGHMEM64G if X86_NUMAQ 1019 default HIGHMEM64G if X86_NUMAQ
1016 default HIGHMEM4G 1020 default HIGHMEM4G
1017 depends on X86_32 1021 depends on X86_32
1018 1022
1019 config NOHIGHMEM 1023 config NOHIGHMEM
1020 bool "off" 1024 bool "off"
1021 depends on !X86_NUMAQ 1025 depends on !X86_NUMAQ
1022 ---help--- 1026 ---help---
1023 Linux can use up to 64 Gigabytes of physical memory on x86 systems. 1027 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
1024 However, the address space of 32-bit x86 processors is only 4 1028 However, the address space of 32-bit x86 processors is only 4
1025 Gigabytes large. That means that, if you have a large amount of 1029 Gigabytes large. That means that, if you have a large amount of
1026 physical memory, not all of it can be "permanently mapped" by the 1030 physical memory, not all of it can be "permanently mapped" by the
1027 kernel. The physical memory that's not permanently mapped is called 1031 kernel. The physical memory that's not permanently mapped is called
1028 "high memory". 1032 "high memory".
1029 1033
1030 If you are compiling a kernel which will never run on a machine with 1034 If you are compiling a kernel which will never run on a machine with
1031 more than 1 Gigabyte total physical RAM, answer "off" here (default 1035 more than 1 Gigabyte total physical RAM, answer "off" here (default
1032 choice and suitable for most users). This will result in a "3GB/1GB" 1036 choice and suitable for most users). This will result in a "3GB/1GB"
1033 split: 3GB are mapped so that each process sees a 3GB virtual memory 1037 split: 3GB are mapped so that each process sees a 3GB virtual memory
1034 space and the remaining part of the 4GB virtual memory space is used 1038 space and the remaining part of the 4GB virtual memory space is used
1035 by the kernel to permanently map as much physical memory as 1039 by the kernel to permanently map as much physical memory as
1036 possible. 1040 possible.
1037 1041
1038 If the machine has between 1 and 4 Gigabytes physical RAM, then 1042 If the machine has between 1 and 4 Gigabytes physical RAM, then
1039 answer "4GB" here. 1043 answer "4GB" here.
1040 1044
1041 If more than 4 Gigabytes is used then answer "64GB" here. This 1045 If more than 4 Gigabytes is used then answer "64GB" here. This
1042 selection turns Intel PAE (Physical Address Extension) mode on. 1046 selection turns Intel PAE (Physical Address Extension) mode on.
1043 PAE implements 3-level paging on IA32 processors. PAE is fully 1047 PAE implements 3-level paging on IA32 processors. PAE is fully
1044 supported by Linux, PAE mode is implemented on all recent Intel 1048 supported by Linux, PAE mode is implemented on all recent Intel
1045 processors (Pentium Pro and better). NOTE: If you say "64GB" here, 1049 processors (Pentium Pro and better). NOTE: If you say "64GB" here,
1046 then the kernel will not boot on CPUs that don't support PAE! 1050 then the kernel will not boot on CPUs that don't support PAE!
1047 1051
1048 The actual amount of total physical memory will either be 1052 The actual amount of total physical memory will either be
1049 auto detected or can be forced by using a kernel command line option 1053 auto detected or can be forced by using a kernel command line option
1050 such as "mem=256M". (Try "man bootparam" or see the documentation of 1054 such as "mem=256M". (Try "man bootparam" or see the documentation of
1051 your boot loader (lilo or loadlin) about how to pass options to the 1055 your boot loader (lilo or loadlin) about how to pass options to the
1052 kernel at boot time.) 1056 kernel at boot time.)
1053 1057
1054 If unsure, say "off". 1058 If unsure, say "off".
1055 1059
1056 config HIGHMEM4G 1060 config HIGHMEM4G
1057 bool "4GB" 1061 bool "4GB"
1058 depends on !X86_NUMAQ 1062 depends on !X86_NUMAQ
1059 ---help--- 1063 ---help---
1060 Select this if you have a 32-bit processor and between 1 and 4 1064 Select this if you have a 32-bit processor and between 1 and 4
1061 gigabytes of physical RAM. 1065 gigabytes of physical RAM.
1062 1066
1063 config HIGHMEM64G 1067 config HIGHMEM64G
1064 bool "64GB" 1068 bool "64GB"
1065 depends on !M386 && !M486 1069 depends on !M386 && !M486
1066 select X86_PAE 1070 select X86_PAE
1067 ---help--- 1071 ---help---
1068 Select this if you have a 32-bit processor and more than 4 1072 Select this if you have a 32-bit processor and more than 4
1069 gigabytes of physical RAM. 1073 gigabytes of physical RAM.
1070 1074
1071 endchoice 1075 endchoice
1072 1076
1073 choice 1077 choice
1074 depends on EXPERIMENTAL 1078 depends on EXPERIMENTAL
1075 prompt "Memory split" if EXPERT 1079 prompt "Memory split" if EXPERT
1076 default VMSPLIT_3G 1080 default VMSPLIT_3G
1077 depends on X86_32 1081 depends on X86_32
1078 ---help--- 1082 ---help---
1079 Select the desired split between kernel and user memory. 1083 Select the desired split between kernel and user memory.
1080 1084
1081 If the address range available to the kernel is less than the 1085 If the address range available to the kernel is less than the
1082 physical memory installed, the remaining memory will be available 1086 physical memory installed, the remaining memory will be available
1083 as "high memory". Accessing high memory is a little more costly 1087 as "high memory". Accessing high memory is a little more costly
1084 than low memory, as it needs to be mapped into the kernel first. 1088 than low memory, as it needs to be mapped into the kernel first.
1085 Note that increasing the kernel address space limits the range 1089 Note that increasing the kernel address space limits the range
1086 available to user programs, making the address space there 1090 available to user programs, making the address space there
1087 tighter. Selecting anything other than the default 3G/1G split 1091 tighter. Selecting anything other than the default 3G/1G split
1088 will also likely make your kernel incompatible with binary-only 1092 will also likely make your kernel incompatible with binary-only
1089 kernel modules. 1093 kernel modules.
1090 1094
1091 If you are not absolutely sure what you are doing, leave this 1095 If you are not absolutely sure what you are doing, leave this
1092 option alone! 1096 option alone!
1093 1097
1094 config VMSPLIT_3G 1098 config VMSPLIT_3G
1095 bool "3G/1G user/kernel split" 1099 bool "3G/1G user/kernel split"
1096 config VMSPLIT_3G_OPT 1100 config VMSPLIT_3G_OPT
1097 depends on !X86_PAE 1101 depends on !X86_PAE
1098 bool "3G/1G user/kernel split (for full 1G low memory)" 1102 bool "3G/1G user/kernel split (for full 1G low memory)"
1099 config VMSPLIT_2G 1103 config VMSPLIT_2G
1100 bool "2G/2G user/kernel split" 1104 bool "2G/2G user/kernel split"
1101 config VMSPLIT_2G_OPT 1105 config VMSPLIT_2G_OPT
1102 depends on !X86_PAE 1106 depends on !X86_PAE
1103 bool "2G/2G user/kernel split (for full 2G low memory)" 1107 bool "2G/2G user/kernel split (for full 2G low memory)"
1104 config VMSPLIT_1G 1108 config VMSPLIT_1G
1105 bool "1G/3G user/kernel split" 1109 bool "1G/3G user/kernel split"
1106 endchoice 1110 endchoice
1107 1111
1108 config PAGE_OFFSET 1112 config PAGE_OFFSET
1109 hex 1113 hex
1110 default 0xB0000000 if VMSPLIT_3G_OPT 1114 default 0xB0000000 if VMSPLIT_3G_OPT
1111 default 0x80000000 if VMSPLIT_2G 1115 default 0x80000000 if VMSPLIT_2G
1112 default 0x78000000 if VMSPLIT_2G_OPT 1116 default 0x78000000 if VMSPLIT_2G_OPT
1113 default 0x40000000 if VMSPLIT_1G 1117 default 0x40000000 if VMSPLIT_1G
1114 default 0xC0000000 1118 default 0xC0000000
1115 depends on X86_32 1119 depends on X86_32
1116 1120
1117 config HIGHMEM 1121 config HIGHMEM
1118 def_bool y 1122 def_bool y
1119 depends on X86_32 && (HIGHMEM64G || HIGHMEM4G) 1123 depends on X86_32 && (HIGHMEM64G || HIGHMEM4G)
1120 1124
1121 config X86_PAE 1125 config X86_PAE
1122 bool "PAE (Physical Address Extension) Support" 1126 bool "PAE (Physical Address Extension) Support"
1123 depends on X86_32 && !HIGHMEM4G 1127 depends on X86_32 && !HIGHMEM4G
1124 ---help--- 1128 ---help---
1125 PAE is required for NX support, and furthermore enables 1129 PAE is required for NX support, and furthermore enables
1126 larger swapspace support for non-overcommit purposes. It 1130 larger swapspace support for non-overcommit purposes. It
1127 has the cost of more pagetable lookup overhead, and also 1131 has the cost of more pagetable lookup overhead, and also
1128 consumes more pagetable space per process. 1132 consumes more pagetable space per process.
1129 1133
1130 config ARCH_PHYS_ADDR_T_64BIT 1134 config ARCH_PHYS_ADDR_T_64BIT
1131 def_bool X86_64 || X86_PAE 1135 def_bool X86_64 || X86_PAE
1132 1136
1133 config ARCH_DMA_ADDR_T_64BIT 1137 config ARCH_DMA_ADDR_T_64BIT
1134 def_bool X86_64 || HIGHMEM64G 1138 def_bool X86_64 || HIGHMEM64G
1135 1139
1136 config DIRECT_GBPAGES 1140 config DIRECT_GBPAGES
1137 bool "Enable 1GB pages for kernel pagetables" if EXPERT 1141 bool "Enable 1GB pages for kernel pagetables" if EXPERT
1138 default y 1142 default y
1139 depends on X86_64 1143 depends on X86_64
1140 ---help--- 1144 ---help---
1141 Allow the kernel linear mapping to use 1GB pages on CPUs that 1145 Allow the kernel linear mapping to use 1GB pages on CPUs that
1142 support it. This can improve the kernel's performance a tiny bit by 1146 support it. This can improve the kernel's performance a tiny bit by
1143 reducing TLB pressure. If in doubt, say "Y". 1147 reducing TLB pressure. If in doubt, say "Y".
1144 1148
1145 # Common NUMA Features 1149 # Common NUMA Features
1146 config NUMA 1150 config NUMA
1147 bool "Numa Memory Allocation and Scheduler Support" 1151 bool "Numa Memory Allocation and Scheduler Support"
1148 depends on SMP 1152 depends on SMP
1149 depends on X86_64 || (X86_32 && HIGHMEM64G && (X86_NUMAQ || X86_BIGSMP || X86_SUMMIT && ACPI) && EXPERIMENTAL) 1153 depends on X86_64 || (X86_32 && HIGHMEM64G && (X86_NUMAQ || X86_BIGSMP || X86_SUMMIT && ACPI) && EXPERIMENTAL)
1150 default y if (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP) 1154 default y if (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP)
1151 ---help--- 1155 ---help---
1152 Enable NUMA (Non Uniform Memory Access) support. 1156 Enable NUMA (Non Uniform Memory Access) support.
1153 1157
1154 The kernel will try to allocate memory used by a CPU on the 1158 The kernel will try to allocate memory used by a CPU on the
1155 local memory controller of the CPU and add some more 1159 local memory controller of the CPU and add some more
1156 NUMA awareness to the kernel. 1160 NUMA awareness to the kernel.
1157 1161
1158 For 64-bit this is recommended if the system is Intel Core i7 1162 For 64-bit this is recommended if the system is Intel Core i7
1159 (or later), AMD Opteron, or EM64T NUMA. 1163 (or later), AMD Opteron, or EM64T NUMA.
1160 1164
1161 For 32-bit this is only needed on (rare) 32-bit-only platforms 1165 For 32-bit this is only needed on (rare) 32-bit-only platforms
1162 that support NUMA topologies, such as NUMAQ / Summit, or if you 1166 that support NUMA topologies, such as NUMAQ / Summit, or if you
1163 boot a 32-bit kernel on a 64-bit NUMA platform. 1167 boot a 32-bit kernel on a 64-bit NUMA platform.
1164 1168
1165 Otherwise, you should say N. 1169 Otherwise, you should say N.
1166 1170
1167 comment "NUMA (Summit) requires SMP, 64GB highmem support, ACPI" 1171 comment "NUMA (Summit) requires SMP, 64GB highmem support, ACPI"
1168 depends on X86_32 && X86_SUMMIT && (!HIGHMEM64G || !ACPI) 1172 depends on X86_32 && X86_SUMMIT && (!HIGHMEM64G || !ACPI)
1169 1173
1170 config AMD_NUMA 1174 config AMD_NUMA
1171 def_bool y 1175 def_bool y
1172 prompt "Old style AMD Opteron NUMA detection" 1176 prompt "Old style AMD Opteron NUMA detection"
1173 depends on X86_64 && NUMA && PCI 1177 depends on X86_64 && NUMA && PCI
1174 ---help--- 1178 ---help---
1175 Enable AMD NUMA node topology detection. You should say Y here if 1179 Enable AMD NUMA node topology detection. You should say Y here if
1176 you have a multi processor AMD system. This uses an old method to 1180 you have a multi processor AMD system. This uses an old method to
1177 read the NUMA configuration directly from the builtin Northbridge 1181 read the NUMA configuration directly from the builtin Northbridge
1178 of Opteron. It is recommended to use X86_64_ACPI_NUMA instead, 1182 of Opteron. It is recommended to use X86_64_ACPI_NUMA instead,
1179 which also takes priority if both are compiled in. 1183 which also takes priority if both are compiled in.
1180 1184
1181 config X86_64_ACPI_NUMA 1185 config X86_64_ACPI_NUMA
1182 def_bool y 1186 def_bool y
1183 prompt "ACPI NUMA detection" 1187 prompt "ACPI NUMA detection"
1184 depends on X86_64 && NUMA && ACPI && PCI 1188 depends on X86_64 && NUMA && ACPI && PCI
1185 select ACPI_NUMA 1189 select ACPI_NUMA
1186 ---help--- 1190 ---help---
1187 Enable ACPI SRAT based node topology detection. 1191 Enable ACPI SRAT based node topology detection.
1188 1192
1189 # Some NUMA nodes have memory ranges that span 1193 # Some NUMA nodes have memory ranges that span
1190 # other nodes. Even though a pfn is valid and 1194 # other nodes. Even though a pfn is valid and
1191 # between a node's start and end pfns, it may not 1195 # between a node's start and end pfns, it may not
1192 # reside on that node. See memmap_init_zone() 1196 # reside on that node. See memmap_init_zone()
1193 # for details. 1197 # for details.
1194 config NODES_SPAN_OTHER_NODES 1198 config NODES_SPAN_OTHER_NODES
1195 def_bool y 1199 def_bool y
1196 depends on X86_64_ACPI_NUMA 1200 depends on X86_64_ACPI_NUMA
1197 1201
1198 config NUMA_EMU 1202 config NUMA_EMU
1199 bool "NUMA emulation" 1203 bool "NUMA emulation"
1200 depends on NUMA 1204 depends on NUMA
1201 ---help--- 1205 ---help---
1202 Enable NUMA emulation. A flat machine will be split 1206 Enable NUMA emulation. A flat machine will be split
1203 into virtual nodes when booted with "numa=fake=N", where N is the 1207 into virtual nodes when booted with "numa=fake=N", where N is the
1204 number of nodes. This is only useful for debugging. 1208 number of nodes. This is only useful for debugging.
1205 1209
1206 config NODES_SHIFT 1210 config NODES_SHIFT
1207 int "Maximum NUMA Nodes (as a power of 2)" if !MAXSMP 1211 int "Maximum NUMA Nodes (as a power of 2)" if !MAXSMP
1208 range 1 10 1212 range 1 10
1209 default "10" if MAXSMP 1213 default "10" if MAXSMP
1210 default "6" if X86_64 1214 default "6" if X86_64
1211 default "4" if X86_NUMAQ 1215 default "4" if X86_NUMAQ
1212 default "3" 1216 default "3"
1213 depends on NEED_MULTIPLE_NODES 1217 depends on NEED_MULTIPLE_NODES
1214 ---help--- 1218 ---help---
1215 Specify the maximum number of NUMA Nodes available on the target 1219 Specify the maximum number of NUMA Nodes available on the target
1216 system. Increases memory reserved to accommodate various tables. 1220 system. Increases memory reserved to accommodate various tables.
1217 1221
1218 config HAVE_ARCH_BOOTMEM 1222 config HAVE_ARCH_BOOTMEM
1219 def_bool y 1223 def_bool y
1220 depends on X86_32 && NUMA 1224 depends on X86_32 && NUMA
1221 1225
1222 config HAVE_ARCH_ALLOC_REMAP 1226 config HAVE_ARCH_ALLOC_REMAP
1223 def_bool y 1227 def_bool y
1224 depends on X86_32 && NUMA 1228 depends on X86_32 && NUMA
1225 1229
1226 config ARCH_HAVE_MEMORY_PRESENT 1230 config ARCH_HAVE_MEMORY_PRESENT
1227 def_bool y 1231 def_bool y
1228 depends on X86_32 && DISCONTIGMEM 1232 depends on X86_32 && DISCONTIGMEM
1229 1233
1230 config NEED_NODE_MEMMAP_SIZE 1234 config NEED_NODE_MEMMAP_SIZE
1231 def_bool y 1235 def_bool y
1232 depends on X86_32 && (DISCONTIGMEM || SPARSEMEM) 1236 depends on X86_32 && (DISCONTIGMEM || SPARSEMEM)
1233 1237
1234 config ARCH_FLATMEM_ENABLE 1238 config ARCH_FLATMEM_ENABLE
1235 def_bool y 1239 def_bool y
1236 depends on X86_32 && !NUMA 1240 depends on X86_32 && !NUMA
1237 1241
1238 config ARCH_DISCONTIGMEM_ENABLE 1242 config ARCH_DISCONTIGMEM_ENABLE
1239 def_bool y 1243 def_bool y
1240 depends on NUMA && X86_32 1244 depends on NUMA && X86_32
1241 1245
1242 config ARCH_DISCONTIGMEM_DEFAULT 1246 config ARCH_DISCONTIGMEM_DEFAULT
1243 def_bool y 1247 def_bool y
1244 depends on NUMA && X86_32 1248 depends on NUMA && X86_32
1245 1249
1246 config ARCH_SPARSEMEM_ENABLE 1250 config ARCH_SPARSEMEM_ENABLE
1247 def_bool y 1251 def_bool y
1248 depends on X86_64 || NUMA || (EXPERIMENTAL && X86_32) || X86_32_NON_STANDARD 1252 depends on X86_64 || NUMA || (EXPERIMENTAL && X86_32) || X86_32_NON_STANDARD
1249 select SPARSEMEM_STATIC if X86_32 1253 select SPARSEMEM_STATIC if X86_32
1250 select SPARSEMEM_VMEMMAP_ENABLE if X86_64 1254 select SPARSEMEM_VMEMMAP_ENABLE if X86_64
1251 1255
1252 config ARCH_SPARSEMEM_DEFAULT 1256 config ARCH_SPARSEMEM_DEFAULT
1253 def_bool y 1257 def_bool y
1254 depends on X86_64 1258 depends on X86_64
1255 1259
1256 config ARCH_SELECT_MEMORY_MODEL 1260 config ARCH_SELECT_MEMORY_MODEL
1257 def_bool y 1261 def_bool y
1258 depends on ARCH_SPARSEMEM_ENABLE 1262 depends on ARCH_SPARSEMEM_ENABLE
1259 1263
1260 config ARCH_MEMORY_PROBE 1264 config ARCH_MEMORY_PROBE
1261 def_bool X86_64 1265 def_bool X86_64
1262 depends on MEMORY_HOTPLUG 1266 depends on MEMORY_HOTPLUG
1263 1267
1264 config ARCH_PROC_KCORE_TEXT 1268 config ARCH_PROC_KCORE_TEXT
1265 def_bool y 1269 def_bool y
1266 depends on X86_64 && PROC_KCORE 1270 depends on X86_64 && PROC_KCORE
1267 1271
1268 config ILLEGAL_POINTER_VALUE 1272 config ILLEGAL_POINTER_VALUE
1269 hex 1273 hex
1270 default 0 if X86_32 1274 default 0 if X86_32
1271 default 0xdead000000000000 if X86_64 1275 default 0xdead000000000000 if X86_64
1272 1276
1273 source "mm/Kconfig" 1277 source "mm/Kconfig"
1274 1278
1275 config HIGHPTE 1279 config HIGHPTE
1276 bool "Allocate 3rd-level pagetables from highmem" 1280 bool "Allocate 3rd-level pagetables from highmem"
1277 depends on HIGHMEM 1281 depends on HIGHMEM
1278 ---help--- 1282 ---help---
1279 The VM uses one page table entry for each page of physical memory. 1283 The VM uses one page table entry for each page of physical memory.
1280 For systems with a lot of RAM, this can be wasteful of precious 1284 For systems with a lot of RAM, this can be wasteful of precious
1281 low memory. Setting this option will put user-space page table 1285 low memory. Setting this option will put user-space page table
1282 entries in high memory. 1286 entries in high memory.
1283 1287
1284 config X86_CHECK_BIOS_CORRUPTION 1288 config X86_CHECK_BIOS_CORRUPTION
1285 bool "Check for low memory corruption" 1289 bool "Check for low memory corruption"
1286 ---help--- 1290 ---help---
1287 Periodically check for memory corruption in low memory, which 1291 Periodically check for memory corruption in low memory, which
1288 is suspected to be caused by BIOS. Even when enabled in the 1292 is suspected to be caused by BIOS. Even when enabled in the
1289 configuration, it is disabled at runtime. Enable it by 1293 configuration, it is disabled at runtime. Enable it by
1290 setting "memory_corruption_check=1" on the kernel command 1294 setting "memory_corruption_check=1" on the kernel command
1291 line. By default it scans the low 64k of memory every 60 1295 line. By default it scans the low 64k of memory every 60
1292 seconds; see the memory_corruption_check_size and 1296 seconds; see the memory_corruption_check_size and
1293 memory_corruption_check_period parameters in 1297 memory_corruption_check_period parameters in
1294 Documentation/kernel-parameters.txt to adjust this. 1298 Documentation/kernel-parameters.txt to adjust this.
1295 1299
1296 When enabled with the default parameters, this option has 1300 When enabled with the default parameters, this option has
1297 almost no overhead, as it reserves a relatively small amount 1301 almost no overhead, as it reserves a relatively small amount
1298 of memory and scans it infrequently. It both detects corruption 1302 of memory and scans it infrequently. It both detects corruption
1299 and prevents it from affecting the running system. 1303 and prevents it from affecting the running system.
1300 1304
1301 It is, however, intended as a diagnostic tool; if repeatable 1305 It is, however, intended as a diagnostic tool; if repeatable
1302 BIOS-originated corruption always affects the same memory, 1306 BIOS-originated corruption always affects the same memory,
1303 you can use memmap= to prevent the kernel from using that 1307 you can use memmap= to prevent the kernel from using that
1304 memory. 1308 memory.
1305 1309
1306 config X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK 1310 config X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK
1307 bool "Set the default setting of memory_corruption_check" 1311 bool "Set the default setting of memory_corruption_check"
1308 depends on X86_CHECK_BIOS_CORRUPTION 1312 depends on X86_CHECK_BIOS_CORRUPTION
1309 default y 1313 default y
1310 ---help--- 1314 ---help---
1311 Set whether the default state of memory_corruption_check is 1315 Set whether the default state of memory_corruption_check is
1312 on or off. 1316 on or off.
1313 1317
1314 config X86_RESERVE_LOW 1318 config X86_RESERVE_LOW
1315 int "Amount of low memory, in kilobytes, to reserve for the BIOS" 1319 int "Amount of low memory, in kilobytes, to reserve for the BIOS"
1316 default 64 1320 default 64
1317 range 4 640 1321 range 4 640
1318 ---help--- 1322 ---help---
1319 Specify the amount of low memory to reserve for the BIOS. 1323 Specify the amount of low memory to reserve for the BIOS.
1320 1324
1321 The first page contains BIOS data structures that the kernel 1325 The first page contains BIOS data structures that the kernel
1322 must not use, so that page must always be reserved. 1326 must not use, so that page must always be reserved.
1323 1327
1324 By default we reserve the first 64K of physical RAM, as a 1328 By default we reserve the first 64K of physical RAM, as a
1325 number of BIOSes are known to corrupt that memory range 1329 number of BIOSes are known to corrupt that memory range
1326 during events such as suspend/resume or monitor cable 1330 during events such as suspend/resume or monitor cable
1327 insertion, so it must not be used by the kernel. 1331 insertion, so it must not be used by the kernel.
1328 1332
1329 You can set this to 4 if you are absolutely sure that you 1333 You can set this to 4 if you are absolutely sure that you
1330 trust the BIOS to get all its memory reservations and usages 1334 trust the BIOS to get all its memory reservations and usages
1331 right. If you know your BIOS have problems beyond the 1335 right. If you know your BIOS have problems beyond the
1332 default 64K area, you can set this to 640 to avoid using the 1336 default 64K area, you can set this to 640 to avoid using the
1333 entire low memory range. 1337 entire low memory range.
1334 1338
1335 If you have doubts about the BIOS (e.g. suspend/resume does 1339 If you have doubts about the BIOS (e.g. suspend/resume does
1336 not work or there's kernel crashes after certain hardware 1340 not work or there's kernel crashes after certain hardware
1337 hotplug events) then you might want to enable 1341 hotplug events) then you might want to enable
1338 X86_CHECK_BIOS_CORRUPTION=y to allow the kernel to check 1342 X86_CHECK_BIOS_CORRUPTION=y to allow the kernel to check
1339 typical corruption patterns. 1343 typical corruption patterns.
1340 1344
1341 Leave this to the default value of 64 if you are unsure. 1345 Leave this to the default value of 64 if you are unsure.
1342 1346
1343 config MATH_EMULATION 1347 config MATH_EMULATION
1344 bool 1348 bool
1345 prompt "Math emulation" if X86_32 1349 prompt "Math emulation" if X86_32
1346 ---help--- 1350 ---help---
1347 Linux can emulate a math coprocessor (used for floating point 1351 Linux can emulate a math coprocessor (used for floating point
1348 operations) if you don't have one. 486DX and Pentium processors have 1352 operations) if you don't have one. 486DX and Pentium processors have
1349 a math coprocessor built in, 486SX and 386 do not, unless you added 1353 a math coprocessor built in, 486SX and 386 do not, unless you added
1350 a 487DX or 387, respectively. (The messages during boot time can 1354 a 487DX or 387, respectively. (The messages during boot time can
1351 give you some hints here ["man dmesg"].) Everyone needs either a 1355 give you some hints here ["man dmesg"].) Everyone needs either a
1352 coprocessor or this emulation. 1356 coprocessor or this emulation.
1353 1357
1354 If you don't have a math coprocessor, you need to say Y here; if you 1358 If you don't have a math coprocessor, you need to say Y here; if you
1355 say Y here even though you have a coprocessor, the coprocessor will 1359 say Y here even though you have a coprocessor, the coprocessor will
1356 be used nevertheless. (This behavior can be changed with the kernel 1360 be used nevertheless. (This behavior can be changed with the kernel
1357 command line option "no387", which comes handy if your coprocessor 1361 command line option "no387", which comes handy if your coprocessor
1358 is broken. Try "man bootparam" or see the documentation of your boot 1362 is broken. Try "man bootparam" or see the documentation of your boot
1359 loader (lilo or loadlin) about how to pass options to the kernel at 1363 loader (lilo or loadlin) about how to pass options to the kernel at
1360 boot time.) This means that it is a good idea to say Y here if you 1364 boot time.) This means that it is a good idea to say Y here if you
1361 intend to use this kernel on different machines. 1365 intend to use this kernel on different machines.
1362 1366
1363 More information about the internals of the Linux math coprocessor 1367 More information about the internals of the Linux math coprocessor
1364 emulation can be found in <file:arch/x86/math-emu/README>. 1368 emulation can be found in <file:arch/x86/math-emu/README>.
1365 1369
1366 If you are not sure, say Y; apart from resulting in a 66 KB bigger 1370 If you are not sure, say Y; apart from resulting in a 66 KB bigger
1367 kernel, it won't hurt. 1371 kernel, it won't hurt.
1368 1372
1369 config MTRR 1373 config MTRR
1370 def_bool y 1374 def_bool y
1371 prompt "MTRR (Memory Type Range Register) support" if EXPERT 1375 prompt "MTRR (Memory Type Range Register) support" if EXPERT
1372 ---help--- 1376 ---help---
1373 On Intel P6 family processors (Pentium Pro, Pentium II and later) 1377 On Intel P6 family processors (Pentium Pro, Pentium II and later)
1374 the Memory Type Range Registers (MTRRs) may be used to control 1378 the Memory Type Range Registers (MTRRs) may be used to control
1375 processor access to memory ranges. This is most useful if you have 1379 processor access to memory ranges. This is most useful if you have
1376 a video (VGA) card on a PCI or AGP bus. Enabling write-combining 1380 a video (VGA) card on a PCI or AGP bus. Enabling write-combining
1377 allows bus write transfers to be combined into a larger transfer 1381 allows bus write transfers to be combined into a larger transfer
1378 before bursting over the PCI/AGP bus. This can increase performance 1382 before bursting over the PCI/AGP bus. This can increase performance
1379 of image write operations 2.5 times or more. Saying Y here creates a 1383 of image write operations 2.5 times or more. Saying Y here creates a
1380 /proc/mtrr file which may be used to manipulate your processor's 1384 /proc/mtrr file which may be used to manipulate your processor's
1381 MTRRs. Typically the X server should use this. 1385 MTRRs. Typically the X server should use this.
1382 1386
1383 This code has a reasonably generic interface so that similar 1387 This code has a reasonably generic interface so that similar
1384 control registers on other processors can be easily supported 1388 control registers on other processors can be easily supported
1385 as well: 1389 as well:
1386 1390
1387 The Cyrix 6x86, 6x86MX and M II processors have Address Range 1391 The Cyrix 6x86, 6x86MX and M II processors have Address Range
1388 Registers (ARRs) which provide a similar functionality to MTRRs. For 1392 Registers (ARRs) which provide a similar functionality to MTRRs. For
1389 these, the ARRs are used to emulate the MTRRs. 1393 these, the ARRs are used to emulate the MTRRs.
1390 The AMD K6-2 (stepping 8 and above) and K6-3 processors have two 1394 The AMD K6-2 (stepping 8 and above) and K6-3 processors have two
1391 MTRRs. The Centaur C6 (WinChip) has 8 MCRs, allowing 1395 MTRRs. The Centaur C6 (WinChip) has 8 MCRs, allowing
1392 write-combining. All of these processors are supported by this code 1396 write-combining. All of these processors are supported by this code
1393 and it makes sense to say Y here if you have one of them. 1397 and it makes sense to say Y here if you have one of them.
1394 1398
1395 Saying Y here also fixes a problem with buggy SMP BIOSes which only 1399 Saying Y here also fixes a problem with buggy SMP BIOSes which only
1396 set the MTRRs for the boot CPU and not for the secondary CPUs. This 1400 set the MTRRs for the boot CPU and not for the secondary CPUs. This
1397 can lead to all sorts of problems, so it's good to say Y here. 1401 can lead to all sorts of problems, so it's good to say Y here.
1398 1402
1399 You can safely say Y even if your machine doesn't have MTRRs, you'll 1403 You can safely say Y even if your machine doesn't have MTRRs, you'll
1400 just add about 9 KB to your kernel. 1404 just add about 9 KB to your kernel.
1401 1405
1402 See <file:Documentation/x86/mtrr.txt> for more information. 1406 See <file:Documentation/x86/mtrr.txt> for more information.
1403 1407
1404 config MTRR_SANITIZER 1408 config MTRR_SANITIZER
1405 def_bool y 1409 def_bool y
1406 prompt "MTRR cleanup support" 1410 prompt "MTRR cleanup support"
1407 depends on MTRR 1411 depends on MTRR
1408 ---help--- 1412 ---help---
1409 Convert MTRR layout from continuous to discrete, so X drivers can 1413 Convert MTRR layout from continuous to discrete, so X drivers can
1410 add writeback entries. 1414 add writeback entries.
1411 1415
1412 Can be disabled with disable_mtrr_cleanup on the kernel command line. 1416 Can be disabled with disable_mtrr_cleanup on the kernel command line.
1413 The largest mtrr entry size for a continuous block can be set with 1417 The largest mtrr entry size for a continuous block can be set with
1414 mtrr_chunk_size. 1418 mtrr_chunk_size.
1415 1419
1416 If unsure, say Y. 1420 If unsure, say Y.
1417 1421
1418 config MTRR_SANITIZER_ENABLE_DEFAULT 1422 config MTRR_SANITIZER_ENABLE_DEFAULT
1419 int "MTRR cleanup enable value (0-1)" 1423 int "MTRR cleanup enable value (0-1)"
1420 range 0 1 1424 range 0 1
1421 default "0" 1425 default "0"
1422 depends on MTRR_SANITIZER 1426 depends on MTRR_SANITIZER
1423 ---help--- 1427 ---help---
1424 Enable mtrr cleanup default value 1428 Enable mtrr cleanup default value
1425 1429
1426 config MTRR_SANITIZER_SPARE_REG_NR_DEFAULT 1430 config MTRR_SANITIZER_SPARE_REG_NR_DEFAULT
1427 int "MTRR cleanup spare reg num (0-7)" 1431 int "MTRR cleanup spare reg num (0-7)"
1428 range 0 7 1432 range 0 7
1429 default "1" 1433 default "1"
1430 depends on MTRR_SANITIZER 1434 depends on MTRR_SANITIZER
1431 ---help--- 1435 ---help---
1432 mtrr cleanup spare entries default, it can be changed via 1436 mtrr cleanup spare entries default, it can be changed via
1433 mtrr_spare_reg_nr=N on the kernel command line. 1437 mtrr_spare_reg_nr=N on the kernel command line.
1434 1438
1435 config X86_PAT 1439 config X86_PAT
1436 def_bool y 1440 def_bool y
1437 prompt "x86 PAT support" if EXPERT 1441 prompt "x86 PAT support" if EXPERT
1438 depends on MTRR 1442 depends on MTRR
1439 ---help--- 1443 ---help---
1440 Use PAT attributes to setup page level cache control. 1444 Use PAT attributes to setup page level cache control.
1441 1445
1442 PATs are the modern equivalents of MTRRs and are much more 1446 PATs are the modern equivalents of MTRRs and are much more
1443 flexible than MTRRs. 1447 flexible than MTRRs.
1444 1448
1445 Say N here if you see bootup problems (boot crash, boot hang, 1449 Say N here if you see bootup problems (boot crash, boot hang,
1446 spontaneous reboots) or a non-working video driver. 1450 spontaneous reboots) or a non-working video driver.
1447 1451
1448 If unsure, say Y. 1452 If unsure, say Y.
1449 1453
1450 config ARCH_USES_PG_UNCACHED 1454 config ARCH_USES_PG_UNCACHED
1451 def_bool y 1455 def_bool y
1452 depends on X86_PAT 1456 depends on X86_PAT
1453 1457
1454 config ARCH_RANDOM 1458 config ARCH_RANDOM
1455 def_bool y 1459 def_bool y
1456 prompt "x86 architectural random number generator" if EXPERT 1460 prompt "x86 architectural random number generator" if EXPERT
1457 ---help--- 1461 ---help---
1458 Enable the x86 architectural RDRAND instruction 1462 Enable the x86 architectural RDRAND instruction
1459 (Intel Bull Mountain technology) to generate random numbers. 1463 (Intel Bull Mountain technology) to generate random numbers.
1460 If supported, this is a high bandwidth, cryptographically 1464 If supported, this is a high bandwidth, cryptographically
1461 secure hardware random number generator. 1465 secure hardware random number generator.
1462 1466
1463 config EFI 1467 config EFI
1464 bool "EFI runtime service support" 1468 bool "EFI runtime service support"
1465 depends on ACPI 1469 depends on ACPI
1466 ---help--- 1470 ---help---
1467 This enables the kernel to use EFI runtime services that are 1471 This enables the kernel to use EFI runtime services that are
1468 available (such as the EFI variable services). 1472 available (such as the EFI variable services).
1469 1473
1470 This option is only useful on systems that have EFI firmware. 1474 This option is only useful on systems that have EFI firmware.
1471 In addition, you should use the latest ELILO loader available 1475 In addition, you should use the latest ELILO loader available
1472 at <http://elilo.sourceforge.net> in order to take advantage 1476 at <http://elilo.sourceforge.net> in order to take advantage
1473 of EFI runtime services. However, even with this option, the 1477 of EFI runtime services. However, even with this option, the
1474 resultant kernel should continue to boot on existing non-EFI 1478 resultant kernel should continue to boot on existing non-EFI
1475 platforms. 1479 platforms.
1476 1480
1477 config SECCOMP 1481 config SECCOMP
1478 def_bool y 1482 def_bool y
1479 prompt "Enable seccomp to safely compute untrusted bytecode" 1483 prompt "Enable seccomp to safely compute untrusted bytecode"
1480 ---help--- 1484 ---help---
1481 This kernel feature is useful for number crunching applications 1485 This kernel feature is useful for number crunching applications
1482 that may need to compute untrusted bytecode during their 1486 that may need to compute untrusted bytecode during their
1483 execution. By using pipes or other transports made available to 1487 execution. By using pipes or other transports made available to
1484 the process as file descriptors supporting the read/write 1488 the process as file descriptors supporting the read/write
1485 syscalls, it's possible to isolate those applications in 1489 syscalls, it's possible to isolate those applications in
1486 their own address space using seccomp. Once seccomp is 1490 their own address space using seccomp. Once seccomp is
1487 enabled via prctl(PR_SET_SECCOMP), it cannot be disabled 1491 enabled via prctl(PR_SET_SECCOMP), it cannot be disabled
1488 and the task is only allowed to execute a few safe syscalls 1492 and the task is only allowed to execute a few safe syscalls
1489 defined by each seccomp mode. 1493 defined by each seccomp mode.
1490 1494
1491 If unsure, say Y. Only embedded should say N here. 1495 If unsure, say Y. Only embedded should say N here.
1492 1496
1493 config CC_STACKPROTECTOR 1497 config CC_STACKPROTECTOR
1494 bool "Enable -fstack-protector buffer overflow detection (EXPERIMENTAL)" 1498 bool "Enable -fstack-protector buffer overflow detection (EXPERIMENTAL)"
1495 ---help--- 1499 ---help---
1496 This option turns on the -fstack-protector GCC feature. This 1500 This option turns on the -fstack-protector GCC feature. This
1497 feature puts, at the beginning of functions, a canary value on 1501 feature puts, at the beginning of functions, a canary value on
1498 the stack just before the return address, and validates 1502 the stack just before the return address, and validates
1499 the value just before actually returning. Stack based buffer 1503 the value just before actually returning. Stack based buffer
1500 overflows (that need to overwrite this return address) now also 1504 overflows (that need to overwrite this return address) now also
1501 overwrite the canary, which gets detected and the attack is then 1505 overwrite the canary, which gets detected and the attack is then
1502 neutralized via a kernel panic. 1506 neutralized via a kernel panic.
1503 1507
1504 This feature requires gcc version 4.2 or above, or a distribution 1508 This feature requires gcc version 4.2 or above, or a distribution
1505 gcc with the feature backported. Older versions are automatically 1509 gcc with the feature backported. Older versions are automatically
1506 detected and for those versions, this configuration option is 1510 detected and for those versions, this configuration option is
1507 ignored. (and a warning is printed during bootup) 1511 ignored. (and a warning is printed during bootup)
1508 1512
1509 source kernel/Kconfig.hz 1513 source kernel/Kconfig.hz
1510 1514
1511 config KEXEC 1515 config KEXEC
1512 bool "kexec system call" 1516 bool "kexec system call"
1513 ---help--- 1517 ---help---
1514 kexec is a system call that implements the ability to shutdown your 1518 kexec is a system call that implements the ability to shutdown your
1515 current kernel, and to start another kernel. It is like a reboot 1519 current kernel, and to start another kernel. It is like a reboot
1516 but it is independent of the system firmware. And like a reboot 1520 but it is independent of the system firmware. And like a reboot
1517 you can start any kernel with it, not just Linux. 1521 you can start any kernel with it, not just Linux.
1518 1522
1519 The name comes from the similarity to the exec system call. 1523 The name comes from the similarity to the exec system call.
1520 1524
1521 It is an ongoing process to be certain the hardware in a machine 1525 It is an ongoing process to be certain the hardware in a machine
1522 is properly shutdown, so do not be surprised if this code does not 1526 is properly shutdown, so do not be surprised if this code does not
1523 initially work for you. It may help to enable device hotplugging 1527 initially work for you. It may help to enable device hotplugging
1524 support. As of this writing the exact hardware interface is 1528 support. As of this writing the exact hardware interface is
1525 strongly in flux, so no good recommendation can be made. 1529 strongly in flux, so no good recommendation can be made.
1526 1530
1527 config CRASH_DUMP 1531 config CRASH_DUMP
1528 bool "kernel crash dumps" 1532 bool "kernel crash dumps"
1529 depends on X86_64 || (X86_32 && HIGHMEM) 1533 depends on X86_64 || (X86_32 && HIGHMEM)
1530 ---help--- 1534 ---help---
1531 Generate crash dump after being started by kexec. 1535 Generate crash dump after being started by kexec.
1532 This should be normally only set in special crash dump kernels 1536 This should be normally only set in special crash dump kernels
1533 which are loaded in the main kernel with kexec-tools into 1537 which are loaded in the main kernel with kexec-tools into
1534 a specially reserved region and then later executed after 1538 a specially reserved region and then later executed after
1535 a crash by kdump/kexec. The crash dump kernel must be compiled 1539 a crash by kdump/kexec. The crash dump kernel must be compiled
1536 to a memory address not used by the main kernel or BIOS using 1540 to a memory address not used by the main kernel or BIOS using
1537 PHYSICAL_START, or it must be built as a relocatable image 1541 PHYSICAL_START, or it must be built as a relocatable image
1538 (CONFIG_RELOCATABLE=y). 1542 (CONFIG_RELOCATABLE=y).
1539 For more details see Documentation/kdump/kdump.txt 1543 For more details see Documentation/kdump/kdump.txt
1540 1544
1541 config KEXEC_JUMP 1545 config KEXEC_JUMP
1542 bool "kexec jump (EXPERIMENTAL)" 1546 bool "kexec jump (EXPERIMENTAL)"
1543 depends on EXPERIMENTAL 1547 depends on EXPERIMENTAL
1544 depends on KEXEC && HIBERNATION 1548 depends on KEXEC && HIBERNATION
1545 ---help--- 1549 ---help---
1546 Jump between original kernel and kexeced kernel and invoke 1550 Jump between original kernel and kexeced kernel and invoke
1547 code in physical address mode via KEXEC 1551 code in physical address mode via KEXEC
1548 1552
1549 config PHYSICAL_START 1553 config PHYSICAL_START
1550 hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP) 1554 hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP)
1551 default "0x1000000" 1555 default "0x1000000"
1552 ---help--- 1556 ---help---
1553 This gives the physical address where the kernel is loaded. 1557 This gives the physical address where the kernel is loaded.
1554 1558
1555 If kernel is a not relocatable (CONFIG_RELOCATABLE=n) then 1559 If kernel is a not relocatable (CONFIG_RELOCATABLE=n) then
1556 bzImage will decompress itself to above physical address and 1560 bzImage will decompress itself to above physical address and
1557 run from there. Otherwise, bzImage will run from the address where 1561 run from there. Otherwise, bzImage will run from the address where
1558 it has been loaded by the boot loader and will ignore above physical 1562 it has been loaded by the boot loader and will ignore above physical
1559 address. 1563 address.
1560 1564
1561 In normal kdump cases one does not have to set/change this option 1565 In normal kdump cases one does not have to set/change this option
1562 as now bzImage can be compiled as a completely relocatable image 1566 as now bzImage can be compiled as a completely relocatable image
1563 (CONFIG_RELOCATABLE=y) and be used to load and run from a different 1567 (CONFIG_RELOCATABLE=y) and be used to load and run from a different
1564 address. This option is mainly useful for the folks who don't want 1568 address. This option is mainly useful for the folks who don't want
1565 to use a bzImage for capturing the crash dump and want to use a 1569 to use a bzImage for capturing the crash dump and want to use a
1566 vmlinux instead. vmlinux is not relocatable hence a kernel needs 1570 vmlinux instead. vmlinux is not relocatable hence a kernel needs
1567 to be specifically compiled to run from a specific memory area 1571 to be specifically compiled to run from a specific memory area
1568 (normally a reserved region) and this option comes handy. 1572 (normally a reserved region) and this option comes handy.
1569 1573
1570 So if you are using bzImage for capturing the crash dump, 1574 So if you are using bzImage for capturing the crash dump,
1571 leave the value here unchanged to 0x1000000 and set 1575 leave the value here unchanged to 0x1000000 and set
1572 CONFIG_RELOCATABLE=y. Otherwise if you plan to use vmlinux 1576 CONFIG_RELOCATABLE=y. Otherwise if you plan to use vmlinux
1573 for capturing the crash dump change this value to start of 1577 for capturing the crash dump change this value to start of
1574 the reserved region. In other words, it can be set based on 1578 the reserved region. In other words, it can be set based on
1575 the "X" value as specified in the "crashkernel=YM@XM" 1579 the "X" value as specified in the "crashkernel=YM@XM"
1576 command line boot parameter passed to the panic-ed 1580 command line boot parameter passed to the panic-ed
1577 kernel. Please take a look at Documentation/kdump/kdump.txt 1581 kernel. Please take a look at Documentation/kdump/kdump.txt
1578 for more details about crash dumps. 1582 for more details about crash dumps.
1579 1583
1580 Usage of bzImage for capturing the crash dump is recommended as 1584 Usage of bzImage for capturing the crash dump is recommended as
1581 one does not have to build two kernels. Same kernel can be used 1585 one does not have to build two kernels. Same kernel can be used
1582 as production kernel and capture kernel. Above option should have 1586 as production kernel and capture kernel. Above option should have
1583 gone away after relocatable bzImage support is introduced. But it 1587 gone away after relocatable bzImage support is introduced. But it
1584 is present because there are users out there who continue to use 1588 is present because there are users out there who continue to use
1585 vmlinux for dump capture. This option should go away down the 1589 vmlinux for dump capture. This option should go away down the
1586 line. 1590 line.
1587 1591
1588 Don't change this unless you know what you are doing. 1592 Don't change this unless you know what you are doing.
1589 1593
1590 config RELOCATABLE 1594 config RELOCATABLE
1591 bool "Build a relocatable kernel" 1595 bool "Build a relocatable kernel"
1592 default y 1596 default y
1593 ---help--- 1597 ---help---
1594 This builds a kernel image that retains relocation information 1598 This builds a kernel image that retains relocation information
1595 so it can be loaded someplace besides the default 1MB. 1599 so it can be loaded someplace besides the default 1MB.
1596 The relocations tend to make the kernel binary about 10% larger, 1600 The relocations tend to make the kernel binary about 10% larger,
1597 but are discarded at runtime. 1601 but are discarded at runtime.
1598 1602
1599 One use is for the kexec on panic case where the recovery kernel 1603 One use is for the kexec on panic case where the recovery kernel
1600 must live at a different physical address than the primary 1604 must live at a different physical address than the primary
1601 kernel. 1605 kernel.
1602 1606
1603 Note: If CONFIG_RELOCATABLE=y, then the kernel runs from the address 1607 Note: If CONFIG_RELOCATABLE=y, then the kernel runs from the address
1604 it has been loaded at and the compile time physical address 1608 it has been loaded at and the compile time physical address
1605 (CONFIG_PHYSICAL_START) is ignored. 1609 (CONFIG_PHYSICAL_START) is ignored.
1606 1610
1607 # Relocation on x86-32 needs some additional build support 1611 # Relocation on x86-32 needs some additional build support
1608 config X86_NEED_RELOCS 1612 config X86_NEED_RELOCS
1609 def_bool y 1613 def_bool y
1610 depends on X86_32 && RELOCATABLE 1614 depends on X86_32 && RELOCATABLE
1611 1615
1612 config PHYSICAL_ALIGN 1616 config PHYSICAL_ALIGN
1613 hex "Alignment value to which kernel should be aligned" if X86_32 1617 hex "Alignment value to which kernel should be aligned" if X86_32
1614 default "0x1000000" 1618 default "0x1000000"
1615 range 0x2000 0x1000000 1619 range 0x2000 0x1000000
1616 ---help--- 1620 ---help---
1617 This value puts the alignment restrictions on physical address 1621 This value puts the alignment restrictions on physical address
1618 where kernel is loaded and run from. Kernel is compiled for an 1622 where kernel is loaded and run from. Kernel is compiled for an
1619 address which meets above alignment restriction. 1623 address which meets above alignment restriction.
1620 1624
1621 If bootloader loads the kernel at a non-aligned address and 1625 If bootloader loads the kernel at a non-aligned address and
1622 CONFIG_RELOCATABLE is set, kernel will move itself to nearest 1626 CONFIG_RELOCATABLE is set, kernel will move itself to nearest
1623 address aligned to above value and run from there. 1627 address aligned to above value and run from there.
1624 1628
1625 If bootloader loads the kernel at a non-aligned address and 1629 If bootloader loads the kernel at a non-aligned address and
1626 CONFIG_RELOCATABLE is not set, kernel will ignore the run time 1630 CONFIG_RELOCATABLE is not set, kernel will ignore the run time
1627 load address and decompress itself to the address it has been 1631 load address and decompress itself to the address it has been
1628 compiled for and run from there. The address for which kernel is 1632 compiled for and run from there. The address for which kernel is
1629 compiled already meets above alignment restrictions. Hence the 1633 compiled already meets above alignment restrictions. Hence the
1630 end result is that kernel runs from a physical address meeting 1634 end result is that kernel runs from a physical address meeting
1631 above alignment restrictions. 1635 above alignment restrictions.
1632 1636
1633 Don't change this unless you know what you are doing. 1637 Don't change this unless you know what you are doing.
1634 1638
1635 config HOTPLUG_CPU 1639 config HOTPLUG_CPU
1636 bool "Support for hot-pluggable CPUs" 1640 bool "Support for hot-pluggable CPUs"
1637 depends on SMP && HOTPLUG 1641 depends on SMP && HOTPLUG
1638 ---help--- 1642 ---help---
1639 Say Y here to allow turning CPUs off and on. CPUs can be 1643 Say Y here to allow turning CPUs off and on. CPUs can be
1640 controlled through /sys/devices/system/cpu. 1644 controlled through /sys/devices/system/cpu.
1641 ( Note: power management support will enable this option 1645 ( Note: power management support will enable this option
1642 automatically on SMP systems. ) 1646 automatically on SMP systems. )
1643 Say N if you want to disable CPU hotplug. 1647 Say N if you want to disable CPU hotplug.
1644 1648
1645 config COMPAT_VDSO 1649 config COMPAT_VDSO
1646 def_bool y 1650 def_bool y
1647 prompt "Compat VDSO support" 1651 prompt "Compat VDSO support"
1648 depends on X86_32 || IA32_EMULATION 1652 depends on X86_32 || IA32_EMULATION
1649 ---help--- 1653 ---help---
1650 Map the 32-bit VDSO to the predictable old-style address too. 1654 Map the 32-bit VDSO to the predictable old-style address too.
1651 1655
1652 Say N here if you are running a sufficiently recent glibc 1656 Say N here if you are running a sufficiently recent glibc
1653 version (2.3.3 or later), to remove the high-mapped 1657 version (2.3.3 or later), to remove the high-mapped
1654 VDSO mapping and to exclusively use the randomized VDSO. 1658 VDSO mapping and to exclusively use the randomized VDSO.
1655 1659
1656 If unsure, say Y. 1660 If unsure, say Y.
1657 1661
1658 config CMDLINE_BOOL 1662 config CMDLINE_BOOL
1659 bool "Built-in kernel command line" 1663 bool "Built-in kernel command line"
1660 ---help--- 1664 ---help---
1661 Allow for specifying boot arguments to the kernel at 1665 Allow for specifying boot arguments to the kernel at
1662 build time. On some systems (e.g. embedded ones), it is 1666 build time. On some systems (e.g. embedded ones), it is
1663 necessary or convenient to provide some or all of the 1667 necessary or convenient to provide some or all of the
1664 kernel boot arguments with the kernel itself (that is, 1668 kernel boot arguments with the kernel itself (that is,
1665 to not rely on the boot loader to provide them.) 1669 to not rely on the boot loader to provide them.)
1666 1670
1667 To compile command line arguments into the kernel, 1671 To compile command line arguments into the kernel,
1668 set this option to 'Y', then fill in the 1672 set this option to 'Y', then fill in the
1669 the boot arguments in CONFIG_CMDLINE. 1673 the boot arguments in CONFIG_CMDLINE.
1670 1674
1671 Systems with fully functional boot loaders (i.e. non-embedded) 1675 Systems with fully functional boot loaders (i.e. non-embedded)
1672 should leave this option set to 'N'. 1676 should leave this option set to 'N'.
1673 1677
1674 config CMDLINE 1678 config CMDLINE
1675 string "Built-in kernel command string" 1679 string "Built-in kernel command string"
1676 depends on CMDLINE_BOOL 1680 depends on CMDLINE_BOOL
1677 default "" 1681 default ""
1678 ---help--- 1682 ---help---
1679 Enter arguments here that should be compiled into the kernel 1683 Enter arguments here that should be compiled into the kernel
1680 image and used at boot time. If the boot loader provides a 1684 image and used at boot time. If the boot loader provides a
1681 command line at boot time, it is appended to this string to 1685 command line at boot time, it is appended to this string to
1682 form the full kernel command line, when the system boots. 1686 form the full kernel command line, when the system boots.
1683 1687
1684 However, you can use the CONFIG_CMDLINE_OVERRIDE option to 1688 However, you can use the CONFIG_CMDLINE_OVERRIDE option to
1685 change this behavior. 1689 change this behavior.
1686 1690
1687 In most cases, the command line (whether built-in or provided 1691 In most cases, the command line (whether built-in or provided
1688 by the boot loader) should specify the device for the root 1692 by the boot loader) should specify the device for the root
1689 file system. 1693 file system.
1690 1694
1691 config CMDLINE_OVERRIDE 1695 config CMDLINE_OVERRIDE
1692 bool "Built-in command line overrides boot loader arguments" 1696 bool "Built-in command line overrides boot loader arguments"
1693 depends on CMDLINE_BOOL 1697 depends on CMDLINE_BOOL
1694 ---help--- 1698 ---help---
1695 Set this option to 'Y' to have the kernel ignore the boot loader 1699 Set this option to 'Y' to have the kernel ignore the boot loader
1696 command line, and use ONLY the built-in command line. 1700 command line, and use ONLY the built-in command line.
1697 1701
1698 This is used to work around broken boot loaders. This should 1702 This is used to work around broken boot loaders. This should
1699 be set to 'N' under normal conditions. 1703 be set to 'N' under normal conditions.
1700 1704
1701 endmenu 1705 endmenu
1702 1706
1703 config ARCH_ENABLE_MEMORY_HOTPLUG 1707 config ARCH_ENABLE_MEMORY_HOTPLUG
1704 def_bool y 1708 def_bool y
1705 depends on X86_64 || (X86_32 && HIGHMEM) 1709 depends on X86_64 || (X86_32 && HIGHMEM)
1706 1710
1707 config ARCH_ENABLE_MEMORY_HOTREMOVE 1711 config ARCH_ENABLE_MEMORY_HOTREMOVE
1708 def_bool y 1712 def_bool y
1709 depends on MEMORY_HOTPLUG 1713 depends on MEMORY_HOTPLUG
1710 1714
1711 config USE_PERCPU_NUMA_NODE_ID 1715 config USE_PERCPU_NUMA_NODE_ID
1712 def_bool y 1716 def_bool y
1713 depends on NUMA 1717 depends on NUMA
1714 1718
1715 menu "Power management and ACPI options" 1719 menu "Power management and ACPI options"
1716 1720
1717 config ARCH_HIBERNATION_HEADER 1721 config ARCH_HIBERNATION_HEADER
1718 def_bool y 1722 def_bool y
1719 depends on X86_64 && HIBERNATION 1723 depends on X86_64 && HIBERNATION
1720 1724
1721 source "kernel/power/Kconfig" 1725 source "kernel/power/Kconfig"
1722 1726
1723 source "drivers/acpi/Kconfig" 1727 source "drivers/acpi/Kconfig"
1724 1728
1725 source "drivers/sfi/Kconfig" 1729 source "drivers/sfi/Kconfig"
1726 1730
1727 config X86_APM_BOOT 1731 config X86_APM_BOOT
1728 def_bool y 1732 def_bool y
1729 depends on APM || APM_MODULE 1733 depends on APM || APM_MODULE
1730 1734
1731 menuconfig APM 1735 menuconfig APM
1732 tristate "APM (Advanced Power Management) BIOS support" 1736 tristate "APM (Advanced Power Management) BIOS support"
1733 depends on X86_32 && PM_SLEEP 1737 depends on X86_32 && PM_SLEEP
1734 ---help--- 1738 ---help---
1735 APM is a BIOS specification for saving power using several different 1739 APM is a BIOS specification for saving power using several different
1736 techniques. This is mostly useful for battery powered laptops with 1740 techniques. This is mostly useful for battery powered laptops with
1737 APM compliant BIOSes. If you say Y here, the system time will be 1741 APM compliant BIOSes. If you say Y here, the system time will be
1738 reset after a RESUME operation, the /proc/apm device will provide 1742 reset after a RESUME operation, the /proc/apm device will provide
1739 battery status information, and user-space programs will receive 1743 battery status information, and user-space programs will receive
1740 notification of APM "events" (e.g. battery status change). 1744 notification of APM "events" (e.g. battery status change).
1741 1745
1742 If you select "Y" here, you can disable actual use of the APM 1746 If you select "Y" here, you can disable actual use of the APM
1743 BIOS by passing the "apm=off" option to the kernel at boot time. 1747 BIOS by passing the "apm=off" option to the kernel at boot time.
1744 1748
1745 Note that the APM support is almost completely disabled for 1749 Note that the APM support is almost completely disabled for
1746 machines with more than one CPU. 1750 machines with more than one CPU.
1747 1751
1748 In order to use APM, you will need supporting software. For location 1752 In order to use APM, you will need supporting software. For location
1749 and more information, read <file:Documentation/power/apm-acpi.txt> 1753 and more information, read <file:Documentation/power/apm-acpi.txt>
1750 and the Battery Powered Linux mini-HOWTO, available from 1754 and the Battery Powered Linux mini-HOWTO, available from
1751 <http://www.tldp.org/docs.html#howto>. 1755 <http://www.tldp.org/docs.html#howto>.
1752 1756
1753 This driver does not spin down disk drives (see the hdparm(8) 1757 This driver does not spin down disk drives (see the hdparm(8)
1754 manpage ("man 8 hdparm") for that), and it doesn't turn off 1758 manpage ("man 8 hdparm") for that), and it doesn't turn off
1755 VESA-compliant "green" monitors. 1759 VESA-compliant "green" monitors.
1756 1760
1757 This driver does not support the TI 4000M TravelMate and the ACER 1761 This driver does not support the TI 4000M TravelMate and the ACER
1758 486/DX4/75 because they don't have compliant BIOSes. Many "green" 1762 486/DX4/75 because they don't have compliant BIOSes. Many "green"
1759 desktop machines also don't have compliant BIOSes, and this driver 1763 desktop machines also don't have compliant BIOSes, and this driver
1760 may cause those machines to panic during the boot phase. 1764 may cause those machines to panic during the boot phase.
1761 1765
1762 Generally, if you don't have a battery in your machine, there isn't 1766 Generally, if you don't have a battery in your machine, there isn't
1763 much point in using this driver and you should say N. If you get 1767 much point in using this driver and you should say N. If you get
1764 random kernel OOPSes or reboots that don't seem to be related to 1768 random kernel OOPSes or reboots that don't seem to be related to
1765 anything, try disabling/enabling this option (or disabling/enabling 1769 anything, try disabling/enabling this option (or disabling/enabling
1766 APM in your BIOS). 1770 APM in your BIOS).
1767 1771
1768 Some other things you should try when experiencing seemingly random, 1772 Some other things you should try when experiencing seemingly random,
1769 "weird" problems: 1773 "weird" problems:
1770 1774
1771 1) make sure that you have enough swap space and that it is 1775 1) make sure that you have enough swap space and that it is
1772 enabled. 1776 enabled.
1773 2) pass the "no-hlt" option to the kernel 1777 2) pass the "no-hlt" option to the kernel
1774 3) switch on floating point emulation in the kernel and pass 1778 3) switch on floating point emulation in the kernel and pass
1775 the "no387" option to the kernel 1779 the "no387" option to the kernel
1776 4) pass the "floppy=nodma" option to the kernel 1780 4) pass the "floppy=nodma" option to the kernel
1777 5) pass the "mem=4M" option to the kernel (thereby disabling 1781 5) pass the "mem=4M" option to the kernel (thereby disabling
1778 all but the first 4 MB of RAM) 1782 all but the first 4 MB of RAM)
1779 6) make sure that the CPU is not over clocked. 1783 6) make sure that the CPU is not over clocked.
1780 7) read the sig11 FAQ at <http://www.bitwizard.nl/sig11/> 1784 7) read the sig11 FAQ at <http://www.bitwizard.nl/sig11/>
1781 8) disable the cache from your BIOS settings 1785 8) disable the cache from your BIOS settings
1782 9) install a fan for the video card or exchange video RAM 1786 9) install a fan for the video card or exchange video RAM
1783 10) install a better fan for the CPU 1787 10) install a better fan for the CPU
1784 11) exchange RAM chips 1788 11) exchange RAM chips
1785 12) exchange the motherboard. 1789 12) exchange the motherboard.
1786 1790
1787 To compile this driver as a module, choose M here: the 1791 To compile this driver as a module, choose M here: the
1788 module will be called apm. 1792 module will be called apm.
1789 1793
1790 if APM 1794 if APM
1791 1795
1792 config APM_IGNORE_USER_SUSPEND 1796 config APM_IGNORE_USER_SUSPEND
1793 bool "Ignore USER SUSPEND" 1797 bool "Ignore USER SUSPEND"
1794 ---help--- 1798 ---help---
1795 This option will ignore USER SUSPEND requests. On machines with a 1799 This option will ignore USER SUSPEND requests. On machines with a
1796 compliant APM BIOS, you want to say N. However, on the NEC Versa M 1800 compliant APM BIOS, you want to say N. However, on the NEC Versa M
1797 series notebooks, it is necessary to say Y because of a BIOS bug. 1801 series notebooks, it is necessary to say Y because of a BIOS bug.
1798 1802
1799 config APM_DO_ENABLE 1803 config APM_DO_ENABLE
1800 bool "Enable PM at boot time" 1804 bool "Enable PM at boot time"
1801 ---help--- 1805 ---help---
1802 Enable APM features at boot time. From page 36 of the APM BIOS 1806 Enable APM features at boot time. From page 36 of the APM BIOS
1803 specification: "When disabled, the APM BIOS does not automatically 1807 specification: "When disabled, the APM BIOS does not automatically
1804 power manage devices, enter the Standby State, enter the Suspend 1808 power manage devices, enter the Standby State, enter the Suspend
1805 State, or take power saving steps in response to CPU Idle calls." 1809 State, or take power saving steps in response to CPU Idle calls."
1806 This driver will make CPU Idle calls when Linux is idle (unless this 1810 This driver will make CPU Idle calls when Linux is idle (unless this
1807 feature is turned off -- see "Do CPU IDLE calls", below). This 1811 feature is turned off -- see "Do CPU IDLE calls", below). This
1808 should always save battery power, but more complicated APM features 1812 should always save battery power, but more complicated APM features
1809 will be dependent on your BIOS implementation. You may need to turn 1813 will be dependent on your BIOS implementation. You may need to turn
1810 this option off if your computer hangs at boot time when using APM 1814 this option off if your computer hangs at boot time when using APM
1811 support, or if it beeps continuously instead of suspending. Turn 1815 support, or if it beeps continuously instead of suspending. Turn
1812 this off if you have a NEC UltraLite Versa 33/C or a Toshiba 1816 this off if you have a NEC UltraLite Versa 33/C or a Toshiba
1813 T400CDT. This is off by default since most machines do fine without 1817 T400CDT. This is off by default since most machines do fine without
1814 this feature. 1818 this feature.
1815 1819
1816 config APM_CPU_IDLE 1820 config APM_CPU_IDLE
1817 bool "Make CPU Idle calls when idle" 1821 bool "Make CPU Idle calls when idle"
1818 ---help--- 1822 ---help---
1819 Enable calls to APM CPU Idle/CPU Busy inside the kernel's idle loop. 1823 Enable calls to APM CPU Idle/CPU Busy inside the kernel's idle loop.
1820 On some machines, this can activate improved power savings, such as 1824 On some machines, this can activate improved power savings, such as
1821 a slowed CPU clock rate, when the machine is idle. These idle calls 1825 a slowed CPU clock rate, when the machine is idle. These idle calls
1822 are made after the idle loop has run for some length of time (e.g., 1826 are made after the idle loop has run for some length of time (e.g.,
1823 333 mS). On some machines, this will cause a hang at boot time or 1827 333 mS). On some machines, this will cause a hang at boot time or
1824 whenever the CPU becomes idle. (On machines with more than one CPU, 1828 whenever the CPU becomes idle. (On machines with more than one CPU,
1825 this option does nothing.) 1829 this option does nothing.)
1826 1830
1827 config APM_DISPLAY_BLANK 1831 config APM_DISPLAY_BLANK
1828 bool "Enable console blanking using APM" 1832 bool "Enable console blanking using APM"
1829 ---help--- 1833 ---help---
1830 Enable console blanking using the APM. Some laptops can use this to 1834 Enable console blanking using the APM. Some laptops can use this to
1831 turn off the LCD backlight when the screen blanker of the Linux 1835 turn off the LCD backlight when the screen blanker of the Linux
1832 virtual console blanks the screen. Note that this is only used by 1836 virtual console blanks the screen. Note that this is only used by
1833 the virtual console screen blanker, and won't turn off the backlight 1837 the virtual console screen blanker, and won't turn off the backlight
1834 when using the X Window system. This also doesn't have anything to 1838 when using the X Window system. This also doesn't have anything to
1835 do with your VESA-compliant power-saving monitor. Further, this 1839 do with your VESA-compliant power-saving monitor. Further, this
1836 option doesn't work for all laptops -- it might not turn off your 1840 option doesn't work for all laptops -- it might not turn off your
1837 backlight at all, or it might print a lot of errors to the console, 1841 backlight at all, or it might print a lot of errors to the console,
1838 especially if you are using gpm. 1842 especially if you are using gpm.
1839 1843
1840 config APM_ALLOW_INTS 1844 config APM_ALLOW_INTS
1841 bool "Allow interrupts during APM BIOS calls" 1845 bool "Allow interrupts during APM BIOS calls"
1842 ---help--- 1846 ---help---
1843 Normally we disable external interrupts while we are making calls to 1847 Normally we disable external interrupts while we are making calls to
1844 the APM BIOS as a measure to lessen the effects of a badly behaving 1848 the APM BIOS as a measure to lessen the effects of a badly behaving
1845 BIOS implementation. The BIOS should reenable interrupts if it 1849 BIOS implementation. The BIOS should reenable interrupts if it
1846 needs to. Unfortunately, some BIOSes do not -- especially those in 1850 needs to. Unfortunately, some BIOSes do not -- especially those in
1847 many of the newer IBM Thinkpads. If you experience hangs when you 1851 many of the newer IBM Thinkpads. If you experience hangs when you
1848 suspend, try setting this to Y. Otherwise, say N. 1852 suspend, try setting this to Y. Otherwise, say N.
1849 1853
1850 endif # APM 1854 endif # APM
1851 1855
1852 source "drivers/cpufreq/Kconfig" 1856 source "drivers/cpufreq/Kconfig"
1853 1857
1854 source "drivers/cpuidle/Kconfig" 1858 source "drivers/cpuidle/Kconfig"
1855 1859
1856 source "drivers/idle/Kconfig" 1860 source "drivers/idle/Kconfig"
1857 1861
1858 endmenu 1862 endmenu
1859 1863
1860 1864
1861 menu "Bus options (PCI etc.)" 1865 menu "Bus options (PCI etc.)"
1862 1866
1863 config PCI 1867 config PCI
1864 bool "PCI support" 1868 bool "PCI support"
1865 default y 1869 default y
1866 select ARCH_SUPPORTS_MSI if (X86_LOCAL_APIC && X86_IO_APIC) 1870 select ARCH_SUPPORTS_MSI if (X86_LOCAL_APIC && X86_IO_APIC)
1867 ---help--- 1871 ---help---
1868 Find out whether you have a PCI motherboard. PCI is the name of a 1872 Find out whether you have a PCI motherboard. PCI is the name of a
1869 bus system, i.e. the way the CPU talks to the other stuff inside 1873 bus system, i.e. the way the CPU talks to the other stuff inside
1870 your box. Other bus systems are ISA, EISA, MicroChannel (MCA) or 1874 your box. Other bus systems are ISA, EISA, MicroChannel (MCA) or
1871 VESA. If you have PCI, say Y, otherwise N. 1875 VESA. If you have PCI, say Y, otherwise N.
1872 1876
1873 choice 1877 choice
1874 prompt "PCI access mode" 1878 prompt "PCI access mode"
1875 depends on X86_32 && PCI 1879 depends on X86_32 && PCI
1876 default PCI_GOANY 1880 default PCI_GOANY
1877 ---help--- 1881 ---help---
1878 On PCI systems, the BIOS can be used to detect the PCI devices and 1882 On PCI systems, the BIOS can be used to detect the PCI devices and
1879 determine their configuration. However, some old PCI motherboards 1883 determine their configuration. However, some old PCI motherboards
1880 have BIOS bugs and may crash if this is done. Also, some embedded 1884 have BIOS bugs and may crash if this is done. Also, some embedded
1881 PCI-based systems don't have any BIOS at all. Linux can also try to 1885 PCI-based systems don't have any BIOS at all. Linux can also try to
1882 detect the PCI hardware directly without using the BIOS. 1886 detect the PCI hardware directly without using the BIOS.
1883 1887
1884 With this option, you can specify how Linux should detect the 1888 With this option, you can specify how Linux should detect the
1885 PCI devices. If you choose "BIOS", the BIOS will be used, 1889 PCI devices. If you choose "BIOS", the BIOS will be used,
1886 if you choose "Direct", the BIOS won't be used, and if you 1890 if you choose "Direct", the BIOS won't be used, and if you
1887 choose "MMConfig", then PCI Express MMCONFIG will be used. 1891 choose "MMConfig", then PCI Express MMCONFIG will be used.
1888 If you choose "Any", the kernel will try MMCONFIG, then the 1892 If you choose "Any", the kernel will try MMCONFIG, then the
1889 direct access method and falls back to the BIOS if that doesn't 1893 direct access method and falls back to the BIOS if that doesn't
1890 work. If unsure, go with the default, which is "Any". 1894 work. If unsure, go with the default, which is "Any".
1891 1895
1892 config PCI_GOBIOS 1896 config PCI_GOBIOS
1893 bool "BIOS" 1897 bool "BIOS"
1894 1898
1895 config PCI_GOMMCONFIG 1899 config PCI_GOMMCONFIG
1896 bool "MMConfig" 1900 bool "MMConfig"
1897 1901
1898 config PCI_GODIRECT 1902 config PCI_GODIRECT
1899 bool "Direct" 1903 bool "Direct"
1900 1904
1901 config PCI_GOOLPC 1905 config PCI_GOOLPC
1902 bool "OLPC XO-1" 1906 bool "OLPC XO-1"
1903 depends on OLPC 1907 depends on OLPC
1904 1908
1905 config PCI_GOANY 1909 config PCI_GOANY
1906 bool "Any" 1910 bool "Any"
1907 1911
1908 endchoice 1912 endchoice
1909 1913
1910 config PCI_BIOS 1914 config PCI_BIOS
1911 def_bool y 1915 def_bool y
1912 depends on X86_32 && PCI && (PCI_GOBIOS || PCI_GOANY) 1916 depends on X86_32 && PCI && (PCI_GOBIOS || PCI_GOANY)
1913 1917
1914 # x86-64 doesn't support PCI BIOS access from long mode so always go direct. 1918 # x86-64 doesn't support PCI BIOS access from long mode so always go direct.
1915 config PCI_DIRECT 1919 config PCI_DIRECT
1916 def_bool y 1920 def_bool y
1917 depends on PCI && (X86_64 || (PCI_GODIRECT || PCI_GOANY || PCI_GOOLPC || PCI_GOMMCONFIG)) 1921 depends on PCI && (X86_64 || (PCI_GODIRECT || PCI_GOANY || PCI_GOOLPC || PCI_GOMMCONFIG))
1918 1922
1919 config PCI_MMCONFIG 1923 config PCI_MMCONFIG
1920 def_bool y 1924 def_bool y
1921 depends on X86_32 && PCI && (ACPI || SFI) && (PCI_GOMMCONFIG || PCI_GOANY) 1925 depends on X86_32 && PCI && (ACPI || SFI) && (PCI_GOMMCONFIG || PCI_GOANY)
1922 1926
1923 config PCI_OLPC 1927 config PCI_OLPC
1924 def_bool y 1928 def_bool y
1925 depends on PCI && OLPC && (PCI_GOOLPC || PCI_GOANY) 1929 depends on PCI && OLPC && (PCI_GOOLPC || PCI_GOANY)
1926 1930
1927 config PCI_XEN 1931 config PCI_XEN
1928 def_bool y 1932 def_bool y
1929 depends on PCI && XEN 1933 depends on PCI && XEN
1930 select SWIOTLB_XEN 1934 select SWIOTLB_XEN
1931 1935
1932 config PCI_DOMAINS 1936 config PCI_DOMAINS
1933 def_bool y 1937 def_bool y
1934 depends on PCI 1938 depends on PCI
1935 1939
1936 config PCI_MMCONFIG 1940 config PCI_MMCONFIG
1937 bool "Support mmconfig PCI config space access" 1941 bool "Support mmconfig PCI config space access"
1938 depends on X86_64 && PCI && ACPI 1942 depends on X86_64 && PCI && ACPI
1939 1943
1940 config PCI_CNB20LE_QUIRK 1944 config PCI_CNB20LE_QUIRK
1941 bool "Read CNB20LE Host Bridge Windows" if EXPERT 1945 bool "Read CNB20LE Host Bridge Windows" if EXPERT
1942 default n 1946 default n
1943 depends on PCI && EXPERIMENTAL 1947 depends on PCI && EXPERIMENTAL
1944 help 1948 help
1945 Read the PCI windows out of the CNB20LE host bridge. This allows 1949 Read the PCI windows out of the CNB20LE host bridge. This allows
1946 PCI hotplug to work on systems with the CNB20LE chipset which do 1950 PCI hotplug to work on systems with the CNB20LE chipset which do
1947 not have ACPI. 1951 not have ACPI.
1948 1952
1949 There's no public spec for this chipset, and this functionality 1953 There's no public spec for this chipset, and this functionality
1950 is known to be incomplete. 1954 is known to be incomplete.
1951 1955
1952 You should say N unless you know you need this. 1956 You should say N unless you know you need this.
1953 1957
1954 source "drivers/pci/pcie/Kconfig" 1958 source "drivers/pci/pcie/Kconfig"
1955 1959
1956 source "drivers/pci/Kconfig" 1960 source "drivers/pci/Kconfig"
1957 1961
1958 # x86_64 have no ISA slots, but can have ISA-style DMA. 1962 # x86_64 have no ISA slots, but can have ISA-style DMA.
1959 config ISA_DMA_API 1963 config ISA_DMA_API
1960 bool "ISA-style DMA support" if (X86_64 && EXPERT) 1964 bool "ISA-style DMA support" if (X86_64 && EXPERT)
1961 default y 1965 default y
1962 help 1966 help
1963 Enables ISA-style DMA support for devices requiring such controllers. 1967 Enables ISA-style DMA support for devices requiring such controllers.
1964 If unsure, say Y. 1968 If unsure, say Y.
1965 1969
1966 if X86_32 1970 if X86_32
1967 1971
1968 config ISA 1972 config ISA
1969 bool "ISA support" 1973 bool "ISA support"
1970 ---help--- 1974 ---help---
1971 Find out whether you have ISA slots on your motherboard. ISA is the 1975 Find out whether you have ISA slots on your motherboard. ISA is the
1972 name of a bus system, i.e. the way the CPU talks to the other stuff 1976 name of a bus system, i.e. the way the CPU talks to the other stuff
1973 inside your box. Other bus systems are PCI, EISA, MicroChannel 1977 inside your box. Other bus systems are PCI, EISA, MicroChannel
1974 (MCA) or VESA. ISA is an older system, now being displaced by PCI; 1978 (MCA) or VESA. ISA is an older system, now being displaced by PCI;
1975 newer boards don't support it. If you have ISA, say Y, otherwise N. 1979 newer boards don't support it. If you have ISA, say Y, otherwise N.
1976 1980
1977 config EISA 1981 config EISA
1978 bool "EISA support" 1982 bool "EISA support"
1979 depends on ISA 1983 depends on ISA
1980 ---help--- 1984 ---help---
1981 The Extended Industry Standard Architecture (EISA) bus was 1985 The Extended Industry Standard Architecture (EISA) bus was
1982 developed as an open alternative to the IBM MicroChannel bus. 1986 developed as an open alternative to the IBM MicroChannel bus.
1983 1987
1984 The EISA bus provided some of the features of the IBM MicroChannel 1988 The EISA bus provided some of the features of the IBM MicroChannel
1985 bus while maintaining backward compatibility with cards made for 1989 bus while maintaining backward compatibility with cards made for
1986 the older ISA bus. The EISA bus saw limited use between 1988 and 1990 the older ISA bus. The EISA bus saw limited use between 1988 and
1987 1995 when it was made obsolete by the PCI bus. 1991 1995 when it was made obsolete by the PCI bus.
1988 1992
1989 Say Y here if you are building a kernel for an EISA-based machine. 1993 Say Y here if you are building a kernel for an EISA-based machine.
1990 1994
1991 Otherwise, say N. 1995 Otherwise, say N.
1992 1996
1993 source "drivers/eisa/Kconfig" 1997 source "drivers/eisa/Kconfig"
1994 1998
1995 config MCA 1999 config MCA
1996 bool "MCA support" 2000 bool "MCA support"
1997 ---help--- 2001 ---help---
1998 MicroChannel Architecture is found in some IBM PS/2 machines and 2002 MicroChannel Architecture is found in some IBM PS/2 machines and
1999 laptops. It is a bus system similar to PCI or ISA. See 2003 laptops. It is a bus system similar to PCI or ISA. See
2000 <file:Documentation/mca.txt> (and especially the web page given 2004 <file:Documentation/mca.txt> (and especially the web page given
2001 there) before attempting to build an MCA bus kernel. 2005 there) before attempting to build an MCA bus kernel.
2002 2006
2003 source "drivers/mca/Kconfig" 2007 source "drivers/mca/Kconfig"
2004 2008
2005 config SCx200 2009 config SCx200
2006 tristate "NatSemi SCx200 support" 2010 tristate "NatSemi SCx200 support"
2007 ---help--- 2011 ---help---
2008 This provides basic support for National Semiconductor's 2012 This provides basic support for National Semiconductor's
2009 (now AMD's) Geode processors. The driver probes for the 2013 (now AMD's) Geode processors. The driver probes for the
2010 PCI-IDs of several on-chip devices, so its a good dependency 2014 PCI-IDs of several on-chip devices, so its a good dependency
2011 for other scx200_* drivers. 2015 for other scx200_* drivers.
2012 2016
2013 If compiled as a module, the driver is named scx200. 2017 If compiled as a module, the driver is named scx200.
2014 2018
2015 config SCx200HR_TIMER 2019 config SCx200HR_TIMER
2016 tristate "NatSemi SCx200 27MHz High-Resolution Timer Support" 2020 tristate "NatSemi SCx200 27MHz High-Resolution Timer Support"
2017 depends on SCx200 2021 depends on SCx200
2018 default y 2022 default y
2019 ---help--- 2023 ---help---
2020 This driver provides a clocksource built upon the on-chip 2024 This driver provides a clocksource built upon the on-chip
2021 27MHz high-resolution timer. Its also a workaround for 2025 27MHz high-resolution timer. Its also a workaround for
2022 NSC Geode SC-1100's buggy TSC, which loses time when the 2026 NSC Geode SC-1100's buggy TSC, which loses time when the
2023 processor goes idle (as is done by the scheduler). The 2027 processor goes idle (as is done by the scheduler). The
2024 other workaround is idle=poll boot option. 2028 other workaround is idle=poll boot option.
2025 2029
2026 config OLPC 2030 config OLPC
2027 bool "One Laptop Per Child support" 2031 bool "One Laptop Per Child support"
2028 depends on !X86_PAE 2032 depends on !X86_PAE
2029 select GPIOLIB 2033 select GPIOLIB
2030 select OF 2034 select OF
2031 select OF_PROMTREE 2035 select OF_PROMTREE
2032 ---help--- 2036 ---help---
2033 Add support for detecting the unique features of the OLPC 2037 Add support for detecting the unique features of the OLPC
2034 XO hardware. 2038 XO hardware.
2035 2039
2036 config OLPC_XO1_PM 2040 config OLPC_XO1_PM
2037 bool "OLPC XO-1 Power Management" 2041 bool "OLPC XO-1 Power Management"
2038 depends on OLPC && MFD_CS5535 && PM_SLEEP 2042 depends on OLPC && MFD_CS5535 && PM_SLEEP
2039 select MFD_CORE 2043 select MFD_CORE
2040 ---help--- 2044 ---help---
2041 Add support for poweroff and suspend of the OLPC XO-1 laptop. 2045 Add support for poweroff and suspend of the OLPC XO-1 laptop.
2042 2046
2043 config OLPC_XO1_RTC 2047 config OLPC_XO1_RTC
2044 bool "OLPC XO-1 Real Time Clock" 2048 bool "OLPC XO-1 Real Time Clock"
2045 depends on OLPC_XO1_PM && RTC_DRV_CMOS 2049 depends on OLPC_XO1_PM && RTC_DRV_CMOS
2046 ---help--- 2050 ---help---
2047 Add support for the XO-1 real time clock, which can be used as a 2051 Add support for the XO-1 real time clock, which can be used as a
2048 programmable wakeup source. 2052 programmable wakeup source.
2049 2053
2050 config OLPC_XO1_SCI 2054 config OLPC_XO1_SCI
2051 bool "OLPC XO-1 SCI extras" 2055 bool "OLPC XO-1 SCI extras"
2052 depends on OLPC && OLPC_XO1_PM 2056 depends on OLPC && OLPC_XO1_PM
2053 select POWER_SUPPLY 2057 select POWER_SUPPLY
2054 select GPIO_CS5535 2058 select GPIO_CS5535
2055 select MFD_CORE 2059 select MFD_CORE
2056 ---help--- 2060 ---help---
2057 Add support for SCI-based features of the OLPC XO-1 laptop: 2061 Add support for SCI-based features of the OLPC XO-1 laptop:
2058 - EC-driven system wakeups 2062 - EC-driven system wakeups
2059 - Power button 2063 - Power button
2060 - Ebook switch 2064 - Ebook switch
2061 - Lid switch 2065 - Lid switch
2062 - AC adapter status updates 2066 - AC adapter status updates
2063 - Battery status updates 2067 - Battery status updates
2064 2068
2065 config OLPC_XO15_SCI 2069 config OLPC_XO15_SCI
2066 bool "OLPC XO-1.5 SCI extras" 2070 bool "OLPC XO-1.5 SCI extras"
2067 depends on OLPC && ACPI 2071 depends on OLPC && ACPI
2068 select POWER_SUPPLY 2072 select POWER_SUPPLY
2069 ---help--- 2073 ---help---
2070 Add support for SCI-based features of the OLPC XO-1.5 laptop: 2074 Add support for SCI-based features of the OLPC XO-1.5 laptop:
2071 - EC-driven system wakeups 2075 - EC-driven system wakeups
2072 - AC adapter status updates 2076 - AC adapter status updates
2073 - Battery status updates 2077 - Battery status updates
2074 2078
2075 config ALIX 2079 config ALIX
2076 bool "PCEngines ALIX System Support (LED setup)" 2080 bool "PCEngines ALIX System Support (LED setup)"
2077 select GPIOLIB 2081 select GPIOLIB
2078 ---help--- 2082 ---help---
2079 This option enables system support for the PCEngines ALIX. 2083 This option enables system support for the PCEngines ALIX.
2080 At present this just sets up LEDs for GPIO control on 2084 At present this just sets up LEDs for GPIO control on
2081 ALIX2/3/6 boards. However, other system specific setup should 2085 ALIX2/3/6 boards. However, other system specific setup should
2082 get added here. 2086 get added here.
2083 2087
2084 Note: You must still enable the drivers for GPIO and LED support 2088 Note: You must still enable the drivers for GPIO and LED support
2085 (GPIO_CS5535 & LEDS_GPIO) to actually use the LEDs 2089 (GPIO_CS5535 & LEDS_GPIO) to actually use the LEDs
2086 2090
2087 Note: You have to set alix.force=1 for boards with Award BIOS. 2091 Note: You have to set alix.force=1 for boards with Award BIOS.
2088 2092
2089 endif # X86_32 2093 endif # X86_32
2090 2094
2091 config AMD_NB 2095 config AMD_NB
2092 def_bool y 2096 def_bool y
2093 depends on CPU_SUP_AMD && PCI 2097 depends on CPU_SUP_AMD && PCI
2094 2098
2095 source "drivers/pcmcia/Kconfig" 2099 source "drivers/pcmcia/Kconfig"
2096 2100
2097 source "drivers/pci/hotplug/Kconfig" 2101 source "drivers/pci/hotplug/Kconfig"
2098 2102
2099 config RAPIDIO 2103 config RAPIDIO
2100 bool "RapidIO support" 2104 bool "RapidIO support"
2101 depends on PCI 2105 depends on PCI
2102 default n 2106 default n
2103 help 2107 help
2104 If you say Y here, the kernel will include drivers and 2108 If you say Y here, the kernel will include drivers and
2105 infrastructure code to support RapidIO interconnect devices. 2109 infrastructure code to support RapidIO interconnect devices.
2106 2110
2107 source "drivers/rapidio/Kconfig" 2111 source "drivers/rapidio/Kconfig"
2108 2112
2109 endmenu 2113 endmenu
2110 2114
2111 2115
2112 menu "Executable file formats / Emulations" 2116 menu "Executable file formats / Emulations"
2113 2117
2114 source "fs/Kconfig.binfmt" 2118 source "fs/Kconfig.binfmt"
2115 2119
2116 config IA32_EMULATION 2120 config IA32_EMULATION
2117 bool "IA32 Emulation" 2121 bool "IA32 Emulation"
2118 depends on X86_64 2122 depends on X86_64
2119 select COMPAT_BINFMT_ELF 2123 select COMPAT_BINFMT_ELF
2120 ---help--- 2124 ---help---
2121 Include code to run 32-bit programs under a 64-bit kernel. You should 2125 Include code to run 32-bit programs under a 64-bit kernel. You should
2122 likely turn this on, unless you're 100% sure that you don't have any 2126 likely turn this on, unless you're 100% sure that you don't have any
2123 32-bit programs left. 2127 32-bit programs left.
2124 2128
2125 config IA32_AOUT 2129 config IA32_AOUT
2126 tristate "IA32 a.out support" 2130 tristate "IA32 a.out support"
2127 depends on IA32_EMULATION 2131 depends on IA32_EMULATION
2128 ---help--- 2132 ---help---
2129 Support old a.out binaries in the 32bit emulation. 2133 Support old a.out binaries in the 32bit emulation.
2130 2134
2131 config COMPAT 2135 config COMPAT
2132 def_bool y 2136 def_bool y
2133 depends on IA32_EMULATION 2137 depends on IA32_EMULATION
2134 2138
2135 config COMPAT_FOR_U64_ALIGNMENT 2139 config COMPAT_FOR_U64_ALIGNMENT
2136 def_bool COMPAT 2140 def_bool COMPAT
2137 depends on X86_64 2141 depends on X86_64
2138 2142
2139 config SYSVIPC_COMPAT 2143 config SYSVIPC_COMPAT
2140 def_bool y 2144 def_bool y
2141 depends on COMPAT && SYSVIPC 2145 depends on COMPAT && SYSVIPC
2142 2146
2143 config KEYS_COMPAT 2147 config KEYS_COMPAT
2144 bool 2148 bool
2145 depends on COMPAT && KEYS 2149 depends on COMPAT && KEYS
2146 default y 2150 default y
2147 2151
2148 endmenu 2152 endmenu
2149 2153
2150 2154
2151 config HAVE_ATOMIC_IOMAP 2155 config HAVE_ATOMIC_IOMAP
2152 def_bool y 2156 def_bool y
2153 depends on X86_32 2157 depends on X86_32
2154 2158
2155 config HAVE_TEXT_POKE_SMP 2159 config HAVE_TEXT_POKE_SMP
2156 bool 2160 bool
2157 select STOP_MACHINE if SMP 2161 select STOP_MACHINE if SMP
2158 2162
2159 source "net/Kconfig" 2163 source "net/Kconfig"
2160 2164
2161 source "drivers/Kconfig" 2165 source "drivers/Kconfig"
2162 2166
2163 source "drivers/firmware/Kconfig" 2167 source "drivers/firmware/Kconfig"
2164 2168
2165 source "fs/Kconfig" 2169 source "fs/Kconfig"
2166 2170
2167 source "arch/x86/Kconfig.debug" 2171 source "arch/x86/Kconfig.debug"
2168 2172
2169 source "security/Kconfig" 2173 source "security/Kconfig"
2170 2174
2171 source "crypto/Kconfig" 2175 source "crypto/Kconfig"
2172 2176
2173 source "arch/x86/kvm/Kconfig" 2177 source "arch/x86/kvm/Kconfig"
2174 2178
2175 source "lib/Kconfig" 2179 source "lib/Kconfig"
2176 2180
arch/x86/include/asm/e820.h
1 #ifndef _ASM_X86_E820_H 1 #ifndef _ASM_X86_E820_H
2 #define _ASM_X86_E820_H 2 #define _ASM_X86_E820_H
3 #define E820MAP 0x2d0 /* our map */ 3 #define E820MAP 0x2d0 /* our map */
4 #define E820MAX 128 /* number of entries in E820MAP */ 4 #define E820MAX 128 /* number of entries in E820MAP */
5 5
6 /* 6 /*
7 * Legacy E820 BIOS limits us to 128 (E820MAX) nodes due to the 7 * Legacy E820 BIOS limits us to 128 (E820MAX) nodes due to the
8 * constrained space in the zeropage. If we have more nodes than 8 * constrained space in the zeropage. If we have more nodes than
9 * that, and if we've booted off EFI firmware, then the EFI tables 9 * that, and if we've booted off EFI firmware, then the EFI tables
10 * passed us from the EFI firmware can list more nodes. Size our 10 * passed us from the EFI firmware can list more nodes. Size our
11 * internal memory map tables to have room for these additional 11 * internal memory map tables to have room for these additional
12 * nodes, based on up to three entries per node for which the 12 * nodes, based on up to three entries per node for which the
13 * kernel was built: MAX_NUMNODES == (1 << CONFIG_NODES_SHIFT), 13 * kernel was built: MAX_NUMNODES == (1 << CONFIG_NODES_SHIFT),
14 * plus E820MAX, allowing space for the possible duplicate E820 14 * plus E820MAX, allowing space for the possible duplicate E820
15 * entries that might need room in the same arrays, prior to the 15 * entries that might need room in the same arrays, prior to the
16 * call to sanitize_e820_map() to remove duplicates. The allowance 16 * call to sanitize_e820_map() to remove duplicates. The allowance
17 * of three memory map entries per node is "enough" entries for 17 * of three memory map entries per node is "enough" entries for
18 * the initial hardware platform motivating this mechanism to make 18 * the initial hardware platform motivating this mechanism to make
19 * use of additional EFI map entries. Future platforms may want 19 * use of additional EFI map entries. Future platforms may want
20 * to allow more than three entries per node or otherwise refine 20 * to allow more than three entries per node or otherwise refine
21 * this size. 21 * this size.
22 */ 22 */
23 23
24 /* 24 /*
25 * Odd: 'make headers_check' complains about numa.h if I try 25 * Odd: 'make headers_check' complains about numa.h if I try
26 * to collapse the next two #ifdef lines to a single line: 26 * to collapse the next two #ifdef lines to a single line:
27 * #if defined(__KERNEL__) && defined(CONFIG_EFI) 27 * #if defined(__KERNEL__) && defined(CONFIG_EFI)
28 */ 28 */
29 #ifdef __KERNEL__ 29 #ifdef __KERNEL__
30 #ifdef CONFIG_EFI 30 #ifdef CONFIG_EFI
31 #include <linux/numa.h> 31 #include <linux/numa.h>
32 #define E820_X_MAX (E820MAX + 3 * MAX_NUMNODES) 32 #define E820_X_MAX (E820MAX + 3 * MAX_NUMNODES)
33 #else /* ! CONFIG_EFI */ 33 #else /* ! CONFIG_EFI */
34 #define E820_X_MAX E820MAX 34 #define E820_X_MAX E820MAX
35 #endif 35 #endif
36 #else /* ! __KERNEL__ */ 36 #else /* ! __KERNEL__ */
37 #define E820_X_MAX E820MAX 37 #define E820_X_MAX E820MAX
38 #endif 38 #endif
39 39
40 #define E820NR 0x1e8 /* # entries in E820MAP */ 40 #define E820NR 0x1e8 /* # entries in E820MAP */
41 41
42 #define E820_RAM 1 42 #define E820_RAM 1
43 #define E820_RESERVED 2 43 #define E820_RESERVED 2
44 #define E820_ACPI 3 44 #define E820_ACPI 3
45 #define E820_NVS 4 45 #define E820_NVS 4
46 #define E820_UNUSABLE 5 46 #define E820_UNUSABLE 5
47 47
48 /* 48 /*
49 * reserved RAM used by kernel itself 49 * reserved RAM used by kernel itself
50 * if CONFIG_INTEL_TXT is enabled, memory of this type will be 50 * if CONFIG_INTEL_TXT is enabled, memory of this type will be
51 * included in the S3 integrity calculation and so should not include 51 * included in the S3 integrity calculation and so should not include
52 * any memory that BIOS might alter over the S3 transition 52 * any memory that BIOS might alter over the S3 transition
53 */ 53 */
54 #define E820_RESERVED_KERN 128 54 #define E820_RESERVED_KERN 128
55 55
56 /*
57 * Address ranges that need to be mapped by the kernel direct
58 * mapping. This is used to make sure regions such as
59 * EFI_RUNTIME_SERVICES_DATA are directly mapped. See setup_arch().
60 */
61 #define E820_RESERVED_EFI 129
62
56 #ifndef __ASSEMBLY__ 63 #ifndef __ASSEMBLY__
57 #include <linux/types.h> 64 #include <linux/types.h>
58 struct e820entry { 65 struct e820entry {
59 __u64 addr; /* start of memory segment */ 66 __u64 addr; /* start of memory segment */
60 __u64 size; /* size of memory segment */ 67 __u64 size; /* size of memory segment */
61 __u32 type; /* type of memory segment */ 68 __u32 type; /* type of memory segment */
62 } __attribute__((packed)); 69 } __attribute__((packed));
63 70
64 struct e820map { 71 struct e820map {
65 __u32 nr_map; 72 __u32 nr_map;
66 struct e820entry map[E820_X_MAX]; 73 struct e820entry map[E820_X_MAX];
67 }; 74 };
68 75
69 #define ISA_START_ADDRESS 0xa0000 76 #define ISA_START_ADDRESS 0xa0000
70 #define ISA_END_ADDRESS 0x100000 77 #define ISA_END_ADDRESS 0x100000
71 78
72 #define BIOS_BEGIN 0x000a0000 79 #define BIOS_BEGIN 0x000a0000
73 #define BIOS_END 0x00100000 80 #define BIOS_END 0x00100000
74 81
75 #define BIOS_ROM_BASE 0xffe00000 82 #define BIOS_ROM_BASE 0xffe00000
76 #define BIOS_ROM_END 0xffffffff 83 #define BIOS_ROM_END 0xffffffff
77 84
78 #ifdef __KERNEL__ 85 #ifdef __KERNEL__
79 /* see comment in arch/x86/kernel/e820.c */ 86 /* see comment in arch/x86/kernel/e820.c */
80 extern struct e820map e820; 87 extern struct e820map e820;
81 extern struct e820map e820_saved; 88 extern struct e820map e820_saved;
82 89
83 extern unsigned long pci_mem_start; 90 extern unsigned long pci_mem_start;
84 extern int e820_any_mapped(u64 start, u64 end, unsigned type); 91 extern int e820_any_mapped(u64 start, u64 end, unsigned type);
85 extern int e820_all_mapped(u64 start, u64 end, unsigned type); 92 extern int e820_all_mapped(u64 start, u64 end, unsigned type);
86 extern void e820_add_region(u64 start, u64 size, int type); 93 extern void e820_add_region(u64 start, u64 size, int type);
87 extern void e820_print_map(char *who); 94 extern void e820_print_map(char *who);
88 extern int 95 extern int
89 sanitize_e820_map(struct e820entry *biosmap, int max_nr_map, u32 *pnr_map); 96 sanitize_e820_map(struct e820entry *biosmap, int max_nr_map, u32 *pnr_map);
90 extern u64 e820_update_range(u64 start, u64 size, unsigned old_type, 97 extern u64 e820_update_range(u64 start, u64 size, unsigned old_type,
91 unsigned new_type); 98 unsigned new_type);
92 extern u64 e820_remove_range(u64 start, u64 size, unsigned old_type, 99 extern u64 e820_remove_range(u64 start, u64 size, unsigned old_type,
93 int checktype); 100 int checktype);
94 extern void update_e820(void); 101 extern void update_e820(void);
95 extern void e820_setup_gap(void); 102 extern void e820_setup_gap(void);
96 extern int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize, 103 extern int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize,
97 unsigned long start_addr, unsigned long long end_addr); 104 unsigned long start_addr, unsigned long long end_addr);
98 struct setup_data; 105 struct setup_data;
99 extern void parse_e820_ext(struct setup_data *data); 106 extern void parse_e820_ext(struct setup_data *data);
100 107
101 #if defined(CONFIG_X86_64) || \ 108 #if defined(CONFIG_X86_64) || \
102 (defined(CONFIG_X86_32) && defined(CONFIG_HIBERNATION)) 109 (defined(CONFIG_X86_32) && defined(CONFIG_HIBERNATION))
103 extern void e820_mark_nosave_regions(unsigned long limit_pfn); 110 extern void e820_mark_nosave_regions(unsigned long limit_pfn);
104 #else 111 #else
105 static inline void e820_mark_nosave_regions(unsigned long limit_pfn) 112 static inline void e820_mark_nosave_regions(unsigned long limit_pfn)
106 { 113 {
107 } 114 }
108 #endif 115 #endif
109 116
110 #ifdef CONFIG_MEMTEST 117 #ifdef CONFIG_MEMTEST
111 extern void early_memtest(unsigned long start, unsigned long end); 118 extern void early_memtest(unsigned long start, unsigned long end);
112 #else 119 #else
113 static inline void early_memtest(unsigned long start, unsigned long end) 120 static inline void early_memtest(unsigned long start, unsigned long end)
114 { 121 {
115 } 122 }
116 #endif 123 #endif
117 124
125 extern unsigned long e820_end_pfn(unsigned long limit_pfn, unsigned type);
118 extern unsigned long e820_end_of_ram_pfn(void); 126 extern unsigned long e820_end_of_ram_pfn(void);
119 extern unsigned long e820_end_of_low_ram_pfn(void); 127 extern unsigned long e820_end_of_low_ram_pfn(void);
120 extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align); 128 extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align);
121 129
122 void memblock_x86_fill(void); 130 void memblock_x86_fill(void);
123 void memblock_find_dma_reserve(void); 131 void memblock_find_dma_reserve(void);
124 132
125 extern void finish_e820_parsing(void); 133 extern void finish_e820_parsing(void);
126 extern void e820_reserve_resources(void); 134 extern void e820_reserve_resources(void);
127 extern void e820_reserve_resources_late(void); 135 extern void e820_reserve_resources_late(void);
128 extern void setup_memory_map(void); 136 extern void setup_memory_map(void);
129 extern char *default_machine_specific_memory_setup(void); 137 extern char *default_machine_specific_memory_setup(void);
130 138
131 /* 139 /*
132 * Returns true iff the specified range [s,e) is completely contained inside 140 * Returns true iff the specified range [s,e) is completely contained inside
133 * the ISA region. 141 * the ISA region.
134 */ 142 */
135 static inline bool is_ISA_range(u64 s, u64 e) 143 static inline bool is_ISA_range(u64 s, u64 e)
136 { 144 {
137 return s >= ISA_START_ADDRESS && e <= ISA_END_ADDRESS; 145 return s >= ISA_START_ADDRESS && e <= ISA_END_ADDRESS;
138 } 146 }
139 147
140 #endif /* __KERNEL__ */ 148 #endif /* __KERNEL__ */
141 #endif /* __ASSEMBLY__ */ 149 #endif /* __ASSEMBLY__ */
142 150
143 #ifdef __KERNEL__ 151 #ifdef __KERNEL__
144 #include <linux/ioport.h> 152 #include <linux/ioport.h>
145 153
146 #define HIGH_MEMORY (1024*1024) 154 #define HIGH_MEMORY (1024*1024)
147 #endif /* __KERNEL__ */ 155 #endif /* __KERNEL__ */
148 156
149 #endif /* _ASM_X86_E820_H */ 157 #endif /* _ASM_X86_E820_H */
150 158
arch/x86/include/asm/efi.h
1 #ifndef _ASM_X86_EFI_H 1 #ifndef _ASM_X86_EFI_H
2 #define _ASM_X86_EFI_H 2 #define _ASM_X86_EFI_H
3 3
4 #ifdef CONFIG_X86_32 4 #ifdef CONFIG_X86_32
5 5
6 extern unsigned long asmlinkage efi_call_phys(void *, ...); 6 extern unsigned long asmlinkage efi_call_phys(void *, ...);
7 7
8 #define efi_call_phys0(f) efi_call_phys(f) 8 #define efi_call_phys0(f) efi_call_phys(f)
9 #define efi_call_phys1(f, a1) efi_call_phys(f, a1) 9 #define efi_call_phys1(f, a1) efi_call_phys(f, a1)
10 #define efi_call_phys2(f, a1, a2) efi_call_phys(f, a1, a2) 10 #define efi_call_phys2(f, a1, a2) efi_call_phys(f, a1, a2)
11 #define efi_call_phys3(f, a1, a2, a3) efi_call_phys(f, a1, a2, a3) 11 #define efi_call_phys3(f, a1, a2, a3) efi_call_phys(f, a1, a2, a3)
12 #define efi_call_phys4(f, a1, a2, a3, a4) \ 12 #define efi_call_phys4(f, a1, a2, a3, a4) \
13 efi_call_phys(f, a1, a2, a3, a4) 13 efi_call_phys(f, a1, a2, a3, a4)
14 #define efi_call_phys5(f, a1, a2, a3, a4, a5) \ 14 #define efi_call_phys5(f, a1, a2, a3, a4, a5) \
15 efi_call_phys(f, a1, a2, a3, a4, a5) 15 efi_call_phys(f, a1, a2, a3, a4, a5)
16 #define efi_call_phys6(f, a1, a2, a3, a4, a5, a6) \ 16 #define efi_call_phys6(f, a1, a2, a3, a4, a5, a6) \
17 efi_call_phys(f, a1, a2, a3, a4, a5, a6) 17 efi_call_phys(f, a1, a2, a3, a4, a5, a6)
18 /* 18 /*
19 * Wrap all the virtual calls in a way that forces the parameters on the stack. 19 * Wrap all the virtual calls in a way that forces the parameters on the stack.
20 */ 20 */
21 21
22 #define efi_call_virt(f, args...) \ 22 #define efi_call_virt(f, args...) \
23 ((efi_##f##_t __attribute__((regparm(0)))*)efi.systab->runtime->f)(args) 23 ((efi_##f##_t __attribute__((regparm(0)))*)efi.systab->runtime->f)(args)
24 24
25 #define efi_call_virt0(f) efi_call_virt(f) 25 #define efi_call_virt0(f) efi_call_virt(f)
26 #define efi_call_virt1(f, a1) efi_call_virt(f, a1) 26 #define efi_call_virt1(f, a1) efi_call_virt(f, a1)
27 #define efi_call_virt2(f, a1, a2) efi_call_virt(f, a1, a2) 27 #define efi_call_virt2(f, a1, a2) efi_call_virt(f, a1, a2)
28 #define efi_call_virt3(f, a1, a2, a3) efi_call_virt(f, a1, a2, a3) 28 #define efi_call_virt3(f, a1, a2, a3) efi_call_virt(f, a1, a2, a3)
29 #define efi_call_virt4(f, a1, a2, a3, a4) \ 29 #define efi_call_virt4(f, a1, a2, a3, a4) \
30 efi_call_virt(f, a1, a2, a3, a4) 30 efi_call_virt(f, a1, a2, a3, a4)
31 #define efi_call_virt5(f, a1, a2, a3, a4, a5) \ 31 #define efi_call_virt5(f, a1, a2, a3, a4, a5) \
32 efi_call_virt(f, a1, a2, a3, a4, a5) 32 efi_call_virt(f, a1, a2, a3, a4, a5)
33 #define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \ 33 #define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \
34 efi_call_virt(f, a1, a2, a3, a4, a5, a6) 34 efi_call_virt(f, a1, a2, a3, a4, a5, a6)
35 35
36 #define efi_ioremap(addr, size, type) ioremap_cache(addr, size)
37
38 #else /* !CONFIG_X86_32 */ 36 #else /* !CONFIG_X86_32 */
39 37
40 extern u64 efi_call0(void *fp); 38 extern u64 efi_call0(void *fp);
41 extern u64 efi_call1(void *fp, u64 arg1); 39 extern u64 efi_call1(void *fp, u64 arg1);
42 extern u64 efi_call2(void *fp, u64 arg1, u64 arg2); 40 extern u64 efi_call2(void *fp, u64 arg1, u64 arg2);
43 extern u64 efi_call3(void *fp, u64 arg1, u64 arg2, u64 arg3); 41 extern u64 efi_call3(void *fp, u64 arg1, u64 arg2, u64 arg3);
44 extern u64 efi_call4(void *fp, u64 arg1, u64 arg2, u64 arg3, u64 arg4); 42 extern u64 efi_call4(void *fp, u64 arg1, u64 arg2, u64 arg3, u64 arg4);
45 extern u64 efi_call5(void *fp, u64 arg1, u64 arg2, u64 arg3, 43 extern u64 efi_call5(void *fp, u64 arg1, u64 arg2, u64 arg3,
46 u64 arg4, u64 arg5); 44 u64 arg4, u64 arg5);
47 extern u64 efi_call6(void *fp, u64 arg1, u64 arg2, u64 arg3, 45 extern u64 efi_call6(void *fp, u64 arg1, u64 arg2, u64 arg3,
48 u64 arg4, u64 arg5, u64 arg6); 46 u64 arg4, u64 arg5, u64 arg6);
49 47
50 #define efi_call_phys0(f) \ 48 #define efi_call_phys0(f) \
51 efi_call0((void *)(f)) 49 efi_call0((void *)(f))
52 #define efi_call_phys1(f, a1) \ 50 #define efi_call_phys1(f, a1) \
53 efi_call1((void *)(f), (u64)(a1)) 51 efi_call1((void *)(f), (u64)(a1))
54 #define efi_call_phys2(f, a1, a2) \ 52 #define efi_call_phys2(f, a1, a2) \
55 efi_call2((void *)(f), (u64)(a1), (u64)(a2)) 53 efi_call2((void *)(f), (u64)(a1), (u64)(a2))
56 #define efi_call_phys3(f, a1, a2, a3) \ 54 #define efi_call_phys3(f, a1, a2, a3) \
57 efi_call3((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3)) 55 efi_call3((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3))
58 #define efi_call_phys4(f, a1, a2, a3, a4) \ 56 #define efi_call_phys4(f, a1, a2, a3, a4) \
59 efi_call4((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \ 57 efi_call4((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \
60 (u64)(a4)) 58 (u64)(a4))
61 #define efi_call_phys5(f, a1, a2, a3, a4, a5) \ 59 #define efi_call_phys5(f, a1, a2, a3, a4, a5) \
62 efi_call5((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \ 60 efi_call5((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \
63 (u64)(a4), (u64)(a5)) 61 (u64)(a4), (u64)(a5))
64 #define efi_call_phys6(f, a1, a2, a3, a4, a5, a6) \ 62 #define efi_call_phys6(f, a1, a2, a3, a4, a5, a6) \
65 efi_call6((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \ 63 efi_call6((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \
66 (u64)(a4), (u64)(a5), (u64)(a6)) 64 (u64)(a4), (u64)(a5), (u64)(a6))
67 65
68 #define efi_call_virt0(f) \ 66 #define efi_call_virt0(f) \
69 efi_call0((void *)(efi.systab->runtime->f)) 67 efi_call0((void *)(efi.systab->runtime->f))
70 #define efi_call_virt1(f, a1) \ 68 #define efi_call_virt1(f, a1) \
71 efi_call1((void *)(efi.systab->runtime->f), (u64)(a1)) 69 efi_call1((void *)(efi.systab->runtime->f), (u64)(a1))
72 #define efi_call_virt2(f, a1, a2) \ 70 #define efi_call_virt2(f, a1, a2) \
73 efi_call2((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2)) 71 efi_call2((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2))
74 #define efi_call_virt3(f, a1, a2, a3) \ 72 #define efi_call_virt3(f, a1, a2, a3) \
75 efi_call3((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \ 73 efi_call3((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
76 (u64)(a3)) 74 (u64)(a3))
77 #define efi_call_virt4(f, a1, a2, a3, a4) \ 75 #define efi_call_virt4(f, a1, a2, a3, a4) \
78 efi_call4((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \ 76 efi_call4((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
79 (u64)(a3), (u64)(a4)) 77 (u64)(a3), (u64)(a4))
80 #define efi_call_virt5(f, a1, a2, a3, a4, a5) \ 78 #define efi_call_virt5(f, a1, a2, a3, a4, a5) \
81 efi_call5((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \ 79 efi_call5((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
82 (u64)(a3), (u64)(a4), (u64)(a5)) 80 (u64)(a3), (u64)(a4), (u64)(a5))
83 #define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \ 81 #define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \
84 efi_call6((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \ 82 efi_call6((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
85 (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6)) 83 (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6))
86
87 extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size,
88 u32 type);
89 84
90 #endif /* CONFIG_X86_32 */ 85 #endif /* CONFIG_X86_32 */
91 86
92 extern int add_efi_memmap; 87 extern int add_efi_memmap;
93 extern void efi_set_executable(efi_memory_desc_t *md, bool executable); 88 extern void efi_set_executable(efi_memory_desc_t *md, bool executable);
94 extern void efi_memblock_x86_reserve_range(void); 89 extern void efi_memblock_x86_reserve_range(void);
95 extern void efi_call_phys_prelog(void); 90 extern void efi_call_phys_prelog(void);
96 extern void efi_call_phys_epilog(void); 91 extern void efi_call_phys_epilog(void);
97 92
98 #ifndef CONFIG_EFI 93 #ifndef CONFIG_EFI
99 /* 94 /*
100 * IF EFI is not configured, have the EFI calls return -ENOSYS. 95 * IF EFI is not configured, have the EFI calls return -ENOSYS.
101 */ 96 */
102 #define efi_call0(_f) (-ENOSYS) 97 #define efi_call0(_f) (-ENOSYS)
103 #define efi_call1(_f, _a1) (-ENOSYS) 98 #define efi_call1(_f, _a1) (-ENOSYS)
104 #define efi_call2(_f, _a1, _a2) (-ENOSYS) 99 #define efi_call2(_f, _a1, _a2) (-ENOSYS)
105 #define efi_call3(_f, _a1, _a2, _a3) (-ENOSYS) 100 #define efi_call3(_f, _a1, _a2, _a3) (-ENOSYS)
106 #define efi_call4(_f, _a1, _a2, _a3, _a4) (-ENOSYS) 101 #define efi_call4(_f, _a1, _a2, _a3, _a4) (-ENOSYS)
107 #define efi_call5(_f, _a1, _a2, _a3, _a4, _a5) (-ENOSYS) 102 #define efi_call5(_f, _a1, _a2, _a3, _a4, _a5) (-ENOSYS)
108 #define efi_call6(_f, _a1, _a2, _a3, _a4, _a5, _a6) (-ENOSYS) 103 #define efi_call6(_f, _a1, _a2, _a3, _a4, _a5, _a6) (-ENOSYS)
109 #endif /* CONFIG_EFI */ 104 #endif /* CONFIG_EFI */
110 105
111 #endif /* _ASM_X86_EFI_H */ 106 #endif /* _ASM_X86_EFI_H */
112 107
arch/x86/kernel/e820.c
1 /* 1 /*
2 * Handle the memory map. 2 * Handle the memory map.
3 * The functions here do the job until bootmem takes over. 3 * The functions here do the job until bootmem takes over.
4 * 4 *
5 * Getting sanitize_e820_map() in sync with i386 version by applying change: 5 * Getting sanitize_e820_map() in sync with i386 version by applying change:
6 * - Provisions for empty E820 memory regions (reported by certain BIOSes). 6 * - Provisions for empty E820 memory regions (reported by certain BIOSes).
7 * Alex Achenbach <xela@slit.de>, December 2002. 7 * Alex Achenbach <xela@slit.de>, December 2002.
8 * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> 8 * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
9 * 9 *
10 */ 10 */
11 #include <linux/kernel.h> 11 #include <linux/kernel.h>
12 #include <linux/types.h> 12 #include <linux/types.h>
13 #include <linux/init.h> 13 #include <linux/init.h>
14 #include <linux/crash_dump.h> 14 #include <linux/crash_dump.h>
15 #include <linux/export.h> 15 #include <linux/export.h>
16 #include <linux/bootmem.h> 16 #include <linux/bootmem.h>
17 #include <linux/pfn.h> 17 #include <linux/pfn.h>
18 #include <linux/suspend.h> 18 #include <linux/suspend.h>
19 #include <linux/acpi.h> 19 #include <linux/acpi.h>
20 #include <linux/firmware-map.h> 20 #include <linux/firmware-map.h>
21 #include <linux/memblock.h> 21 #include <linux/memblock.h>
22 22
23 #include <asm/e820.h> 23 #include <asm/e820.h>
24 #include <asm/proto.h> 24 #include <asm/proto.h>
25 #include <asm/setup.h> 25 #include <asm/setup.h>
26 26
27 /* 27 /*
28 * The e820 map is the map that gets modified e.g. with command line parameters 28 * The e820 map is the map that gets modified e.g. with command line parameters
29 * and that is also registered with modifications in the kernel resource tree 29 * and that is also registered with modifications in the kernel resource tree
30 * with the iomem_resource as parent. 30 * with the iomem_resource as parent.
31 * 31 *
32 * The e820_saved is directly saved after the BIOS-provided memory map is 32 * The e820_saved is directly saved after the BIOS-provided memory map is
33 * copied. It doesn't get modified afterwards. It's registered for the 33 * copied. It doesn't get modified afterwards. It's registered for the
34 * /sys/firmware/memmap interface. 34 * /sys/firmware/memmap interface.
35 * 35 *
36 * That memory map is not modified and is used as base for kexec. The kexec'd 36 * That memory map is not modified and is used as base for kexec. The kexec'd
37 * kernel should get the same memory map as the firmware provides. Then the 37 * kernel should get the same memory map as the firmware provides. Then the
38 * user can e.g. boot the original kernel with mem=1G while still booting the 38 * user can e.g. boot the original kernel with mem=1G while still booting the
39 * next kernel with full memory. 39 * next kernel with full memory.
40 */ 40 */
41 struct e820map e820; 41 struct e820map e820;
42 struct e820map e820_saved; 42 struct e820map e820_saved;
43 43
44 /* For PCI or other memory-mapped resources */ 44 /* For PCI or other memory-mapped resources */
45 unsigned long pci_mem_start = 0xaeedbabe; 45 unsigned long pci_mem_start = 0xaeedbabe;
46 #ifdef CONFIG_PCI 46 #ifdef CONFIG_PCI
47 EXPORT_SYMBOL(pci_mem_start); 47 EXPORT_SYMBOL(pci_mem_start);
48 #endif 48 #endif
49 49
50 /* 50 /*
51 * This function checks if any part of the range <start,end> is mapped 51 * This function checks if any part of the range <start,end> is mapped
52 * with type. 52 * with type.
53 */ 53 */
54 int 54 int
55 e820_any_mapped(u64 start, u64 end, unsigned type) 55 e820_any_mapped(u64 start, u64 end, unsigned type)
56 { 56 {
57 int i; 57 int i;
58 58
59 for (i = 0; i < e820.nr_map; i++) { 59 for (i = 0; i < e820.nr_map; i++) {
60 struct e820entry *ei = &e820.map[i]; 60 struct e820entry *ei = &e820.map[i];
61 61
62 if (type && ei->type != type) 62 if (type && ei->type != type)
63 continue; 63 continue;
64 if (ei->addr >= end || ei->addr + ei->size <= start) 64 if (ei->addr >= end || ei->addr + ei->size <= start)
65 continue; 65 continue;
66 return 1; 66 return 1;
67 } 67 }
68 return 0; 68 return 0;
69 } 69 }
70 EXPORT_SYMBOL_GPL(e820_any_mapped); 70 EXPORT_SYMBOL_GPL(e820_any_mapped);
71 71
72 /* 72 /*
73 * This function checks if the entire range <start,end> is mapped with type. 73 * This function checks if the entire range <start,end> is mapped with type.
74 * 74 *
75 * Note: this function only works correct if the e820 table is sorted and 75 * Note: this function only works correct if the e820 table is sorted and
76 * not-overlapping, which is the case 76 * not-overlapping, which is the case
77 */ 77 */
78 int __init e820_all_mapped(u64 start, u64 end, unsigned type) 78 int __init e820_all_mapped(u64 start, u64 end, unsigned type)
79 { 79 {
80 int i; 80 int i;
81 81
82 for (i = 0; i < e820.nr_map; i++) { 82 for (i = 0; i < e820.nr_map; i++) {
83 struct e820entry *ei = &e820.map[i]; 83 struct e820entry *ei = &e820.map[i];
84 84
85 if (type && ei->type != type) 85 if (type && ei->type != type)
86 continue; 86 continue;
87 /* is the region (part) in overlap with the current region ?*/ 87 /* is the region (part) in overlap with the current region ?*/
88 if (ei->addr >= end || ei->addr + ei->size <= start) 88 if (ei->addr >= end || ei->addr + ei->size <= start)
89 continue; 89 continue;
90 90
91 /* if the region is at the beginning of <start,end> we move 91 /* if the region is at the beginning of <start,end> we move
92 * start to the end of the region since it's ok until there 92 * start to the end of the region since it's ok until there
93 */ 93 */
94 if (ei->addr <= start) 94 if (ei->addr <= start)
95 start = ei->addr + ei->size; 95 start = ei->addr + ei->size;
96 /* 96 /*
97 * if start is now at or beyond end, we're done, full 97 * if start is now at or beyond end, we're done, full
98 * coverage 98 * coverage
99 */ 99 */
100 if (start >= end) 100 if (start >= end)
101 return 1; 101 return 1;
102 } 102 }
103 return 0; 103 return 0;
104 } 104 }
105 105
106 /* 106 /*
107 * Add a memory region to the kernel e820 map. 107 * Add a memory region to the kernel e820 map.
108 */ 108 */
109 static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size, 109 static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,
110 int type) 110 int type)
111 { 111 {
112 int x = e820x->nr_map; 112 int x = e820x->nr_map;
113 113
114 if (x >= ARRAY_SIZE(e820x->map)) { 114 if (x >= ARRAY_SIZE(e820x->map)) {
115 printk(KERN_ERR "Ooops! Too many entries in the memory map!\n"); 115 printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
116 return; 116 return;
117 } 117 }
118 118
119 e820x->map[x].addr = start; 119 e820x->map[x].addr = start;
120 e820x->map[x].size = size; 120 e820x->map[x].size = size;
121 e820x->map[x].type = type; 121 e820x->map[x].type = type;
122 e820x->nr_map++; 122 e820x->nr_map++;
123 } 123 }
124 124
125 void __init e820_add_region(u64 start, u64 size, int type) 125 void __init e820_add_region(u64 start, u64 size, int type)
126 { 126 {
127 __e820_add_region(&e820, start, size, type); 127 __e820_add_region(&e820, start, size, type);
128 } 128 }
129 129
130 static void __init e820_print_type(u32 type) 130 static void __init e820_print_type(u32 type)
131 { 131 {
132 switch (type) { 132 switch (type) {
133 case E820_RAM: 133 case E820_RAM:
134 case E820_RESERVED_KERN: 134 case E820_RESERVED_KERN:
135 printk(KERN_CONT "(usable)"); 135 printk(KERN_CONT "(usable)");
136 break; 136 break;
137 case E820_RESERVED: 137 case E820_RESERVED:
138 case E820_RESERVED_EFI:
138 printk(KERN_CONT "(reserved)"); 139 printk(KERN_CONT "(reserved)");
139 break; 140 break;
140 case E820_ACPI: 141 case E820_ACPI:
141 printk(KERN_CONT "(ACPI data)"); 142 printk(KERN_CONT "(ACPI data)");
142 break; 143 break;
143 case E820_NVS: 144 case E820_NVS:
144 printk(KERN_CONT "(ACPI NVS)"); 145 printk(KERN_CONT "(ACPI NVS)");
145 break; 146 break;
146 case E820_UNUSABLE: 147 case E820_UNUSABLE:
147 printk(KERN_CONT "(unusable)"); 148 printk(KERN_CONT "(unusable)");
148 break; 149 break;
149 default: 150 default:
150 printk(KERN_CONT "type %u", type); 151 printk(KERN_CONT "type %u", type);
151 break; 152 break;
152 } 153 }
153 } 154 }
154 155
155 void __init e820_print_map(char *who) 156 void __init e820_print_map(char *who)
156 { 157 {
157 int i; 158 int i;
158 159
159 for (i = 0; i < e820.nr_map; i++) { 160 for (i = 0; i < e820.nr_map; i++) {
160 printk(KERN_INFO " %s: %016Lx - %016Lx ", who, 161 printk(KERN_INFO " %s: %016Lx - %016Lx ", who,
161 (unsigned long long) e820.map[i].addr, 162 (unsigned long long) e820.map[i].addr,
162 (unsigned long long) 163 (unsigned long long)
163 (e820.map[i].addr + e820.map[i].size)); 164 (e820.map[i].addr + e820.map[i].size));
164 e820_print_type(e820.map[i].type); 165 e820_print_type(e820.map[i].type);
165 printk(KERN_CONT "\n"); 166 printk(KERN_CONT "\n");
166 } 167 }
167 } 168 }
168 169
169 /* 170 /*
170 * Sanitize the BIOS e820 map. 171 * Sanitize the BIOS e820 map.
171 * 172 *
172 * Some e820 responses include overlapping entries. The following 173 * Some e820 responses include overlapping entries. The following
173 * replaces the original e820 map with a new one, removing overlaps, 174 * replaces the original e820 map with a new one, removing overlaps,
174 * and resolving conflicting memory types in favor of highest 175 * and resolving conflicting memory types in favor of highest
175 * numbered type. 176 * numbered type.
176 * 177 *
177 * The input parameter biosmap points to an array of 'struct 178 * The input parameter biosmap points to an array of 'struct
178 * e820entry' which on entry has elements in the range [0, *pnr_map) 179 * e820entry' which on entry has elements in the range [0, *pnr_map)
179 * valid, and which has space for up to max_nr_map entries. 180 * valid, and which has space for up to max_nr_map entries.
180 * On return, the resulting sanitized e820 map entries will be in 181 * On return, the resulting sanitized e820 map entries will be in
181 * overwritten in the same location, starting at biosmap. 182 * overwritten in the same location, starting at biosmap.
182 * 183 *
183 * The integer pointed to by pnr_map must be valid on entry (the 184 * The integer pointed to by pnr_map must be valid on entry (the
184 * current number of valid entries located at biosmap) and will 185 * current number of valid entries located at biosmap) and will
185 * be updated on return, with the new number of valid entries 186 * be updated on return, with the new number of valid entries
186 * (something no more than max_nr_map.) 187 * (something no more than max_nr_map.)
187 * 188 *
188 * The return value from sanitize_e820_map() is zero if it 189 * The return value from sanitize_e820_map() is zero if it
189 * successfully 'sanitized' the map entries passed in, and is -1 190 * successfully 'sanitized' the map entries passed in, and is -1
190 * if it did nothing, which can happen if either of (1) it was 191 * if it did nothing, which can happen if either of (1) it was
191 * only passed one map entry, or (2) any of the input map entries 192 * only passed one map entry, or (2) any of the input map entries
192 * were invalid (start + size < start, meaning that the size was 193 * were invalid (start + size < start, meaning that the size was
193 * so big the described memory range wrapped around through zero.) 194 * so big the described memory range wrapped around through zero.)
194 * 195 *
195 * Visually we're performing the following 196 * Visually we're performing the following
196 * (1,2,3,4 = memory types)... 197 * (1,2,3,4 = memory types)...
197 * 198 *
198 * Sample memory map (w/overlaps): 199 * Sample memory map (w/overlaps):
199 * ____22__________________ 200 * ____22__________________
200 * ______________________4_ 201 * ______________________4_
201 * ____1111________________ 202 * ____1111________________
202 * _44_____________________ 203 * _44_____________________
203 * 11111111________________ 204 * 11111111________________
204 * ____________________33__ 205 * ____________________33__
205 * ___________44___________ 206 * ___________44___________
206 * __________33333_________ 207 * __________33333_________
207 * ______________22________ 208 * ______________22________
208 * ___________________2222_ 209 * ___________________2222_
209 * _________111111111______ 210 * _________111111111______
210 * _____________________11_ 211 * _____________________11_
211 * _________________4______ 212 * _________________4______
212 * 213 *
213 * Sanitized equivalent (no overlap): 214 * Sanitized equivalent (no overlap):
214 * 1_______________________ 215 * 1_______________________
215 * _44_____________________ 216 * _44_____________________
216 * ___1____________________ 217 * ___1____________________
217 * ____22__________________ 218 * ____22__________________
218 * ______11________________ 219 * ______11________________
219 * _________1______________ 220 * _________1______________
220 * __________3_____________ 221 * __________3_____________
221 * ___________44___________ 222 * ___________44___________
222 * _____________33_________ 223 * _____________33_________
223 * _______________2________ 224 * _______________2________
224 * ________________1_______ 225 * ________________1_______
225 * _________________4______ 226 * _________________4______
226 * ___________________2____ 227 * ___________________2____
227 * ____________________33__ 228 * ____________________33__
228 * ______________________4_ 229 * ______________________4_
229 */ 230 */
230 231
231 int __init sanitize_e820_map(struct e820entry *biosmap, int max_nr_map, 232 int __init sanitize_e820_map(struct e820entry *biosmap, int max_nr_map,
232 u32 *pnr_map) 233 u32 *pnr_map)
233 { 234 {
234 struct change_member { 235 struct change_member {
235 struct e820entry *pbios; /* pointer to original bios entry */ 236 struct e820entry *pbios; /* pointer to original bios entry */
236 unsigned long long addr; /* address for this change point */ 237 unsigned long long addr; /* address for this change point */
237 }; 238 };
238 static struct change_member change_point_list[2*E820_X_MAX] __initdata; 239 static struct change_member change_point_list[2*E820_X_MAX] __initdata;
239 static struct change_member *change_point[2*E820_X_MAX] __initdata; 240 static struct change_member *change_point[2*E820_X_MAX] __initdata;
240 static struct e820entry *overlap_list[E820_X_MAX] __initdata; 241 static struct e820entry *overlap_list[E820_X_MAX] __initdata;
241 static struct e820entry new_bios[E820_X_MAX] __initdata; 242 static struct e820entry new_bios[E820_X_MAX] __initdata;
242 struct change_member *change_tmp; 243 struct change_member *change_tmp;
243 unsigned long current_type, last_type; 244 unsigned long current_type, last_type;
244 unsigned long long last_addr; 245 unsigned long long last_addr;
245 int chgidx, still_changing; 246 int chgidx, still_changing;
246 int overlap_entries; 247 int overlap_entries;
247 int new_bios_entry; 248 int new_bios_entry;
248 int old_nr, new_nr, chg_nr; 249 int old_nr, new_nr, chg_nr;
249 int i; 250 int i;
250 251
251 /* if there's only one memory region, don't bother */ 252 /* if there's only one memory region, don't bother */
252 if (*pnr_map < 2) 253 if (*pnr_map < 2)
253 return -1; 254 return -1;
254 255
255 old_nr = *pnr_map; 256 old_nr = *pnr_map;
256 BUG_ON(old_nr > max_nr_map); 257 BUG_ON(old_nr > max_nr_map);
257 258
258 /* bail out if we find any unreasonable addresses in bios map */ 259 /* bail out if we find any unreasonable addresses in bios map */
259 for (i = 0; i < old_nr; i++) 260 for (i = 0; i < old_nr; i++)
260 if (biosmap[i].addr + biosmap[i].size < biosmap[i].addr) 261 if (biosmap[i].addr + biosmap[i].size < biosmap[i].addr)
261 return -1; 262 return -1;
262 263
263 /* create pointers for initial change-point information (for sorting) */ 264 /* create pointers for initial change-point information (for sorting) */
264 for (i = 0; i < 2 * old_nr; i++) 265 for (i = 0; i < 2 * old_nr; i++)
265 change_point[i] = &change_point_list[i]; 266 change_point[i] = &change_point_list[i];
266 267
267 /* record all known change-points (starting and ending addresses), 268 /* record all known change-points (starting and ending addresses),
268 omitting those that are for empty memory regions */ 269 omitting those that are for empty memory regions */
269 chgidx = 0; 270 chgidx = 0;
270 for (i = 0; i < old_nr; i++) { 271 for (i = 0; i < old_nr; i++) {
271 if (biosmap[i].size != 0) { 272 if (biosmap[i].size != 0) {
272 change_point[chgidx]->addr = biosmap[i].addr; 273 change_point[chgidx]->addr = biosmap[i].addr;
273 change_point[chgidx++]->pbios = &biosmap[i]; 274 change_point[chgidx++]->pbios = &biosmap[i];
274 change_point[chgidx]->addr = biosmap[i].addr + 275 change_point[chgidx]->addr = biosmap[i].addr +
275 biosmap[i].size; 276 biosmap[i].size;
276 change_point[chgidx++]->pbios = &biosmap[i]; 277 change_point[chgidx++]->pbios = &biosmap[i];
277 } 278 }
278 } 279 }
279 chg_nr = chgidx; 280 chg_nr = chgidx;
280 281
281 /* sort change-point list by memory addresses (low -> high) */ 282 /* sort change-point list by memory addresses (low -> high) */
282 still_changing = 1; 283 still_changing = 1;
283 while (still_changing) { 284 while (still_changing) {
284 still_changing = 0; 285 still_changing = 0;
285 for (i = 1; i < chg_nr; i++) { 286 for (i = 1; i < chg_nr; i++) {
286 unsigned long long curaddr, lastaddr; 287 unsigned long long curaddr, lastaddr;
287 unsigned long long curpbaddr, lastpbaddr; 288 unsigned long long curpbaddr, lastpbaddr;
288 289
289 curaddr = change_point[i]->addr; 290 curaddr = change_point[i]->addr;
290 lastaddr = change_point[i - 1]->addr; 291 lastaddr = change_point[i - 1]->addr;
291 curpbaddr = change_point[i]->pbios->addr; 292 curpbaddr = change_point[i]->pbios->addr;
292 lastpbaddr = change_point[i - 1]->pbios->addr; 293 lastpbaddr = change_point[i - 1]->pbios->addr;
293 294
294 /* 295 /*
295 * swap entries, when: 296 * swap entries, when:
296 * 297 *
297 * curaddr > lastaddr or 298 * curaddr > lastaddr or
298 * curaddr == lastaddr and curaddr == curpbaddr and 299 * curaddr == lastaddr and curaddr == curpbaddr and
299 * lastaddr != lastpbaddr 300 * lastaddr != lastpbaddr
300 */ 301 */
301 if (curaddr < lastaddr || 302 if (curaddr < lastaddr ||
302 (curaddr == lastaddr && curaddr == curpbaddr && 303 (curaddr == lastaddr && curaddr == curpbaddr &&
303 lastaddr != lastpbaddr)) { 304 lastaddr != lastpbaddr)) {
304 change_tmp = change_point[i]; 305 change_tmp = change_point[i];
305 change_point[i] = change_point[i-1]; 306 change_point[i] = change_point[i-1];
306 change_point[i-1] = change_tmp; 307 change_point[i-1] = change_tmp;
307 still_changing = 1; 308 still_changing = 1;
308 } 309 }
309 } 310 }
310 } 311 }
311 312
312 /* create a new bios memory map, removing overlaps */ 313 /* create a new bios memory map, removing overlaps */
313 overlap_entries = 0; /* number of entries in the overlap table */ 314 overlap_entries = 0; /* number of entries in the overlap table */
314 new_bios_entry = 0; /* index for creating new bios map entries */ 315 new_bios_entry = 0; /* index for creating new bios map entries */
315 last_type = 0; /* start with undefined memory type */ 316 last_type = 0; /* start with undefined memory type */
316 last_addr = 0; /* start with 0 as last starting address */ 317 last_addr = 0; /* start with 0 as last starting address */
317 318
318 /* loop through change-points, determining affect on the new bios map */ 319 /* loop through change-points, determining affect on the new bios map */
319 for (chgidx = 0; chgidx < chg_nr; chgidx++) { 320 for (chgidx = 0; chgidx < chg_nr; chgidx++) {
320 /* keep track of all overlapping bios entries */ 321 /* keep track of all overlapping bios entries */
321 if (change_point[chgidx]->addr == 322 if (change_point[chgidx]->addr ==
322 change_point[chgidx]->pbios->addr) { 323 change_point[chgidx]->pbios->addr) {
323 /* 324 /*
324 * add map entry to overlap list (> 1 entry 325 * add map entry to overlap list (> 1 entry
325 * implies an overlap) 326 * implies an overlap)
326 */ 327 */
327 overlap_list[overlap_entries++] = 328 overlap_list[overlap_entries++] =
328 change_point[chgidx]->pbios; 329 change_point[chgidx]->pbios;
329 } else { 330 } else {
330 /* 331 /*
331 * remove entry from list (order independent, 332 * remove entry from list (order independent,
332 * so swap with last) 333 * so swap with last)
333 */ 334 */
334 for (i = 0; i < overlap_entries; i++) { 335 for (i = 0; i < overlap_entries; i++) {
335 if (overlap_list[i] == 336 if (overlap_list[i] ==
336 change_point[chgidx]->pbios) 337 change_point[chgidx]->pbios)
337 overlap_list[i] = 338 overlap_list[i] =
338 overlap_list[overlap_entries-1]; 339 overlap_list[overlap_entries-1];
339 } 340 }
340 overlap_entries--; 341 overlap_entries--;
341 } 342 }
342 /* 343 /*
343 * if there are overlapping entries, decide which 344 * if there are overlapping entries, decide which
344 * "type" to use (larger value takes precedence -- 345 * "type" to use (larger value takes precedence --
345 * 1=usable, 2,3,4,4+=unusable) 346 * 1=usable, 2,3,4,4+=unusable)
346 */ 347 */
347 current_type = 0; 348 current_type = 0;
348 for (i = 0; i < overlap_entries; i++) 349 for (i = 0; i < overlap_entries; i++)
349 if (overlap_list[i]->type > current_type) 350 if (overlap_list[i]->type > current_type)
350 current_type = overlap_list[i]->type; 351 current_type = overlap_list[i]->type;
351 /* 352 /*
352 * continue building up new bios map based on this 353 * continue building up new bios map based on this
353 * information 354 * information
354 */ 355 */
355 if (current_type != last_type) { 356 if (current_type != last_type) {
356 if (last_type != 0) { 357 if (last_type != 0) {
357 new_bios[new_bios_entry].size = 358 new_bios[new_bios_entry].size =
358 change_point[chgidx]->addr - last_addr; 359 change_point[chgidx]->addr - last_addr;
359 /* 360 /*
360 * move forward only if the new size 361 * move forward only if the new size
361 * was non-zero 362 * was non-zero
362 */ 363 */
363 if (new_bios[new_bios_entry].size != 0) 364 if (new_bios[new_bios_entry].size != 0)
364 /* 365 /*
365 * no more space left for new 366 * no more space left for new
366 * bios entries ? 367 * bios entries ?
367 */ 368 */
368 if (++new_bios_entry >= max_nr_map) 369 if (++new_bios_entry >= max_nr_map)
369 break; 370 break;
370 } 371 }
371 if (current_type != 0) { 372 if (current_type != 0) {
372 new_bios[new_bios_entry].addr = 373 new_bios[new_bios_entry].addr =
373 change_point[chgidx]->addr; 374 change_point[chgidx]->addr;
374 new_bios[new_bios_entry].type = current_type; 375 new_bios[new_bios_entry].type = current_type;
375 last_addr = change_point[chgidx]->addr; 376 last_addr = change_point[chgidx]->addr;
376 } 377 }
377 last_type = current_type; 378 last_type = current_type;
378 } 379 }
379 } 380 }
380 /* retain count for new bios entries */ 381 /* retain count for new bios entries */
381 new_nr = new_bios_entry; 382 new_nr = new_bios_entry;
382 383
383 /* copy new bios mapping into original location */ 384 /* copy new bios mapping into original location */
384 memcpy(biosmap, new_bios, new_nr * sizeof(struct e820entry)); 385 memcpy(biosmap, new_bios, new_nr * sizeof(struct e820entry));
385 *pnr_map = new_nr; 386 *pnr_map = new_nr;
386 387
387 return 0; 388 return 0;
388 } 389 }
389 390
390 static int __init __append_e820_map(struct e820entry *biosmap, int nr_map) 391 static int __init __append_e820_map(struct e820entry *biosmap, int nr_map)
391 { 392 {
392 while (nr_map) { 393 while (nr_map) {
393 u64 start = biosmap->addr; 394 u64 start = biosmap->addr;
394 u64 size = biosmap->size; 395 u64 size = biosmap->size;
395 u64 end = start + size; 396 u64 end = start + size;
396 u32 type = biosmap->type; 397 u32 type = biosmap->type;
397 398
398 /* Overflow in 64 bits? Ignore the memory map. */ 399 /* Overflow in 64 bits? Ignore the memory map. */
399 if (start > end) 400 if (start > end)
400 return -1; 401 return -1;
401 402
402 e820_add_region(start, size, type); 403 e820_add_region(start, size, type);
403 404
404 biosmap++; 405 biosmap++;
405 nr_map--; 406 nr_map--;
406 } 407 }
407 return 0; 408 return 0;
408 } 409 }
409 410
410 /* 411 /*
411 * Copy the BIOS e820 map into a safe place. 412 * Copy the BIOS e820 map into a safe place.
412 * 413 *
413 * Sanity-check it while we're at it.. 414 * Sanity-check it while we're at it..
414 * 415 *
415 * If we're lucky and live on a modern system, the setup code 416 * If we're lucky and live on a modern system, the setup code
416 * will have given us a memory map that we can use to properly 417 * will have given us a memory map that we can use to properly
417 * set up memory. If we aren't, we'll fake a memory map. 418 * set up memory. If we aren't, we'll fake a memory map.
418 */ 419 */
419 static int __init append_e820_map(struct e820entry *biosmap, int nr_map) 420 static int __init append_e820_map(struct e820entry *biosmap, int nr_map)
420 { 421 {
421 /* Only one memory region (or negative)? Ignore it */ 422 /* Only one memory region (or negative)? Ignore it */
422 if (nr_map < 2) 423 if (nr_map < 2)
423 return -1; 424 return -1;
424 425
425 return __append_e820_map(biosmap, nr_map); 426 return __append_e820_map(biosmap, nr_map);
426 } 427 }
427 428
428 static u64 __init __e820_update_range(struct e820map *e820x, u64 start, 429 static u64 __init __e820_update_range(struct e820map *e820x, u64 start,
429 u64 size, unsigned old_type, 430 u64 size, unsigned old_type,
430 unsigned new_type) 431 unsigned new_type)
431 { 432 {
432 u64 end; 433 u64 end;
433 unsigned int i; 434 unsigned int i;
434 u64 real_updated_size = 0; 435 u64 real_updated_size = 0;
435 436
436 BUG_ON(old_type == new_type); 437 BUG_ON(old_type == new_type);
437 438
438 if (size > (ULLONG_MAX - start)) 439 if (size > (ULLONG_MAX - start))
439 size = ULLONG_MAX - start; 440 size = ULLONG_MAX - start;
440 441
441 end = start + size; 442 end = start + size;
442 printk(KERN_DEBUG "e820 update range: %016Lx - %016Lx ", 443 printk(KERN_DEBUG "e820 update range: %016Lx - %016Lx ",
443 (unsigned long long) start, 444 (unsigned long long) start,
444 (unsigned long long) end); 445 (unsigned long long) end);
445 e820_print_type(old_type); 446 e820_print_type(old_type);
446 printk(KERN_CONT " ==> "); 447 printk(KERN_CONT " ==> ");
447 e820_print_type(new_type); 448 e820_print_type(new_type);
448 printk(KERN_CONT "\n"); 449 printk(KERN_CONT "\n");
449 450
450 for (i = 0; i < e820x->nr_map; i++) { 451 for (i = 0; i < e820x->nr_map; i++) {
451 struct e820entry *ei = &e820x->map[i]; 452 struct e820entry *ei = &e820x->map[i];
452 u64 final_start, final_end; 453 u64 final_start, final_end;
453 u64 ei_end; 454 u64 ei_end;
454 455
455 if (ei->type != old_type) 456 if (ei->type != old_type)
456 continue; 457 continue;
457 458
458 ei_end = ei->addr + ei->size; 459 ei_end = ei->addr + ei->size;
459 /* totally covered by new range? */ 460 /* totally covered by new range? */
460 if (ei->addr >= start && ei_end <= end) { 461 if (ei->addr >= start && ei_end <= end) {
461 ei->type = new_type; 462 ei->type = new_type;
462 real_updated_size += ei->size; 463 real_updated_size += ei->size;
463 continue; 464 continue;
464 } 465 }
465 466
466 /* new range is totally covered? */ 467 /* new range is totally covered? */
467 if (ei->addr < start && ei_end > end) { 468 if (ei->addr < start && ei_end > end) {
468 __e820_add_region(e820x, start, size, new_type); 469 __e820_add_region(e820x, start, size, new_type);
469 __e820_add_region(e820x, end, ei_end - end, ei->type); 470 __e820_add_region(e820x, end, ei_end - end, ei->type);
470 ei->size = start - ei->addr; 471 ei->size = start - ei->addr;
471 real_updated_size += size; 472 real_updated_size += size;
472 continue; 473 continue;
473 } 474 }
474 475
475 /* partially covered */ 476 /* partially covered */
476 final_start = max(start, ei->addr); 477 final_start = max(start, ei->addr);
477 final_end = min(end, ei_end); 478 final_end = min(end, ei_end);
478 if (final_start >= final_end) 479 if (final_start >= final_end)
479 continue; 480 continue;
480 481
481 __e820_add_region(e820x, final_start, final_end - final_start, 482 __e820_add_region(e820x, final_start, final_end - final_start,
482 new_type); 483 new_type);
483 484
484 real_updated_size += final_end - final_start; 485 real_updated_size += final_end - final_start;
485 486
486 /* 487 /*
487 * left range could be head or tail, so need to update 488 * left range could be head or tail, so need to update
488 * size at first. 489 * size at first.
489 */ 490 */
490 ei->size -= final_end - final_start; 491 ei->size -= final_end - final_start;
491 if (ei->addr < final_start) 492 if (ei->addr < final_start)
492 continue; 493 continue;
493 ei->addr = final_end; 494 ei->addr = final_end;
494 } 495 }
495 return real_updated_size; 496 return real_updated_size;
496 } 497 }
497 498
498 u64 __init e820_update_range(u64 start, u64 size, unsigned old_type, 499 u64 __init e820_update_range(u64 start, u64 size, unsigned old_type,
499 unsigned new_type) 500 unsigned new_type)
500 { 501 {
501 return __e820_update_range(&e820, start, size, old_type, new_type); 502 return __e820_update_range(&e820, start, size, old_type, new_type);
502 } 503 }
503 504
504 static u64 __init e820_update_range_saved(u64 start, u64 size, 505 static u64 __init e820_update_range_saved(u64 start, u64 size,
505 unsigned old_type, unsigned new_type) 506 unsigned old_type, unsigned new_type)
506 { 507 {
507 return __e820_update_range(&e820_saved, start, size, old_type, 508 return __e820_update_range(&e820_saved, start, size, old_type,
508 new_type); 509 new_type);
509 } 510 }
510 511
511 /* make e820 not cover the range */ 512 /* make e820 not cover the range */
512 u64 __init e820_remove_range(u64 start, u64 size, unsigned old_type, 513 u64 __init e820_remove_range(u64 start, u64 size, unsigned old_type,
513 int checktype) 514 int checktype)
514 { 515 {
515 int i; 516 int i;
516 u64 end; 517 u64 end;
517 u64 real_removed_size = 0; 518 u64 real_removed_size = 0;
518 519
519 if (size > (ULLONG_MAX - start)) 520 if (size > (ULLONG_MAX - start))
520 size = ULLONG_MAX - start; 521 size = ULLONG_MAX - start;
521 522
522 end = start + size; 523 end = start + size;
523 printk(KERN_DEBUG "e820 remove range: %016Lx - %016Lx ", 524 printk(KERN_DEBUG "e820 remove range: %016Lx - %016Lx ",
524 (unsigned long long) start, 525 (unsigned long long) start,
525 (unsigned long long) end); 526 (unsigned long long) end);
526 if (checktype) 527 if (checktype)
527 e820_print_type(old_type); 528 e820_print_type(old_type);
528 printk(KERN_CONT "\n"); 529 printk(KERN_CONT "\n");
529 530
530 for (i = 0; i < e820.nr_map; i++) { 531 for (i = 0; i < e820.nr_map; i++) {
531 struct e820entry *ei = &e820.map[i]; 532 struct e820entry *ei = &e820.map[i];
532 u64 final_start, final_end; 533 u64 final_start, final_end;
533 u64 ei_end; 534 u64 ei_end;
534 535
535 if (checktype && ei->type != old_type) 536 if (checktype && ei->type != old_type)
536 continue; 537 continue;
537 538
538 ei_end = ei->addr + ei->size; 539 ei_end = ei->addr + ei->size;
539 /* totally covered? */ 540 /* totally covered? */
540 if (ei->addr >= start && ei_end <= end) { 541 if (ei->addr >= start && ei_end <= end) {
541 real_removed_size += ei->size; 542 real_removed_size += ei->size;
542 memset(ei, 0, sizeof(struct e820entry)); 543 memset(ei, 0, sizeof(struct e820entry));
543 continue; 544 continue;
544 } 545 }
545 546
546 /* new range is totally covered? */ 547 /* new range is totally covered? */
547 if (ei->addr < start && ei_end > end) { 548 if (ei->addr < start && ei_end > end) {
548 e820_add_region(end, ei_end - end, ei->type); 549 e820_add_region(end, ei_end - end, ei->type);
549 ei->size = start - ei->addr; 550 ei->size = start - ei->addr;
550 real_removed_size += size; 551 real_removed_size += size;
551 continue; 552 continue;
552 } 553 }
553 554
554 /* partially covered */ 555 /* partially covered */
555 final_start = max(start, ei->addr); 556 final_start = max(start, ei->addr);
556 final_end = min(end, ei_end); 557 final_end = min(end, ei_end);
557 if (final_start >= final_end) 558 if (final_start >= final_end)
558 continue; 559 continue;
559 real_removed_size += final_end - final_start; 560 real_removed_size += final_end - final_start;
560 561
561 /* 562 /*
562 * left range could be head or tail, so need to update 563 * left range could be head or tail, so need to update
563 * size at first. 564 * size at first.
564 */ 565 */
565 ei->size -= final_end - final_start; 566 ei->size -= final_end - final_start;
566 if (ei->addr < final_start) 567 if (ei->addr < final_start)
567 continue; 568 continue;
568 ei->addr = final_end; 569 ei->addr = final_end;
569 } 570 }
570 return real_removed_size; 571 return real_removed_size;
571 } 572 }
572 573
573 void __init update_e820(void) 574 void __init update_e820(void)
574 { 575 {
575 u32 nr_map; 576 u32 nr_map;
576 577
577 nr_map = e820.nr_map; 578 nr_map = e820.nr_map;
578 if (sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &nr_map)) 579 if (sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &nr_map))
579 return; 580 return;
580 e820.nr_map = nr_map; 581 e820.nr_map = nr_map;
581 printk(KERN_INFO "modified physical RAM map:\n"); 582 printk(KERN_INFO "modified physical RAM map:\n");
582 e820_print_map("modified"); 583 e820_print_map("modified");
583 } 584 }
584 static void __init update_e820_saved(void) 585 static void __init update_e820_saved(void)
585 { 586 {
586 u32 nr_map; 587 u32 nr_map;
587 588
588 nr_map = e820_saved.nr_map; 589 nr_map = e820_saved.nr_map;
589 if (sanitize_e820_map(e820_saved.map, ARRAY_SIZE(e820_saved.map), &nr_map)) 590 if (sanitize_e820_map(e820_saved.map, ARRAY_SIZE(e820_saved.map), &nr_map))
590 return; 591 return;
591 e820_saved.nr_map = nr_map; 592 e820_saved.nr_map = nr_map;
592 } 593 }
593 #define MAX_GAP_END 0x100000000ull 594 #define MAX_GAP_END 0x100000000ull
594 /* 595 /*
595 * Search for a gap in the e820 memory space from start_addr to end_addr. 596 * Search for a gap in the e820 memory space from start_addr to end_addr.
596 */ 597 */
597 __init int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize, 598 __init int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize,
598 unsigned long start_addr, unsigned long long end_addr) 599 unsigned long start_addr, unsigned long long end_addr)
599 { 600 {
600 unsigned long long last; 601 unsigned long long last;
601 int i = e820.nr_map; 602 int i = e820.nr_map;
602 int found = 0; 603 int found = 0;
603 604
604 last = (end_addr && end_addr < MAX_GAP_END) ? end_addr : MAX_GAP_END; 605 last = (end_addr && end_addr < MAX_GAP_END) ? end_addr : MAX_GAP_END;
605 606
606 while (--i >= 0) { 607 while (--i >= 0) {
607 unsigned long long start = e820.map[i].addr; 608 unsigned long long start = e820.map[i].addr;
608 unsigned long long end = start + e820.map[i].size; 609 unsigned long long end = start + e820.map[i].size;
609 610
610 if (end < start_addr) 611 if (end < start_addr)
611 continue; 612 continue;
612 613
613 /* 614 /*
614 * Since "last" is at most 4GB, we know we'll 615 * Since "last" is at most 4GB, we know we'll
615 * fit in 32 bits if this condition is true 616 * fit in 32 bits if this condition is true
616 */ 617 */
617 if (last > end) { 618 if (last > end) {
618 unsigned long gap = last - end; 619 unsigned long gap = last - end;
619 620
620 if (gap >= *gapsize) { 621 if (gap >= *gapsize) {
621 *gapsize = gap; 622 *gapsize = gap;
622 *gapstart = end; 623 *gapstart = end;
623 found = 1; 624 found = 1;
624 } 625 }
625 } 626 }
626 if (start < last) 627 if (start < last)
627 last = start; 628 last = start;
628 } 629 }
629 return found; 630 return found;
630 } 631 }
631 632
632 /* 633 /*
633 * Search for the biggest gap in the low 32 bits of the e820 634 * Search for the biggest gap in the low 32 bits of the e820
634 * memory space. We pass this space to PCI to assign MMIO resources 635 * memory space. We pass this space to PCI to assign MMIO resources
635 * for hotplug or unconfigured devices in. 636 * for hotplug or unconfigured devices in.
636 * Hopefully the BIOS let enough space left. 637 * Hopefully the BIOS let enough space left.
637 */ 638 */
638 __init void e820_setup_gap(void) 639 __init void e820_setup_gap(void)
639 { 640 {
640 unsigned long gapstart, gapsize; 641 unsigned long gapstart, gapsize;
641 int found; 642 int found;
642 643
643 gapstart = 0x10000000; 644 gapstart = 0x10000000;
644 gapsize = 0x400000; 645 gapsize = 0x400000;
645 found = e820_search_gap(&gapstart, &gapsize, 0, MAX_GAP_END); 646 found = e820_search_gap(&gapstart, &gapsize, 0, MAX_GAP_END);
646 647
647 #ifdef CONFIG_X86_64 648 #ifdef CONFIG_X86_64
648 if (!found) { 649 if (!found) {
649 gapstart = (max_pfn << PAGE_SHIFT) + 1024*1024; 650 gapstart = (max_pfn << PAGE_SHIFT) + 1024*1024;
650 printk(KERN_ERR 651 printk(KERN_ERR
651 "PCI: Warning: Cannot find a gap in the 32bit address range\n" 652 "PCI: Warning: Cannot find a gap in the 32bit address range\n"
652 "PCI: Unassigned devices with 32bit resource registers may break!\n"); 653 "PCI: Unassigned devices with 32bit resource registers may break!\n");
653 } 654 }
654 #endif 655 #endif
655 656
656 /* 657 /*
657 * e820_reserve_resources_late protect stolen RAM already 658 * e820_reserve_resources_late protect stolen RAM already
658 */ 659 */
659 pci_mem_start = gapstart; 660 pci_mem_start = gapstart;
660 661
661 printk(KERN_INFO 662 printk(KERN_INFO
662 "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n", 663 "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n",
663 pci_mem_start, gapstart, gapsize); 664 pci_mem_start, gapstart, gapsize);
664 } 665 }
665 666
666 /** 667 /**
667 * Because of the size limitation of struct boot_params, only first 668 * Because of the size limitation of struct boot_params, only first
668 * 128 E820 memory entries are passed to kernel via 669 * 128 E820 memory entries are passed to kernel via
669 * boot_params.e820_map, others are passed via SETUP_E820_EXT node of 670 * boot_params.e820_map, others are passed via SETUP_E820_EXT node of
670 * linked list of struct setup_data, which is parsed here. 671 * linked list of struct setup_data, which is parsed here.
671 */ 672 */
672 void __init parse_e820_ext(struct setup_data *sdata) 673 void __init parse_e820_ext(struct setup_data *sdata)
673 { 674 {
674 int entries; 675 int entries;
675 struct e820entry *extmap; 676 struct e820entry *extmap;
676 677
677 entries = sdata->len / sizeof(struct e820entry); 678 entries = sdata->len / sizeof(struct e820entry);
678 extmap = (struct e820entry *)(sdata->data); 679 extmap = (struct e820entry *)(sdata->data);
679 __append_e820_map(extmap, entries); 680 __append_e820_map(extmap, entries);
680 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); 681 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
681 printk(KERN_INFO "extended physical RAM map:\n"); 682 printk(KERN_INFO "extended physical RAM map:\n");
682 e820_print_map("extended"); 683 e820_print_map("extended");
683 } 684 }
684 685
685 #if defined(CONFIG_X86_64) || \ 686 #if defined(CONFIG_X86_64) || \
686 (defined(CONFIG_X86_32) && defined(CONFIG_HIBERNATION)) 687 (defined(CONFIG_X86_32) && defined(CONFIG_HIBERNATION))
687 /** 688 /**
688 * Find the ranges of physical addresses that do not correspond to 689 * Find the ranges of physical addresses that do not correspond to
689 * e820 RAM areas and mark the corresponding pages as nosave for 690 * e820 RAM areas and mark the corresponding pages as nosave for
690 * hibernation (32 bit) or software suspend and suspend to RAM (64 bit). 691 * hibernation (32 bit) or software suspend and suspend to RAM (64 bit).
691 * 692 *
692 * This function requires the e820 map to be sorted and without any 693 * This function requires the e820 map to be sorted and without any
693 * overlapping entries and assumes the first e820 area to be RAM. 694 * overlapping entries and assumes the first e820 area to be RAM.
694 */ 695 */
695 void __init e820_mark_nosave_regions(unsigned long limit_pfn) 696 void __init e820_mark_nosave_regions(unsigned long limit_pfn)
696 { 697 {
697 int i; 698 int i;
698 unsigned long pfn; 699 unsigned long pfn;
699 700
700 pfn = PFN_DOWN(e820.map[0].addr + e820.map[0].size); 701 pfn = PFN_DOWN(e820.map[0].addr + e820.map[0].size);
701 for (i = 1; i < e820.nr_map; i++) { 702 for (i = 1; i < e820.nr_map; i++) {
702 struct e820entry *ei = &e820.map[i]; 703 struct e820entry *ei = &e820.map[i];
703 704
704 if (pfn < PFN_UP(ei->addr)) 705 if (pfn < PFN_UP(ei->addr))
705 register_nosave_region(pfn, PFN_UP(ei->addr)); 706 register_nosave_region(pfn, PFN_UP(ei->addr));
706 707
707 pfn = PFN_DOWN(ei->addr + ei->size); 708 pfn = PFN_DOWN(ei->addr + ei->size);
708 if (ei->type != E820_RAM && ei->type != E820_RESERVED_KERN) 709 if (ei->type != E820_RAM && ei->type != E820_RESERVED_KERN)
709 register_nosave_region(PFN_UP(ei->addr), pfn); 710 register_nosave_region(PFN_UP(ei->addr), pfn);
710 711
711 if (pfn >= limit_pfn) 712 if (pfn >= limit_pfn)
712 break; 713 break;
713 } 714 }
714 } 715 }
715 #endif 716 #endif
716 717
717 #ifdef CONFIG_HIBERNATION 718 #ifdef CONFIG_HIBERNATION
718 /** 719 /**
719 * Mark ACPI NVS memory region, so that we can save/restore it during 720 * Mark ACPI NVS memory region, so that we can save/restore it during
720 * hibernation and the subsequent resume. 721 * hibernation and the subsequent resume.
721 */ 722 */
722 static int __init e820_mark_nvs_memory(void) 723 static int __init e820_mark_nvs_memory(void)
723 { 724 {
724 int i; 725 int i;
725 726
726 for (i = 0; i < e820.nr_map; i++) { 727 for (i = 0; i < e820.nr_map; i++) {
727 struct e820entry *ei = &e820.map[i]; 728 struct e820entry *ei = &e820.map[i];
728 729
729 if (ei->type == E820_NVS) 730 if (ei->type == E820_NVS)
730 suspend_nvs_register(ei->addr, ei->size); 731 suspend_nvs_register(ei->addr, ei->size);
731 } 732 }
732 733
733 return 0; 734 return 0;
734 } 735 }
735 core_initcall(e820_mark_nvs_memory); 736 core_initcall(e820_mark_nvs_memory);
736 #endif 737 #endif
737 738
738 /* 739 /*
739 * pre allocated 4k and reserved it in memblock and e820_saved 740 * pre allocated 4k and reserved it in memblock and e820_saved
740 */ 741 */
741 u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align) 742 u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align)
742 { 743 {
743 u64 size = 0; 744 u64 size = 0;
744 u64 addr; 745 u64 addr;
745 u64 start; 746 u64 start;
746 747
747 for (start = startt; ; start += size) { 748 for (start = startt; ; start += size) {
748 start = memblock_x86_find_in_range_size(start, &size, align); 749 start = memblock_x86_find_in_range_size(start, &size, align);
749 if (start == MEMBLOCK_ERROR) 750 if (start == MEMBLOCK_ERROR)
750 return 0; 751 return 0;
751 if (size >= sizet) 752 if (size >= sizet)
752 break; 753 break;
753 } 754 }
754 755
755 #ifdef CONFIG_X86_32 756 #ifdef CONFIG_X86_32
756 if (start >= MAXMEM) 757 if (start >= MAXMEM)
757 return 0; 758 return 0;
758 if (start + size > MAXMEM) 759 if (start + size > MAXMEM)
759 size = MAXMEM - start; 760 size = MAXMEM - start;
760 #endif 761 #endif
761 762
762 addr = round_down(start + size - sizet, align); 763 addr = round_down(start + size - sizet, align);
763 if (addr < start) 764 if (addr < start)
764 return 0; 765 return 0;
765 memblock_x86_reserve_range(addr, addr + sizet, "new next"); 766 memblock_x86_reserve_range(addr, addr + sizet, "new next");
766 e820_update_range_saved(addr, sizet, E820_RAM, E820_RESERVED); 767 e820_update_range_saved(addr, sizet, E820_RAM, E820_RESERVED);
767 printk(KERN_INFO "update e820_saved for early_reserve_e820\n"); 768 printk(KERN_INFO "update e820_saved for early_reserve_e820\n");
768 update_e820_saved(); 769 update_e820_saved();
769 770
770 return addr; 771 return addr;
771 } 772 }
772 773
773 #ifdef CONFIG_X86_32 774 #ifdef CONFIG_X86_32
774 # ifdef CONFIG_X86_PAE 775 # ifdef CONFIG_X86_PAE
775 # define MAX_ARCH_PFN (1ULL<<(36-PAGE_SHIFT)) 776 # define MAX_ARCH_PFN (1ULL<<(36-PAGE_SHIFT))
776 # else 777 # else
777 # define MAX_ARCH_PFN (1ULL<<(32-PAGE_SHIFT)) 778 # define MAX_ARCH_PFN (1ULL<<(32-PAGE_SHIFT))
778 # endif 779 # endif
779 #else /* CONFIG_X86_32 */ 780 #else /* CONFIG_X86_32 */
780 # define MAX_ARCH_PFN MAXMEM>>PAGE_SHIFT 781 # define MAX_ARCH_PFN MAXMEM>>PAGE_SHIFT
781 #endif 782 #endif
782 783
783 /* 784 /*
784 * Find the highest page frame number we have available 785 * Find the highest page frame number we have available
785 */ 786 */
786 static unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned type) 787 unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned type)
787 { 788 {
788 int i; 789 int i;
789 unsigned long last_pfn = 0; 790 unsigned long last_pfn = 0;
790 unsigned long max_arch_pfn = MAX_ARCH_PFN; 791 unsigned long max_arch_pfn = MAX_ARCH_PFN;
791 792
792 for (i = 0; i < e820.nr_map; i++) { 793 for (i = 0; i < e820.nr_map; i++) {
793 struct e820entry *ei = &e820.map[i]; 794 struct e820entry *ei = &e820.map[i];
794 unsigned long start_pfn; 795 unsigned long start_pfn;
795 unsigned long end_pfn; 796 unsigned long end_pfn;
796 797
797 if (ei->type != type) 798 if (ei->type != type)
798 continue; 799 continue;
799 800
800 start_pfn = ei->addr >> PAGE_SHIFT; 801 start_pfn = ei->addr >> PAGE_SHIFT;
801 end_pfn = (ei->addr + ei->size) >> PAGE_SHIFT; 802 end_pfn = (ei->addr + ei->size) >> PAGE_SHIFT;
802 803
803 if (start_pfn >= limit_pfn) 804 if (start_pfn >= limit_pfn)
804 continue; 805 continue;
805 if (end_pfn > limit_pfn) { 806 if (end_pfn > limit_pfn) {
806 last_pfn = limit_pfn; 807 last_pfn = limit_pfn;
807 break; 808 break;
808 } 809 }
809 if (end_pfn > last_pfn) 810 if (end_pfn > last_pfn)
810 last_pfn = end_pfn; 811 last_pfn = end_pfn;
811 } 812 }
812 813
813 if (last_pfn > max_arch_pfn) 814 if (last_pfn > max_arch_pfn)
814 last_pfn = max_arch_pfn; 815 last_pfn = max_arch_pfn;
815 816
816 printk(KERN_INFO "last_pfn = %#lx max_arch_pfn = %#lx\n", 817 printk(KERN_INFO "last_pfn = %#lx max_arch_pfn = %#lx\n",
817 last_pfn, max_arch_pfn); 818 last_pfn, max_arch_pfn);
818 return last_pfn; 819 return last_pfn;
819 } 820 }
820 unsigned long __init e820_end_of_ram_pfn(void) 821 unsigned long __init e820_end_of_ram_pfn(void)
821 { 822 {
822 return e820_end_pfn(MAX_ARCH_PFN, E820_RAM); 823 return e820_end_pfn(MAX_ARCH_PFN, E820_RAM);
823 } 824 }
824 825
825 unsigned long __init e820_end_of_low_ram_pfn(void) 826 unsigned long __init e820_end_of_low_ram_pfn(void)
826 { 827 {
827 return e820_end_pfn(1UL<<(32 - PAGE_SHIFT), E820_RAM); 828 return e820_end_pfn(1UL<<(32 - PAGE_SHIFT), E820_RAM);
828 } 829 }
829 830
830 static void early_panic(char *msg) 831 static void early_panic(char *msg)
831 { 832 {
832 early_printk(msg); 833 early_printk(msg);
833 panic(msg); 834 panic(msg);
834 } 835 }
835 836
836 static int userdef __initdata; 837 static int userdef __initdata;
837 838
838 /* "mem=nopentium" disables the 4MB page tables. */ 839 /* "mem=nopentium" disables the 4MB page tables. */
839 static int __init parse_memopt(char *p) 840 static int __init parse_memopt(char *p)
840 { 841 {
841 u64 mem_size; 842 u64 mem_size;
842 843
843 if (!p) 844 if (!p)
844 return -EINVAL; 845 return -EINVAL;
845 846
846 if (!strcmp(p, "nopentium")) { 847 if (!strcmp(p, "nopentium")) {
847 #ifdef CONFIG_X86_32 848 #ifdef CONFIG_X86_32
848 setup_clear_cpu_cap(X86_FEATURE_PSE); 849 setup_clear_cpu_cap(X86_FEATURE_PSE);
849 return 0; 850 return 0;
850 #else 851 #else
851 printk(KERN_WARNING "mem=nopentium ignored! (only supported on x86_32)\n"); 852 printk(KERN_WARNING "mem=nopentium ignored! (only supported on x86_32)\n");
852 return -EINVAL; 853 return -EINVAL;
853 #endif 854 #endif
854 } 855 }
855 856
856 userdef = 1; 857 userdef = 1;
857 mem_size = memparse(p, &p); 858 mem_size = memparse(p, &p);
858 /* don't remove all of memory when handling "mem={invalid}" param */ 859 /* don't remove all of memory when handling "mem={invalid}" param */
859 if (mem_size == 0) 860 if (mem_size == 0)
860 return -EINVAL; 861 return -EINVAL;
861 e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1); 862 e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
862 863
863 return 0; 864 return 0;
864 } 865 }
865 early_param("mem", parse_memopt); 866 early_param("mem", parse_memopt);
866 867
867 static int __init parse_memmap_opt(char *p) 868 static int __init parse_memmap_opt(char *p)
868 { 869 {
869 char *oldp; 870 char *oldp;
870 u64 start_at, mem_size; 871 u64 start_at, mem_size;
871 872
872 if (!p) 873 if (!p)
873 return -EINVAL; 874 return -EINVAL;
874 875
875 if (!strncmp(p, "exactmap", 8)) { 876 if (!strncmp(p, "exactmap", 8)) {
876 #ifdef CONFIG_CRASH_DUMP 877 #ifdef CONFIG_CRASH_DUMP
877 /* 878 /*
878 * If we are doing a crash dump, we still need to know 879 * If we are doing a crash dump, we still need to know
879 * the real mem size before original memory map is 880 * the real mem size before original memory map is
880 * reset. 881 * reset.
881 */ 882 */
882 saved_max_pfn = e820_end_of_ram_pfn(); 883 saved_max_pfn = e820_end_of_ram_pfn();
883 #endif 884 #endif
884 e820.nr_map = 0; 885 e820.nr_map = 0;
885 userdef = 1; 886 userdef = 1;
886 return 0; 887 return 0;
887 } 888 }
888 889
889 oldp = p; 890 oldp = p;
890 mem_size = memparse(p, &p); 891 mem_size = memparse(p, &p);
891 if (p == oldp) 892 if (p == oldp)
892 return -EINVAL; 893 return -EINVAL;
893 894
894 userdef = 1; 895 userdef = 1;
895 if (*p == '@') { 896 if (*p == '@') {
896 start_at = memparse(p+1, &p); 897 start_at = memparse(p+1, &p);
897 e820_add_region(start_at, mem_size, E820_RAM); 898 e820_add_region(start_at, mem_size, E820_RAM);
898 } else if (*p == '#') { 899 } else if (*p == '#') {
899 start_at = memparse(p+1, &p); 900 start_at = memparse(p+1, &p);
900 e820_add_region(start_at, mem_size, E820_ACPI); 901 e820_add_region(start_at, mem_size, E820_ACPI);
901 } else if (*p == '$') { 902 } else if (*p == '$') {
902 start_at = memparse(p+1, &p); 903 start_at = memparse(p+1, &p);
903 e820_add_region(start_at, mem_size, E820_RESERVED); 904 e820_add_region(start_at, mem_size, E820_RESERVED);
904 } else 905 } else
905 e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1); 906 e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
906 907
907 return *p == '\0' ? 0 : -EINVAL; 908 return *p == '\0' ? 0 : -EINVAL;
908 } 909 }
909 early_param("memmap", parse_memmap_opt); 910 early_param("memmap", parse_memmap_opt);
910 911
911 void __init finish_e820_parsing(void) 912 void __init finish_e820_parsing(void)
912 { 913 {
913 if (userdef) { 914 if (userdef) {
914 u32 nr = e820.nr_map; 915 u32 nr = e820.nr_map;
915 916
916 if (sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &nr) < 0) 917 if (sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &nr) < 0)
917 early_panic("Invalid user supplied memory map"); 918 early_panic("Invalid user supplied memory map");
918 e820.nr_map = nr; 919 e820.nr_map = nr;
919 920
920 printk(KERN_INFO "user-defined physical RAM map:\n"); 921 printk(KERN_INFO "user-defined physical RAM map:\n");
921 e820_print_map("user"); 922 e820_print_map("user");
922 } 923 }
923 } 924 }
924 925
925 static inline const char *e820_type_to_string(int e820_type) 926 static inline const char *e820_type_to_string(int e820_type)
926 { 927 {
927 switch (e820_type) { 928 switch (e820_type) {
928 case E820_RESERVED_KERN: 929 case E820_RESERVED_KERN:
929 case E820_RAM: return "System RAM"; 930 case E820_RAM: return "System RAM";
930 case E820_ACPI: return "ACPI Tables"; 931 case E820_ACPI: return "ACPI Tables";
931 case E820_NVS: return "ACPI Non-volatile Storage"; 932 case E820_NVS: return "ACPI Non-volatile Storage";
932 case E820_UNUSABLE: return "Unusable memory"; 933 case E820_UNUSABLE: return "Unusable memory";
933 default: return "reserved"; 934 default: return "reserved";
934 } 935 }
935 } 936 }
936 937
937 /* 938 /*
938 * Mark e820 reserved areas as busy for the resource manager. 939 * Mark e820 reserved areas as busy for the resource manager.
939 */ 940 */
940 static struct resource __initdata *e820_res; 941 static struct resource __initdata *e820_res;
941 void __init e820_reserve_resources(void) 942 void __init e820_reserve_resources(void)
942 { 943 {
943 int i; 944 int i;
944 struct resource *res; 945 struct resource *res;
945 u64 end; 946 u64 end;
946 947
947 res = alloc_bootmem(sizeof(struct resource) * e820.nr_map); 948 res = alloc_bootmem(sizeof(struct resource) * e820.nr_map);
948 e820_res = res; 949 e820_res = res;
949 for (i = 0; i < e820.nr_map; i++) { 950 for (i = 0; i < e820.nr_map; i++) {
950 end = e820.map[i].addr + e820.map[i].size - 1; 951 end = e820.map[i].addr + e820.map[i].size - 1;
951 if (end != (resource_size_t)end) { 952 if (end != (resource_size_t)end) {
952 res++; 953 res++;
953 continue; 954 continue;
954 } 955 }
955 res->name = e820_type_to_string(e820.map[i].type); 956 res->name = e820_type_to_string(e820.map[i].type);
956 res->start = e820.map[i].addr; 957 res->start = e820.map[i].addr;
957 res->end = end; 958 res->end = end;
958 959
959 res->flags = IORESOURCE_MEM; 960 res->flags = IORESOURCE_MEM;
960 961
961 /* 962 /*
962 * don't register the region that could be conflicted with 963 * don't register the region that could be conflicted with
963 * pci device BAR resource and insert them later in 964 * pci device BAR resource and insert them later in
964 * pcibios_resource_survey() 965 * pcibios_resource_survey()
965 */ 966 */
966 if (e820.map[i].type != E820_RESERVED || res->start < (1ULL<<20)) { 967 if (e820.map[i].type != E820_RESERVED || res->start < (1ULL<<20)) {
967 res->flags |= IORESOURCE_BUSY; 968 res->flags |= IORESOURCE_BUSY;
968 insert_resource(&iomem_resource, res); 969 insert_resource(&iomem_resource, res);
969 } 970 }
970 res++; 971 res++;
971 } 972 }
972 973
973 for (i = 0; i < e820_saved.nr_map; i++) { 974 for (i = 0; i < e820_saved.nr_map; i++) {
974 struct e820entry *entry = &e820_saved.map[i]; 975 struct e820entry *entry = &e820_saved.map[i];
975 firmware_map_add_early(entry->addr, 976 firmware_map_add_early(entry->addr,
976 entry->addr + entry->size - 1, 977 entry->addr + entry->size - 1,
977 e820_type_to_string(entry->type)); 978 e820_type_to_string(entry->type));
978 } 979 }
979 } 980 }
980 981
981 /* How much should we pad RAM ending depending on where it is? */ 982 /* How much should we pad RAM ending depending on where it is? */
982 static unsigned long ram_alignment(resource_size_t pos) 983 static unsigned long ram_alignment(resource_size_t pos)
983 { 984 {
984 unsigned long mb = pos >> 20; 985 unsigned long mb = pos >> 20;
985 986
986 /* To 64kB in the first megabyte */ 987 /* To 64kB in the first megabyte */
987 if (!mb) 988 if (!mb)
988 return 64*1024; 989 return 64*1024;
989 990
990 /* To 1MB in the first 16MB */ 991 /* To 1MB in the first 16MB */
991 if (mb < 16) 992 if (mb < 16)
992 return 1024*1024; 993 return 1024*1024;
993 994
994 /* To 64MB for anything above that */ 995 /* To 64MB for anything above that */
995 return 64*1024*1024; 996 return 64*1024*1024;
996 } 997 }
997 998
998 #define MAX_RESOURCE_SIZE ((resource_size_t)-1) 999 #define MAX_RESOURCE_SIZE ((resource_size_t)-1)
999 1000
1000 void __init e820_reserve_resources_late(void) 1001 void __init e820_reserve_resources_late(void)
1001 { 1002 {
1002 int i; 1003 int i;
1003 struct resource *res; 1004 struct resource *res;
1004 1005
1005 res = e820_res; 1006 res = e820_res;
1006 for (i = 0; i < e820.nr_map; i++) { 1007 for (i = 0; i < e820.nr_map; i++) {
1007 if (!res->parent && res->end) 1008 if (!res->parent && res->end)
1008 insert_resource_expand_to_fit(&iomem_resource, res); 1009 insert_resource_expand_to_fit(&iomem_resource, res);
1009 res++; 1010 res++;
1010 } 1011 }
1011 1012
1012 /* 1013 /*
1013 * Try to bump up RAM regions to reasonable boundaries to 1014 * Try to bump up RAM regions to reasonable boundaries to
1014 * avoid stolen RAM: 1015 * avoid stolen RAM:
1015 */ 1016 */
1016 for (i = 0; i < e820.nr_map; i++) { 1017 for (i = 0; i < e820.nr_map; i++) {
1017 struct e820entry *entry = &e820.map[i]; 1018 struct e820entry *entry = &e820.map[i];
1018 u64 start, end; 1019 u64 start, end;
1019 1020
1020 if (entry->type != E820_RAM) 1021 if (entry->type != E820_RAM)
1021 continue; 1022 continue;
1022 start = entry->addr + entry->size; 1023 start = entry->addr + entry->size;
1023 end = round_up(start, ram_alignment(start)) - 1; 1024 end = round_up(start, ram_alignment(start)) - 1;
1024 if (end > MAX_RESOURCE_SIZE) 1025 if (end > MAX_RESOURCE_SIZE)
1025 end = MAX_RESOURCE_SIZE; 1026 end = MAX_RESOURCE_SIZE;
1026 if (start >= end) 1027 if (start >= end)
1027 continue; 1028 continue;
1028 printk(KERN_DEBUG "reserve RAM buffer: %016llx - %016llx ", 1029 printk(KERN_DEBUG "reserve RAM buffer: %016llx - %016llx ",
1029 start, end); 1030 start, end);
1030 reserve_region_with_split(&iomem_resource, start, end, 1031 reserve_region_with_split(&iomem_resource, start, end,
1031 "RAM buffer"); 1032 "RAM buffer");
1032 } 1033 }
1033 } 1034 }
1034 1035
1035 char *__init default_machine_specific_memory_setup(void) 1036 char *__init default_machine_specific_memory_setup(void)
1036 { 1037 {
1037 char *who = "BIOS-e820"; 1038 char *who = "BIOS-e820";
1038 u32 new_nr; 1039 u32 new_nr;
1039 /* 1040 /*
1040 * Try to copy the BIOS-supplied E820-map. 1041 * Try to copy the BIOS-supplied E820-map.
1041 * 1042 *
1042 * Otherwise fake a memory map; one section from 0k->640k, 1043 * Otherwise fake a memory map; one section from 0k->640k,
1043 * the next section from 1mb->appropriate_mem_k 1044 * the next section from 1mb->appropriate_mem_k
1044 */ 1045 */
1045 new_nr = boot_params.e820_entries; 1046 new_nr = boot_params.e820_entries;
1046 sanitize_e820_map(boot_params.e820_map, 1047 sanitize_e820_map(boot_params.e820_map,
1047 ARRAY_SIZE(boot_params.e820_map), 1048 ARRAY_SIZE(boot_params.e820_map),
1048 &new_nr); 1049 &new_nr);
1049 boot_params.e820_entries = new_nr; 1050 boot_params.e820_entries = new_nr;
1050 if (append_e820_map(boot_params.e820_map, boot_params.e820_entries) 1051 if (append_e820_map(boot_params.e820_map, boot_params.e820_entries)
1051 < 0) { 1052 < 0) {
1052 u64 mem_size; 1053 u64 mem_size;
1053 1054
1054 /* compare results from other methods and take the greater */ 1055 /* compare results from other methods and take the greater */
1055 if (boot_params.alt_mem_k 1056 if (boot_params.alt_mem_k
1056 < boot_params.screen_info.ext_mem_k) { 1057 < boot_params.screen_info.ext_mem_k) {
1057 mem_size = boot_params.screen_info.ext_mem_k; 1058 mem_size = boot_params.screen_info.ext_mem_k;
1058 who = "BIOS-88"; 1059 who = "BIOS-88";
1059 } else { 1060 } else {
1060 mem_size = boot_params.alt_mem_k; 1061 mem_size = boot_params.alt_mem_k;
1061 who = "BIOS-e801"; 1062 who = "BIOS-e801";
1062 } 1063 }
1063 1064
1064 e820.nr_map = 0; 1065 e820.nr_map = 0;
1065 e820_add_region(0, LOWMEMSIZE(), E820_RAM); 1066 e820_add_region(0, LOWMEMSIZE(), E820_RAM);
1066 e820_add_region(HIGH_MEMORY, mem_size << 10, E820_RAM); 1067 e820_add_region(HIGH_MEMORY, mem_size << 10, E820_RAM);
1067 } 1068 }
1068 1069
1069 /* In case someone cares... */ 1070 /* In case someone cares... */
1070 return who; 1071 return who;
1071 } 1072 }
1072 1073
1073 void __init setup_memory_map(void) 1074 void __init setup_memory_map(void)
1074 { 1075 {
1075 char *who; 1076 char *who;
1076 1077
1077 who = x86_init.resources.memory_setup(); 1078 who = x86_init.resources.memory_setup();
1078 memcpy(&e820_saved, &e820, sizeof(struct e820map)); 1079 memcpy(&e820_saved, &e820, sizeof(struct e820map));
1079 printk(KERN_INFO "BIOS-provided physical RAM map:\n"); 1080 printk(KERN_INFO "BIOS-provided physical RAM map:\n");
1080 e820_print_map(who); 1081 e820_print_map(who);
1081 } 1082 }
1082 1083
1083 void __init memblock_x86_fill(void) 1084 void __init memblock_x86_fill(void)
1084 { 1085 {
1085 int i; 1086 int i;
1086 u64 end; 1087 u64 end;
1087 1088
1088 /* 1089 /*
1089 * EFI may have more than 128 entries 1090 * EFI may have more than 128 entries
1090 * We are safe to enable resizing, beause memblock_x86_fill() 1091 * We are safe to enable resizing, beause memblock_x86_fill()
1091 * is rather later for x86 1092 * is rather later for x86
1092 */ 1093 */
1093 memblock_can_resize = 1; 1094 memblock_can_resize = 1;
1094 1095
1095 for (i = 0; i < e820.nr_map; i++) { 1096 for (i = 0; i < e820.nr_map; i++) {
1096 struct e820entry *ei = &e820.map[i]; 1097 struct e820entry *ei = &e820.map[i];
1097 1098
1098 end = ei->addr + ei->size; 1099 end = ei->addr + ei->size;
1099 if (end != (resource_size_t)end) 1100 if (end != (resource_size_t)end)
1100 continue; 1101 continue;
1101 1102
1102 if (ei->type != E820_RAM && ei->type != E820_RESERVED_KERN) 1103 if (ei->type != E820_RAM && ei->type != E820_RESERVED_KERN)
1103 continue; 1104 continue;
1104 1105
1105 memblock_add(ei->addr, ei->size); 1106 memblock_add(ei->addr, ei->size);
1106 } 1107 }
1107 1108
1108 memblock_analyze(); 1109 memblock_analyze();
1109 memblock_dump_all(); 1110 memblock_dump_all();
1110 } 1111 }
1111 1112
1112 void __init memblock_find_dma_reserve(void) 1113 void __init memblock_find_dma_reserve(void)
1113 { 1114 {
1114 #ifdef CONFIG_X86_64 1115 #ifdef CONFIG_X86_64
1115 u64 free_size_pfn; 1116 u64 free_size_pfn;
1116 u64 mem_size_pfn; 1117 u64 mem_size_pfn;
1117 /* 1118 /*
1118 * need to find out used area below MAX_DMA_PFN 1119 * need to find out used area below MAX_DMA_PFN
1119 * need to use memblock to get free size in [0, MAX_DMA_PFN] 1120 * need to use memblock to get free size in [0, MAX_DMA_PFN]
1120 * at first, and assume boot_mem will not take below MAX_DMA_PFN 1121 * at first, and assume boot_mem will not take below MAX_DMA_PFN
1121 */ 1122 */
1122 mem_size_pfn = memblock_x86_memory_in_range(0, MAX_DMA_PFN << PAGE_SHIFT) >> PAGE_SHIFT; 1123 mem_size_pfn = memblock_x86_memory_in_range(0, MAX_DMA_PFN << PAGE_SHIFT) >> PAGE_SHIFT;
1123 free_size_pfn = memblock_x86_free_memory_in_range(0, MAX_DMA_PFN << PAGE_SHIFT) >> PAGE_SHIFT; 1124 free_size_pfn = memblock_x86_free_memory_in_range(0, MAX_DMA_PFN << PAGE_SHIFT) >> PAGE_SHIFT;
1124 set_dma_reserve(mem_size_pfn - free_size_pfn); 1125 set_dma_reserve(mem_size_pfn - free_size_pfn);
1125 #endif 1126 #endif
1126 } 1127 }
1127 1128
arch/x86/kernel/hpet.c
1 #include <linux/clocksource.h> 1 #include <linux/clocksource.h>
2 #include <linux/clockchips.h> 2 #include <linux/clockchips.h>
3 #include <linux/interrupt.h> 3 #include <linux/interrupt.h>
4 #include <linux/export.h> 4 #include <linux/export.h>
5 #include <linux/sysdev.h> 5 #include <linux/sysdev.h>
6 #include <linux/delay.h> 6 #include <linux/delay.h>
7 #include <linux/errno.h> 7 #include <linux/errno.h>
8 #include <linux/i8253.h> 8 #include <linux/i8253.h>
9 #include <linux/slab.h> 9 #include <linux/slab.h>
10 #include <linux/hpet.h> 10 #include <linux/hpet.h>
11 #include <linux/init.h> 11 #include <linux/init.h>
12 #include <linux/cpu.h> 12 #include <linux/cpu.h>
13 #include <linux/pm.h> 13 #include <linux/pm.h>
14 #include <linux/io.h> 14 #include <linux/io.h>
15 15
16 #include <asm/fixmap.h> 16 #include <asm/fixmap.h>
17 #include <asm/hpet.h> 17 #include <asm/hpet.h>
18 #include <asm/time.h> 18 #include <asm/time.h>
19 19
20 #define HPET_MASK CLOCKSOURCE_MASK(32) 20 #define HPET_MASK CLOCKSOURCE_MASK(32)
21 21
22 /* FSEC = 10^-15 22 /* FSEC = 10^-15
23 NSEC = 10^-9 */ 23 NSEC = 10^-9 */
24 #define FSEC_PER_NSEC 1000000L 24 #define FSEC_PER_NSEC 1000000L
25 25
26 #define HPET_DEV_USED_BIT 2 26 #define HPET_DEV_USED_BIT 2
27 #define HPET_DEV_USED (1 << HPET_DEV_USED_BIT) 27 #define HPET_DEV_USED (1 << HPET_DEV_USED_BIT)
28 #define HPET_DEV_VALID 0x8 28 #define HPET_DEV_VALID 0x8
29 #define HPET_DEV_FSB_CAP 0x1000 29 #define HPET_DEV_FSB_CAP 0x1000
30 #define HPET_DEV_PERI_CAP 0x2000 30 #define HPET_DEV_PERI_CAP 0x2000
31 31
32 #define HPET_MIN_CYCLES 128 32 #define HPET_MIN_CYCLES 128
33 #define HPET_MIN_PROG_DELTA (HPET_MIN_CYCLES + (HPET_MIN_CYCLES >> 1)) 33 #define HPET_MIN_PROG_DELTA (HPET_MIN_CYCLES + (HPET_MIN_CYCLES >> 1))
34 34
35 #define EVT_TO_HPET_DEV(evt) container_of(evt, struct hpet_dev, evt) 35 #define EVT_TO_HPET_DEV(evt) container_of(evt, struct hpet_dev, evt)
36 36
37 /* 37 /*
38 * HPET address is set in acpi/boot.c, when an ACPI entry exists 38 * HPET address is set in acpi/boot.c, when an ACPI entry exists
39 */ 39 */
40 unsigned long hpet_address; 40 unsigned long hpet_address;
41 u8 hpet_blockid; /* OS timer block num */ 41 u8 hpet_blockid; /* OS timer block num */
42 u8 hpet_msi_disable; 42 u8 hpet_msi_disable;
43 43
44 #ifdef CONFIG_PCI_MSI 44 #ifdef CONFIG_PCI_MSI
45 static unsigned long hpet_num_timers; 45 static unsigned long hpet_num_timers;
46 #endif 46 #endif
47 static void __iomem *hpet_virt_address; 47 static void __iomem *hpet_virt_address;
48 48
49 struct hpet_dev { 49 struct hpet_dev {
50 struct clock_event_device evt; 50 struct clock_event_device evt;
51 unsigned int num; 51 unsigned int num;
52 int cpu; 52 int cpu;
53 unsigned int irq; 53 unsigned int irq;
54 unsigned int flags; 54 unsigned int flags;
55 char name[10]; 55 char name[10];
56 }; 56 };
57 57
58 inline unsigned int hpet_readl(unsigned int a) 58 inline unsigned int hpet_readl(unsigned int a)
59 { 59 {
60 return readl(hpet_virt_address + a); 60 return readl(hpet_virt_address + a);
61 } 61 }
62 62
63 static inline void hpet_writel(unsigned int d, unsigned int a) 63 static inline void hpet_writel(unsigned int d, unsigned int a)
64 { 64 {
65 writel(d, hpet_virt_address + a); 65 writel(d, hpet_virt_address + a);
66 } 66 }
67 67
68 #ifdef CONFIG_X86_64 68 #ifdef CONFIG_X86_64
69 #include <asm/pgtable.h> 69 #include <asm/pgtable.h>
70 #endif 70 #endif
71 71
72 static inline void hpet_set_mapping(void) 72 static inline void hpet_set_mapping(void)
73 { 73 {
74 hpet_virt_address = ioremap_nocache(hpet_address, HPET_MMAP_SIZE); 74 hpet_virt_address = ioremap_nocache(hpet_address, HPET_MMAP_SIZE);
75 #ifdef CONFIG_X86_64 75 #ifdef CONFIG_X86_64
76 __set_fixmap(VSYSCALL_HPET, hpet_address, PAGE_KERNEL_VVAR_NOCACHE); 76 __set_fixmap(VSYSCALL_HPET, hpet_address, PAGE_KERNEL_VVAR_NOCACHE);
77 #endif 77 #endif
78 } 78 }
79 79
80 static inline void hpet_clear_mapping(void) 80 static inline void hpet_clear_mapping(void)
81 { 81 {
82 iounmap(hpet_virt_address); 82 iounmap(hpet_virt_address);
83 hpet_virt_address = NULL; 83 hpet_virt_address = NULL;
84 } 84 }
85 85
86 /* 86 /*
87 * HPET command line enable / disable 87 * HPET command line enable / disable
88 */ 88 */
89 static int boot_hpet_disable; 89 static int boot_hpet_disable;
90 int hpet_force_user; 90 int hpet_force_user;
91 static int hpet_verbose; 91 static int hpet_verbose;
92 92
93 static int __init hpet_setup(char *str) 93 static int __init hpet_setup(char *str)
94 { 94 {
95 if (str) { 95 if (str) {
96 if (!strncmp("disable", str, 7)) 96 if (!strncmp("disable", str, 7))
97 boot_hpet_disable = 1; 97 boot_hpet_disable = 1;
98 if (!strncmp("force", str, 5)) 98 if (!strncmp("force", str, 5))
99 hpet_force_user = 1; 99 hpet_force_user = 1;
100 if (!strncmp("verbose", str, 7)) 100 if (!strncmp("verbose", str, 7))
101 hpet_verbose = 1; 101 hpet_verbose = 1;
102 } 102 }
103 return 1; 103 return 1;
104 } 104 }
105 __setup("hpet=", hpet_setup); 105 __setup("hpet=", hpet_setup);
106 106
107 static int __init disable_hpet(char *str) 107 static int __init disable_hpet(char *str)
108 { 108 {
109 boot_hpet_disable = 1; 109 boot_hpet_disable = 1;
110 return 1; 110 return 1;
111 } 111 }
112 __setup("nohpet", disable_hpet); 112 __setup("nohpet", disable_hpet);
113 113
114 static inline int is_hpet_capable(void) 114 static inline int is_hpet_capable(void)
115 { 115 {
116 return !boot_hpet_disable && hpet_address; 116 return !boot_hpet_disable && hpet_address;
117 } 117 }
118 118
119 /* 119 /*
120 * HPET timer interrupt enable / disable 120 * HPET timer interrupt enable / disable
121 */ 121 */
122 static int hpet_legacy_int_enabled; 122 static int hpet_legacy_int_enabled;
123 123
124 /** 124 /**
125 * is_hpet_enabled - check whether the hpet timer interrupt is enabled 125 * is_hpet_enabled - check whether the hpet timer interrupt is enabled
126 */ 126 */
127 int is_hpet_enabled(void) 127 int is_hpet_enabled(void)
128 { 128 {
129 return is_hpet_capable() && hpet_legacy_int_enabled; 129 return is_hpet_capable() && hpet_legacy_int_enabled;
130 } 130 }
131 EXPORT_SYMBOL_GPL(is_hpet_enabled); 131 EXPORT_SYMBOL_GPL(is_hpet_enabled);
132 132
133 static void _hpet_print_config(const char *function, int line) 133 static void _hpet_print_config(const char *function, int line)
134 { 134 {
135 u32 i, timers, l, h; 135 u32 i, timers, l, h;
136 printk(KERN_INFO "hpet: %s(%d):\n", function, line); 136 printk(KERN_INFO "hpet: %s(%d):\n", function, line);
137 l = hpet_readl(HPET_ID); 137 l = hpet_readl(HPET_ID);
138 h = hpet_readl(HPET_PERIOD); 138 h = hpet_readl(HPET_PERIOD);
139 timers = ((l & HPET_ID_NUMBER) >> HPET_ID_NUMBER_SHIFT) + 1; 139 timers = ((l & HPET_ID_NUMBER) >> HPET_ID_NUMBER_SHIFT) + 1;
140 printk(KERN_INFO "hpet: ID: 0x%x, PERIOD: 0x%x\n", l, h); 140 printk(KERN_INFO "hpet: ID: 0x%x, PERIOD: 0x%x\n", l, h);
141 l = hpet_readl(HPET_CFG); 141 l = hpet_readl(HPET_CFG);
142 h = hpet_readl(HPET_STATUS); 142 h = hpet_readl(HPET_STATUS);
143 printk(KERN_INFO "hpet: CFG: 0x%x, STATUS: 0x%x\n", l, h); 143 printk(KERN_INFO "hpet: CFG: 0x%x, STATUS: 0x%x\n", l, h);
144 l = hpet_readl(HPET_COUNTER); 144 l = hpet_readl(HPET_COUNTER);
145 h = hpet_readl(HPET_COUNTER+4); 145 h = hpet_readl(HPET_COUNTER+4);
146 printk(KERN_INFO "hpet: COUNTER_l: 0x%x, COUNTER_h: 0x%x\n", l, h); 146 printk(KERN_INFO "hpet: COUNTER_l: 0x%x, COUNTER_h: 0x%x\n", l, h);
147 147
148 for (i = 0; i < timers; i++) { 148 for (i = 0; i < timers; i++) {
149 l = hpet_readl(HPET_Tn_CFG(i)); 149 l = hpet_readl(HPET_Tn_CFG(i));
150 h = hpet_readl(HPET_Tn_CFG(i)+4); 150 h = hpet_readl(HPET_Tn_CFG(i)+4);
151 printk(KERN_INFO "hpet: T%d: CFG_l: 0x%x, CFG_h: 0x%x\n", 151 printk(KERN_INFO "hpet: T%d: CFG_l: 0x%x, CFG_h: 0x%x\n",
152 i, l, h); 152 i, l, h);
153 l = hpet_readl(HPET_Tn_CMP(i)); 153 l = hpet_readl(HPET_Tn_CMP(i));
154 h = hpet_readl(HPET_Tn_CMP(i)+4); 154 h = hpet_readl(HPET_Tn_CMP(i)+4);
155 printk(KERN_INFO "hpet: T%d: CMP_l: 0x%x, CMP_h: 0x%x\n", 155 printk(KERN_INFO "hpet: T%d: CMP_l: 0x%x, CMP_h: 0x%x\n",
156 i, l, h); 156 i, l, h);
157 l = hpet_readl(HPET_Tn_ROUTE(i)); 157 l = hpet_readl(HPET_Tn_ROUTE(i));
158 h = hpet_readl(HPET_Tn_ROUTE(i)+4); 158 h = hpet_readl(HPET_Tn_ROUTE(i)+4);
159 printk(KERN_INFO "hpet: T%d ROUTE_l: 0x%x, ROUTE_h: 0x%x\n", 159 printk(KERN_INFO "hpet: T%d ROUTE_l: 0x%x, ROUTE_h: 0x%x\n",
160 i, l, h); 160 i, l, h);
161 } 161 }
162 } 162 }
163 163
164 #define hpet_print_config() \ 164 #define hpet_print_config() \
165 do { \ 165 do { \
166 if (hpet_verbose) \ 166 if (hpet_verbose) \
167 _hpet_print_config(__FUNCTION__, __LINE__); \ 167 _hpet_print_config(__FUNCTION__, __LINE__); \
168 } while (0) 168 } while (0)
169 169
170 /* 170 /*
171 * When the hpet driver (/dev/hpet) is enabled, we need to reserve 171 * When the hpet driver (/dev/hpet) is enabled, we need to reserve
172 * timer 0 and timer 1 in case of RTC emulation. 172 * timer 0 and timer 1 in case of RTC emulation.
173 */ 173 */
174 #ifdef CONFIG_HPET 174 #ifdef CONFIG_HPET
175 175
176 static void hpet_reserve_msi_timers(struct hpet_data *hd); 176 static void hpet_reserve_msi_timers(struct hpet_data *hd);
177 177
178 static void hpet_reserve_platform_timers(unsigned int id) 178 static void hpet_reserve_platform_timers(unsigned int id)
179 { 179 {
180 struct hpet __iomem *hpet = hpet_virt_address; 180 struct hpet __iomem *hpet = hpet_virt_address;
181 struct hpet_timer __iomem *timer = &hpet->hpet_timers[2]; 181 struct hpet_timer __iomem *timer = &hpet->hpet_timers[2];
182 unsigned int nrtimers, i; 182 unsigned int nrtimers, i;
183 struct hpet_data hd; 183 struct hpet_data hd;
184 184
185 nrtimers = ((id & HPET_ID_NUMBER) >> HPET_ID_NUMBER_SHIFT) + 1; 185 nrtimers = ((id & HPET_ID_NUMBER) >> HPET_ID_NUMBER_SHIFT) + 1;
186 186
187 memset(&hd, 0, sizeof(hd)); 187 memset(&hd, 0, sizeof(hd));
188 hd.hd_phys_address = hpet_address; 188 hd.hd_phys_address = hpet_address;
189 hd.hd_address = hpet; 189 hd.hd_address = hpet;
190 hd.hd_nirqs = nrtimers; 190 hd.hd_nirqs = nrtimers;
191 hpet_reserve_timer(&hd, 0); 191 hpet_reserve_timer(&hd, 0);
192 192
193 #ifdef CONFIG_HPET_EMULATE_RTC 193 #ifdef CONFIG_HPET_EMULATE_RTC
194 hpet_reserve_timer(&hd, 1); 194 hpet_reserve_timer(&hd, 1);
195 #endif 195 #endif
196 196
197 /* 197 /*
198 * NOTE that hd_irq[] reflects IOAPIC input pins (LEGACY_8254 198 * NOTE that hd_irq[] reflects IOAPIC input pins (LEGACY_8254
199 * is wrong for i8259!) not the output IRQ. Many BIOS writers 199 * is wrong for i8259!) not the output IRQ. Many BIOS writers
200 * don't bother configuring *any* comparator interrupts. 200 * don't bother configuring *any* comparator interrupts.
201 */ 201 */
202 hd.hd_irq[0] = HPET_LEGACY_8254; 202 hd.hd_irq[0] = HPET_LEGACY_8254;
203 hd.hd_irq[1] = HPET_LEGACY_RTC; 203 hd.hd_irq[1] = HPET_LEGACY_RTC;
204 204
205 for (i = 2; i < nrtimers; timer++, i++) { 205 for (i = 2; i < nrtimers; timer++, i++) {
206 hd.hd_irq[i] = (readl(&timer->hpet_config) & 206 hd.hd_irq[i] = (readl(&timer->hpet_config) &
207 Tn_INT_ROUTE_CNF_MASK) >> Tn_INT_ROUTE_CNF_SHIFT; 207 Tn_INT_ROUTE_CNF_MASK) >> Tn_INT_ROUTE_CNF_SHIFT;
208 } 208 }
209 209
210 hpet_reserve_msi_timers(&hd); 210 hpet_reserve_msi_timers(&hd);
211 211
212 hpet_alloc(&hd); 212 hpet_alloc(&hd);
213 213
214 } 214 }
215 #else 215 #else
216 static void hpet_reserve_platform_timers(unsigned int id) { } 216 static void hpet_reserve_platform_timers(unsigned int id) { }
217 #endif 217 #endif
218 218
219 /* 219 /*
220 * Common hpet info 220 * Common hpet info
221 */ 221 */
222 static unsigned long hpet_freq; 222 static unsigned long hpet_freq;
223 223
224 static void hpet_legacy_set_mode(enum clock_event_mode mode, 224 static void hpet_legacy_set_mode(enum clock_event_mode mode,
225 struct clock_event_device *evt); 225 struct clock_event_device *evt);
226 static int hpet_legacy_next_event(unsigned long delta, 226 static int hpet_legacy_next_event(unsigned long delta,
227 struct clock_event_device *evt); 227 struct clock_event_device *evt);
228 228
229 /* 229 /*
230 * The hpet clock event device 230 * The hpet clock event device
231 */ 231 */
232 static struct clock_event_device hpet_clockevent = { 232 static struct clock_event_device hpet_clockevent = {
233 .name = "hpet", 233 .name = "hpet",
234 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, 234 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
235 .set_mode = hpet_legacy_set_mode, 235 .set_mode = hpet_legacy_set_mode,
236 .set_next_event = hpet_legacy_next_event, 236 .set_next_event = hpet_legacy_next_event,
237 .irq = 0, 237 .irq = 0,
238 .rating = 50, 238 .rating = 50,
239 }; 239 };
240 240
241 static void hpet_stop_counter(void) 241 static void hpet_stop_counter(void)
242 { 242 {
243 unsigned long cfg = hpet_readl(HPET_CFG); 243 unsigned long cfg = hpet_readl(HPET_CFG);
244 cfg &= ~HPET_CFG_ENABLE; 244 cfg &= ~HPET_CFG_ENABLE;
245 hpet_writel(cfg, HPET_CFG); 245 hpet_writel(cfg, HPET_CFG);
246 } 246 }
247 247
248 static void hpet_reset_counter(void) 248 static void hpet_reset_counter(void)
249 { 249 {
250 hpet_writel(0, HPET_COUNTER); 250 hpet_writel(0, HPET_COUNTER);
251 hpet_writel(0, HPET_COUNTER + 4); 251 hpet_writel(0, HPET_COUNTER + 4);
252 } 252 }
253 253
254 static void hpet_start_counter(void) 254 static void hpet_start_counter(void)
255 { 255 {
256 unsigned int cfg = hpet_readl(HPET_CFG); 256 unsigned int cfg = hpet_readl(HPET_CFG);
257 cfg |= HPET_CFG_ENABLE; 257 cfg |= HPET_CFG_ENABLE;
258 hpet_writel(cfg, HPET_CFG); 258 hpet_writel(cfg, HPET_CFG);
259 } 259 }
260 260
261 static void hpet_restart_counter(void) 261 static void hpet_restart_counter(void)
262 { 262 {
263 hpet_stop_counter(); 263 hpet_stop_counter();
264 hpet_reset_counter(); 264 hpet_reset_counter();
265 hpet_start_counter(); 265 hpet_start_counter();
266 } 266 }
267 267
268 static void hpet_resume_device(void) 268 static void hpet_resume_device(void)
269 { 269 {
270 force_hpet_resume(); 270 force_hpet_resume();
271 } 271 }
272 272
273 static void hpet_resume_counter(struct clocksource *cs) 273 static void hpet_resume_counter(struct clocksource *cs)
274 { 274 {
275 hpet_resume_device(); 275 hpet_resume_device();
276 hpet_restart_counter(); 276 hpet_restart_counter();
277 } 277 }
278 278
279 static void hpet_enable_legacy_int(void) 279 static void hpet_enable_legacy_int(void)
280 { 280 {
281 unsigned int cfg = hpet_readl(HPET_CFG); 281 unsigned int cfg = hpet_readl(HPET_CFG);
282 282
283 cfg |= HPET_CFG_LEGACY; 283 cfg |= HPET_CFG_LEGACY;
284 hpet_writel(cfg, HPET_CFG); 284 hpet_writel(cfg, HPET_CFG);
285 hpet_legacy_int_enabled = 1; 285 hpet_legacy_int_enabled = 1;
286 } 286 }
287 287
288 static void hpet_legacy_clockevent_register(void) 288 static void hpet_legacy_clockevent_register(void)
289 { 289 {
290 /* Start HPET legacy interrupts */ 290 /* Start HPET legacy interrupts */
291 hpet_enable_legacy_int(); 291 hpet_enable_legacy_int();
292 292
293 /* 293 /*
294 * Start hpet with the boot cpu mask and make it 294 * Start hpet with the boot cpu mask and make it
295 * global after the IO_APIC has been initialized. 295 * global after the IO_APIC has been initialized.
296 */ 296 */
297 hpet_clockevent.cpumask = cpumask_of(smp_processor_id()); 297 hpet_clockevent.cpumask = cpumask_of(smp_processor_id());
298 clockevents_config_and_register(&hpet_clockevent, hpet_freq, 298 clockevents_config_and_register(&hpet_clockevent, hpet_freq,
299 HPET_MIN_PROG_DELTA, 0x7FFFFFFF); 299 HPET_MIN_PROG_DELTA, 0x7FFFFFFF);
300 global_clock_event = &hpet_clockevent; 300 global_clock_event = &hpet_clockevent;
301 printk(KERN_DEBUG "hpet clockevent registered\n"); 301 printk(KERN_DEBUG "hpet clockevent registered\n");
302 } 302 }
303 303
304 static int hpet_setup_msi_irq(unsigned int irq); 304 static int hpet_setup_msi_irq(unsigned int irq);
305 305
306 static void hpet_set_mode(enum clock_event_mode mode, 306 static void hpet_set_mode(enum clock_event_mode mode,
307 struct clock_event_device *evt, int timer) 307 struct clock_event_device *evt, int timer)
308 { 308 {
309 unsigned int cfg, cmp, now; 309 unsigned int cfg, cmp, now;
310 uint64_t delta; 310 uint64_t delta;
311 311
312 switch (mode) { 312 switch (mode) {
313 case CLOCK_EVT_MODE_PERIODIC: 313 case CLOCK_EVT_MODE_PERIODIC:
314 hpet_stop_counter(); 314 hpet_stop_counter();
315 delta = ((uint64_t)(NSEC_PER_SEC/HZ)) * evt->mult; 315 delta = ((uint64_t)(NSEC_PER_SEC/HZ)) * evt->mult;
316 delta >>= evt->shift; 316 delta >>= evt->shift;
317 now = hpet_readl(HPET_COUNTER); 317 now = hpet_readl(HPET_COUNTER);
318 cmp = now + (unsigned int) delta; 318 cmp = now + (unsigned int) delta;
319 cfg = hpet_readl(HPET_Tn_CFG(timer)); 319 cfg = hpet_readl(HPET_Tn_CFG(timer));
320 /* Make sure we use edge triggered interrupts */ 320 /* Make sure we use edge triggered interrupts */
321 cfg &= ~HPET_TN_LEVEL; 321 cfg &= ~HPET_TN_LEVEL;
322 cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC | 322 cfg |= HPET_TN_ENABLE | HPET_TN_PERIODIC |
323 HPET_TN_SETVAL | HPET_TN_32BIT; 323 HPET_TN_SETVAL | HPET_TN_32BIT;
324 hpet_writel(cfg, HPET_Tn_CFG(timer)); 324 hpet_writel(cfg, HPET_Tn_CFG(timer));
325 hpet_writel(cmp, HPET_Tn_CMP(timer)); 325 hpet_writel(cmp, HPET_Tn_CMP(timer));
326 udelay(1); 326 udelay(1);
327 /* 327 /*
328 * HPET on AMD 81xx needs a second write (with HPET_TN_SETVAL 328 * HPET on AMD 81xx needs a second write (with HPET_TN_SETVAL
329 * cleared) to T0_CMP to set the period. The HPET_TN_SETVAL 329 * cleared) to T0_CMP to set the period. The HPET_TN_SETVAL
330 * bit is automatically cleared after the first write. 330 * bit is automatically cleared after the first write.
331 * (See AMD-8111 HyperTransport I/O Hub Data Sheet, 331 * (See AMD-8111 HyperTransport I/O Hub Data Sheet,
332 * Publication # 24674) 332 * Publication # 24674)
333 */ 333 */
334 hpet_writel((unsigned int) delta, HPET_Tn_CMP(timer)); 334 hpet_writel((unsigned int) delta, HPET_Tn_CMP(timer));
335 hpet_start_counter(); 335 hpet_start_counter();
336 hpet_print_config(); 336 hpet_print_config();
337 break; 337 break;
338 338
339 case CLOCK_EVT_MODE_ONESHOT: 339 case CLOCK_EVT_MODE_ONESHOT:
340 cfg = hpet_readl(HPET_Tn_CFG(timer)); 340 cfg = hpet_readl(HPET_Tn_CFG(timer));
341 cfg &= ~HPET_TN_PERIODIC; 341 cfg &= ~HPET_TN_PERIODIC;
342 cfg |= HPET_TN_ENABLE | HPET_TN_32BIT; 342 cfg |= HPET_TN_ENABLE | HPET_TN_32BIT;
343 hpet_writel(cfg, HPET_Tn_CFG(timer)); 343 hpet_writel(cfg, HPET_Tn_CFG(timer));
344 break; 344 break;
345 345
346 case CLOCK_EVT_MODE_UNUSED: 346 case CLOCK_EVT_MODE_UNUSED:
347 case CLOCK_EVT_MODE_SHUTDOWN: 347 case CLOCK_EVT_MODE_SHUTDOWN:
348 cfg = hpet_readl(HPET_Tn_CFG(timer)); 348 cfg = hpet_readl(HPET_Tn_CFG(timer));
349 cfg &= ~HPET_TN_ENABLE; 349 cfg &= ~HPET_TN_ENABLE;
350 hpet_writel(cfg, HPET_Tn_CFG(timer)); 350 hpet_writel(cfg, HPET_Tn_CFG(timer));
351 break; 351 break;
352 352
353 case CLOCK_EVT_MODE_RESUME: 353 case CLOCK_EVT_MODE_RESUME:
354 if (timer == 0) { 354 if (timer == 0) {
355 hpet_enable_legacy_int(); 355 hpet_enable_legacy_int();
356 } else { 356 } else {
357 struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt); 357 struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt);
358 hpet_setup_msi_irq(hdev->irq); 358 hpet_setup_msi_irq(hdev->irq);
359 disable_irq(hdev->irq); 359 disable_irq(hdev->irq);
360 irq_set_affinity(hdev->irq, cpumask_of(hdev->cpu)); 360 irq_set_affinity(hdev->irq, cpumask_of(hdev->cpu));
361 enable_irq(hdev->irq); 361 enable_irq(hdev->irq);
362 } 362 }
363 hpet_print_config(); 363 hpet_print_config();
364 break; 364 break;
365 } 365 }
366 } 366 }
367 367
368 static int hpet_next_event(unsigned long delta, 368 static int hpet_next_event(unsigned long delta,
369 struct clock_event_device *evt, int timer) 369 struct clock_event_device *evt, int timer)
370 { 370 {
371 u32 cnt; 371 u32 cnt;
372 s32 res; 372 s32 res;
373 373
374 cnt = hpet_readl(HPET_COUNTER); 374 cnt = hpet_readl(HPET_COUNTER);
375 cnt += (u32) delta; 375 cnt += (u32) delta;
376 hpet_writel(cnt, HPET_Tn_CMP(timer)); 376 hpet_writel(cnt, HPET_Tn_CMP(timer));
377 377
378 /* 378 /*
379 * HPETs are a complete disaster. The compare register is 379 * HPETs are a complete disaster. The compare register is
380 * based on a equal comparison and neither provides a less 380 * based on a equal comparison and neither provides a less
381 * than or equal functionality (which would require to take 381 * than or equal functionality (which would require to take
382 * the wraparound into account) nor a simple count down event 382 * the wraparound into account) nor a simple count down event
383 * mode. Further the write to the comparator register is 383 * mode. Further the write to the comparator register is
384 * delayed internally up to two HPET clock cycles in certain 384 * delayed internally up to two HPET clock cycles in certain
385 * chipsets (ATI, ICH9,10). Some newer AMD chipsets have even 385 * chipsets (ATI, ICH9,10). Some newer AMD chipsets have even
386 * longer delays. We worked around that by reading back the 386 * longer delays. We worked around that by reading back the
387 * compare register, but that required another workaround for 387 * compare register, but that required another workaround for
388 * ICH9,10 chips where the first readout after write can 388 * ICH9,10 chips where the first readout after write can
389 * return the old stale value. We already had a minimum 389 * return the old stale value. We already had a minimum
390 * programming delta of 5us enforced, but a NMI or SMI hitting 390 * programming delta of 5us enforced, but a NMI or SMI hitting
391 * between the counter readout and the comparator write can 391 * between the counter readout and the comparator write can
392 * move us behind that point easily. Now instead of reading 392 * move us behind that point easily. Now instead of reading
393 * the compare register back several times, we make the ETIME 393 * the compare register back several times, we make the ETIME
394 * decision based on the following: Return ETIME if the 394 * decision based on the following: Return ETIME if the
395 * counter value after the write is less than HPET_MIN_CYCLES 395 * counter value after the write is less than HPET_MIN_CYCLES
396 * away from the event or if the counter is already ahead of 396 * away from the event or if the counter is already ahead of
397 * the event. The minimum programming delta for the generic 397 * the event. The minimum programming delta for the generic
398 * clockevents code is set to 1.5 * HPET_MIN_CYCLES. 398 * clockevents code is set to 1.5 * HPET_MIN_CYCLES.
399 */ 399 */
400 res = (s32)(cnt - hpet_readl(HPET_COUNTER)); 400 res = (s32)(cnt - hpet_readl(HPET_COUNTER));
401 401
402 return res < HPET_MIN_CYCLES ? -ETIME : 0; 402 return res < HPET_MIN_CYCLES ? -ETIME : 0;
403 } 403 }
404 404
405 static void hpet_legacy_set_mode(enum clock_event_mode mode, 405 static void hpet_legacy_set_mode(enum clock_event_mode mode,
406 struct clock_event_device *evt) 406 struct clock_event_device *evt)
407 { 407 {
408 hpet_set_mode(mode, evt, 0); 408 hpet_set_mode(mode, evt, 0);
409 } 409 }
410 410
411 static int hpet_legacy_next_event(unsigned long delta, 411 static int hpet_legacy_next_event(unsigned long delta,
412 struct clock_event_device *evt) 412 struct clock_event_device *evt)
413 { 413 {
414 return hpet_next_event(delta, evt, 0); 414 return hpet_next_event(delta, evt, 0);
415 } 415 }
416 416
417 /* 417 /*
418 * HPET MSI Support 418 * HPET MSI Support
419 */ 419 */
420 #ifdef CONFIG_PCI_MSI 420 #ifdef CONFIG_PCI_MSI
421 421
422 static DEFINE_PER_CPU(struct hpet_dev *, cpu_hpet_dev); 422 static DEFINE_PER_CPU(struct hpet_dev *, cpu_hpet_dev);
423 static struct hpet_dev *hpet_devs; 423 static struct hpet_dev *hpet_devs;
424 424
425 void hpet_msi_unmask(struct irq_data *data) 425 void hpet_msi_unmask(struct irq_data *data)
426 { 426 {
427 struct hpet_dev *hdev = data->handler_data; 427 struct hpet_dev *hdev = data->handler_data;
428 unsigned int cfg; 428 unsigned int cfg;
429 429
430 /* unmask it */ 430 /* unmask it */
431 cfg = hpet_readl(HPET_Tn_CFG(hdev->num)); 431 cfg = hpet_readl(HPET_Tn_CFG(hdev->num));
432 cfg |= HPET_TN_FSB; 432 cfg |= HPET_TN_FSB;
433 hpet_writel(cfg, HPET_Tn_CFG(hdev->num)); 433 hpet_writel(cfg, HPET_Tn_CFG(hdev->num));
434 } 434 }
435 435
436 void hpet_msi_mask(struct irq_data *data) 436 void hpet_msi_mask(struct irq_data *data)
437 { 437 {
438 struct hpet_dev *hdev = data->handler_data; 438 struct hpet_dev *hdev = data->handler_data;
439 unsigned int cfg; 439 unsigned int cfg;
440 440
441 /* mask it */ 441 /* mask it */
442 cfg = hpet_readl(HPET_Tn_CFG(hdev->num)); 442 cfg = hpet_readl(HPET_Tn_CFG(hdev->num));
443 cfg &= ~HPET_TN_FSB; 443 cfg &= ~HPET_TN_FSB;
444 hpet_writel(cfg, HPET_Tn_CFG(hdev->num)); 444 hpet_writel(cfg, HPET_Tn_CFG(hdev->num));
445 } 445 }
446 446
447 void hpet_msi_write(struct hpet_dev *hdev, struct msi_msg *msg) 447 void hpet_msi_write(struct hpet_dev *hdev, struct msi_msg *msg)
448 { 448 {
449 hpet_writel(msg->data, HPET_Tn_ROUTE(hdev->num)); 449 hpet_writel(msg->data, HPET_Tn_ROUTE(hdev->num));
450 hpet_writel(msg->address_lo, HPET_Tn_ROUTE(hdev->num) + 4); 450 hpet_writel(msg->address_lo, HPET_Tn_ROUTE(hdev->num) + 4);
451 } 451 }
452 452
453 void hpet_msi_read(struct hpet_dev *hdev, struct msi_msg *msg) 453 void hpet_msi_read(struct hpet_dev *hdev, struct msi_msg *msg)
454 { 454 {
455 msg->data = hpet_readl(HPET_Tn_ROUTE(hdev->num)); 455 msg->data = hpet_readl(HPET_Tn_ROUTE(hdev->num));
456 msg->address_lo = hpet_readl(HPET_Tn_ROUTE(hdev->num) + 4); 456 msg->address_lo = hpet_readl(HPET_Tn_ROUTE(hdev->num) + 4);
457 msg->address_hi = 0; 457 msg->address_hi = 0;
458 } 458 }
459 459
460 static void hpet_msi_set_mode(enum clock_event_mode mode, 460 static void hpet_msi_set_mode(enum clock_event_mode mode,
461 struct clock_event_device *evt) 461 struct clock_event_device *evt)
462 { 462 {
463 struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt); 463 struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt);
464 hpet_set_mode(mode, evt, hdev->num); 464 hpet_set_mode(mode, evt, hdev->num);
465 } 465 }
466 466
467 static int hpet_msi_next_event(unsigned long delta, 467 static int hpet_msi_next_event(unsigned long delta,
468 struct clock_event_device *evt) 468 struct clock_event_device *evt)
469 { 469 {
470 struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt); 470 struct hpet_dev *hdev = EVT_TO_HPET_DEV(evt);
471 return hpet_next_event(delta, evt, hdev->num); 471 return hpet_next_event(delta, evt, hdev->num);
472 } 472 }
473 473
474 static int hpet_setup_msi_irq(unsigned int irq) 474 static int hpet_setup_msi_irq(unsigned int irq)
475 { 475 {
476 if (arch_setup_hpet_msi(irq, hpet_blockid)) { 476 if (arch_setup_hpet_msi(irq, hpet_blockid)) {
477 destroy_irq(irq); 477 destroy_irq(irq);
478 return -EINVAL; 478 return -EINVAL;
479 } 479 }
480 return 0; 480 return 0;
481 } 481 }
482 482
483 static int hpet_assign_irq(struct hpet_dev *dev) 483 static int hpet_assign_irq(struct hpet_dev *dev)
484 { 484 {
485 unsigned int irq; 485 unsigned int irq;
486 486
487 irq = create_irq_nr(0, -1); 487 irq = create_irq_nr(0, -1);
488 if (!irq) 488 if (!irq)
489 return -EINVAL; 489 return -EINVAL;
490 490
491 irq_set_handler_data(irq, dev); 491 irq_set_handler_data(irq, dev);
492 492
493 if (hpet_setup_msi_irq(irq)) 493 if (hpet_setup_msi_irq(irq))
494 return -EINVAL; 494 return -EINVAL;
495 495
496 dev->irq = irq; 496 dev->irq = irq;
497 return 0; 497 return 0;
498 } 498 }
499 499
500 static irqreturn_t hpet_interrupt_handler(int irq, void *data) 500 static irqreturn_t hpet_interrupt_handler(int irq, void *data)
501 { 501 {
502 struct hpet_dev *dev = (struct hpet_dev *)data; 502 struct hpet_dev *dev = (struct hpet_dev *)data;
503 struct clock_event_device *hevt = &dev->evt; 503 struct clock_event_device *hevt = &dev->evt;
504 504
505 if (!hevt->event_handler) { 505 if (!hevt->event_handler) {
506 printk(KERN_INFO "Spurious HPET timer interrupt on HPET timer %d\n", 506 printk(KERN_INFO "Spurious HPET timer interrupt on HPET timer %d\n",
507 dev->num); 507 dev->num);
508 return IRQ_HANDLED; 508 return IRQ_HANDLED;
509 } 509 }
510 510
511 hevt->event_handler(hevt); 511 hevt->event_handler(hevt);
512 return IRQ_HANDLED; 512 return IRQ_HANDLED;
513 } 513 }
514 514
515 static int hpet_setup_irq(struct hpet_dev *dev) 515 static int hpet_setup_irq(struct hpet_dev *dev)
516 { 516 {
517 517
518 if (request_irq(dev->irq, hpet_interrupt_handler, 518 if (request_irq(dev->irq, hpet_interrupt_handler,
519 IRQF_TIMER | IRQF_DISABLED | IRQF_NOBALANCING, 519 IRQF_TIMER | IRQF_DISABLED | IRQF_NOBALANCING,
520 dev->name, dev)) 520 dev->name, dev))
521 return -1; 521 return -1;
522 522
523 disable_irq(dev->irq); 523 disable_irq(dev->irq);
524 irq_set_affinity(dev->irq, cpumask_of(dev->cpu)); 524 irq_set_affinity(dev->irq, cpumask_of(dev->cpu));
525 enable_irq(dev->irq); 525 enable_irq(dev->irq);
526 526
527 printk(KERN_DEBUG "hpet: %s irq %d for MSI\n", 527 printk(KERN_DEBUG "hpet: %s irq %d for MSI\n",
528 dev->name, dev->irq); 528 dev->name, dev->irq);
529 529
530 return 0; 530 return 0;
531 } 531 }
532 532
533 /* This should be called in specific @cpu */ 533 /* This should be called in specific @cpu */
534 static void init_one_hpet_msi_clockevent(struct hpet_dev *hdev, int cpu) 534 static void init_one_hpet_msi_clockevent(struct hpet_dev *hdev, int cpu)
535 { 535 {
536 struct clock_event_device *evt = &hdev->evt; 536 struct clock_event_device *evt = &hdev->evt;
537 537
538 WARN_ON(cpu != smp_processor_id()); 538 WARN_ON(cpu != smp_processor_id());
539 if (!(hdev->flags & HPET_DEV_VALID)) 539 if (!(hdev->flags & HPET_DEV_VALID))
540 return; 540 return;
541 541
542 if (hpet_setup_msi_irq(hdev->irq)) 542 if (hpet_setup_msi_irq(hdev->irq))
543 return; 543 return;
544 544
545 hdev->cpu = cpu; 545 hdev->cpu = cpu;
546 per_cpu(cpu_hpet_dev, cpu) = hdev; 546 per_cpu(cpu_hpet_dev, cpu) = hdev;
547 evt->name = hdev->name; 547 evt->name = hdev->name;
548 hpet_setup_irq(hdev); 548 hpet_setup_irq(hdev);
549 evt->irq = hdev->irq; 549 evt->irq = hdev->irq;
550 550
551 evt->rating = 110; 551 evt->rating = 110;
552 evt->features = CLOCK_EVT_FEAT_ONESHOT; 552 evt->features = CLOCK_EVT_FEAT_ONESHOT;
553 if (hdev->flags & HPET_DEV_PERI_CAP) 553 if (hdev->flags & HPET_DEV_PERI_CAP)
554 evt->features |= CLOCK_EVT_FEAT_PERIODIC; 554 evt->features |= CLOCK_EVT_FEAT_PERIODIC;
555 555
556 evt->set_mode = hpet_msi_set_mode; 556 evt->set_mode = hpet_msi_set_mode;
557 evt->set_next_event = hpet_msi_next_event; 557 evt->set_next_event = hpet_msi_next_event;
558 evt->cpumask = cpumask_of(hdev->cpu); 558 evt->cpumask = cpumask_of(hdev->cpu);
559 559
560 clockevents_config_and_register(evt, hpet_freq, HPET_MIN_PROG_DELTA, 560 clockevents_config_and_register(evt, hpet_freq, HPET_MIN_PROG_DELTA,
561 0x7FFFFFFF); 561 0x7FFFFFFF);
562 } 562 }
563 563
564 #ifdef CONFIG_HPET 564 #ifdef CONFIG_HPET
565 /* Reserve at least one timer for userspace (/dev/hpet) */ 565 /* Reserve at least one timer for userspace (/dev/hpet) */
566 #define RESERVE_TIMERS 1 566 #define RESERVE_TIMERS 1
567 #else 567 #else
568 #define RESERVE_TIMERS 0 568 #define RESERVE_TIMERS 0
569 #endif 569 #endif
570 570
571 static void hpet_msi_capability_lookup(unsigned int start_timer) 571 static void hpet_msi_capability_lookup(unsigned int start_timer)
572 { 572 {
573 unsigned int id; 573 unsigned int id;
574 unsigned int num_timers; 574 unsigned int num_timers;
575 unsigned int num_timers_used = 0; 575 unsigned int num_timers_used = 0;
576 int i; 576 int i;
577 577
578 if (hpet_msi_disable) 578 if (hpet_msi_disable)
579 return; 579 return;
580 580
581 if (boot_cpu_has(X86_FEATURE_ARAT)) 581 if (boot_cpu_has(X86_FEATURE_ARAT))
582 return; 582 return;
583 id = hpet_readl(HPET_ID); 583 id = hpet_readl(HPET_ID);
584 584
585 num_timers = ((id & HPET_ID_NUMBER) >> HPET_ID_NUMBER_SHIFT); 585 num_timers = ((id & HPET_ID_NUMBER) >> HPET_ID_NUMBER_SHIFT);
586 num_timers++; /* Value read out starts from 0 */ 586 num_timers++; /* Value read out starts from 0 */
587 hpet_print_config(); 587 hpet_print_config();
588 588
589 hpet_devs = kzalloc(sizeof(struct hpet_dev) * num_timers, GFP_KERNEL); 589 hpet_devs = kzalloc(sizeof(struct hpet_dev) * num_timers, GFP_KERNEL);
590 if (!hpet_devs) 590 if (!hpet_devs)
591 return; 591 return;
592 592
593 hpet_num_timers = num_timers; 593 hpet_num_timers = num_timers;
594 594
595 for (i = start_timer; i < num_timers - RESERVE_TIMERS; i++) { 595 for (i = start_timer; i < num_timers - RESERVE_TIMERS; i++) {
596 struct hpet_dev *hdev = &hpet_devs[num_timers_used]; 596 struct hpet_dev *hdev = &hpet_devs[num_timers_used];
597 unsigned int cfg = hpet_readl(HPET_Tn_CFG(i)); 597 unsigned int cfg = hpet_readl(HPET_Tn_CFG(i));
598 598
599 /* Only consider HPET timer with MSI support */ 599 /* Only consider HPET timer with MSI support */
600 if (!(cfg & HPET_TN_FSB_CAP)) 600 if (!(cfg & HPET_TN_FSB_CAP))
601 continue; 601 continue;
602 602
603 hdev->flags = 0; 603 hdev->flags = 0;
604 if (cfg & HPET_TN_PERIODIC_CAP) 604 if (cfg & HPET_TN_PERIODIC_CAP)
605 hdev->flags |= HPET_DEV_PERI_CAP; 605 hdev->flags |= HPET_DEV_PERI_CAP;
606 hdev->num = i; 606 hdev->num = i;
607 607
608 sprintf(hdev->name, "hpet%d", i); 608 sprintf(hdev->name, "hpet%d", i);
609 if (hpet_assign_irq(hdev)) 609 if (hpet_assign_irq(hdev))
610 continue; 610 continue;
611 611
612 hdev->flags |= HPET_DEV_FSB_CAP; 612 hdev->flags |= HPET_DEV_FSB_CAP;
613 hdev->flags |= HPET_DEV_VALID; 613 hdev->flags |= HPET_DEV_VALID;
614 num_timers_used++; 614 num_timers_used++;
615 if (num_timers_used == num_possible_cpus()) 615 if (num_timers_used == num_possible_cpus())
616 break; 616 break;
617 } 617 }
618 618
619 printk(KERN_INFO "HPET: %d timers in total, %d timers will be used for per-cpu timer\n", 619 printk(KERN_INFO "HPET: %d timers in total, %d timers will be used for per-cpu timer\n",
620 num_timers, num_timers_used); 620 num_timers, num_timers_used);
621 } 621 }
622 622
623 #ifdef CONFIG_HPET 623 #ifdef CONFIG_HPET
624 static void hpet_reserve_msi_timers(struct hpet_data *hd) 624 static void hpet_reserve_msi_timers(struct hpet_data *hd)
625 { 625 {
626 int i; 626 int i;
627 627
628 if (!hpet_devs) 628 if (!hpet_devs)
629 return; 629 return;
630 630
631 for (i = 0; i < hpet_num_timers; i++) { 631 for (i = 0; i < hpet_num_timers; i++) {
632 struct hpet_dev *hdev = &hpet_devs[i]; 632 struct hpet_dev *hdev = &hpet_devs[i];
633 633
634 if (!(hdev->flags & HPET_DEV_VALID)) 634 if (!(hdev->flags & HPET_DEV_VALID))
635 continue; 635 continue;
636 636
637 hd->hd_irq[hdev->num] = hdev->irq; 637 hd->hd_irq[hdev->num] = hdev->irq;
638 hpet_reserve_timer(hd, hdev->num); 638 hpet_reserve_timer(hd, hdev->num);
639 } 639 }
640 } 640 }
641 #endif 641 #endif
642 642
643 static struct hpet_dev *hpet_get_unused_timer(void) 643 static struct hpet_dev *hpet_get_unused_timer(void)
644 { 644 {
645 int i; 645 int i;
646 646
647 if (!hpet_devs) 647 if (!hpet_devs)
648 return NULL; 648 return NULL;
649 649
650 for (i = 0; i < hpet_num_timers; i++) { 650 for (i = 0; i < hpet_num_timers; i++) {
651 struct hpet_dev *hdev = &hpet_devs[i]; 651 struct hpet_dev *hdev = &hpet_devs[i];
652 652
653 if (!(hdev->flags & HPET_DEV_VALID)) 653 if (!(hdev->flags & HPET_DEV_VALID))
654 continue; 654 continue;
655 if (test_and_set_bit(HPET_DEV_USED_BIT, 655 if (test_and_set_bit(HPET_DEV_USED_BIT,
656 (unsigned long *)&hdev->flags)) 656 (unsigned long *)&hdev->flags))
657 continue; 657 continue;
658 return hdev; 658 return hdev;
659 } 659 }
660 return NULL; 660 return NULL;
661 } 661 }
662 662
663 struct hpet_work_struct { 663 struct hpet_work_struct {
664 struct delayed_work work; 664 struct delayed_work work;
665 struct completion complete; 665 struct completion complete;
666 }; 666 };
667 667
668 static void hpet_work(struct work_struct *w) 668 static void hpet_work(struct work_struct *w)
669 { 669 {
670 struct hpet_dev *hdev; 670 struct hpet_dev *hdev;
671 int cpu = smp_processor_id(); 671 int cpu = smp_processor_id();
672 struct hpet_work_struct *hpet_work; 672 struct hpet_work_struct *hpet_work;
673 673
674 hpet_work = container_of(w, struct hpet_work_struct, work.work); 674 hpet_work = container_of(w, struct hpet_work_struct, work.work);
675 675
676 hdev = hpet_get_unused_timer(); 676 hdev = hpet_get_unused_timer();
677 if (hdev) 677 if (hdev)
678 init_one_hpet_msi_clockevent(hdev, cpu); 678 init_one_hpet_msi_clockevent(hdev, cpu);
679 679
680 complete(&hpet_work->complete); 680 complete(&hpet_work->complete);
681 } 681 }
682 682
683 static int hpet_cpuhp_notify(struct notifier_block *n, 683 static int hpet_cpuhp_notify(struct notifier_block *n,
684 unsigned long action, void *hcpu) 684 unsigned long action, void *hcpu)
685 { 685 {
686 unsigned long cpu = (unsigned long)hcpu; 686 unsigned long cpu = (unsigned long)hcpu;
687 struct hpet_work_struct work; 687 struct hpet_work_struct work;
688 struct hpet_dev *hdev = per_cpu(cpu_hpet_dev, cpu); 688 struct hpet_dev *hdev = per_cpu(cpu_hpet_dev, cpu);
689 689
690 switch (action & 0xf) { 690 switch (action & 0xf) {
691 case CPU_ONLINE: 691 case CPU_ONLINE:
692 INIT_DELAYED_WORK_ONSTACK(&work.work, hpet_work); 692 INIT_DELAYED_WORK_ONSTACK(&work.work, hpet_work);
693 init_completion(&work.complete); 693 init_completion(&work.complete);
694 /* FIXME: add schedule_work_on() */ 694 /* FIXME: add schedule_work_on() */
695 schedule_delayed_work_on(cpu, &work.work, 0); 695 schedule_delayed_work_on(cpu, &work.work, 0);
696 wait_for_completion(&work.complete); 696 wait_for_completion(&work.complete);
697 destroy_timer_on_stack(&work.work.timer); 697 destroy_timer_on_stack(&work.work.timer);
698 break; 698 break;
699 case CPU_DEAD: 699 case CPU_DEAD:
700 if (hdev) { 700 if (hdev) {
701 free_irq(hdev->irq, hdev); 701 free_irq(hdev->irq, hdev);
702 hdev->flags &= ~HPET_DEV_USED; 702 hdev->flags &= ~HPET_DEV_USED;
703 per_cpu(cpu_hpet_dev, cpu) = NULL; 703 per_cpu(cpu_hpet_dev, cpu) = NULL;
704 } 704 }
705 break; 705 break;
706 } 706 }
707 return NOTIFY_OK; 707 return NOTIFY_OK;
708 } 708 }
709 #else 709 #else
710 710
711 static int hpet_setup_msi_irq(unsigned int irq) 711 static int hpet_setup_msi_irq(unsigned int irq)
712 { 712 {
713 return 0; 713 return 0;
714 } 714 }
715 static void hpet_msi_capability_lookup(unsigned int start_timer) 715 static void hpet_msi_capability_lookup(unsigned int start_timer)
716 { 716 {
717 return; 717 return;
718 } 718 }
719 719
720 #ifdef CONFIG_HPET 720 #ifdef CONFIG_HPET
721 static void hpet_reserve_msi_timers(struct hpet_data *hd) 721 static void hpet_reserve_msi_timers(struct hpet_data *hd)
722 { 722 {
723 return; 723 return;
724 } 724 }
725 #endif 725 #endif
726 726
727 static int hpet_cpuhp_notify(struct notifier_block *n, 727 static int hpet_cpuhp_notify(struct notifier_block *n,
728 unsigned long action, void *hcpu) 728 unsigned long action, void *hcpu)
729 { 729 {
730 return NOTIFY_OK; 730 return NOTIFY_OK;
731 } 731 }
732 732
733 #endif 733 #endif
734 734
735 /* 735 /*
736 * Clock source related code 736 * Clock source related code
737 */ 737 */
738 static cycle_t read_hpet(struct clocksource *cs) 738 static cycle_t read_hpet(struct clocksource *cs)
739 { 739 {
740 return (cycle_t)hpet_readl(HPET_COUNTER); 740 return (cycle_t)hpet_readl(HPET_COUNTER);
741 } 741 }
742 742
743 static struct clocksource clocksource_hpet = { 743 static struct clocksource clocksource_hpet = {
744 .name = "hpet", 744 .name = "hpet",
745 .rating = 250, 745 .rating = 250,
746 .read = read_hpet, 746 .read = read_hpet,
747 .mask = HPET_MASK, 747 .mask = HPET_MASK,
748 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 748 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
749 .resume = hpet_resume_counter, 749 .resume = hpet_resume_counter,
750 #ifdef CONFIG_X86_64 750 #ifdef CONFIG_X86_64
751 .archdata = { .vclock_mode = VCLOCK_HPET }, 751 .archdata = { .vclock_mode = VCLOCK_HPET },
752 #endif 752 #endif
753 }; 753 };
754 754
755 static int hpet_clocksource_register(void) 755 static int hpet_clocksource_register(void)
756 { 756 {
757 u64 start, now; 757 u64 start, now;
758 cycle_t t1; 758 cycle_t t1;
759 759
760 /* Start the counter */ 760 /* Start the counter */
761 hpet_restart_counter(); 761 hpet_restart_counter();
762 762
763 /* Verify whether hpet counter works */ 763 /* Verify whether hpet counter works */
764 t1 = hpet_readl(HPET_COUNTER); 764 t1 = hpet_readl(HPET_COUNTER);
765 rdtscll(start); 765 rdtscll(start);
766 766
767 /* 767 /*
768 * We don't know the TSC frequency yet, but waiting for 768 * We don't know the TSC frequency yet, but waiting for
769 * 200000 TSC cycles is safe: 769 * 200000 TSC cycles is safe:
770 * 4 GHz == 50us 770 * 4 GHz == 50us
771 * 1 GHz == 200us 771 * 1 GHz == 200us
772 */ 772 */
773 do { 773 do {
774 rep_nop(); 774 rep_nop();
775 rdtscll(now); 775 rdtscll(now);
776 } while ((now - start) < 200000UL); 776 } while ((now - start) < 200000UL);
777 777
778 if (t1 == hpet_readl(HPET_COUNTER)) { 778 if (t1 == hpet_readl(HPET_COUNTER)) {
779 printk(KERN_WARNING 779 printk(KERN_WARNING
780 "HPET counter not counting. HPET disabled\n"); 780 "HPET counter not counting. HPET disabled\n");
781 return -ENODEV; 781 return -ENODEV;
782 } 782 }
783 783
784 clocksource_register_hz(&clocksource_hpet, (u32)hpet_freq); 784 clocksource_register_hz(&clocksource_hpet, (u32)hpet_freq);
785 return 0; 785 return 0;
786 } 786 }
787 787
788 /** 788 /**
789 * hpet_enable - Try to setup the HPET timer. Returns 1 on success. 789 * hpet_enable - Try to setup the HPET timer. Returns 1 on success.
790 */ 790 */
791 int __init hpet_enable(void) 791 int __init hpet_enable(void)
792 { 792 {
793 unsigned long hpet_period; 793 unsigned long hpet_period;
794 unsigned int id; 794 unsigned int id;
795 u64 freq; 795 u64 freq;
796 int i; 796 int i;
797 797
798 if (!is_hpet_capable()) 798 if (!is_hpet_capable())
799 return 0; 799 return 0;
800 800
801 hpet_set_mapping(); 801 hpet_set_mapping();
802 802
803 /* 803 /*
804 * Read the period and check for a sane value: 804 * Read the period and check for a sane value:
805 */ 805 */
806 hpet_period = hpet_readl(HPET_PERIOD); 806 hpet_period = hpet_readl(HPET_PERIOD);
807 807
808 /* 808 /*
809 * AMD SB700 based systems with spread spectrum enabled use a 809 * AMD SB700 based systems with spread spectrum enabled use a
810 * SMM based HPET emulation to provide proper frequency 810 * SMM based HPET emulation to provide proper frequency
811 * setting. The SMM code is initialized with the first HPET 811 * setting. The SMM code is initialized with the first HPET
812 * register access and takes some time to complete. During 812 * register access and takes some time to complete. During
813 * this time the config register reads 0xffffffff. We check 813 * this time the config register reads 0xffffffff. We check
814 * for max. 1000 loops whether the config register reads a non 814 * for max. 1000 loops whether the config register reads a non
815 * 0xffffffff value to make sure that HPET is up and running 815 * 0xffffffff value to make sure that HPET is up and running
816 * before we go further. A counting loop is safe, as the HPET 816 * before we go further. A counting loop is safe, as the HPET
817 * access takes thousands of CPU cycles. On non SB700 based 817 * access takes thousands of CPU cycles. On non SB700 based
818 * machines this check is only done once and has no side 818 * machines this check is only done once and has no side
819 * effects. 819 * effects.
820 */ 820 */
821 for (i = 0; hpet_readl(HPET_CFG) == 0xFFFFFFFF; i++) { 821 for (i = 0; hpet_readl(HPET_CFG) == 0xFFFFFFFF; i++) {
822 if (i == 1000) { 822 if (i == 1000) {
823 printk(KERN_WARNING 823 printk(KERN_WARNING
824 "HPET config register value = 0xFFFFFFFF. " 824 "HPET config register value = 0xFFFFFFFF. "
825 "Disabling HPET\n"); 825 "Disabling HPET\n");
826 goto out_nohpet; 826 goto out_nohpet;
827 } 827 }
828 } 828 }
829 829
830 if (hpet_period < HPET_MIN_PERIOD || hpet_period > HPET_MAX_PERIOD) 830 if (hpet_period < HPET_MIN_PERIOD || hpet_period > HPET_MAX_PERIOD)
831 goto out_nohpet; 831 goto out_nohpet;
832 832
833 /* 833 /*
834 * The period is a femto seconds value. Convert it to a 834 * The period is a femto seconds value. Convert it to a
835 * frequency. 835 * frequency.
836 */ 836 */
837 freq = FSEC_PER_SEC; 837 freq = FSEC_PER_SEC;
838 do_div(freq, hpet_period); 838 do_div(freq, hpet_period);
839 hpet_freq = freq; 839 hpet_freq = freq;
840 840
841 /* 841 /*
842 * Read the HPET ID register to retrieve the IRQ routing 842 * Read the HPET ID register to retrieve the IRQ routing
843 * information and the number of channels 843 * information and the number of channels
844 */ 844 */
845 id = hpet_readl(HPET_ID); 845 id = hpet_readl(HPET_ID);
846 hpet_print_config(); 846 hpet_print_config();
847 847
848 #ifdef CONFIG_HPET_EMULATE_RTC 848 #ifdef CONFIG_HPET_EMULATE_RTC
849 /* 849 /*
850 * The legacy routing mode needs at least two channels, tick timer 850 * The legacy routing mode needs at least two channels, tick timer
851 * and the rtc emulation channel. 851 * and the rtc emulation channel.
852 */ 852 */
853 if (!(id & HPET_ID_NUMBER)) 853 if (!(id & HPET_ID_NUMBER))
854 goto out_nohpet; 854 goto out_nohpet;
855 #endif 855 #endif
856 856
857 if (hpet_clocksource_register()) 857 if (hpet_clocksource_register())
858 goto out_nohpet; 858 goto out_nohpet;
859 859
860 if (id & HPET_ID_LEGSUP) { 860 if (id & HPET_ID_LEGSUP) {
861 hpet_legacy_clockevent_register(); 861 hpet_legacy_clockevent_register();
862 return 1; 862 return 1;
863 } 863 }
864 return 0; 864 return 0;
865 865
866 out_nohpet: 866 out_nohpet:
867 hpet_clear_mapping(); 867 hpet_clear_mapping();
868 hpet_address = 0; 868 hpet_address = 0;
869 return 0; 869 return 0;
870 } 870 }
871 871
872 /* 872 /*
873 * Needs to be late, as the reserve_timer code calls kalloc ! 873 * Needs to be late, as the reserve_timer code calls kalloc !
874 * 874 *
875 * Not a problem on i386 as hpet_enable is called from late_time_init, 875 * Not a problem on i386 as hpet_enable is called from late_time_init,
876 * but on x86_64 it is necessary ! 876 * but on x86_64 it is necessary !
877 */ 877 */
878 static __init int hpet_late_init(void) 878 static __init int hpet_late_init(void)
879 { 879 {
880 int cpu; 880 int cpu;
881 881
882 if (boot_hpet_disable) 882 if (boot_hpet_disable)
883 return -ENODEV; 883 return -ENODEV;
884 884
885 if (!hpet_address) { 885 if (!hpet_address) {
886 if (!force_hpet_address) 886 if (!force_hpet_address)
887 return -ENODEV; 887 return -ENODEV;
888 888
889 hpet_address = force_hpet_address; 889 hpet_address = force_hpet_address;
890 hpet_enable(); 890 hpet_enable();
891 } 891 }
892 892
893 if (!hpet_virt_address) 893 if (!hpet_virt_address)
894 return -ENODEV; 894 return -ENODEV;
895 895
896 if (hpet_readl(HPET_ID) & HPET_ID_LEGSUP) 896 if (hpet_readl(HPET_ID) & HPET_ID_LEGSUP)
897 hpet_msi_capability_lookup(2); 897 hpet_msi_capability_lookup(2);
898 else 898 else
899 hpet_msi_capability_lookup(0); 899 hpet_msi_capability_lookup(0);
900 900
901 hpet_reserve_platform_timers(hpet_readl(HPET_ID)); 901 hpet_reserve_platform_timers(hpet_readl(HPET_ID));
902 hpet_print_config(); 902 hpet_print_config();
903 903
904 if (hpet_msi_disable) 904 if (hpet_msi_disable)
905 return 0; 905 return 0;
906 906
907 if (boot_cpu_has(X86_FEATURE_ARAT)) 907 if (boot_cpu_has(X86_FEATURE_ARAT))
908 return 0; 908 return 0;
909 909
910 for_each_online_cpu(cpu) { 910 for_each_online_cpu(cpu) {
911 hpet_cpuhp_notify(NULL, CPU_ONLINE, (void *)(long)cpu); 911 hpet_cpuhp_notify(NULL, CPU_ONLINE, (void *)(long)cpu);
912 } 912 }
913 913
914 /* This notifier should be called after workqueue is ready */ 914 /* This notifier should be called after workqueue is ready */
915 hotcpu_notifier(hpet_cpuhp_notify, -20); 915 hotcpu_notifier(hpet_cpuhp_notify, -20);
916 916
917 return 0; 917 return 0;
918 } 918 }
919 fs_initcall(hpet_late_init); 919 fs_initcall(hpet_late_init);
920 920
921 void hpet_disable(void) 921 void hpet_disable(void)
922 { 922 {
923 if (is_hpet_capable() && hpet_virt_address) { 923 if (is_hpet_capable() && hpet_virt_address) {
924 unsigned int cfg = hpet_readl(HPET_CFG); 924 unsigned int cfg = hpet_readl(HPET_CFG);
925 925
926 if (hpet_legacy_int_enabled) { 926 if (hpet_legacy_int_enabled) {
927 cfg &= ~HPET_CFG_LEGACY; 927 cfg &= ~HPET_CFG_LEGACY;
928 hpet_legacy_int_enabled = 0; 928 hpet_legacy_int_enabled = 0;
929 } 929 }
930 cfg &= ~HPET_CFG_ENABLE; 930 cfg &= ~HPET_CFG_ENABLE;
931 hpet_writel(cfg, HPET_CFG); 931 hpet_writel(cfg, HPET_CFG);
932 } 932 }
933 } 933 }
934 934
935 #ifdef CONFIG_HPET_EMULATE_RTC 935 #ifdef CONFIG_HPET_EMULATE_RTC
936 936
937 /* HPET in LegacyReplacement Mode eats up RTC interrupt line. When, HPET 937 /* HPET in LegacyReplacement Mode eats up RTC interrupt line. When, HPET
938 * is enabled, we support RTC interrupt functionality in software. 938 * is enabled, we support RTC interrupt functionality in software.
939 * RTC has 3 kinds of interrupts: 939 * RTC has 3 kinds of interrupts:
940 * 1) Update Interrupt - generate an interrupt, every sec, when RTC clock 940 * 1) Update Interrupt - generate an interrupt, every sec, when RTC clock
941 * is updated 941 * is updated
942 * 2) Alarm Interrupt - generate an interrupt at a specific time of day 942 * 2) Alarm Interrupt - generate an interrupt at a specific time of day
943 * 3) Periodic Interrupt - generate periodic interrupt, with frequencies 943 * 3) Periodic Interrupt - generate periodic interrupt, with frequencies
944 * 2Hz-8192Hz (2Hz-64Hz for non-root user) (all freqs in powers of 2) 944 * 2Hz-8192Hz (2Hz-64Hz for non-root user) (all freqs in powers of 2)
945 * (1) and (2) above are implemented using polling at a frequency of 945 * (1) and (2) above are implemented using polling at a frequency of
946 * 64 Hz. The exact frequency is a tradeoff between accuracy and interrupt 946 * 64 Hz. The exact frequency is a tradeoff between accuracy and interrupt
947 * overhead. (DEFAULT_RTC_INT_FREQ) 947 * overhead. (DEFAULT_RTC_INT_FREQ)
948 * For (3), we use interrupts at 64Hz or user specified periodic 948 * For (3), we use interrupts at 64Hz or user specified periodic
949 * frequency, whichever is higher. 949 * frequency, whichever is higher.
950 */ 950 */
951 #include <linux/mc146818rtc.h> 951 #include <linux/mc146818rtc.h>
952 #include <linux/rtc.h> 952 #include <linux/rtc.h>
953 #include <asm/rtc.h> 953 #include <asm/rtc.h>
954 954
955 #define DEFAULT_RTC_INT_FREQ 64 955 #define DEFAULT_RTC_INT_FREQ 64
956 #define DEFAULT_RTC_SHIFT 6 956 #define DEFAULT_RTC_SHIFT 6
957 #define RTC_NUM_INTS 1 957 #define RTC_NUM_INTS 1
958 958
959 static unsigned long hpet_rtc_flags; 959 static unsigned long hpet_rtc_flags;
960 static int hpet_prev_update_sec; 960 static int hpet_prev_update_sec;
961 static struct rtc_time hpet_alarm_time; 961 static struct rtc_time hpet_alarm_time;
962 static unsigned long hpet_pie_count; 962 static unsigned long hpet_pie_count;
963 static u32 hpet_t1_cmp; 963 static u32 hpet_t1_cmp;
964 static u32 hpet_default_delta; 964 static u32 hpet_default_delta;
965 static u32 hpet_pie_delta; 965 static u32 hpet_pie_delta;
966 static unsigned long hpet_pie_limit; 966 static unsigned long hpet_pie_limit;
967 967
968 static rtc_irq_handler irq_handler; 968 static rtc_irq_handler irq_handler;
969 969
970 /* 970 /*
971 * Check that the hpet counter c1 is ahead of the c2 971 * Check that the hpet counter c1 is ahead of the c2
972 */ 972 */
973 static inline int hpet_cnt_ahead(u32 c1, u32 c2) 973 static inline int hpet_cnt_ahead(u32 c1, u32 c2)
974 { 974 {
975 return (s32)(c2 - c1) < 0; 975 return (s32)(c2 - c1) < 0;
976 } 976 }
977 977
978 /* 978 /*
979 * Registers a IRQ handler. 979 * Registers a IRQ handler.
980 */ 980 */
981 int hpet_register_irq_handler(rtc_irq_handler handler) 981 int hpet_register_irq_handler(rtc_irq_handler handler)
982 { 982 {
983 if (!is_hpet_enabled()) 983 if (!is_hpet_enabled())
984 return -ENODEV; 984 return -ENODEV;
985 if (irq_handler) 985 if (irq_handler)
986 return -EBUSY; 986 return -EBUSY;
987 987
988 irq_handler = handler; 988 irq_handler = handler;
989 989
990 return 0; 990 return 0;
991 } 991 }
992 EXPORT_SYMBOL_GPL(hpet_register_irq_handler); 992 EXPORT_SYMBOL_GPL(hpet_register_irq_handler);
993 993
994 /* 994 /*
995 * Deregisters the IRQ handler registered with hpet_register_irq_handler() 995 * Deregisters the IRQ handler registered with hpet_register_irq_handler()
996 * and does cleanup. 996 * and does cleanup.
997 */ 997 */
998 void hpet_unregister_irq_handler(rtc_irq_handler handler) 998 void hpet_unregister_irq_handler(rtc_irq_handler handler)
999 { 999 {
1000 if (!is_hpet_enabled()) 1000 if (!is_hpet_enabled())
1001 return; 1001 return;
1002 1002
1003 irq_handler = NULL; 1003 irq_handler = NULL;
1004 hpet_rtc_flags = 0; 1004 hpet_rtc_flags = 0;
1005 } 1005 }
1006 EXPORT_SYMBOL_GPL(hpet_unregister_irq_handler); 1006 EXPORT_SYMBOL_GPL(hpet_unregister_irq_handler);
1007 1007
1008 /* 1008 /*
1009 * Timer 1 for RTC emulation. We use one shot mode, as periodic mode 1009 * Timer 1 for RTC emulation. We use one shot mode, as periodic mode
1010 * is not supported by all HPET implementations for timer 1. 1010 * is not supported by all HPET implementations for timer 1.
1011 * 1011 *
1012 * hpet_rtc_timer_init() is called when the rtc is initialized. 1012 * hpet_rtc_timer_init() is called when the rtc is initialized.
1013 */ 1013 */
1014 int hpet_rtc_timer_init(void) 1014 int hpet_rtc_timer_init(void)
1015 { 1015 {
1016 unsigned int cfg, cnt, delta; 1016 unsigned int cfg, cnt, delta;
1017 unsigned long flags; 1017 unsigned long flags;
1018 1018
1019 if (!is_hpet_enabled()) 1019 if (!is_hpet_enabled())
1020 return 0; 1020 return 0;
1021 1021
1022 if (!hpet_default_delta) { 1022 if (!hpet_default_delta) {
1023 uint64_t clc; 1023 uint64_t clc;
1024 1024
1025 clc = (uint64_t) hpet_clockevent.mult * NSEC_PER_SEC; 1025 clc = (uint64_t) hpet_clockevent.mult * NSEC_PER_SEC;
1026 clc >>= hpet_clockevent.shift + DEFAULT_RTC_SHIFT; 1026 clc >>= hpet_clockevent.shift + DEFAULT_RTC_SHIFT;
1027 hpet_default_delta = clc; 1027 hpet_default_delta = clc;
1028 } 1028 }
1029 1029
1030 if (!(hpet_rtc_flags & RTC_PIE) || hpet_pie_limit) 1030 if (!(hpet_rtc_flags & RTC_PIE) || hpet_pie_limit)
1031 delta = hpet_default_delta; 1031 delta = hpet_default_delta;
1032 else 1032 else
1033 delta = hpet_pie_delta; 1033 delta = hpet_pie_delta;
1034 1034
1035 local_irq_save(flags); 1035 local_irq_save(flags);
1036 1036
1037 cnt = delta + hpet_readl(HPET_COUNTER); 1037 cnt = delta + hpet_readl(HPET_COUNTER);
1038 hpet_writel(cnt, HPET_T1_CMP); 1038 hpet_writel(cnt, HPET_T1_CMP);
1039 hpet_t1_cmp = cnt; 1039 hpet_t1_cmp = cnt;
1040 1040
1041 cfg = hpet_readl(HPET_T1_CFG); 1041 cfg = hpet_readl(HPET_T1_CFG);
1042 cfg &= ~HPET_TN_PERIODIC; 1042 cfg &= ~HPET_TN_PERIODIC;
1043 cfg |= HPET_TN_ENABLE | HPET_TN_32BIT; 1043 cfg |= HPET_TN_ENABLE | HPET_TN_32BIT;
1044 hpet_writel(cfg, HPET_T1_CFG); 1044 hpet_writel(cfg, HPET_T1_CFG);
1045 1045
1046 local_irq_restore(flags); 1046 local_irq_restore(flags);
1047 1047
1048 return 1; 1048 return 1;
1049 } 1049 }
1050 EXPORT_SYMBOL_GPL(hpet_rtc_timer_init); 1050 EXPORT_SYMBOL_GPL(hpet_rtc_timer_init);
1051 1051
1052 static void hpet_disable_rtc_channel(void)
1053 {
1054 unsigned long cfg;
1055 cfg = hpet_readl(HPET_T1_CFG);
1056 cfg &= ~HPET_TN_ENABLE;
1057 hpet_writel(cfg, HPET_T1_CFG);
1058 }
1059
1052 /* 1060 /*
1053 * The functions below are called from rtc driver. 1061 * The functions below are called from rtc driver.
1054 * Return 0 if HPET is not being used. 1062 * Return 0 if HPET is not being used.
1055 * Otherwise do the necessary changes and return 1. 1063 * Otherwise do the necessary changes and return 1.
1056 */ 1064 */
1057 int hpet_mask_rtc_irq_bit(unsigned long bit_mask) 1065 int hpet_mask_rtc_irq_bit(unsigned long bit_mask)
1058 { 1066 {
1059 if (!is_hpet_enabled()) 1067 if (!is_hpet_enabled())
1060 return 0; 1068 return 0;
1061 1069
1062 hpet_rtc_flags &= ~bit_mask; 1070 hpet_rtc_flags &= ~bit_mask;
1071 if (unlikely(!hpet_rtc_flags))
1072 hpet_disable_rtc_channel();
1073
1063 return 1; 1074 return 1;
1064 } 1075 }
1065 EXPORT_SYMBOL_GPL(hpet_mask_rtc_irq_bit); 1076 EXPORT_SYMBOL_GPL(hpet_mask_rtc_irq_bit);
1066 1077
1067 int hpet_set_rtc_irq_bit(unsigned long bit_mask) 1078 int hpet_set_rtc_irq_bit(unsigned long bit_mask)
1068 { 1079 {
1069 unsigned long oldbits = hpet_rtc_flags; 1080 unsigned long oldbits = hpet_rtc_flags;
1070 1081
1071 if (!is_hpet_enabled()) 1082 if (!is_hpet_enabled())
1072 return 0; 1083 return 0;
1073 1084
1074 hpet_rtc_flags |= bit_mask; 1085 hpet_rtc_flags |= bit_mask;
1075 1086
1076 if ((bit_mask & RTC_UIE) && !(oldbits & RTC_UIE)) 1087 if ((bit_mask & RTC_UIE) && !(oldbits & RTC_UIE))
1077 hpet_prev_update_sec = -1; 1088 hpet_prev_update_sec = -1;
1078 1089
1079 if (!oldbits) 1090 if (!oldbits)
1080 hpet_rtc_timer_init(); 1091 hpet_rtc_timer_init();
1081 1092
1082 return 1; 1093 return 1;
1083 } 1094 }
1084 EXPORT_SYMBOL_GPL(hpet_set_rtc_irq_bit); 1095 EXPORT_SYMBOL_GPL(hpet_set_rtc_irq_bit);
1085 1096
1086 int hpet_set_alarm_time(unsigned char hrs, unsigned char min, 1097 int hpet_set_alarm_time(unsigned char hrs, unsigned char min,
1087 unsigned char sec) 1098 unsigned char sec)
1088 { 1099 {
1089 if (!is_hpet_enabled()) 1100 if (!is_hpet_enabled())
1090 return 0; 1101 return 0;
1091 1102
1092 hpet_alarm_time.tm_hour = hrs; 1103 hpet_alarm_time.tm_hour = hrs;
1093 hpet_alarm_time.tm_min = min; 1104 hpet_alarm_time.tm_min = min;
1094 hpet_alarm_time.tm_sec = sec; 1105 hpet_alarm_time.tm_sec = sec;
1095 1106
1096 return 1; 1107 return 1;
1097 } 1108 }
1098 EXPORT_SYMBOL_GPL(hpet_set_alarm_time); 1109 EXPORT_SYMBOL_GPL(hpet_set_alarm_time);
1099 1110
1100 int hpet_set_periodic_freq(unsigned long freq) 1111 int hpet_set_periodic_freq(unsigned long freq)
1101 { 1112 {
1102 uint64_t clc; 1113 uint64_t clc;
1103 1114
1104 if (!is_hpet_enabled()) 1115 if (!is_hpet_enabled())
1105 return 0; 1116 return 0;
1106 1117
1107 if (freq <= DEFAULT_RTC_INT_FREQ) 1118 if (freq <= DEFAULT_RTC_INT_FREQ)
1108 hpet_pie_limit = DEFAULT_RTC_INT_FREQ / freq; 1119 hpet_pie_limit = DEFAULT_RTC_INT_FREQ / freq;
1109 else { 1120 else {
1110 clc = (uint64_t) hpet_clockevent.mult * NSEC_PER_SEC; 1121 clc = (uint64_t) hpet_clockevent.mult * NSEC_PER_SEC;
1111 do_div(clc, freq); 1122 do_div(clc, freq);
1112 clc >>= hpet_clockevent.shift; 1123 clc >>= hpet_clockevent.shift;
1113 hpet_pie_delta = clc; 1124 hpet_pie_delta = clc;
1114 hpet_pie_limit = 0; 1125 hpet_pie_limit = 0;
1115 } 1126 }
1116 return 1; 1127 return 1;
1117 } 1128 }
1118 EXPORT_SYMBOL_GPL(hpet_set_periodic_freq); 1129 EXPORT_SYMBOL_GPL(hpet_set_periodic_freq);
1119 1130
1120 int hpet_rtc_dropped_irq(void) 1131 int hpet_rtc_dropped_irq(void)
1121 { 1132 {
1122 return is_hpet_enabled(); 1133 return is_hpet_enabled();
1123 } 1134 }
1124 EXPORT_SYMBOL_GPL(hpet_rtc_dropped_irq); 1135 EXPORT_SYMBOL_GPL(hpet_rtc_dropped_irq);
1125 1136
1126 static void hpet_rtc_timer_reinit(void) 1137 static void hpet_rtc_timer_reinit(void)
1127 { 1138 {
1128 unsigned int cfg, delta; 1139 unsigned int delta;
1129 int lost_ints = -1; 1140 int lost_ints = -1;
1130 1141
1131 if (unlikely(!hpet_rtc_flags)) { 1142 if (unlikely(!hpet_rtc_flags))
1132 cfg = hpet_readl(HPET_T1_CFG); 1143 hpet_disable_rtc_channel();
1133 cfg &= ~HPET_TN_ENABLE;
1134 hpet_writel(cfg, HPET_T1_CFG);
1135 return;
1136 }
1137 1144
1138 if (!(hpet_rtc_flags & RTC_PIE) || hpet_pie_limit) 1145 if (!(hpet_rtc_flags & RTC_PIE) || hpet_pie_limit)
1139 delta = hpet_default_delta; 1146 delta = hpet_default_delta;
1140 else 1147 else
1141 delta = hpet_pie_delta; 1148 delta = hpet_pie_delta;
1142 1149
1143 /* 1150 /*
1144 * Increment the comparator value until we are ahead of the 1151 * Increment the comparator value until we are ahead of the
1145 * current count. 1152 * current count.
1146 */ 1153 */
1147 do { 1154 do {
1148 hpet_t1_cmp += delta; 1155 hpet_t1_cmp += delta;
1149 hpet_writel(hpet_t1_cmp, HPET_T1_CMP); 1156 hpet_writel(hpet_t1_cmp, HPET_T1_CMP);
1150 lost_ints++; 1157 lost_ints++;
1151 } while (!hpet_cnt_ahead(hpet_t1_cmp, hpet_readl(HPET_COUNTER))); 1158 } while (!hpet_cnt_ahead(hpet_t1_cmp, hpet_readl(HPET_COUNTER)));
1152 1159
1153 if (lost_ints) { 1160 if (lost_ints) {
1154 if (hpet_rtc_flags & RTC_PIE) 1161 if (hpet_rtc_flags & RTC_PIE)
1155 hpet_pie_count += lost_ints; 1162 hpet_pie_count += lost_ints;
1156 if (printk_ratelimit()) 1163 if (printk_ratelimit())
1157 printk(KERN_WARNING "hpet1: lost %d rtc interrupts\n", 1164 printk(KERN_WARNING "hpet1: lost %d rtc interrupts\n",
1158 lost_ints); 1165 lost_ints);
1159 } 1166 }
1160 } 1167 }
1161 1168
1162 irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id) 1169 irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id)
1163 { 1170 {
1164 struct rtc_time curr_time; 1171 struct rtc_time curr_time;
1165 unsigned long rtc_int_flag = 0; 1172 unsigned long rtc_int_flag = 0;
1166 1173
1167 hpet_rtc_timer_reinit(); 1174 hpet_rtc_timer_reinit();
1168 memset(&curr_time, 0, sizeof(struct rtc_time)); 1175 memset(&curr_time, 0, sizeof(struct rtc_time));
1169 1176
1170 if (hpet_rtc_flags & (RTC_UIE | RTC_AIE)) 1177 if (hpet_rtc_flags & (RTC_UIE | RTC_AIE))
1171 get_rtc_time(&curr_time); 1178 get_rtc_time(&curr_time);
1172 1179
1173 if (hpet_rtc_flags & RTC_UIE && 1180 if (hpet_rtc_flags & RTC_UIE &&
1174 curr_time.tm_sec != hpet_prev_update_sec) { 1181 curr_time.tm_sec != hpet_prev_update_sec) {
1175 if (hpet_prev_update_sec >= 0) 1182 if (hpet_prev_update_sec >= 0)
1176 rtc_int_flag = RTC_UF; 1183 rtc_int_flag = RTC_UF;
1177 hpet_prev_update_sec = curr_time.tm_sec; 1184 hpet_prev_update_sec = curr_time.tm_sec;
1178 } 1185 }
1179 1186
1180 if (hpet_rtc_flags & RTC_PIE && 1187 if (hpet_rtc_flags & RTC_PIE &&
1181 ++hpet_pie_count >= hpet_pie_limit) { 1188 ++hpet_pie_count >= hpet_pie_limit) {
1182 rtc_int_flag |= RTC_PF; 1189 rtc_int_flag |= RTC_PF;
1183 hpet_pie_count = 0; 1190 hpet_pie_count = 0;
1184 } 1191 }
1185 1192
1186 if (hpet_rtc_flags & RTC_AIE && 1193 if (hpet_rtc_flags & RTC_AIE &&
1187 (curr_time.tm_sec == hpet_alarm_time.tm_sec) && 1194 (curr_time.tm_sec == hpet_alarm_time.tm_sec) &&
1188 (curr_time.tm_min == hpet_alarm_time.tm_min) && 1195 (curr_time.tm_min == hpet_alarm_time.tm_min) &&
1189 (curr_time.tm_hour == hpet_alarm_time.tm_hour)) 1196 (curr_time.tm_hour == hpet_alarm_time.tm_hour))
1190 rtc_int_flag |= RTC_AF; 1197 rtc_int_flag |= RTC_AF;
1191 1198
1192 if (rtc_int_flag) { 1199 if (rtc_int_flag) {
1193 rtc_int_flag |= (RTC_IRQF | (RTC_NUM_INTS << 8)); 1200 rtc_int_flag |= (RTC_IRQF | (RTC_NUM_INTS << 8));
1194 if (irq_handler) 1201 if (irq_handler)
1195 irq_handler(rtc_int_flag, dev_id); 1202 irq_handler(rtc_int_flag, dev_id);
1196 } 1203 }
1197 return IRQ_HANDLED; 1204 return IRQ_HANDLED;
arch/x86/kernel/setup.c
1 /* 1 /*
2 * Copyright (C) 1995 Linus Torvalds 2 * Copyright (C) 1995 Linus Torvalds
3 * 3 *
4 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999 4 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
5 * 5 *
6 * Memory region support 6 * Memory region support
7 * David Parsons <orc@pell.chi.il.us>, July-August 1999 7 * David Parsons <orc@pell.chi.il.us>, July-August 1999
8 * 8 *
9 * Added E820 sanitization routine (removes overlapping memory regions); 9 * Added E820 sanitization routine (removes overlapping memory regions);
10 * Brian Moyle <bmoyle@mvista.com>, February 2001 10 * Brian Moyle <bmoyle@mvista.com>, February 2001
11 * 11 *
12 * Moved CPU detection code to cpu/${cpu}.c 12 * Moved CPU detection code to cpu/${cpu}.c
13 * Patrick Mochel <mochel@osdl.org>, March 2002 13 * Patrick Mochel <mochel@osdl.org>, March 2002
14 * 14 *
15 * Provisions for empty E820 memory regions (reported by certain BIOSes). 15 * Provisions for empty E820 memory regions (reported by certain BIOSes).
16 * Alex Achenbach <xela@slit.de>, December 2002. 16 * Alex Achenbach <xela@slit.de>, December 2002.
17 * 17 *
18 */ 18 */
19 19
20 /* 20 /*
21 * This file handles the architecture-dependent parts of initialization 21 * This file handles the architecture-dependent parts of initialization
22 */ 22 */
23 23
24 #include <linux/sched.h> 24 #include <linux/sched.h>
25 #include <linux/mm.h> 25 #include <linux/mm.h>
26 #include <linux/mmzone.h> 26 #include <linux/mmzone.h>
27 #include <linux/screen_info.h> 27 #include <linux/screen_info.h>
28 #include <linux/ioport.h> 28 #include <linux/ioport.h>
29 #include <linux/acpi.h> 29 #include <linux/acpi.h>
30 #include <linux/sfi.h> 30 #include <linux/sfi.h>
31 #include <linux/apm_bios.h> 31 #include <linux/apm_bios.h>
32 #include <linux/initrd.h> 32 #include <linux/initrd.h>
33 #include <linux/bootmem.h> 33 #include <linux/bootmem.h>
34 #include <linux/memblock.h> 34 #include <linux/memblock.h>
35 #include <linux/seq_file.h> 35 #include <linux/seq_file.h>
36 #include <linux/console.h> 36 #include <linux/console.h>
37 #include <linux/mca.h> 37 #include <linux/mca.h>
38 #include <linux/root_dev.h> 38 #include <linux/root_dev.h>
39 #include <linux/highmem.h> 39 #include <linux/highmem.h>
40 #include <linux/module.h> 40 #include <linux/module.h>
41 #include <linux/efi.h> 41 #include <linux/efi.h>
42 #include <linux/init.h> 42 #include <linux/init.h>
43 #include <linux/edd.h> 43 #include <linux/edd.h>
44 #include <linux/iscsi_ibft.h> 44 #include <linux/iscsi_ibft.h>
45 #include <linux/nodemask.h> 45 #include <linux/nodemask.h>
46 #include <linux/kexec.h> 46 #include <linux/kexec.h>
47 #include <linux/dmi.h> 47 #include <linux/dmi.h>
48 #include <linux/pfn.h> 48 #include <linux/pfn.h>
49 #include <linux/pci.h> 49 #include <linux/pci.h>
50 #include <asm/pci-direct.h> 50 #include <asm/pci-direct.h>
51 #include <linux/init_ohci1394_dma.h> 51 #include <linux/init_ohci1394_dma.h>
52 #include <linux/kvm_para.h> 52 #include <linux/kvm_para.h>
53 53
54 #include <linux/errno.h> 54 #include <linux/errno.h>
55 #include <linux/kernel.h> 55 #include <linux/kernel.h>
56 #include <linux/stddef.h> 56 #include <linux/stddef.h>
57 #include <linux/unistd.h> 57 #include <linux/unistd.h>
58 #include <linux/ptrace.h> 58 #include <linux/ptrace.h>
59 #include <linux/user.h> 59 #include <linux/user.h>
60 #include <linux/delay.h> 60 #include <linux/delay.h>
61 61
62 #include <linux/kallsyms.h> 62 #include <linux/kallsyms.h>
63 #include <linux/cpufreq.h> 63 #include <linux/cpufreq.h>
64 #include <linux/dma-mapping.h> 64 #include <linux/dma-mapping.h>
65 #include <linux/ctype.h> 65 #include <linux/ctype.h>
66 #include <linux/uaccess.h> 66 #include <linux/uaccess.h>
67 67
68 #include <linux/percpu.h> 68 #include <linux/percpu.h>
69 #include <linux/crash_dump.h> 69 #include <linux/crash_dump.h>
70 #include <linux/tboot.h> 70 #include <linux/tboot.h>
71 71
72 #include <video/edid.h> 72 #include <video/edid.h>
73 73
74 #include <asm/mtrr.h> 74 #include <asm/mtrr.h>
75 #include <asm/apic.h> 75 #include <asm/apic.h>
76 #include <asm/trampoline.h> 76 #include <asm/trampoline.h>
77 #include <asm/e820.h> 77 #include <asm/e820.h>
78 #include <asm/mpspec.h> 78 #include <asm/mpspec.h>
79 #include <asm/setup.h> 79 #include <asm/setup.h>
80 #include <asm/efi.h> 80 #include <asm/efi.h>
81 #include <asm/timer.h> 81 #include <asm/timer.h>
82 #include <asm/i8259.h> 82 #include <asm/i8259.h>
83 #include <asm/sections.h> 83 #include <asm/sections.h>
84 #include <asm/dmi.h> 84 #include <asm/dmi.h>
85 #include <asm/io_apic.h> 85 #include <asm/io_apic.h>
86 #include <asm/ist.h> 86 #include <asm/ist.h>
87 #include <asm/setup_arch.h> 87 #include <asm/setup_arch.h>
88 #include <asm/bios_ebda.h> 88 #include <asm/bios_ebda.h>
89 #include <asm/cacheflush.h> 89 #include <asm/cacheflush.h>
90 #include <asm/processor.h> 90 #include <asm/processor.h>
91 #include <asm/bugs.h> 91 #include <asm/bugs.h>
92 92
93 #include <asm/system.h> 93 #include <asm/system.h>
94 #include <asm/vsyscall.h> 94 #include <asm/vsyscall.h>
95 #include <asm/cpu.h> 95 #include <asm/cpu.h>
96 #include <asm/desc.h> 96 #include <asm/desc.h>
97 #include <asm/dma.h> 97 #include <asm/dma.h>
98 #include <asm/iommu.h> 98 #include <asm/iommu.h>
99 #include <asm/gart.h> 99 #include <asm/gart.h>
100 #include <asm/mmu_context.h> 100 #include <asm/mmu_context.h>
101 #include <asm/proto.h> 101 #include <asm/proto.h>
102 102
103 #include <asm/paravirt.h> 103 #include <asm/paravirt.h>
104 #include <asm/hypervisor.h> 104 #include <asm/hypervisor.h>
105 #include <asm/olpc_ofw.h> 105 #include <asm/olpc_ofw.h>
106 106
107 #include <asm/percpu.h> 107 #include <asm/percpu.h>
108 #include <asm/topology.h> 108 #include <asm/topology.h>
109 #include <asm/apicdef.h> 109 #include <asm/apicdef.h>
110 #include <asm/amd_nb.h> 110 #include <asm/amd_nb.h>
111 #ifdef CONFIG_X86_64 111 #ifdef CONFIG_X86_64
112 #include <asm/numa_64.h> 112 #include <asm/numa_64.h>
113 #endif 113 #endif
114 #include <asm/mce.h> 114 #include <asm/mce.h>
115 #include <asm/alternative.h> 115 #include <asm/alternative.h>
116 #include <asm/prom.h> 116 #include <asm/prom.h>
117 117
118 /* 118 /*
119 * end_pfn only includes RAM, while max_pfn_mapped includes all e820 entries. 119 * end_pfn only includes RAM, while max_pfn_mapped includes all e820 entries.
120 * The direct mapping extends to max_pfn_mapped, so that we can directly access 120 * The direct mapping extends to max_pfn_mapped, so that we can directly access
121 * apertures, ACPI and other tables without having to play with fixmaps. 121 * apertures, ACPI and other tables without having to play with fixmaps.
122 */ 122 */
123 unsigned long max_low_pfn_mapped; 123 unsigned long max_low_pfn_mapped;
124 unsigned long max_pfn_mapped; 124 unsigned long max_pfn_mapped;
125 125
126 #ifdef CONFIG_DMI 126 #ifdef CONFIG_DMI
127 RESERVE_BRK(dmi_alloc, 65536); 127 RESERVE_BRK(dmi_alloc, 65536);
128 #endif 128 #endif
129 129
130 130
131 static __initdata unsigned long _brk_start = (unsigned long)__brk_base; 131 static __initdata unsigned long _brk_start = (unsigned long)__brk_base;
132 unsigned long _brk_end = (unsigned long)__brk_base; 132 unsigned long _brk_end = (unsigned long)__brk_base;
133 133
134 #ifdef CONFIG_X86_64 134 #ifdef CONFIG_X86_64
135 int default_cpu_present_to_apicid(int mps_cpu) 135 int default_cpu_present_to_apicid(int mps_cpu)
136 { 136 {
137 return __default_cpu_present_to_apicid(mps_cpu); 137 return __default_cpu_present_to_apicid(mps_cpu);
138 } 138 }
139 139
140 int default_check_phys_apicid_present(int phys_apicid) 140 int default_check_phys_apicid_present(int phys_apicid)
141 { 141 {
142 return __default_check_phys_apicid_present(phys_apicid); 142 return __default_check_phys_apicid_present(phys_apicid);
143 } 143 }
144 #endif 144 #endif
145 145
146 #ifndef CONFIG_DEBUG_BOOT_PARAMS 146 #ifndef CONFIG_DEBUG_BOOT_PARAMS
147 struct boot_params __initdata boot_params; 147 struct boot_params __initdata boot_params;
148 #else 148 #else
149 struct boot_params boot_params; 149 struct boot_params boot_params;
150 #endif 150 #endif
151 151
152 /* 152 /*
153 * Machine setup.. 153 * Machine setup..
154 */ 154 */
155 static struct resource data_resource = { 155 static struct resource data_resource = {
156 .name = "Kernel data", 156 .name = "Kernel data",
157 .start = 0, 157 .start = 0,
158 .end = 0, 158 .end = 0,
159 .flags = IORESOURCE_BUSY | IORESOURCE_MEM 159 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
160 }; 160 };
161 161
162 static struct resource code_resource = { 162 static struct resource code_resource = {
163 .name = "Kernel code", 163 .name = "Kernel code",
164 .start = 0, 164 .start = 0,
165 .end = 0, 165 .end = 0,
166 .flags = IORESOURCE_BUSY | IORESOURCE_MEM 166 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
167 }; 167 };
168 168
169 static struct resource bss_resource = { 169 static struct resource bss_resource = {
170 .name = "Kernel bss", 170 .name = "Kernel bss",
171 .start = 0, 171 .start = 0,
172 .end = 0, 172 .end = 0,
173 .flags = IORESOURCE_BUSY | IORESOURCE_MEM 173 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
174 }; 174 };
175 175
176 176
177 #ifdef CONFIG_X86_32 177 #ifdef CONFIG_X86_32
178 /* cpu data as detected by the assembly code in head.S */ 178 /* cpu data as detected by the assembly code in head.S */
179 struct cpuinfo_x86 new_cpu_data __cpuinitdata = {0, 0, 0, 0, -1, 1, 0, 0, -1}; 179 struct cpuinfo_x86 new_cpu_data __cpuinitdata = {0, 0, 0, 0, -1, 1, 0, 0, -1};
180 /* common cpu data for all cpus */ 180 /* common cpu data for all cpus */
181 struct cpuinfo_x86 boot_cpu_data __read_mostly = {0, 0, 0, 0, -1, 1, 0, 0, -1}; 181 struct cpuinfo_x86 boot_cpu_data __read_mostly = {0, 0, 0, 0, -1, 1, 0, 0, -1};
182 EXPORT_SYMBOL(boot_cpu_data); 182 EXPORT_SYMBOL(boot_cpu_data);
183 static void set_mca_bus(int x) 183 static void set_mca_bus(int x)
184 { 184 {
185 #ifdef CONFIG_MCA 185 #ifdef CONFIG_MCA
186 MCA_bus = x; 186 MCA_bus = x;
187 #endif 187 #endif
188 } 188 }
189 189
190 unsigned int def_to_bigsmp; 190 unsigned int def_to_bigsmp;
191 191
192 /* for MCA, but anyone else can use it if they want */ 192 /* for MCA, but anyone else can use it if they want */
193 unsigned int machine_id; 193 unsigned int machine_id;
194 unsigned int machine_submodel_id; 194 unsigned int machine_submodel_id;
195 unsigned int BIOS_revision; 195 unsigned int BIOS_revision;
196 196
197 struct apm_info apm_info; 197 struct apm_info apm_info;
198 EXPORT_SYMBOL(apm_info); 198 EXPORT_SYMBOL(apm_info);
199 199
200 #if defined(CONFIG_X86_SPEEDSTEP_SMI) || \ 200 #if defined(CONFIG_X86_SPEEDSTEP_SMI) || \
201 defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE) 201 defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
202 struct ist_info ist_info; 202 struct ist_info ist_info;
203 EXPORT_SYMBOL(ist_info); 203 EXPORT_SYMBOL(ist_info);
204 #else 204 #else
205 struct ist_info ist_info; 205 struct ist_info ist_info;
206 #endif 206 #endif
207 207
208 #else 208 #else
209 struct cpuinfo_x86 boot_cpu_data __read_mostly = { 209 struct cpuinfo_x86 boot_cpu_data __read_mostly = {
210 .x86_phys_bits = MAX_PHYSMEM_BITS, 210 .x86_phys_bits = MAX_PHYSMEM_BITS,
211 }; 211 };
212 EXPORT_SYMBOL(boot_cpu_data); 212 EXPORT_SYMBOL(boot_cpu_data);
213 #endif 213 #endif
214 214
215 215
216 #if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64) 216 #if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
217 unsigned long mmu_cr4_features; 217 unsigned long mmu_cr4_features;
218 #else 218 #else
219 unsigned long mmu_cr4_features = X86_CR4_PAE; 219 unsigned long mmu_cr4_features = X86_CR4_PAE;
220 #endif 220 #endif
221 221
222 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */ 222 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
223 int bootloader_type, bootloader_version; 223 int bootloader_type, bootloader_version;
224 224
225 /* 225 /*
226 * Setup options 226 * Setup options
227 */ 227 */
228 struct screen_info screen_info; 228 struct screen_info screen_info;
229 EXPORT_SYMBOL(screen_info); 229 EXPORT_SYMBOL(screen_info);
230 struct edid_info edid_info; 230 struct edid_info edid_info;
231 EXPORT_SYMBOL_GPL(edid_info); 231 EXPORT_SYMBOL_GPL(edid_info);
232 232
233 extern int root_mountflags; 233 extern int root_mountflags;
234 234
235 unsigned long saved_video_mode; 235 unsigned long saved_video_mode;
236 236
237 #define RAMDISK_IMAGE_START_MASK 0x07FF 237 #define RAMDISK_IMAGE_START_MASK 0x07FF
238 #define RAMDISK_PROMPT_FLAG 0x8000 238 #define RAMDISK_PROMPT_FLAG 0x8000
239 #define RAMDISK_LOAD_FLAG 0x4000 239 #define RAMDISK_LOAD_FLAG 0x4000
240 240
241 static char __initdata command_line[COMMAND_LINE_SIZE]; 241 static char __initdata command_line[COMMAND_LINE_SIZE];
242 #ifdef CONFIG_CMDLINE_BOOL 242 #ifdef CONFIG_CMDLINE_BOOL
243 static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE; 243 static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
244 #endif 244 #endif
245 245
246 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE) 246 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
247 struct edd edd; 247 struct edd edd;
248 #ifdef CONFIG_EDD_MODULE 248 #ifdef CONFIG_EDD_MODULE
249 EXPORT_SYMBOL(edd); 249 EXPORT_SYMBOL(edd);
250 #endif 250 #endif
251 /** 251 /**
252 * copy_edd() - Copy the BIOS EDD information 252 * copy_edd() - Copy the BIOS EDD information
253 * from boot_params into a safe place. 253 * from boot_params into a safe place.
254 * 254 *
255 */ 255 */
256 static inline void __init copy_edd(void) 256 static inline void __init copy_edd(void)
257 { 257 {
258 memcpy(edd.mbr_signature, boot_params.edd_mbr_sig_buffer, 258 memcpy(edd.mbr_signature, boot_params.edd_mbr_sig_buffer,
259 sizeof(edd.mbr_signature)); 259 sizeof(edd.mbr_signature));
260 memcpy(edd.edd_info, boot_params.eddbuf, sizeof(edd.edd_info)); 260 memcpy(edd.edd_info, boot_params.eddbuf, sizeof(edd.edd_info));
261 edd.mbr_signature_nr = boot_params.edd_mbr_sig_buf_entries; 261 edd.mbr_signature_nr = boot_params.edd_mbr_sig_buf_entries;
262 edd.edd_info_nr = boot_params.eddbuf_entries; 262 edd.edd_info_nr = boot_params.eddbuf_entries;
263 } 263 }
264 #else 264 #else
265 static inline void __init copy_edd(void) 265 static inline void __init copy_edd(void)
266 { 266 {
267 } 267 }
268 #endif 268 #endif
269 269
270 void * __init extend_brk(size_t size, size_t align) 270 void * __init extend_brk(size_t size, size_t align)
271 { 271 {
272 size_t mask = align - 1; 272 size_t mask = align - 1;
273 void *ret; 273 void *ret;
274 274
275 BUG_ON(_brk_start == 0); 275 BUG_ON(_brk_start == 0);
276 BUG_ON(align & mask); 276 BUG_ON(align & mask);
277 277
278 _brk_end = (_brk_end + mask) & ~mask; 278 _brk_end = (_brk_end + mask) & ~mask;
279 BUG_ON((char *)(_brk_end + size) > __brk_limit); 279 BUG_ON((char *)(_brk_end + size) > __brk_limit);
280 280
281 ret = (void *)_brk_end; 281 ret = (void *)_brk_end;
282 _brk_end += size; 282 _brk_end += size;
283 283
284 memset(ret, 0, size); 284 memset(ret, 0, size);
285 285
286 return ret; 286 return ret;
287 } 287 }
288 288
289 #ifdef CONFIG_X86_64 289 #ifdef CONFIG_X86_64
290 static void __init init_gbpages(void) 290 static void __init init_gbpages(void)
291 { 291 {
292 if (direct_gbpages && cpu_has_gbpages) 292 if (direct_gbpages && cpu_has_gbpages)
293 printk(KERN_INFO "Using GB pages for direct mapping\n"); 293 printk(KERN_INFO "Using GB pages for direct mapping\n");
294 else 294 else
295 direct_gbpages = 0; 295 direct_gbpages = 0;
296 } 296 }
297 #else 297 #else
298 static inline void init_gbpages(void) 298 static inline void init_gbpages(void)
299 { 299 {
300 } 300 }
301 static void __init cleanup_highmap(void) 301 static void __init cleanup_highmap(void)
302 { 302 {
303 } 303 }
304 #endif 304 #endif
305 305
306 static void __init reserve_brk(void) 306 static void __init reserve_brk(void)
307 { 307 {
308 if (_brk_end > _brk_start) 308 if (_brk_end > _brk_start)
309 memblock_x86_reserve_range(__pa(_brk_start), __pa(_brk_end), "BRK"); 309 memblock_x86_reserve_range(__pa(_brk_start), __pa(_brk_end), "BRK");
310 310
311 /* Mark brk area as locked down and no longer taking any 311 /* Mark brk area as locked down and no longer taking any
312 new allocations */ 312 new allocations */
313 _brk_start = 0; 313 _brk_start = 0;
314 } 314 }
315 315
316 #ifdef CONFIG_BLK_DEV_INITRD 316 #ifdef CONFIG_BLK_DEV_INITRD
317 317
318 #define MAX_MAP_CHUNK (NR_FIX_BTMAPS << PAGE_SHIFT) 318 #define MAX_MAP_CHUNK (NR_FIX_BTMAPS << PAGE_SHIFT)
319 static void __init relocate_initrd(void) 319 static void __init relocate_initrd(void)
320 { 320 {
321 /* Assume only end is not page aligned */ 321 /* Assume only end is not page aligned */
322 u64 ramdisk_image = boot_params.hdr.ramdisk_image; 322 u64 ramdisk_image = boot_params.hdr.ramdisk_image;
323 u64 ramdisk_size = boot_params.hdr.ramdisk_size; 323 u64 ramdisk_size = boot_params.hdr.ramdisk_size;
324 u64 area_size = PAGE_ALIGN(ramdisk_size); 324 u64 area_size = PAGE_ALIGN(ramdisk_size);
325 u64 end_of_lowmem = max_low_pfn_mapped << PAGE_SHIFT; 325 u64 end_of_lowmem = max_low_pfn_mapped << PAGE_SHIFT;
326 u64 ramdisk_here; 326 u64 ramdisk_here;
327 unsigned long slop, clen, mapaddr; 327 unsigned long slop, clen, mapaddr;
328 char *p, *q; 328 char *p, *q;
329 329
330 /* We need to move the initrd down into lowmem */ 330 /* We need to move the initrd down into lowmem */
331 ramdisk_here = memblock_find_in_range(0, end_of_lowmem, area_size, 331 ramdisk_here = memblock_find_in_range(0, end_of_lowmem, area_size,
332 PAGE_SIZE); 332 PAGE_SIZE);
333 333
334 if (ramdisk_here == MEMBLOCK_ERROR) 334 if (ramdisk_here == MEMBLOCK_ERROR)
335 panic("Cannot find place for new RAMDISK of size %lld\n", 335 panic("Cannot find place for new RAMDISK of size %lld\n",
336 ramdisk_size); 336 ramdisk_size);
337 337
338 /* Note: this includes all the lowmem currently occupied by 338 /* Note: this includes all the lowmem currently occupied by
339 the initrd, we rely on that fact to keep the data intact. */ 339 the initrd, we rely on that fact to keep the data intact. */
340 memblock_x86_reserve_range(ramdisk_here, ramdisk_here + area_size, "NEW RAMDISK"); 340 memblock_x86_reserve_range(ramdisk_here, ramdisk_here + area_size, "NEW RAMDISK");
341 initrd_start = ramdisk_here + PAGE_OFFSET; 341 initrd_start = ramdisk_here + PAGE_OFFSET;
342 initrd_end = initrd_start + ramdisk_size; 342 initrd_end = initrd_start + ramdisk_size;
343 printk(KERN_INFO "Allocated new RAMDISK: %08llx - %08llx\n", 343 printk(KERN_INFO "Allocated new RAMDISK: %08llx - %08llx\n",
344 ramdisk_here, ramdisk_here + ramdisk_size); 344 ramdisk_here, ramdisk_here + ramdisk_size);
345 345
346 q = (char *)initrd_start; 346 q = (char *)initrd_start;
347 347
348 /* Copy any lowmem portion of the initrd */ 348 /* Copy any lowmem portion of the initrd */
349 if (ramdisk_image < end_of_lowmem) { 349 if (ramdisk_image < end_of_lowmem) {
350 clen = end_of_lowmem - ramdisk_image; 350 clen = end_of_lowmem - ramdisk_image;
351 p = (char *)__va(ramdisk_image); 351 p = (char *)__va(ramdisk_image);
352 memcpy(q, p, clen); 352 memcpy(q, p, clen);
353 q += clen; 353 q += clen;
354 ramdisk_image += clen; 354 ramdisk_image += clen;
355 ramdisk_size -= clen; 355 ramdisk_size -= clen;
356 } 356 }
357 357
358 /* Copy the highmem portion of the initrd */ 358 /* Copy the highmem portion of the initrd */
359 while (ramdisk_size) { 359 while (ramdisk_size) {
360 slop = ramdisk_image & ~PAGE_MASK; 360 slop = ramdisk_image & ~PAGE_MASK;
361 clen = ramdisk_size; 361 clen = ramdisk_size;
362 if (clen > MAX_MAP_CHUNK-slop) 362 if (clen > MAX_MAP_CHUNK-slop)
363 clen = MAX_MAP_CHUNK-slop; 363 clen = MAX_MAP_CHUNK-slop;
364 mapaddr = ramdisk_image & PAGE_MASK; 364 mapaddr = ramdisk_image & PAGE_MASK;
365 p = early_memremap(mapaddr, clen+slop); 365 p = early_memremap(mapaddr, clen+slop);
366 memcpy(q, p+slop, clen); 366 memcpy(q, p+slop, clen);
367 early_iounmap(p, clen+slop); 367 early_iounmap(p, clen+slop);
368 q += clen; 368 q += clen;
369 ramdisk_image += clen; 369 ramdisk_image += clen;
370 ramdisk_size -= clen; 370 ramdisk_size -= clen;
371 } 371 }
372 /* high pages is not converted by early_res_to_bootmem */ 372 /* high pages is not converted by early_res_to_bootmem */
373 ramdisk_image = boot_params.hdr.ramdisk_image; 373 ramdisk_image = boot_params.hdr.ramdisk_image;
374 ramdisk_size = boot_params.hdr.ramdisk_size; 374 ramdisk_size = boot_params.hdr.ramdisk_size;
375 printk(KERN_INFO "Move RAMDISK from %016llx - %016llx to" 375 printk(KERN_INFO "Move RAMDISK from %016llx - %016llx to"
376 " %08llx - %08llx\n", 376 " %08llx - %08llx\n",
377 ramdisk_image, ramdisk_image + ramdisk_size - 1, 377 ramdisk_image, ramdisk_image + ramdisk_size - 1,
378 ramdisk_here, ramdisk_here + ramdisk_size - 1); 378 ramdisk_here, ramdisk_here + ramdisk_size - 1);
379 } 379 }
380 380
381 static void __init reserve_initrd(void) 381 static void __init reserve_initrd(void)
382 { 382 {
383 /* Assume only end is not page aligned */ 383 /* Assume only end is not page aligned */
384 u64 ramdisk_image = boot_params.hdr.ramdisk_image; 384 u64 ramdisk_image = boot_params.hdr.ramdisk_image;
385 u64 ramdisk_size = boot_params.hdr.ramdisk_size; 385 u64 ramdisk_size = boot_params.hdr.ramdisk_size;
386 u64 ramdisk_end = PAGE_ALIGN(ramdisk_image + ramdisk_size); 386 u64 ramdisk_end = PAGE_ALIGN(ramdisk_image + ramdisk_size);
387 u64 end_of_lowmem = max_low_pfn_mapped << PAGE_SHIFT; 387 u64 end_of_lowmem = max_low_pfn_mapped << PAGE_SHIFT;
388 388
389 if (!boot_params.hdr.type_of_loader || 389 if (!boot_params.hdr.type_of_loader ||
390 !ramdisk_image || !ramdisk_size) 390 !ramdisk_image || !ramdisk_size)
391 return; /* No initrd provided by bootloader */ 391 return; /* No initrd provided by bootloader */
392 392
393 initrd_start = 0; 393 initrd_start = 0;
394 394
395 if (ramdisk_size >= (end_of_lowmem>>1)) { 395 if (ramdisk_size >= (end_of_lowmem>>1)) {
396 memblock_x86_free_range(ramdisk_image, ramdisk_end); 396 memblock_x86_free_range(ramdisk_image, ramdisk_end);
397 printk(KERN_ERR "initrd too large to handle, " 397 printk(KERN_ERR "initrd too large to handle, "
398 "disabling initrd\n"); 398 "disabling initrd\n");
399 return; 399 return;
400 } 400 }
401 401
402 printk(KERN_INFO "RAMDISK: %08llx - %08llx\n", ramdisk_image, 402 printk(KERN_INFO "RAMDISK: %08llx - %08llx\n", ramdisk_image,
403 ramdisk_end); 403 ramdisk_end);
404 404
405 405
406 if (ramdisk_end <= end_of_lowmem) { 406 if (ramdisk_end <= end_of_lowmem) {
407 /* All in lowmem, easy case */ 407 /* All in lowmem, easy case */
408 /* 408 /*
409 * don't need to reserve again, already reserved early 409 * don't need to reserve again, already reserved early
410 * in i386_start_kernel 410 * in i386_start_kernel
411 */ 411 */
412 initrd_start = ramdisk_image + PAGE_OFFSET; 412 initrd_start = ramdisk_image + PAGE_OFFSET;
413 initrd_end = initrd_start + ramdisk_size; 413 initrd_end = initrd_start + ramdisk_size;
414 return; 414 return;
415 } 415 }
416 416
417 relocate_initrd(); 417 relocate_initrd();
418 418
419 memblock_x86_free_range(ramdisk_image, ramdisk_end); 419 memblock_x86_free_range(ramdisk_image, ramdisk_end);
420 } 420 }
421 #else 421 #else
422 static void __init reserve_initrd(void) 422 static void __init reserve_initrd(void)
423 { 423 {
424 } 424 }
425 #endif /* CONFIG_BLK_DEV_INITRD */ 425 #endif /* CONFIG_BLK_DEV_INITRD */
426 426
427 static void __init parse_setup_data(void) 427 static void __init parse_setup_data(void)
428 { 428 {
429 struct setup_data *data; 429 struct setup_data *data;
430 u64 pa_data; 430 u64 pa_data;
431 431
432 if (boot_params.hdr.version < 0x0209) 432 if (boot_params.hdr.version < 0x0209)
433 return; 433 return;
434 pa_data = boot_params.hdr.setup_data; 434 pa_data = boot_params.hdr.setup_data;
435 while (pa_data) { 435 while (pa_data) {
436 u32 data_len, map_len; 436 u32 data_len, map_len;
437 437
438 map_len = max(PAGE_SIZE - (pa_data & ~PAGE_MASK), 438 map_len = max(PAGE_SIZE - (pa_data & ~PAGE_MASK),
439 (u64)sizeof(struct setup_data)); 439 (u64)sizeof(struct setup_data));
440 data = early_memremap(pa_data, map_len); 440 data = early_memremap(pa_data, map_len);
441 data_len = data->len + sizeof(struct setup_data); 441 data_len = data->len + sizeof(struct setup_data);
442 if (data_len > map_len) { 442 if (data_len > map_len) {
443 early_iounmap(data, map_len); 443 early_iounmap(data, map_len);
444 data = early_memremap(pa_data, data_len); 444 data = early_memremap(pa_data, data_len);
445 map_len = data_len; 445 map_len = data_len;
446 } 446 }
447 447
448 switch (data->type) { 448 switch (data->type) {
449 case SETUP_E820_EXT: 449 case SETUP_E820_EXT:
450 parse_e820_ext(data); 450 parse_e820_ext(data);
451 break; 451 break;
452 case SETUP_DTB: 452 case SETUP_DTB:
453 add_dtb(pa_data); 453 add_dtb(pa_data);
454 break; 454 break;
455 default: 455 default:
456 break; 456 break;
457 } 457 }
458 pa_data = data->next; 458 pa_data = data->next;
459 early_iounmap(data, map_len); 459 early_iounmap(data, map_len);
460 } 460 }
461 } 461 }
462 462
463 static void __init e820_reserve_setup_data(void) 463 static void __init e820_reserve_setup_data(void)
464 { 464 {
465 struct setup_data *data; 465 struct setup_data *data;
466 u64 pa_data; 466 u64 pa_data;
467 int found = 0; 467 int found = 0;
468 468
469 if (boot_params.hdr.version < 0x0209) 469 if (boot_params.hdr.version < 0x0209)
470 return; 470 return;
471 pa_data = boot_params.hdr.setup_data; 471 pa_data = boot_params.hdr.setup_data;
472 while (pa_data) { 472 while (pa_data) {
473 data = early_memremap(pa_data, sizeof(*data)); 473 data = early_memremap(pa_data, sizeof(*data));
474 e820_update_range(pa_data, sizeof(*data)+data->len, 474 e820_update_range(pa_data, sizeof(*data)+data->len,
475 E820_RAM, E820_RESERVED_KERN); 475 E820_RAM, E820_RESERVED_KERN);
476 found = 1; 476 found = 1;
477 pa_data = data->next; 477 pa_data = data->next;
478 early_iounmap(data, sizeof(*data)); 478 early_iounmap(data, sizeof(*data));
479 } 479 }
480 if (!found) 480 if (!found)
481 return; 481 return;
482 482
483 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); 483 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
484 memcpy(&e820_saved, &e820, sizeof(struct e820map)); 484 memcpy(&e820_saved, &e820, sizeof(struct e820map));
485 printk(KERN_INFO "extended physical RAM map:\n"); 485 printk(KERN_INFO "extended physical RAM map:\n");
486 e820_print_map("reserve setup_data"); 486 e820_print_map("reserve setup_data");
487 } 487 }
488 488
489 static void __init memblock_x86_reserve_range_setup_data(void) 489 static void __init memblock_x86_reserve_range_setup_data(void)
490 { 490 {
491 struct setup_data *data; 491 struct setup_data *data;
492 u64 pa_data; 492 u64 pa_data;
493 char buf[32]; 493 char buf[32];
494 494
495 if (boot_params.hdr.version < 0x0209) 495 if (boot_params.hdr.version < 0x0209)
496 return; 496 return;
497 pa_data = boot_params.hdr.setup_data; 497 pa_data = boot_params.hdr.setup_data;
498 while (pa_data) { 498 while (pa_data) {
499 data = early_memremap(pa_data, sizeof(*data)); 499 data = early_memremap(pa_data, sizeof(*data));
500 sprintf(buf, "setup data %x", data->type); 500 sprintf(buf, "setup data %x", data->type);
501 memblock_x86_reserve_range(pa_data, pa_data+sizeof(*data)+data->len, buf); 501 memblock_x86_reserve_range(pa_data, pa_data+sizeof(*data)+data->len, buf);
502 pa_data = data->next; 502 pa_data = data->next;
503 early_iounmap(data, sizeof(*data)); 503 early_iounmap(data, sizeof(*data));
504 } 504 }
505 } 505 }
506 506
507 /* 507 /*
508 * --------- Crashkernel reservation ------------------------------ 508 * --------- Crashkernel reservation ------------------------------
509 */ 509 */
510 510
511 #ifdef CONFIG_KEXEC 511 #ifdef CONFIG_KEXEC
512 512
513 static inline unsigned long long get_total_mem(void) 513 static inline unsigned long long get_total_mem(void)
514 { 514 {
515 unsigned long long total; 515 unsigned long long total;
516 516
517 total = max_pfn - min_low_pfn; 517 total = max_pfn - min_low_pfn;
518 518
519 return total << PAGE_SHIFT; 519 return total << PAGE_SHIFT;
520 } 520 }
521 521
522 /* 522 /*
523 * Keep the crash kernel below this limit. On 32 bits earlier kernels 523 * Keep the crash kernel below this limit. On 32 bits earlier kernels
524 * would limit the kernel to the low 512 MiB due to mapping restrictions. 524 * would limit the kernel to the low 512 MiB due to mapping restrictions.
525 * On 64 bits, kexec-tools currently limits us to 896 MiB; increase this 525 * On 64 bits, kexec-tools currently limits us to 896 MiB; increase this
526 * limit once kexec-tools are fixed. 526 * limit once kexec-tools are fixed.
527 */ 527 */
528 #ifdef CONFIG_X86_32 528 #ifdef CONFIG_X86_32
529 # define CRASH_KERNEL_ADDR_MAX (512 << 20) 529 # define CRASH_KERNEL_ADDR_MAX (512 << 20)
530 #else 530 #else
531 # define CRASH_KERNEL_ADDR_MAX (896 << 20) 531 # define CRASH_KERNEL_ADDR_MAX (896 << 20)
532 #endif 532 #endif
533 533
534 static void __init reserve_crashkernel(void) 534 static void __init reserve_crashkernel(void)
535 { 535 {
536 unsigned long long total_mem; 536 unsigned long long total_mem;
537 unsigned long long crash_size, crash_base; 537 unsigned long long crash_size, crash_base;
538 int ret; 538 int ret;
539 539
540 total_mem = get_total_mem(); 540 total_mem = get_total_mem();
541 541
542 ret = parse_crashkernel(boot_command_line, total_mem, 542 ret = parse_crashkernel(boot_command_line, total_mem,
543 &crash_size, &crash_base); 543 &crash_size, &crash_base);
544 if (ret != 0 || crash_size <= 0) 544 if (ret != 0 || crash_size <= 0)
545 return; 545 return;
546 546
547 /* 0 means: find the address automatically */ 547 /* 0 means: find the address automatically */
548 if (crash_base <= 0) { 548 if (crash_base <= 0) {
549 const unsigned long long alignment = 16<<20; /* 16M */ 549 const unsigned long long alignment = 16<<20; /* 16M */
550 550
551 /* 551 /*
552 * kexec want bzImage is below CRASH_KERNEL_ADDR_MAX 552 * kexec want bzImage is below CRASH_KERNEL_ADDR_MAX
553 */ 553 */
554 crash_base = memblock_find_in_range(alignment, 554 crash_base = memblock_find_in_range(alignment,
555 CRASH_KERNEL_ADDR_MAX, crash_size, alignment); 555 CRASH_KERNEL_ADDR_MAX, crash_size, alignment);
556 556
557 if (crash_base == MEMBLOCK_ERROR) { 557 if (crash_base == MEMBLOCK_ERROR) {
558 pr_info("crashkernel reservation failed - No suitable area found.\n"); 558 pr_info("crashkernel reservation failed - No suitable area found.\n");
559 return; 559 return;
560 } 560 }
561 } else { 561 } else {
562 unsigned long long start; 562 unsigned long long start;
563 563
564 start = memblock_find_in_range(crash_base, 564 start = memblock_find_in_range(crash_base,
565 crash_base + crash_size, crash_size, 1<<20); 565 crash_base + crash_size, crash_size, 1<<20);
566 if (start != crash_base) { 566 if (start != crash_base) {
567 pr_info("crashkernel reservation failed - memory is in use.\n"); 567 pr_info("crashkernel reservation failed - memory is in use.\n");
568 return; 568 return;
569 } 569 }
570 } 570 }
571 memblock_x86_reserve_range(crash_base, crash_base + crash_size, "CRASH KERNEL"); 571 memblock_x86_reserve_range(crash_base, crash_base + crash_size, "CRASH KERNEL");
572 572
573 printk(KERN_INFO "Reserving %ldMB of memory at %ldMB " 573 printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
574 "for crashkernel (System RAM: %ldMB)\n", 574 "for crashkernel (System RAM: %ldMB)\n",
575 (unsigned long)(crash_size >> 20), 575 (unsigned long)(crash_size >> 20),
576 (unsigned long)(crash_base >> 20), 576 (unsigned long)(crash_base >> 20),
577 (unsigned long)(total_mem >> 20)); 577 (unsigned long)(total_mem >> 20));
578 578
579 crashk_res.start = crash_base; 579 crashk_res.start = crash_base;
580 crashk_res.end = crash_base + crash_size - 1; 580 crashk_res.end = crash_base + crash_size - 1;
581 insert_resource(&iomem_resource, &crashk_res); 581 insert_resource(&iomem_resource, &crashk_res);
582 } 582 }
583 #else 583 #else
584 static void __init reserve_crashkernel(void) 584 static void __init reserve_crashkernel(void)
585 { 585 {
586 } 586 }
587 #endif 587 #endif
588 588
589 static struct resource standard_io_resources[] = { 589 static struct resource standard_io_resources[] = {
590 { .name = "dma1", .start = 0x00, .end = 0x1f, 590 { .name = "dma1", .start = 0x00, .end = 0x1f,
591 .flags = IORESOURCE_BUSY | IORESOURCE_IO }, 591 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
592 { .name = "pic1", .start = 0x20, .end = 0x21, 592 { .name = "pic1", .start = 0x20, .end = 0x21,
593 .flags = IORESOURCE_BUSY | IORESOURCE_IO }, 593 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
594 { .name = "timer0", .start = 0x40, .end = 0x43, 594 { .name = "timer0", .start = 0x40, .end = 0x43,
595 .flags = IORESOURCE_BUSY | IORESOURCE_IO }, 595 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
596 { .name = "timer1", .start = 0x50, .end = 0x53, 596 { .name = "timer1", .start = 0x50, .end = 0x53,
597 .flags = IORESOURCE_BUSY | IORESOURCE_IO }, 597 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
598 { .name = "keyboard", .start = 0x60, .end = 0x60, 598 { .name = "keyboard", .start = 0x60, .end = 0x60,
599 .flags = IORESOURCE_BUSY | IORESOURCE_IO }, 599 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
600 { .name = "keyboard", .start = 0x64, .end = 0x64, 600 { .name = "keyboard", .start = 0x64, .end = 0x64,
601 .flags = IORESOURCE_BUSY | IORESOURCE_IO }, 601 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
602 { .name = "dma page reg", .start = 0x80, .end = 0x8f, 602 { .name = "dma page reg", .start = 0x80, .end = 0x8f,
603 .flags = IORESOURCE_BUSY | IORESOURCE_IO }, 603 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
604 { .name = "pic2", .start = 0xa0, .end = 0xa1, 604 { .name = "pic2", .start = 0xa0, .end = 0xa1,
605 .flags = IORESOURCE_BUSY | IORESOURCE_IO }, 605 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
606 { .name = "dma2", .start = 0xc0, .end = 0xdf, 606 { .name = "dma2", .start = 0xc0, .end = 0xdf,
607 .flags = IORESOURCE_BUSY | IORESOURCE_IO }, 607 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
608 { .name = "fpu", .start = 0xf0, .end = 0xff, 608 { .name = "fpu", .start = 0xf0, .end = 0xff,
609 .flags = IORESOURCE_BUSY | IORESOURCE_IO } 609 .flags = IORESOURCE_BUSY | IORESOURCE_IO }
610 }; 610 };
611 611
612 void __init reserve_standard_io_resources(void) 612 void __init reserve_standard_io_resources(void)
613 { 613 {
614 int i; 614 int i;
615 615
616 /* request I/O space for devices used on all i[345]86 PCs */ 616 /* request I/O space for devices used on all i[345]86 PCs */
617 for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++) 617 for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++)
618 request_resource(&ioport_resource, &standard_io_resources[i]); 618 request_resource(&ioport_resource, &standard_io_resources[i]);
619 619
620 } 620 }
621 621
622 static __init void reserve_ibft_region(void) 622 static __init void reserve_ibft_region(void)
623 { 623 {
624 unsigned long addr, size = 0; 624 unsigned long addr, size = 0;
625 625
626 addr = find_ibft_region(&size); 626 addr = find_ibft_region(&size);
627 627
628 if (size) 628 if (size)
629 memblock_x86_reserve_range(addr, addr + size, "* ibft"); 629 memblock_x86_reserve_range(addr, addr + size, "* ibft");
630 } 630 }
631 631
632 static unsigned reserve_low = CONFIG_X86_RESERVE_LOW << 10; 632 static unsigned reserve_low = CONFIG_X86_RESERVE_LOW << 10;
633 633
634 static void __init trim_bios_range(void) 634 static void __init trim_bios_range(void)
635 { 635 {
636 /* 636 /*
637 * A special case is the first 4Kb of memory; 637 * A special case is the first 4Kb of memory;
638 * This is a BIOS owned area, not kernel ram, but generally 638 * This is a BIOS owned area, not kernel ram, but generally
639 * not listed as such in the E820 table. 639 * not listed as such in the E820 table.
640 * 640 *
641 * This typically reserves additional memory (64KiB by default) 641 * This typically reserves additional memory (64KiB by default)
642 * since some BIOSes are known to corrupt low memory. See the 642 * since some BIOSes are known to corrupt low memory. See the
643 * Kconfig help text for X86_RESERVE_LOW. 643 * Kconfig help text for X86_RESERVE_LOW.
644 */ 644 */
645 e820_update_range(0, ALIGN(reserve_low, PAGE_SIZE), 645 e820_update_range(0, ALIGN(reserve_low, PAGE_SIZE),
646 E820_RAM, E820_RESERVED); 646 E820_RAM, E820_RESERVED);
647 647
648 /* 648 /*
649 * special case: Some BIOSen report the PC BIOS 649 * special case: Some BIOSen report the PC BIOS
650 * area (640->1Mb) as ram even though it is not. 650 * area (640->1Mb) as ram even though it is not.
651 * take them out. 651 * take them out.
652 */ 652 */
653 e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1); 653 e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
654 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); 654 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
655 } 655 }
656 656
657 static int __init parse_reservelow(char *p) 657 static int __init parse_reservelow(char *p)
658 { 658 {
659 unsigned long long size; 659 unsigned long long size;
660 660
661 if (!p) 661 if (!p)
662 return -EINVAL; 662 return -EINVAL;
663 663
664 size = memparse(p, &p); 664 size = memparse(p, &p);
665 665
666 if (size < 4096) 666 if (size < 4096)
667 size = 4096; 667 size = 4096;
668 668
669 if (size > 640*1024) 669 if (size > 640*1024)
670 size = 640*1024; 670 size = 640*1024;
671 671
672 reserve_low = size; 672 reserve_low = size;
673 673
674 return 0; 674 return 0;
675 } 675 }
676 676
677 early_param("reservelow", parse_reservelow); 677 early_param("reservelow", parse_reservelow);
678 678
679 /* 679 /*
680 * Determine if we were loaded by an EFI loader. If so, then we have also been 680 * Determine if we were loaded by an EFI loader. If so, then we have also been
681 * passed the efi memmap, systab, etc., so we should use these data structures 681 * passed the efi memmap, systab, etc., so we should use these data structures
682 * for initialization. Note, the efi init code path is determined by the 682 * for initialization. Note, the efi init code path is determined by the
683 * global efi_enabled. This allows the same kernel image to be used on existing 683 * global efi_enabled. This allows the same kernel image to be used on existing
684 * systems (with a traditional BIOS) as well as on EFI systems. 684 * systems (with a traditional BIOS) as well as on EFI systems.
685 */ 685 */
686 /* 686 /*
687 * setup_arch - architecture-specific boot-time initializations 687 * setup_arch - architecture-specific boot-time initializations
688 * 688 *
689 * Note: On x86_64, fixmaps are ready for use even before this is called. 689 * Note: On x86_64, fixmaps are ready for use even before this is called.
690 */ 690 */
691 691
692 void __init setup_arch(char **cmdline_p) 692 void __init setup_arch(char **cmdline_p)
693 { 693 {
694 unsigned long end_pfn;
695
694 #ifdef CONFIG_X86_32 696 #ifdef CONFIG_X86_32
695 memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data)); 697 memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
696 visws_early_detect(); 698 visws_early_detect();
697 699
698 /* 700 /*
699 * copy kernel address range established so far and switch 701 * copy kernel address range established so far and switch
700 * to the proper swapper page table 702 * to the proper swapper page table
701 */ 703 */
702 clone_pgd_range(swapper_pg_dir + KERNEL_PGD_BOUNDARY, 704 clone_pgd_range(swapper_pg_dir + KERNEL_PGD_BOUNDARY,
703 initial_page_table + KERNEL_PGD_BOUNDARY, 705 initial_page_table + KERNEL_PGD_BOUNDARY,
704 KERNEL_PGD_PTRS); 706 KERNEL_PGD_PTRS);
705 707
706 load_cr3(swapper_pg_dir); 708 load_cr3(swapper_pg_dir);
707 __flush_tlb_all(); 709 __flush_tlb_all();
708 #else 710 #else
709 printk(KERN_INFO "Command line: %s\n", boot_command_line); 711 printk(KERN_INFO "Command line: %s\n", boot_command_line);
710 #endif 712 #endif
711 713
712 /* 714 /*
713 * If we have OLPC OFW, we might end up relocating the fixmap due to 715 * If we have OLPC OFW, we might end up relocating the fixmap due to
714 * reserve_top(), so do this before touching the ioremap area. 716 * reserve_top(), so do this before touching the ioremap area.
715 */ 717 */
716 olpc_ofw_detect(); 718 olpc_ofw_detect();
717 719
718 early_trap_init(); 720 early_trap_init();
719 early_cpu_init(); 721 early_cpu_init();
720 early_ioremap_init(); 722 early_ioremap_init();
721 723
722 setup_olpc_ofw_pgd(); 724 setup_olpc_ofw_pgd();
723 725
724 ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev); 726 ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);
725 screen_info = boot_params.screen_info; 727 screen_info = boot_params.screen_info;
726 edid_info = boot_params.edid_info; 728 edid_info = boot_params.edid_info;
727 #ifdef CONFIG_X86_32 729 #ifdef CONFIG_X86_32
728 apm_info.bios = boot_params.apm_bios_info; 730 apm_info.bios = boot_params.apm_bios_info;
729 ist_info = boot_params.ist_info; 731 ist_info = boot_params.ist_info;
730 if (boot_params.sys_desc_table.length != 0) { 732 if (boot_params.sys_desc_table.length != 0) {
731 set_mca_bus(boot_params.sys_desc_table.table[3] & 0x2); 733 set_mca_bus(boot_params.sys_desc_table.table[3] & 0x2);
732 machine_id = boot_params.sys_desc_table.table[0]; 734 machine_id = boot_params.sys_desc_table.table[0];
733 machine_submodel_id = boot_params.sys_desc_table.table[1]; 735 machine_submodel_id = boot_params.sys_desc_table.table[1];
734 BIOS_revision = boot_params.sys_desc_table.table[2]; 736 BIOS_revision = boot_params.sys_desc_table.table[2];
735 } 737 }
736 #endif 738 #endif
737 saved_video_mode = boot_params.hdr.vid_mode; 739 saved_video_mode = boot_params.hdr.vid_mode;
738 bootloader_type = boot_params.hdr.type_of_loader; 740 bootloader_type = boot_params.hdr.type_of_loader;
739 if ((bootloader_type >> 4) == 0xe) { 741 if ((bootloader_type >> 4) == 0xe) {
740 bootloader_type &= 0xf; 742 bootloader_type &= 0xf;
741 bootloader_type |= (boot_params.hdr.ext_loader_type+0x10) << 4; 743 bootloader_type |= (boot_params.hdr.ext_loader_type+0x10) << 4;
742 } 744 }
743 bootloader_version = bootloader_type & 0xf; 745 bootloader_version = bootloader_type & 0xf;
744 bootloader_version |= boot_params.hdr.ext_loader_ver << 4; 746 bootloader_version |= boot_params.hdr.ext_loader_ver << 4;
745 747
746 #ifdef CONFIG_BLK_DEV_RAM 748 #ifdef CONFIG_BLK_DEV_RAM
747 rd_image_start = boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK; 749 rd_image_start = boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK;
748 rd_prompt = ((boot_params.hdr.ram_size & RAMDISK_PROMPT_FLAG) != 0); 750 rd_prompt = ((boot_params.hdr.ram_size & RAMDISK_PROMPT_FLAG) != 0);
749 rd_doload = ((boot_params.hdr.ram_size & RAMDISK_LOAD_FLAG) != 0); 751 rd_doload = ((boot_params.hdr.ram_size & RAMDISK_LOAD_FLAG) != 0);
750 #endif 752 #endif
751 #ifdef CONFIG_EFI 753 #ifdef CONFIG_EFI
752 if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature, 754 if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
753 #ifdef CONFIG_X86_32 755 #ifdef CONFIG_X86_32
754 "EL32", 756 "EL32",
755 #else 757 #else
756 "EL64", 758 "EL64",
757 #endif 759 #endif
758 4)) { 760 4)) {
759 efi_enabled = 1; 761 efi_enabled = 1;
760 efi_memblock_x86_reserve_range(); 762 efi_memblock_x86_reserve_range();
761 } 763 }
762 #endif 764 #endif
763 765
764 x86_init.oem.arch_setup(); 766 x86_init.oem.arch_setup();
765 767
766 iomem_resource.end = (1ULL << boot_cpu_data.x86_phys_bits) - 1; 768 iomem_resource.end = (1ULL << boot_cpu_data.x86_phys_bits) - 1;
767 setup_memory_map(); 769 setup_memory_map();
768 parse_setup_data(); 770 parse_setup_data();
769 /* update the e820_saved too */ 771 /* update the e820_saved too */
770 e820_reserve_setup_data(); 772 e820_reserve_setup_data();
771 773
772 copy_edd(); 774 copy_edd();
773 775
774 if (!boot_params.hdr.root_flags) 776 if (!boot_params.hdr.root_flags)
775 root_mountflags &= ~MS_RDONLY; 777 root_mountflags &= ~MS_RDONLY;
776 init_mm.start_code = (unsigned long) _text; 778 init_mm.start_code = (unsigned long) _text;
777 init_mm.end_code = (unsigned long) _etext; 779 init_mm.end_code = (unsigned long) _etext;
778 init_mm.end_data = (unsigned long) _edata; 780 init_mm.end_data = (unsigned long) _edata;
779 init_mm.brk = _brk_end; 781 init_mm.brk = _brk_end;
780 782
781 code_resource.start = virt_to_phys(_text); 783 code_resource.start = virt_to_phys(_text);
782 code_resource.end = virt_to_phys(_etext)-1; 784 code_resource.end = virt_to_phys(_etext)-1;
783 data_resource.start = virt_to_phys(_etext); 785 data_resource.start = virt_to_phys(_etext);
784 data_resource.end = virt_to_phys(_edata)-1; 786 data_resource.end = virt_to_phys(_edata)-1;
785 bss_resource.start = virt_to_phys(&__bss_start); 787 bss_resource.start = virt_to_phys(&__bss_start);
786 bss_resource.end = virt_to_phys(&__bss_stop)-1; 788 bss_resource.end = virt_to_phys(&__bss_stop)-1;
787 789
788 #ifdef CONFIG_CMDLINE_BOOL 790 #ifdef CONFIG_CMDLINE_BOOL
789 #ifdef CONFIG_CMDLINE_OVERRIDE 791 #ifdef CONFIG_CMDLINE_OVERRIDE
790 strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); 792 strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
791 #else 793 #else
792 if (builtin_cmdline[0]) { 794 if (builtin_cmdline[0]) {
793 /* append boot loader cmdline to builtin */ 795 /* append boot loader cmdline to builtin */
794 strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE); 796 strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
795 strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE); 797 strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
796 strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); 798 strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
797 } 799 }
798 #endif 800 #endif
799 #endif 801 #endif
800 802
801 strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE); 803 strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
802 *cmdline_p = command_line; 804 *cmdline_p = command_line;
803 805
804 /* 806 /*
805 * x86_configure_nx() is called before parse_early_param() to detect 807 * x86_configure_nx() is called before parse_early_param() to detect
806 * whether hardware doesn't support NX (so that the early EHCI debug 808 * whether hardware doesn't support NX (so that the early EHCI debug
807 * console setup can safely call set_fixmap()). It may then be called 809 * console setup can safely call set_fixmap()). It may then be called
808 * again from within noexec_setup() during parsing early parameters 810 * again from within noexec_setup() during parsing early parameters
809 * to honor the respective command line option. 811 * to honor the respective command line option.
810 */ 812 */
811 x86_configure_nx(); 813 x86_configure_nx();
812 814
813 parse_early_param(); 815 parse_early_param();
814 816
815 x86_report_nx(); 817 x86_report_nx();
816 818
817 /* after early param, so could get panic from serial */ 819 /* after early param, so could get panic from serial */
818 memblock_x86_reserve_range_setup_data(); 820 memblock_x86_reserve_range_setup_data();
819 821
820 if (acpi_mps_check()) { 822 if (acpi_mps_check()) {
821 #ifdef CONFIG_X86_LOCAL_APIC 823 #ifdef CONFIG_X86_LOCAL_APIC
822 disable_apic = 1; 824 disable_apic = 1;
823 #endif 825 #endif
824 setup_clear_cpu_cap(X86_FEATURE_APIC); 826 setup_clear_cpu_cap(X86_FEATURE_APIC);
825 } 827 }
826 828
827 #ifdef CONFIG_PCI 829 #ifdef CONFIG_PCI
828 if (pci_early_dump_regs) 830 if (pci_early_dump_regs)
829 early_dump_pci_devices(); 831 early_dump_pci_devices();
830 #endif 832 #endif
831 833
832 finish_e820_parsing(); 834 finish_e820_parsing();
833 835
834 if (efi_enabled) 836 if (efi_enabled)
835 efi_init(); 837 efi_init();
836 838
837 dmi_scan_machine(); 839 dmi_scan_machine();
838 840
839 /* 841 /*
840 * VMware detection requires dmi to be available, so this 842 * VMware detection requires dmi to be available, so this
841 * needs to be done after dmi_scan_machine, for the BP. 843 * needs to be done after dmi_scan_machine, for the BP.
842 */ 844 */
843 init_hypervisor_platform(); 845 init_hypervisor_platform();
844 846
845 x86_init.resources.probe_roms(); 847 x86_init.resources.probe_roms();
846 848
847 /* after parse_early_param, so could debug it */ 849 /* after parse_early_param, so could debug it */
848 insert_resource(&iomem_resource, &code_resource); 850 insert_resource(&iomem_resource, &code_resource);
849 insert_resource(&iomem_resource, &data_resource); 851 insert_resource(&iomem_resource, &data_resource);
850 insert_resource(&iomem_resource, &bss_resource); 852 insert_resource(&iomem_resource, &bss_resource);
851 853
852 trim_bios_range(); 854 trim_bios_range();
853 #ifdef CONFIG_X86_32 855 #ifdef CONFIG_X86_32
854 if (ppro_with_ram_bug()) { 856 if (ppro_with_ram_bug()) {
855 e820_update_range(0x70000000ULL, 0x40000ULL, E820_RAM, 857 e820_update_range(0x70000000ULL, 0x40000ULL, E820_RAM,
856 E820_RESERVED); 858 E820_RESERVED);
857 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); 859 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
858 printk(KERN_INFO "fixed physical RAM map:\n"); 860 printk(KERN_INFO "fixed physical RAM map:\n");
859 e820_print_map("bad_ppro"); 861 e820_print_map("bad_ppro");
860 } 862 }
861 #else 863 #else
862 early_gart_iommu_check(); 864 early_gart_iommu_check();
863 #endif 865 #endif
864 866
865 /* 867 /*
866 * partially used pages are not usable - thus 868 * partially used pages are not usable - thus
867 * we are rounding upwards: 869 * we are rounding upwards:
868 */ 870 */
869 max_pfn = e820_end_of_ram_pfn(); 871 max_pfn = e820_end_of_ram_pfn();
870 872
871 /* update e820 for memory not covered by WB MTRRs */ 873 /* update e820 for memory not covered by WB MTRRs */
872 mtrr_bp_init(); 874 mtrr_bp_init();
873 if (mtrr_trim_uncached_memory(max_pfn)) 875 if (mtrr_trim_uncached_memory(max_pfn))
874 max_pfn = e820_end_of_ram_pfn(); 876 max_pfn = e820_end_of_ram_pfn();
875 877
876 #ifdef CONFIG_X86_32 878 #ifdef CONFIG_X86_32
877 /* max_low_pfn get updated here */ 879 /* max_low_pfn get updated here */
878 find_low_pfn_range(); 880 find_low_pfn_range();
879 #else 881 #else
880 num_physpages = max_pfn; 882 num_physpages = max_pfn;
881 883
882 check_x2apic(); 884 check_x2apic();
883 885
884 /* How many end-of-memory variables you have, grandma! */ 886 /* How many end-of-memory variables you have, grandma! */
885 /* need this before calling reserve_initrd */ 887 /* need this before calling reserve_initrd */
886 if (max_pfn > (1UL<<(32 - PAGE_SHIFT))) 888 if (max_pfn > (1UL<<(32 - PAGE_SHIFT)))
887 max_low_pfn = e820_end_of_low_ram_pfn(); 889 max_low_pfn = e820_end_of_low_ram_pfn();
888 else 890 else
889 max_low_pfn = max_pfn; 891 max_low_pfn = max_pfn;
890 892
891 high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1; 893 high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1;
892 #endif 894 #endif
893 895
894 /* 896 /*
895 * Find and reserve possible boot-time SMP configuration: 897 * Find and reserve possible boot-time SMP configuration:
896 */ 898 */
897 find_smp_config(); 899 find_smp_config();
898 900
899 reserve_ibft_region(); 901 reserve_ibft_region();
900 902
901 /* 903 /*
902 * Need to conclude brk, before memblock_x86_fill() 904 * Need to conclude brk, before memblock_x86_fill()
903 * it could use memblock_find_in_range, could overlap with 905 * it could use memblock_find_in_range, could overlap with
904 * brk area. 906 * brk area.
905 */ 907 */
906 reserve_brk(); 908 reserve_brk();
907 909
908 cleanup_highmap(); 910 cleanup_highmap();
909 911
910 memblock.current_limit = get_max_mapped(); 912 memblock.current_limit = get_max_mapped();
911 memblock_x86_fill(); 913 memblock_x86_fill();
912 914
913 /* 915 /*
914 * The EFI specification says that boot service code won't be called 916 * The EFI specification says that boot service code won't be called
915 * after ExitBootServices(). This is, in fact, a lie. 917 * after ExitBootServices(). This is, in fact, a lie.
916 */ 918 */
917 if (efi_enabled) 919 if (efi_enabled)
918 efi_reserve_boot_services(); 920 efi_reserve_boot_services();
919 921
920 /* preallocate 4k for mptable mpc */ 922 /* preallocate 4k for mptable mpc */
921 early_reserve_e820_mpc_new(); 923 early_reserve_e820_mpc_new();
922 924
923 #ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION 925 #ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION
924 setup_bios_corruption_check(); 926 setup_bios_corruption_check();
925 #endif 927 #endif
926 928
927 printk(KERN_DEBUG "initial memory mapped : 0 - %08lx\n", 929 printk(KERN_DEBUG "initial memory mapped : 0 - %08lx\n",
928 max_pfn_mapped<<PAGE_SHIFT); 930 max_pfn_mapped<<PAGE_SHIFT);
929 931
930 setup_trampolines(); 932 setup_trampolines();
931 933
932 init_gbpages(); 934 init_gbpages();
933 935
934 /* max_pfn_mapped is updated here */ 936 /* max_pfn_mapped is updated here */
935 max_low_pfn_mapped = init_memory_mapping(0, max_low_pfn<<PAGE_SHIFT); 937 end_pfn = max_low_pfn;
938
939 #ifdef CONFIG_X86_64
940 /*
941 * There may be regions after the last E820_RAM region that we
942 * want to include in the kernel direct mapping, such as
943 * EFI_RUNTIME_SERVICES_DATA.
944 */
945 if (efi_enabled) {
946 unsigned long efi_end;
947
948 efi_end = e820_end_pfn(MAXMEM>>PAGE_SHIFT, E820_RESERVED_EFI);
949 if (efi_end > max_low_pfn)
950 end_pfn = efi_end;
951 }
952 #endif
953
954 max_low_pfn_mapped = init_memory_mapping(0, end_pfn << PAGE_SHIFT);
936 max_pfn_mapped = max_low_pfn_mapped; 955 max_pfn_mapped = max_low_pfn_mapped;
937 956
938 #ifdef CONFIG_X86_64 957 #ifdef CONFIG_X86_64
939 if (max_pfn > max_low_pfn) { 958 if (max_pfn > max_low_pfn) {
940 max_pfn_mapped = init_memory_mapping(1UL<<32, 959 max_pfn_mapped = init_memory_mapping(1UL<<32,
941 max_pfn<<PAGE_SHIFT); 960 max_pfn<<PAGE_SHIFT);
942 /* can we preseve max_low_pfn ?*/ 961 /* can we preseve max_low_pfn ?*/
943 max_low_pfn = max_pfn; 962 max_low_pfn = max_pfn;
944 } 963 }
945 #endif 964 #endif
946 memblock.current_limit = get_max_mapped(); 965 memblock.current_limit = get_max_mapped();
947 966
948 /* 967 /*
949 * NOTE: On x86-32, only from this point on, fixmaps are ready for use. 968 * NOTE: On x86-32, only from this point on, fixmaps are ready for use.
950 */ 969 */
951 970
952 #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT 971 #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
953 if (init_ohci1394_dma_early) 972 if (init_ohci1394_dma_early)
954 init_ohci1394_dma_on_all_controllers(); 973 init_ohci1394_dma_on_all_controllers();
955 #endif 974 #endif
956 /* Allocate bigger log buffer */ 975 /* Allocate bigger log buffer */
957 setup_log_buf(1); 976 setup_log_buf(1);
958 977
959 reserve_initrd(); 978 reserve_initrd();
960 979
961 reserve_crashkernel(); 980 reserve_crashkernel();
962 981
963 vsmp_init(); 982 vsmp_init();
964 983
965 io_delay_init(); 984 io_delay_init();
966 985
967 /* 986 /*
968 * Parse the ACPI tables for possible boot-time SMP configuration. 987 * Parse the ACPI tables for possible boot-time SMP configuration.
969 */ 988 */
970 acpi_boot_table_init(); 989 acpi_boot_table_init();
971 990
972 early_acpi_boot_init(); 991 early_acpi_boot_init();
973 992
974 initmem_init(); 993 initmem_init();
975 memblock_find_dma_reserve(); 994 memblock_find_dma_reserve();
976 995
977 #ifdef CONFIG_KVM_CLOCK 996 #ifdef CONFIG_KVM_CLOCK
978 kvmclock_init(); 997 kvmclock_init();
979 #endif 998 #endif
980 999
981 x86_init.paging.pagetable_setup_start(swapper_pg_dir); 1000 x86_init.paging.pagetable_setup_start(swapper_pg_dir);
982 paging_init(); 1001 paging_init();
983 x86_init.paging.pagetable_setup_done(swapper_pg_dir); 1002 x86_init.paging.pagetable_setup_done(swapper_pg_dir);
984 1003
985 if (boot_cpu_data.cpuid_level >= 0) { 1004 if (boot_cpu_data.cpuid_level >= 0) {
986 /* A CPU has %cr4 if and only if it has CPUID */ 1005 /* A CPU has %cr4 if and only if it has CPUID */
987 mmu_cr4_features = read_cr4(); 1006 mmu_cr4_features = read_cr4();
988 } 1007 }
989 1008
990 #ifdef CONFIG_X86_32 1009 #ifdef CONFIG_X86_32
991 /* sync back kernel address range */ 1010 /* sync back kernel address range */
992 clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY, 1011 clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY,
993 swapper_pg_dir + KERNEL_PGD_BOUNDARY, 1012 swapper_pg_dir + KERNEL_PGD_BOUNDARY,
994 KERNEL_PGD_PTRS); 1013 KERNEL_PGD_PTRS);
995 #endif 1014 #endif
996 1015
997 tboot_probe(); 1016 tboot_probe();
998 1017
999 #ifdef CONFIG_X86_64 1018 #ifdef CONFIG_X86_64
1000 map_vsyscall(); 1019 map_vsyscall();
1001 #endif 1020 #endif
1002 1021
1003 generic_apic_probe(); 1022 generic_apic_probe();
1004 1023
1005 early_quirks(); 1024 early_quirks();
1006 1025
1007 /* 1026 /*
1008 * Read APIC and some other early information from ACPI tables. 1027 * Read APIC and some other early information from ACPI tables.
1009 */ 1028 */
1010 acpi_boot_init(); 1029 acpi_boot_init();
1011 sfi_init(); 1030 sfi_init();
1012 x86_dtb_init(); 1031 x86_dtb_init();
1013 1032
1014 /* 1033 /*
1015 * get boot-time SMP configuration: 1034 * get boot-time SMP configuration:
1016 */ 1035 */
1017 if (smp_found_config) 1036 if (smp_found_config)
1018 get_smp_config(); 1037 get_smp_config();
1019 1038
1020 prefill_possible_map(); 1039 prefill_possible_map();
1021 1040
1022 init_cpu_to_node(); 1041 init_cpu_to_node();
1023 1042
1024 init_apic_mappings(); 1043 init_apic_mappings();
1025 ioapic_and_gsi_init(); 1044 ioapic_and_gsi_init();
1026 1045
1027 kvm_guest_init(); 1046 kvm_guest_init();
1028 1047
1029 e820_reserve_resources(); 1048 e820_reserve_resources();
1030 e820_mark_nosave_regions(max_low_pfn); 1049 e820_mark_nosave_regions(max_low_pfn);
1031 1050
1032 x86_init.resources.reserve_resources(); 1051 x86_init.resources.reserve_resources();
1033 1052
1034 e820_setup_gap(); 1053 e820_setup_gap();
1035 1054
1036 #ifdef CONFIG_VT 1055 #ifdef CONFIG_VT
1037 #if defined(CONFIG_VGA_CONSOLE) 1056 #if defined(CONFIG_VGA_CONSOLE)
1038 if (!efi_enabled || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY)) 1057 if (!efi_enabled || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
1039 conswitchp = &vga_con; 1058 conswitchp = &vga_con;
1040 #elif defined(CONFIG_DUMMY_CONSOLE) 1059 #elif defined(CONFIG_DUMMY_CONSOLE)
1041 conswitchp = &dummy_con; 1060 conswitchp = &dummy_con;
1042 #endif 1061 #endif
1043 #endif 1062 #endif
1044 x86_init.oem.banner(); 1063 x86_init.oem.banner();
1045 1064
1046 x86_init.timers.wallclock_init(); 1065 x86_init.timers.wallclock_init();
1047 1066
1048 x86_platform.wallclock_init(); 1067 x86_platform.wallclock_init();
1049 1068
1050 mcheck_init(); 1069 mcheck_init();
1051 1070
1052 arch_init_ideal_nops(); 1071 arch_init_ideal_nops();
1053 } 1072 }
1054 1073
1055 #ifdef CONFIG_X86_32 1074 #ifdef CONFIG_X86_32
1056 1075
1057 static struct resource video_ram_resource = { 1076 static struct resource video_ram_resource = {
1058 .name = "Video RAM area", 1077 .name = "Video RAM area",
1059 .start = 0xa0000, 1078 .start = 0xa0000,
1060 .end = 0xbffff, 1079 .end = 0xbffff,
1061 .flags = IORESOURCE_BUSY | IORESOURCE_MEM 1080 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
1062 }; 1081 };
1063 1082
1064 void __init i386_reserve_resources(void) 1083 void __init i386_reserve_resources(void)
1065 { 1084 {
1066 request_resource(&iomem_resource, &video_ram_resource); 1085 request_resource(&iomem_resource, &video_ram_resource);
1067 reserve_standard_io_resources(); 1086 reserve_standard_io_resources();
1068 } 1087 }
1069 1088
1070 #endif /* CONFIG_X86_32 */ 1089 #endif /* CONFIG_X86_32 */
1071 1090
arch/x86/platform/efi/efi.c
1 /* 1 /*
2 * Common EFI (Extensible Firmware Interface) support functions 2 * Common EFI (Extensible Firmware Interface) support functions
3 * Based on Extensible Firmware Interface Specification version 1.0 3 * Based on Extensible Firmware Interface Specification version 1.0
4 * 4 *
5 * Copyright (C) 1999 VA Linux Systems 5 * Copyright (C) 1999 VA Linux Systems
6 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com> 6 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
7 * Copyright (C) 1999-2002 Hewlett-Packard Co. 7 * Copyright (C) 1999-2002 Hewlett-Packard Co.
8 * David Mosberger-Tang <davidm@hpl.hp.com> 8 * David Mosberger-Tang <davidm@hpl.hp.com>
9 * Stephane Eranian <eranian@hpl.hp.com> 9 * Stephane Eranian <eranian@hpl.hp.com>
10 * Copyright (C) 2005-2008 Intel Co. 10 * Copyright (C) 2005-2008 Intel Co.
11 * Fenghua Yu <fenghua.yu@intel.com> 11 * Fenghua Yu <fenghua.yu@intel.com>
12 * Bibo Mao <bibo.mao@intel.com> 12 * Bibo Mao <bibo.mao@intel.com>
13 * Chandramouli Narayanan <mouli@linux.intel.com> 13 * Chandramouli Narayanan <mouli@linux.intel.com>
14 * Huang Ying <ying.huang@intel.com> 14 * Huang Ying <ying.huang@intel.com>
15 * 15 *
16 * Copied from efi_32.c to eliminate the duplicated code between EFI 16 * Copied from efi_32.c to eliminate the duplicated code between EFI
17 * 32/64 support code. --ying 2007-10-26 17 * 32/64 support code. --ying 2007-10-26
18 * 18 *
19 * All EFI Runtime Services are not implemented yet as EFI only 19 * All EFI Runtime Services are not implemented yet as EFI only
20 * supports physical mode addressing on SoftSDV. This is to be fixed 20 * supports physical mode addressing on SoftSDV. This is to be fixed
21 * in a future version. --drummond 1999-07-20 21 * in a future version. --drummond 1999-07-20
22 * 22 *
23 * Implemented EFI runtime services and virtual mode calls. --davidm 23 * Implemented EFI runtime services and virtual mode calls. --davidm
24 * 24 *
25 * Goutham Rao: <goutham.rao@intel.com> 25 * Goutham Rao: <goutham.rao@intel.com>
26 * Skip non-WB memory and ignore empty memory ranges. 26 * Skip non-WB memory and ignore empty memory ranges.
27 */ 27 */
28 28
29 #include <linux/kernel.h> 29 #include <linux/kernel.h>
30 #include <linux/init.h> 30 #include <linux/init.h>
31 #include <linux/efi.h> 31 #include <linux/efi.h>
32 #include <linux/export.h> 32 #include <linux/export.h>
33 #include <linux/bootmem.h> 33 #include <linux/bootmem.h>
34 #include <linux/memblock.h> 34 #include <linux/memblock.h>
35 #include <linux/spinlock.h> 35 #include <linux/spinlock.h>
36 #include <linux/uaccess.h> 36 #include <linux/uaccess.h>
37 #include <linux/time.h> 37 #include <linux/time.h>
38 #include <linux/io.h> 38 #include <linux/io.h>
39 #include <linux/reboot.h> 39 #include <linux/reboot.h>
40 #include <linux/bcd.h> 40 #include <linux/bcd.h>
41 41
42 #include <asm/setup.h> 42 #include <asm/setup.h>
43 #include <asm/efi.h> 43 #include <asm/efi.h>
44 #include <asm/time.h> 44 #include <asm/time.h>
45 #include <asm/cacheflush.h> 45 #include <asm/cacheflush.h>
46 #include <asm/tlbflush.h> 46 #include <asm/tlbflush.h>
47 #include <asm/x86_init.h> 47 #include <asm/x86_init.h>
48 48
49 #define EFI_DEBUG 1 49 #define EFI_DEBUG 1
50 #define PFX "EFI: " 50 #define PFX "EFI: "
51 51
52 int efi_enabled; 52 int efi_enabled;
53 EXPORT_SYMBOL(efi_enabled); 53 EXPORT_SYMBOL(efi_enabled);
54 54
55 struct efi __read_mostly efi = { 55 struct efi __read_mostly efi = {
56 .mps = EFI_INVALID_TABLE_ADDR, 56 .mps = EFI_INVALID_TABLE_ADDR,
57 .acpi = EFI_INVALID_TABLE_ADDR, 57 .acpi = EFI_INVALID_TABLE_ADDR,
58 .acpi20 = EFI_INVALID_TABLE_ADDR, 58 .acpi20 = EFI_INVALID_TABLE_ADDR,
59 .smbios = EFI_INVALID_TABLE_ADDR, 59 .smbios = EFI_INVALID_TABLE_ADDR,
60 .sal_systab = EFI_INVALID_TABLE_ADDR, 60 .sal_systab = EFI_INVALID_TABLE_ADDR,
61 .boot_info = EFI_INVALID_TABLE_ADDR, 61 .boot_info = EFI_INVALID_TABLE_ADDR,
62 .hcdp = EFI_INVALID_TABLE_ADDR, 62 .hcdp = EFI_INVALID_TABLE_ADDR,
63 .uga = EFI_INVALID_TABLE_ADDR, 63 .uga = EFI_INVALID_TABLE_ADDR,
64 .uv_systab = EFI_INVALID_TABLE_ADDR, 64 .uv_systab = EFI_INVALID_TABLE_ADDR,
65 }; 65 };
66 EXPORT_SYMBOL(efi); 66 EXPORT_SYMBOL(efi);
67 67
68 struct efi_memory_map memmap; 68 struct efi_memory_map memmap;
69 69
70 static struct efi efi_phys __initdata; 70 static struct efi efi_phys __initdata;
71 static efi_system_table_t efi_systab __initdata; 71 static efi_system_table_t efi_systab __initdata;
72 72
73 static int __init setup_noefi(char *arg) 73 static int __init setup_noefi(char *arg)
74 { 74 {
75 efi_enabled = 0; 75 efi_enabled = 0;
76 return 0; 76 return 0;
77 } 77 }
78 early_param("noefi", setup_noefi); 78 early_param("noefi", setup_noefi);
79 79
80 int add_efi_memmap; 80 int add_efi_memmap;
81 EXPORT_SYMBOL(add_efi_memmap); 81 EXPORT_SYMBOL(add_efi_memmap);
82 82
83 static int __init setup_add_efi_memmap(char *arg) 83 static int __init setup_add_efi_memmap(char *arg)
84 { 84 {
85 add_efi_memmap = 1; 85 add_efi_memmap = 1;
86 return 0; 86 return 0;
87 } 87 }
88 early_param("add_efi_memmap", setup_add_efi_memmap); 88 early_param("add_efi_memmap", setup_add_efi_memmap);
89 89
90 90
91 static efi_status_t virt_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc) 91 static efi_status_t virt_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
92 { 92 {
93 unsigned long flags; 93 unsigned long flags;
94 efi_status_t status; 94 efi_status_t status;
95 95
96 spin_lock_irqsave(&rtc_lock, flags); 96 spin_lock_irqsave(&rtc_lock, flags);
97 status = efi_call_virt2(get_time, tm, tc); 97 status = efi_call_virt2(get_time, tm, tc);
98 spin_unlock_irqrestore(&rtc_lock, flags); 98 spin_unlock_irqrestore(&rtc_lock, flags);
99 return status; 99 return status;
100 } 100 }
101 101
102 static efi_status_t virt_efi_set_time(efi_time_t *tm) 102 static efi_status_t virt_efi_set_time(efi_time_t *tm)
103 { 103 {
104 unsigned long flags; 104 unsigned long flags;
105 efi_status_t status; 105 efi_status_t status;
106 106
107 spin_lock_irqsave(&rtc_lock, flags); 107 spin_lock_irqsave(&rtc_lock, flags);
108 status = efi_call_virt1(set_time, tm); 108 status = efi_call_virt1(set_time, tm);
109 spin_unlock_irqrestore(&rtc_lock, flags); 109 spin_unlock_irqrestore(&rtc_lock, flags);
110 return status; 110 return status;
111 } 111 }
112 112
113 static efi_status_t virt_efi_get_wakeup_time(efi_bool_t *enabled, 113 static efi_status_t virt_efi_get_wakeup_time(efi_bool_t *enabled,
114 efi_bool_t *pending, 114 efi_bool_t *pending,
115 efi_time_t *tm) 115 efi_time_t *tm)
116 { 116 {
117 unsigned long flags; 117 unsigned long flags;
118 efi_status_t status; 118 efi_status_t status;
119 119
120 spin_lock_irqsave(&rtc_lock, flags); 120 spin_lock_irqsave(&rtc_lock, flags);
121 status = efi_call_virt3(get_wakeup_time, 121 status = efi_call_virt3(get_wakeup_time,
122 enabled, pending, tm); 122 enabled, pending, tm);
123 spin_unlock_irqrestore(&rtc_lock, flags); 123 spin_unlock_irqrestore(&rtc_lock, flags);
124 return status; 124 return status;
125 } 125 }
126 126
127 static efi_status_t virt_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm) 127 static efi_status_t virt_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
128 { 128 {
129 unsigned long flags; 129 unsigned long flags;
130 efi_status_t status; 130 efi_status_t status;
131 131
132 spin_lock_irqsave(&rtc_lock, flags); 132 spin_lock_irqsave(&rtc_lock, flags);
133 status = efi_call_virt2(set_wakeup_time, 133 status = efi_call_virt2(set_wakeup_time,
134 enabled, tm); 134 enabled, tm);
135 spin_unlock_irqrestore(&rtc_lock, flags); 135 spin_unlock_irqrestore(&rtc_lock, flags);
136 return status; 136 return status;
137 } 137 }
138 138
139 static efi_status_t virt_efi_get_variable(efi_char16_t *name, 139 static efi_status_t virt_efi_get_variable(efi_char16_t *name,
140 efi_guid_t *vendor, 140 efi_guid_t *vendor,
141 u32 *attr, 141 u32 *attr,
142 unsigned long *data_size, 142 unsigned long *data_size,
143 void *data) 143 void *data)
144 { 144 {
145 return efi_call_virt5(get_variable, 145 return efi_call_virt5(get_variable,
146 name, vendor, attr, 146 name, vendor, attr,
147 data_size, data); 147 data_size, data);
148 } 148 }
149 149
150 static efi_status_t virt_efi_get_next_variable(unsigned long *name_size, 150 static efi_status_t virt_efi_get_next_variable(unsigned long *name_size,
151 efi_char16_t *name, 151 efi_char16_t *name,
152 efi_guid_t *vendor) 152 efi_guid_t *vendor)
153 { 153 {
154 return efi_call_virt3(get_next_variable, 154 return efi_call_virt3(get_next_variable,
155 name_size, name, vendor); 155 name_size, name, vendor);
156 } 156 }
157 157
158 static efi_status_t virt_efi_set_variable(efi_char16_t *name, 158 static efi_status_t virt_efi_set_variable(efi_char16_t *name,
159 efi_guid_t *vendor, 159 efi_guid_t *vendor,
160 u32 attr, 160 u32 attr,
161 unsigned long data_size, 161 unsigned long data_size,
162 void *data) 162 void *data)
163 { 163 {
164 return efi_call_virt5(set_variable, 164 return efi_call_virt5(set_variable,
165 name, vendor, attr, 165 name, vendor, attr,
166 data_size, data); 166 data_size, data);
167 } 167 }
168 168
169 static efi_status_t virt_efi_query_variable_info(u32 attr, 169 static efi_status_t virt_efi_query_variable_info(u32 attr,
170 u64 *storage_space, 170 u64 *storage_space,
171 u64 *remaining_space, 171 u64 *remaining_space,
172 u64 *max_variable_size) 172 u64 *max_variable_size)
173 { 173 {
174 if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) 174 if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION)
175 return EFI_UNSUPPORTED; 175 return EFI_UNSUPPORTED;
176 176
177 return efi_call_virt4(query_variable_info, attr, storage_space, 177 return efi_call_virt4(query_variable_info, attr, storage_space,
178 remaining_space, max_variable_size); 178 remaining_space, max_variable_size);
179 } 179 }
180 180
181 static efi_status_t virt_efi_get_next_high_mono_count(u32 *count) 181 static efi_status_t virt_efi_get_next_high_mono_count(u32 *count)
182 { 182 {
183 return efi_call_virt1(get_next_high_mono_count, count); 183 return efi_call_virt1(get_next_high_mono_count, count);
184 } 184 }
185 185
186 static void virt_efi_reset_system(int reset_type, 186 static void virt_efi_reset_system(int reset_type,
187 efi_status_t status, 187 efi_status_t status,
188 unsigned long data_size, 188 unsigned long data_size,
189 efi_char16_t *data) 189 efi_char16_t *data)
190 { 190 {
191 efi_call_virt4(reset_system, reset_type, status, 191 efi_call_virt4(reset_system, reset_type, status,
192 data_size, data); 192 data_size, data);
193 } 193 }
194 194
195 static efi_status_t virt_efi_update_capsule(efi_capsule_header_t **capsules, 195 static efi_status_t virt_efi_update_capsule(efi_capsule_header_t **capsules,
196 unsigned long count, 196 unsigned long count,
197 unsigned long sg_list) 197 unsigned long sg_list)
198 { 198 {
199 if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) 199 if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION)
200 return EFI_UNSUPPORTED; 200 return EFI_UNSUPPORTED;
201 201
202 return efi_call_virt3(update_capsule, capsules, count, sg_list); 202 return efi_call_virt3(update_capsule, capsules, count, sg_list);
203 } 203 }
204 204
205 static efi_status_t virt_efi_query_capsule_caps(efi_capsule_header_t **capsules, 205 static efi_status_t virt_efi_query_capsule_caps(efi_capsule_header_t **capsules,
206 unsigned long count, 206 unsigned long count,
207 u64 *max_size, 207 u64 *max_size,
208 int *reset_type) 208 int *reset_type)
209 { 209 {
210 if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) 210 if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION)
211 return EFI_UNSUPPORTED; 211 return EFI_UNSUPPORTED;
212 212
213 return efi_call_virt4(query_capsule_caps, capsules, count, max_size, 213 return efi_call_virt4(query_capsule_caps, capsules, count, max_size,
214 reset_type); 214 reset_type);
215 } 215 }
216 216
217 static efi_status_t __init phys_efi_set_virtual_address_map( 217 static efi_status_t __init phys_efi_set_virtual_address_map(
218 unsigned long memory_map_size, 218 unsigned long memory_map_size,
219 unsigned long descriptor_size, 219 unsigned long descriptor_size,
220 u32 descriptor_version, 220 u32 descriptor_version,
221 efi_memory_desc_t *virtual_map) 221 efi_memory_desc_t *virtual_map)
222 { 222 {
223 efi_status_t status; 223 efi_status_t status;
224 224
225 efi_call_phys_prelog(); 225 efi_call_phys_prelog();
226 status = efi_call_phys4(efi_phys.set_virtual_address_map, 226 status = efi_call_phys4(efi_phys.set_virtual_address_map,
227 memory_map_size, descriptor_size, 227 memory_map_size, descriptor_size,
228 descriptor_version, virtual_map); 228 descriptor_version, virtual_map);
229 efi_call_phys_epilog(); 229 efi_call_phys_epilog();
230 return status; 230 return status;
231 } 231 }
232 232
233 static efi_status_t __init phys_efi_get_time(efi_time_t *tm, 233 static efi_status_t __init phys_efi_get_time(efi_time_t *tm,
234 efi_time_cap_t *tc) 234 efi_time_cap_t *tc)
235 { 235 {
236 unsigned long flags; 236 unsigned long flags;
237 efi_status_t status; 237 efi_status_t status;
238 238
239 spin_lock_irqsave(&rtc_lock, flags); 239 spin_lock_irqsave(&rtc_lock, flags);
240 efi_call_phys_prelog(); 240 efi_call_phys_prelog();
241 status = efi_call_phys2(efi_phys.get_time, tm, tc); 241 status = efi_call_phys2(efi_phys.get_time, tm, tc);
242 efi_call_phys_epilog(); 242 efi_call_phys_epilog();
243 spin_unlock_irqrestore(&rtc_lock, flags); 243 spin_unlock_irqrestore(&rtc_lock, flags);
244 return status; 244 return status;
245 } 245 }
246 246
247 int efi_set_rtc_mmss(unsigned long nowtime) 247 int efi_set_rtc_mmss(unsigned long nowtime)
248 { 248 {
249 int real_seconds, real_minutes; 249 int real_seconds, real_minutes;
250 efi_status_t status; 250 efi_status_t status;
251 efi_time_t eft; 251 efi_time_t eft;
252 efi_time_cap_t cap; 252 efi_time_cap_t cap;
253 253
254 status = efi.get_time(&eft, &cap); 254 status = efi.get_time(&eft, &cap);
255 if (status != EFI_SUCCESS) { 255 if (status != EFI_SUCCESS) {
256 printk(KERN_ERR "Oops: efitime: can't read time!\n"); 256 printk(KERN_ERR "Oops: efitime: can't read time!\n");
257 return -1; 257 return -1;
258 } 258 }
259 259
260 real_seconds = nowtime % 60; 260 real_seconds = nowtime % 60;
261 real_minutes = nowtime / 60; 261 real_minutes = nowtime / 60;
262 if (((abs(real_minutes - eft.minute) + 15)/30) & 1) 262 if (((abs(real_minutes - eft.minute) + 15)/30) & 1)
263 real_minutes += 30; 263 real_minutes += 30;
264 real_minutes %= 60; 264 real_minutes %= 60;
265 eft.minute = real_minutes; 265 eft.minute = real_minutes;
266 eft.second = real_seconds; 266 eft.second = real_seconds;
267 267
268 status = efi.set_time(&eft); 268 status = efi.set_time(&eft);
269 if (status != EFI_SUCCESS) { 269 if (status != EFI_SUCCESS) {
270 printk(KERN_ERR "Oops: efitime: can't write time!\n"); 270 printk(KERN_ERR "Oops: efitime: can't write time!\n");
271 return -1; 271 return -1;
272 } 272 }
273 return 0; 273 return 0;
274 } 274 }
275 275
276 unsigned long efi_get_time(void) 276 unsigned long efi_get_time(void)
277 { 277 {
278 efi_status_t status; 278 efi_status_t status;
279 efi_time_t eft; 279 efi_time_t eft;
280 efi_time_cap_t cap; 280 efi_time_cap_t cap;
281 281
282 status = efi.get_time(&eft, &cap); 282 status = efi.get_time(&eft, &cap);
283 if (status != EFI_SUCCESS) 283 if (status != EFI_SUCCESS)
284 printk(KERN_ERR "Oops: efitime: can't read time!\n"); 284 printk(KERN_ERR "Oops: efitime: can't read time!\n");
285 285
286 return mktime(eft.year, eft.month, eft.day, eft.hour, 286 return mktime(eft.year, eft.month, eft.day, eft.hour,
287 eft.minute, eft.second); 287 eft.minute, eft.second);
288 } 288 }
289 289
290 /* 290 /*
291 * Tell the kernel about the EFI memory map. This might include 291 * Tell the kernel about the EFI memory map. This might include
292 * more than the max 128 entries that can fit in the e820 legacy 292 * more than the max 128 entries that can fit in the e820 legacy
293 * (zeropage) memory map. 293 * (zeropage) memory map.
294 */ 294 */
295 295
296 static void __init do_add_efi_memmap(void) 296 static void __init do_add_efi_memmap(void)
297 { 297 {
298 void *p; 298 void *p;
299 299
300 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { 300 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
301 efi_memory_desc_t *md = p; 301 efi_memory_desc_t *md = p;
302 unsigned long long start = md->phys_addr; 302 unsigned long long start = md->phys_addr;
303 unsigned long long size = md->num_pages << EFI_PAGE_SHIFT; 303 unsigned long long size = md->num_pages << EFI_PAGE_SHIFT;
304 int e820_type; 304 int e820_type;
305 305
306 switch (md->type) { 306 switch (md->type) {
307 case EFI_LOADER_CODE: 307 case EFI_LOADER_CODE:
308 case EFI_LOADER_DATA: 308 case EFI_LOADER_DATA:
309 case EFI_BOOT_SERVICES_CODE: 309 case EFI_BOOT_SERVICES_CODE:
310 case EFI_BOOT_SERVICES_DATA: 310 case EFI_BOOT_SERVICES_DATA:
311 case EFI_CONVENTIONAL_MEMORY: 311 case EFI_CONVENTIONAL_MEMORY:
312 if (md->attribute & EFI_MEMORY_WB) 312 if (md->attribute & EFI_MEMORY_WB)
313 e820_type = E820_RAM; 313 e820_type = E820_RAM;
314 else 314 else
315 e820_type = E820_RESERVED; 315 e820_type = E820_RESERVED;
316 break; 316 break;
317 case EFI_ACPI_RECLAIM_MEMORY: 317 case EFI_ACPI_RECLAIM_MEMORY:
318 e820_type = E820_ACPI; 318 e820_type = E820_ACPI;
319 break; 319 break;
320 case EFI_ACPI_MEMORY_NVS: 320 case EFI_ACPI_MEMORY_NVS:
321 e820_type = E820_NVS; 321 e820_type = E820_NVS;
322 break; 322 break;
323 case EFI_UNUSABLE_MEMORY: 323 case EFI_UNUSABLE_MEMORY:
324 e820_type = E820_UNUSABLE; 324 e820_type = E820_UNUSABLE;
325 break; 325 break;
326 case EFI_RUNTIME_SERVICES_DATA:
327 e820_type = E820_RESERVED_EFI;
328 break;
326 default: 329 default:
327 /* 330 /*
328 * EFI_RESERVED_TYPE EFI_RUNTIME_SERVICES_CODE 331 * EFI_RESERVED_TYPE EFI_RUNTIME_SERVICES_CODE
329 * EFI_RUNTIME_SERVICES_DATA EFI_MEMORY_MAPPED_IO 332 * EFI_MEMORY_MAPPED_IO
330 * EFI_MEMORY_MAPPED_IO_PORT_SPACE EFI_PAL_CODE 333 * EFI_MEMORY_MAPPED_IO_PORT_SPACE EFI_PAL_CODE
331 */ 334 */
332 e820_type = E820_RESERVED; 335 e820_type = E820_RESERVED;
333 break; 336 break;
334 } 337 }
335 e820_add_region(start, size, e820_type); 338 e820_add_region(start, size, e820_type);
336 } 339 }
337 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); 340 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
338 } 341 }
339 342
340 void __init efi_memblock_x86_reserve_range(void) 343 void __init efi_memblock_x86_reserve_range(void)
341 { 344 {
342 unsigned long pmap; 345 unsigned long pmap;
343 346
344 #ifdef CONFIG_X86_32 347 #ifdef CONFIG_X86_32
345 pmap = boot_params.efi_info.efi_memmap; 348 pmap = boot_params.efi_info.efi_memmap;
346 #else 349 #else
347 pmap = (boot_params.efi_info.efi_memmap | 350 pmap = (boot_params.efi_info.efi_memmap |
348 ((__u64)boot_params.efi_info.efi_memmap_hi<<32)); 351 ((__u64)boot_params.efi_info.efi_memmap_hi<<32));
349 #endif 352 #endif
350 memmap.phys_map = (void *)pmap; 353 memmap.phys_map = (void *)pmap;
351 memmap.nr_map = boot_params.efi_info.efi_memmap_size / 354 memmap.nr_map = boot_params.efi_info.efi_memmap_size /
352 boot_params.efi_info.efi_memdesc_size; 355 boot_params.efi_info.efi_memdesc_size;
353 memmap.desc_version = boot_params.efi_info.efi_memdesc_version; 356 memmap.desc_version = boot_params.efi_info.efi_memdesc_version;
354 memmap.desc_size = boot_params.efi_info.efi_memdesc_size; 357 memmap.desc_size = boot_params.efi_info.efi_memdesc_size;
355 memblock_x86_reserve_range(pmap, pmap + memmap.nr_map * memmap.desc_size, 358 memblock_x86_reserve_range(pmap, pmap + memmap.nr_map * memmap.desc_size,
356 "EFI memmap"); 359 "EFI memmap");
357 } 360 }
358 361
359 #if EFI_DEBUG 362 #if EFI_DEBUG
360 static void __init print_efi_memmap(void) 363 static void __init print_efi_memmap(void)
361 { 364 {
362 efi_memory_desc_t *md; 365 efi_memory_desc_t *md;
363 void *p; 366 void *p;
364 int i; 367 int i;
365 368
366 for (p = memmap.map, i = 0; 369 for (p = memmap.map, i = 0;
367 p < memmap.map_end; 370 p < memmap.map_end;
368 p += memmap.desc_size, i++) { 371 p += memmap.desc_size, i++) {
369 md = p; 372 md = p;
370 printk(KERN_INFO PFX "mem%02u: type=%u, attr=0x%llx, " 373 printk(KERN_INFO PFX "mem%02u: type=%u, attr=0x%llx, "
371 "range=[0x%016llx-0x%016llx) (%lluMB)\n", 374 "range=[0x%016llx-0x%016llx) (%lluMB)\n",
372 i, md->type, md->attribute, md->phys_addr, 375 i, md->type, md->attribute, md->phys_addr,
373 md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT), 376 md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT),
374 (md->num_pages >> (20 - EFI_PAGE_SHIFT))); 377 (md->num_pages >> (20 - EFI_PAGE_SHIFT)));
375 } 378 }
376 } 379 }
377 #endif /* EFI_DEBUG */ 380 #endif /* EFI_DEBUG */
378 381
379 void __init efi_reserve_boot_services(void) 382 void __init efi_reserve_boot_services(void)
380 { 383 {
381 void *p; 384 void *p;
382 385
383 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { 386 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
384 efi_memory_desc_t *md = p; 387 efi_memory_desc_t *md = p;
385 u64 start = md->phys_addr; 388 u64 start = md->phys_addr;
386 u64 size = md->num_pages << EFI_PAGE_SHIFT; 389 u64 size = md->num_pages << EFI_PAGE_SHIFT;
387 390
388 if (md->type != EFI_BOOT_SERVICES_CODE && 391 if (md->type != EFI_BOOT_SERVICES_CODE &&
389 md->type != EFI_BOOT_SERVICES_DATA) 392 md->type != EFI_BOOT_SERVICES_DATA)
390 continue; 393 continue;
391 /* Only reserve where possible: 394 /* Only reserve where possible:
392 * - Not within any already allocated areas 395 * - Not within any already allocated areas
393 * - Not over any memory area (really needed, if above?) 396 * - Not over any memory area (really needed, if above?)
394 * - Not within any part of the kernel 397 * - Not within any part of the kernel
395 * - Not the bios reserved area 398 * - Not the bios reserved area
396 */ 399 */
397 if ((start+size >= virt_to_phys(_text) 400 if ((start+size >= virt_to_phys(_text)
398 && start <= virt_to_phys(_end)) || 401 && start <= virt_to_phys(_end)) ||
399 !e820_all_mapped(start, start+size, E820_RAM) || 402 !e820_all_mapped(start, start+size, E820_RAM) ||
400 memblock_x86_check_reserved_size(&start, &size, 403 memblock_x86_check_reserved_size(&start, &size,
401 1<<EFI_PAGE_SHIFT)) { 404 1<<EFI_PAGE_SHIFT)) {
402 /* Could not reserve, skip it */ 405 /* Could not reserve, skip it */
403 md->num_pages = 0; 406 md->num_pages = 0;
404 memblock_dbg(PFX "Could not reserve boot range " 407 memblock_dbg(PFX "Could not reserve boot range "
405 "[0x%010llx-0x%010llx]\n", 408 "[0x%010llx-0x%010llx]\n",
406 start, start+size-1); 409 start, start+size-1);
407 } else 410 } else
408 memblock_x86_reserve_range(start, start+size, 411 memblock_x86_reserve_range(start, start+size,
409 "EFI Boot"); 412 "EFI Boot");
410 } 413 }
411 } 414 }
412 415
413 static void __init efi_free_boot_services(void) 416 static void __init efi_free_boot_services(void)
414 { 417 {
415 void *p; 418 void *p;
416 419
417 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { 420 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
418 efi_memory_desc_t *md = p; 421 efi_memory_desc_t *md = p;
419 unsigned long long start = md->phys_addr; 422 unsigned long long start = md->phys_addr;
420 unsigned long long size = md->num_pages << EFI_PAGE_SHIFT; 423 unsigned long long size = md->num_pages << EFI_PAGE_SHIFT;
421 424
422 if (md->type != EFI_BOOT_SERVICES_CODE && 425 if (md->type != EFI_BOOT_SERVICES_CODE &&
423 md->type != EFI_BOOT_SERVICES_DATA) 426 md->type != EFI_BOOT_SERVICES_DATA)
424 continue; 427 continue;
425 428
426 /* Could not reserve boot area */ 429 /* Could not reserve boot area */
427 if (!size) 430 if (!size)
428 continue; 431 continue;
429 432
430 free_bootmem_late(start, size); 433 free_bootmem_late(start, size);
431 } 434 }
432 } 435 }
433 436
434 void __init efi_init(void) 437 void __init efi_init(void)
435 { 438 {
436 efi_config_table_t *config_tables; 439 efi_config_table_t *config_tables;
437 efi_runtime_services_t *runtime; 440 efi_runtime_services_t *runtime;
438 efi_char16_t *c16; 441 efi_char16_t *c16;
439 char vendor[100] = "unknown"; 442 char vendor[100] = "unknown";
440 int i = 0; 443 int i = 0;
441 void *tmp; 444 void *tmp;
442 445
443 #ifdef CONFIG_X86_32 446 #ifdef CONFIG_X86_32
444 efi_phys.systab = (efi_system_table_t *)boot_params.efi_info.efi_systab; 447 efi_phys.systab = (efi_system_table_t *)boot_params.efi_info.efi_systab;
445 #else 448 #else
446 efi_phys.systab = (efi_system_table_t *) 449 efi_phys.systab = (efi_system_table_t *)
447 (boot_params.efi_info.efi_systab | 450 (boot_params.efi_info.efi_systab |
448 ((__u64)boot_params.efi_info.efi_systab_hi<<32)); 451 ((__u64)boot_params.efi_info.efi_systab_hi<<32));
449 #endif 452 #endif
450 453
451 efi.systab = early_ioremap((unsigned long)efi_phys.systab, 454 efi.systab = early_ioremap((unsigned long)efi_phys.systab,
452 sizeof(efi_system_table_t)); 455 sizeof(efi_system_table_t));
453 if (efi.systab == NULL) 456 if (efi.systab == NULL)
454 printk(KERN_ERR "Couldn't map the EFI system table!\n"); 457 printk(KERN_ERR "Couldn't map the EFI system table!\n");
455 memcpy(&efi_systab, efi.systab, sizeof(efi_system_table_t)); 458 memcpy(&efi_systab, efi.systab, sizeof(efi_system_table_t));
456 early_iounmap(efi.systab, sizeof(efi_system_table_t)); 459 early_iounmap(efi.systab, sizeof(efi_system_table_t));
457 efi.systab = &efi_systab; 460 efi.systab = &efi_systab;
458 461
459 /* 462 /*
460 * Verify the EFI Table 463 * Verify the EFI Table
461 */ 464 */
462 if (efi.systab->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE) 465 if (efi.systab->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE)
463 printk(KERN_ERR "EFI system table signature incorrect!\n"); 466 printk(KERN_ERR "EFI system table signature incorrect!\n");
464 if ((efi.systab->hdr.revision >> 16) == 0) 467 if ((efi.systab->hdr.revision >> 16) == 0)
465 printk(KERN_ERR "Warning: EFI system table version " 468 printk(KERN_ERR "Warning: EFI system table version "
466 "%d.%02d, expected 1.00 or greater!\n", 469 "%d.%02d, expected 1.00 or greater!\n",
467 efi.systab->hdr.revision >> 16, 470 efi.systab->hdr.revision >> 16,
468 efi.systab->hdr.revision & 0xffff); 471 efi.systab->hdr.revision & 0xffff);
469 472
470 /* 473 /*
471 * Show what we know for posterity 474 * Show what we know for posterity
472 */ 475 */
473 c16 = tmp = early_ioremap(efi.systab->fw_vendor, 2); 476 c16 = tmp = early_ioremap(efi.systab->fw_vendor, 2);
474 if (c16) { 477 if (c16) {
475 for (i = 0; i < sizeof(vendor) - 1 && *c16; ++i) 478 for (i = 0; i < sizeof(vendor) - 1 && *c16; ++i)
476 vendor[i] = *c16++; 479 vendor[i] = *c16++;
477 vendor[i] = '\0'; 480 vendor[i] = '\0';
478 } else 481 } else
479 printk(KERN_ERR PFX "Could not map the firmware vendor!\n"); 482 printk(KERN_ERR PFX "Could not map the firmware vendor!\n");
480 early_iounmap(tmp, 2); 483 early_iounmap(tmp, 2);
481 484
482 printk(KERN_INFO "EFI v%u.%.02u by %s\n", 485 printk(KERN_INFO "EFI v%u.%.02u by %s\n",
483 efi.systab->hdr.revision >> 16, 486 efi.systab->hdr.revision >> 16,
484 efi.systab->hdr.revision & 0xffff, vendor); 487 efi.systab->hdr.revision & 0xffff, vendor);
485 488
486 /* 489 /*
487 * Let's see what config tables the firmware passed to us. 490 * Let's see what config tables the firmware passed to us.
488 */ 491 */
489 config_tables = early_ioremap( 492 config_tables = early_ioremap(
490 efi.systab->tables, 493 efi.systab->tables,
491 efi.systab->nr_tables * sizeof(efi_config_table_t)); 494 efi.systab->nr_tables * sizeof(efi_config_table_t));
492 if (config_tables == NULL) 495 if (config_tables == NULL)
493 printk(KERN_ERR "Could not map EFI Configuration Table!\n"); 496 printk(KERN_ERR "Could not map EFI Configuration Table!\n");
494 497
495 printk(KERN_INFO); 498 printk(KERN_INFO);
496 for (i = 0; i < efi.systab->nr_tables; i++) { 499 for (i = 0; i < efi.systab->nr_tables; i++) {
497 if (!efi_guidcmp(config_tables[i].guid, MPS_TABLE_GUID)) { 500 if (!efi_guidcmp(config_tables[i].guid, MPS_TABLE_GUID)) {
498 efi.mps = config_tables[i].table; 501 efi.mps = config_tables[i].table;
499 printk(" MPS=0x%lx ", config_tables[i].table); 502 printk(" MPS=0x%lx ", config_tables[i].table);
500 } else if (!efi_guidcmp(config_tables[i].guid, 503 } else if (!efi_guidcmp(config_tables[i].guid,
501 ACPI_20_TABLE_GUID)) { 504 ACPI_20_TABLE_GUID)) {
502 efi.acpi20 = config_tables[i].table; 505 efi.acpi20 = config_tables[i].table;
503 printk(" ACPI 2.0=0x%lx ", config_tables[i].table); 506 printk(" ACPI 2.0=0x%lx ", config_tables[i].table);
504 } else if (!efi_guidcmp(config_tables[i].guid, 507 } else if (!efi_guidcmp(config_tables[i].guid,
505 ACPI_TABLE_GUID)) { 508 ACPI_TABLE_GUID)) {
506 efi.acpi = config_tables[i].table; 509 efi.acpi = config_tables[i].table;
507 printk(" ACPI=0x%lx ", config_tables[i].table); 510 printk(" ACPI=0x%lx ", config_tables[i].table);
508 } else if (!efi_guidcmp(config_tables[i].guid, 511 } else if (!efi_guidcmp(config_tables[i].guid,
509 SMBIOS_TABLE_GUID)) { 512 SMBIOS_TABLE_GUID)) {
510 efi.smbios = config_tables[i].table; 513 efi.smbios = config_tables[i].table;
511 printk(" SMBIOS=0x%lx ", config_tables[i].table); 514 printk(" SMBIOS=0x%lx ", config_tables[i].table);
512 #ifdef CONFIG_X86_UV 515 #ifdef CONFIG_X86_UV
513 } else if (!efi_guidcmp(config_tables[i].guid, 516 } else if (!efi_guidcmp(config_tables[i].guid,
514 UV_SYSTEM_TABLE_GUID)) { 517 UV_SYSTEM_TABLE_GUID)) {
515 efi.uv_systab = config_tables[i].table; 518 efi.uv_systab = config_tables[i].table;
516 printk(" UVsystab=0x%lx ", config_tables[i].table); 519 printk(" UVsystab=0x%lx ", config_tables[i].table);
517 #endif 520 #endif
518 } else if (!efi_guidcmp(config_tables[i].guid, 521 } else if (!efi_guidcmp(config_tables[i].guid,
519 HCDP_TABLE_GUID)) { 522 HCDP_TABLE_GUID)) {
520 efi.hcdp = config_tables[i].table; 523 efi.hcdp = config_tables[i].table;
521 printk(" HCDP=0x%lx ", config_tables[i].table); 524 printk(" HCDP=0x%lx ", config_tables[i].table);
522 } else if (!efi_guidcmp(config_tables[i].guid, 525 } else if (!efi_guidcmp(config_tables[i].guid,
523 UGA_IO_PROTOCOL_GUID)) { 526 UGA_IO_PROTOCOL_GUID)) {
524 efi.uga = config_tables[i].table; 527 efi.uga = config_tables[i].table;
525 printk(" UGA=0x%lx ", config_tables[i].table); 528 printk(" UGA=0x%lx ", config_tables[i].table);
526 } 529 }
527 } 530 }
528 printk("\n"); 531 printk("\n");
529 early_iounmap(config_tables, 532 early_iounmap(config_tables,
530 efi.systab->nr_tables * sizeof(efi_config_table_t)); 533 efi.systab->nr_tables * sizeof(efi_config_table_t));
531 534
532 /* 535 /*
533 * Check out the runtime services table. We need to map 536 * Check out the runtime services table. We need to map
534 * the runtime services table so that we can grab the physical 537 * the runtime services table so that we can grab the physical
535 * address of several of the EFI runtime functions, needed to 538 * address of several of the EFI runtime functions, needed to
536 * set the firmware into virtual mode. 539 * set the firmware into virtual mode.
537 */ 540 */
538 runtime = early_ioremap((unsigned long)efi.systab->runtime, 541 runtime = early_ioremap((unsigned long)efi.systab->runtime,
539 sizeof(efi_runtime_services_t)); 542 sizeof(efi_runtime_services_t));
540 if (runtime != NULL) { 543 if (runtime != NULL) {
541 /* 544 /*
542 * We will only need *early* access to the following 545 * We will only need *early* access to the following
543 * two EFI runtime services before set_virtual_address_map 546 * two EFI runtime services before set_virtual_address_map
544 * is invoked. 547 * is invoked.
545 */ 548 */
546 efi_phys.get_time = (efi_get_time_t *)runtime->get_time; 549 efi_phys.get_time = (efi_get_time_t *)runtime->get_time;
547 efi_phys.set_virtual_address_map = 550 efi_phys.set_virtual_address_map =
548 (efi_set_virtual_address_map_t *) 551 (efi_set_virtual_address_map_t *)
549 runtime->set_virtual_address_map; 552 runtime->set_virtual_address_map;
550 /* 553 /*
551 * Make efi_get_time can be called before entering 554 * Make efi_get_time can be called before entering
552 * virtual mode. 555 * virtual mode.
553 */ 556 */
554 efi.get_time = phys_efi_get_time; 557 efi.get_time = phys_efi_get_time;
555 } else 558 } else
556 printk(KERN_ERR "Could not map the EFI runtime service " 559 printk(KERN_ERR "Could not map the EFI runtime service "
557 "table!\n"); 560 "table!\n");
558 early_iounmap(runtime, sizeof(efi_runtime_services_t)); 561 early_iounmap(runtime, sizeof(efi_runtime_services_t));
559 562
560 /* Map the EFI memory map */ 563 /* Map the EFI memory map */
561 memmap.map = early_ioremap((unsigned long)memmap.phys_map, 564 memmap.map = early_ioremap((unsigned long)memmap.phys_map,
562 memmap.nr_map * memmap.desc_size); 565 memmap.nr_map * memmap.desc_size);
563 if (memmap.map == NULL) 566 if (memmap.map == NULL)
564 printk(KERN_ERR "Could not map the EFI memory map!\n"); 567 printk(KERN_ERR "Could not map the EFI memory map!\n");
565 memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size); 568 memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size);
566 569
567 if (memmap.desc_size != sizeof(efi_memory_desc_t)) 570 if (memmap.desc_size != sizeof(efi_memory_desc_t))
568 printk(KERN_WARNING 571 printk(KERN_WARNING
569 "Kernel-defined memdesc doesn't match the one from EFI!\n"); 572 "Kernel-defined memdesc doesn't match the one from EFI!\n");
570 573
571 if (add_efi_memmap) 574 if (add_efi_memmap)
572 do_add_efi_memmap(); 575 do_add_efi_memmap();
573 576
574 #ifdef CONFIG_X86_32 577 #ifdef CONFIG_X86_32
575 x86_platform.get_wallclock = efi_get_time; 578 x86_platform.get_wallclock = efi_get_time;
576 x86_platform.set_wallclock = efi_set_rtc_mmss; 579 x86_platform.set_wallclock = efi_set_rtc_mmss;
577 #endif 580 #endif
578 581
579 #if EFI_DEBUG 582 #if EFI_DEBUG
580 print_efi_memmap(); 583 print_efi_memmap();
581 #endif 584 #endif
582 } 585 }
583 586
584 void __init efi_set_executable(efi_memory_desc_t *md, bool executable) 587 void __init efi_set_executable(efi_memory_desc_t *md, bool executable)
585 { 588 {
586 u64 addr, npages; 589 u64 addr, npages;
587 590
588 addr = md->virt_addr; 591 addr = md->virt_addr;
589 npages = md->num_pages; 592 npages = md->num_pages;
590 593
591 memrange_efi_to_native(&addr, &npages); 594 memrange_efi_to_native(&addr, &npages);
592 595
593 if (executable) 596 if (executable)
594 set_memory_x(addr, npages); 597 set_memory_x(addr, npages);
595 else 598 else
596 set_memory_nx(addr, npages); 599 set_memory_nx(addr, npages);
597 } 600 }
598 601
599 static void __init runtime_code_page_mkexec(void) 602 static void __init runtime_code_page_mkexec(void)
600 { 603 {
601 efi_memory_desc_t *md; 604 efi_memory_desc_t *md;
602 void *p; 605 void *p;
603 606
604 /* Make EFI runtime service code area executable */ 607 /* Make EFI runtime service code area executable */
605 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { 608 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
606 md = p; 609 md = p;
607 610
608 if (md->type != EFI_RUNTIME_SERVICES_CODE) 611 if (md->type != EFI_RUNTIME_SERVICES_CODE)
609 continue; 612 continue;
610 613
611 efi_set_executable(md, true); 614 efi_set_executable(md, true);
612 } 615 }
613 } 616 }
614 617
615 /* 618 /*
616 * This function will switch the EFI runtime services to virtual mode. 619 * This function will switch the EFI runtime services to virtual mode.
617 * Essentially, look through the EFI memmap and map every region that 620 * Essentially, look through the EFI memmap and map every region that
618 * has the runtime attribute bit set in its memory descriptor and update 621 * has the runtime attribute bit set in its memory descriptor and update
619 * that memory descriptor with the virtual address obtained from ioremap(). 622 * that memory descriptor with the virtual address obtained from ioremap().
620 * This enables the runtime services to be called without having to 623 * This enables the runtime services to be called without having to
621 * thunk back into physical mode for every invocation. 624 * thunk back into physical mode for every invocation.
622 */ 625 */
623 void __init efi_enter_virtual_mode(void) 626 void __init efi_enter_virtual_mode(void)
624 { 627 {
625 efi_memory_desc_t *md, *prev_md = NULL; 628 efi_memory_desc_t *md, *prev_md = NULL;
626 efi_status_t status; 629 efi_status_t status;
627 unsigned long size; 630 unsigned long size;
628 u64 end, systab, addr, npages, end_pfn; 631 u64 end, systab, addr, npages, end_pfn;
629 void *p, *va, *new_memmap = NULL; 632 void *p, *va, *new_memmap = NULL;
630 int count = 0; 633 int count = 0;
631 634
632 efi.systab = NULL; 635 efi.systab = NULL;
633 636
634 /* Merge contiguous regions of the same type and attribute */ 637 /* Merge contiguous regions of the same type and attribute */
635 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { 638 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
636 u64 prev_size; 639 u64 prev_size;
637 md = p; 640 md = p;
638 641
639 if (!prev_md) { 642 if (!prev_md) {
640 prev_md = md; 643 prev_md = md;
641 continue; 644 continue;
642 } 645 }
643 646
644 if (prev_md->type != md->type || 647 if (prev_md->type != md->type ||
645 prev_md->attribute != md->attribute) { 648 prev_md->attribute != md->attribute) {
646 prev_md = md; 649 prev_md = md;
647 continue; 650 continue;
648 } 651 }
649 652
650 prev_size = prev_md->num_pages << EFI_PAGE_SHIFT; 653 prev_size = prev_md->num_pages << EFI_PAGE_SHIFT;
651 654
652 if (md->phys_addr == (prev_md->phys_addr + prev_size)) { 655 if (md->phys_addr == (prev_md->phys_addr + prev_size)) {
653 prev_md->num_pages += md->num_pages; 656 prev_md->num_pages += md->num_pages;
654 md->type = EFI_RESERVED_TYPE; 657 md->type = EFI_RESERVED_TYPE;
655 md->attribute = 0; 658 md->attribute = 0;
656 continue; 659 continue;
657 } 660 }
658 prev_md = md; 661 prev_md = md;
659 } 662 }
660 663
661 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { 664 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
662 md = p; 665 md = p;
663 if (!(md->attribute & EFI_MEMORY_RUNTIME) && 666 if (!(md->attribute & EFI_MEMORY_RUNTIME) &&
664 md->type != EFI_BOOT_SERVICES_CODE && 667 md->type != EFI_BOOT_SERVICES_CODE &&
665 md->type != EFI_BOOT_SERVICES_DATA) 668 md->type != EFI_BOOT_SERVICES_DATA)
666 continue; 669 continue;
667 670
668 size = md->num_pages << EFI_PAGE_SHIFT; 671 size = md->num_pages << EFI_PAGE_SHIFT;
669 end = md->phys_addr + size; 672 end = md->phys_addr + size;
670 673
671 end_pfn = PFN_UP(end); 674 end_pfn = PFN_UP(end);
672 if (end_pfn <= max_low_pfn_mapped 675 if (end_pfn <= max_low_pfn_mapped
673 || (end_pfn > (1UL << (32 - PAGE_SHIFT)) 676 || (end_pfn > (1UL << (32 - PAGE_SHIFT))
674 && end_pfn <= max_pfn_mapped)) 677 && end_pfn <= max_pfn_mapped)) {
675 va = __va(md->phys_addr); 678 va = __va(md->phys_addr);
676 else
677 va = efi_ioremap(md->phys_addr, size, md->type);
678 679
680 if (!(md->attribute & EFI_MEMORY_WB)) {
681 addr = (u64) (unsigned long)va;
682 npages = md->num_pages;
683 memrange_efi_to_native(&addr, &npages);
684 set_memory_uc(addr, npages);
685 }
686 } else {
687 if (!(md->attribute & EFI_MEMORY_WB))
688 va = ioremap_nocache(md->phys_addr, size);
689 else
690 va = ioremap_cache(md->phys_addr, size);
691 }
692
679 md->virt_addr = (u64) (unsigned long) va; 693 md->virt_addr = (u64) (unsigned long) va;
680 694
681 if (!va) { 695 if (!va) {
682 printk(KERN_ERR PFX "ioremap of 0x%llX failed!\n", 696 printk(KERN_ERR PFX "ioremap of 0x%llX failed!\n",
683 (unsigned long long)md->phys_addr); 697 (unsigned long long)md->phys_addr);
684 continue; 698 continue;
685 }
686
687 if (!(md->attribute & EFI_MEMORY_WB)) {
688 addr = md->virt_addr;
689 npages = md->num_pages;
690 memrange_efi_to_native(&addr, &npages);
691 set_memory_uc(addr, npages);
692 } 699 }
693 700
694 systab = (u64) (unsigned long) efi_phys.systab; 701 systab = (u64) (unsigned long) efi_phys.systab;
695 if (md->phys_addr <= systab && systab < end) { 702 if (md->phys_addr <= systab && systab < end) {
696 systab += md->virt_addr - md->phys_addr; 703 systab += md->virt_addr - md->phys_addr;
697 efi.systab = (efi_system_table_t *) (unsigned long) systab; 704 efi.systab = (efi_system_table_t *) (unsigned long) systab;
698 } 705 }
699 new_memmap = krealloc(new_memmap, 706 new_memmap = krealloc(new_memmap,
700 (count + 1) * memmap.desc_size, 707 (count + 1) * memmap.desc_size,
701 GFP_KERNEL); 708 GFP_KERNEL);
702 memcpy(new_memmap + (count * memmap.desc_size), md, 709 memcpy(new_memmap + (count * memmap.desc_size), md,
703 memmap.desc_size); 710 memmap.desc_size);
704 count++; 711 count++;
705 } 712 }
706 713
707 BUG_ON(!efi.systab); 714 BUG_ON(!efi.systab);
708 715
709 status = phys_efi_set_virtual_address_map( 716 status = phys_efi_set_virtual_address_map(
710 memmap.desc_size * count, 717 memmap.desc_size * count,
711 memmap.desc_size, 718 memmap.desc_size,
712 memmap.desc_version, 719 memmap.desc_version,
713 (efi_memory_desc_t *)__pa(new_memmap)); 720 (efi_memory_desc_t *)__pa(new_memmap));
714 721
715 if (status != EFI_SUCCESS) { 722 if (status != EFI_SUCCESS) {
716 printk(KERN_ALERT "Unable to switch EFI into virtual mode " 723 printk(KERN_ALERT "Unable to switch EFI into virtual mode "
717 "(status=%lx)!\n", status); 724 "(status=%lx)!\n", status);
718 panic("EFI call to SetVirtualAddressMap() failed!"); 725 panic("EFI call to SetVirtualAddressMap() failed!");
719 } 726 }
720 727
721 /* 728 /*
722 * Thankfully, it does seem that no runtime services other than 729 * Thankfully, it does seem that no runtime services other than
723 * SetVirtualAddressMap() will touch boot services code, so we can 730 * SetVirtualAddressMap() will touch boot services code, so we can
724 * get rid of it all at this point 731 * get rid of it all at this point
725 */ 732 */
726 efi_free_boot_services(); 733 efi_free_boot_services();
727 734
728 /* 735 /*
729 * Now that EFI is in virtual mode, update the function 736 * Now that EFI is in virtual mode, update the function
730 * pointers in the runtime service table to the new virtual addresses. 737 * pointers in the runtime service table to the new virtual addresses.
731 * 738 *
732 * Call EFI services through wrapper functions. 739 * Call EFI services through wrapper functions.
733 */ 740 */
734 efi.get_time = virt_efi_get_time; 741 efi.get_time = virt_efi_get_time;
735 efi.set_time = virt_efi_set_time; 742 efi.set_time = virt_efi_set_time;
736 efi.get_wakeup_time = virt_efi_get_wakeup_time; 743 efi.get_wakeup_time = virt_efi_get_wakeup_time;
737 efi.set_wakeup_time = virt_efi_set_wakeup_time; 744 efi.set_wakeup_time = virt_efi_set_wakeup_time;
738 efi.get_variable = virt_efi_get_variable; 745 efi.get_variable = virt_efi_get_variable;
739 efi.get_next_variable = virt_efi_get_next_variable; 746 efi.get_next_variable = virt_efi_get_next_variable;
740 efi.set_variable = virt_efi_set_variable; 747 efi.set_variable = virt_efi_set_variable;
741 efi.get_next_high_mono_count = virt_efi_get_next_high_mono_count; 748 efi.get_next_high_mono_count = virt_efi_get_next_high_mono_count;
742 efi.reset_system = virt_efi_reset_system; 749 efi.reset_system = virt_efi_reset_system;
743 efi.set_virtual_address_map = NULL; 750 efi.set_virtual_address_map = NULL;
744 efi.query_variable_info = virt_efi_query_variable_info; 751 efi.query_variable_info = virt_efi_query_variable_info;
745 efi.update_capsule = virt_efi_update_capsule; 752 efi.update_capsule = virt_efi_update_capsule;
746 efi.query_capsule_caps = virt_efi_query_capsule_caps; 753 efi.query_capsule_caps = virt_efi_query_capsule_caps;
747 if (__supported_pte_mask & _PAGE_NX) 754 if (__supported_pte_mask & _PAGE_NX)
748 runtime_code_page_mkexec(); 755 runtime_code_page_mkexec();
749 early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size); 756 early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size);
750 memmap.map = NULL; 757 memmap.map = NULL;
751 kfree(new_memmap); 758 kfree(new_memmap);
752 } 759 }
753 760
754 /* 761 /*
755 * Convenience functions to obtain memory types and attributes 762 * Convenience functions to obtain memory types and attributes
756 */ 763 */
757 u32 efi_mem_type(unsigned long phys_addr) 764 u32 efi_mem_type(unsigned long phys_addr)
758 { 765 {
759 efi_memory_desc_t *md; 766 efi_memory_desc_t *md;
760 void *p; 767 void *p;
761 768
762 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { 769 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
763 md = p; 770 md = p;
764 if ((md->phys_addr <= phys_addr) && 771 if ((md->phys_addr <= phys_addr) &&
765 (phys_addr < (md->phys_addr + 772 (phys_addr < (md->phys_addr +
766 (md->num_pages << EFI_PAGE_SHIFT)))) 773 (md->num_pages << EFI_PAGE_SHIFT))))
767 return md->type; 774 return md->type;
768 } 775 }
769 return 0; 776 return 0;
770 } 777 }
771 778
772 u64 efi_mem_attributes(unsigned long phys_addr) 779 u64 efi_mem_attributes(unsigned long phys_addr)
773 { 780 {
774 efi_memory_desc_t *md; 781 efi_memory_desc_t *md;
775 void *p; 782 void *p;
776 783
777 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { 784 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
arch/x86/platform/efi/efi_64.c
1 /* 1 /*
2 * x86_64 specific EFI support functions 2 * x86_64 specific EFI support functions
3 * Based on Extensible Firmware Interface Specification version 1.0 3 * Based on Extensible Firmware Interface Specification version 1.0
4 * 4 *
5 * Copyright (C) 2005-2008 Intel Co. 5 * Copyright (C) 2005-2008 Intel Co.
6 * Fenghua Yu <fenghua.yu@intel.com> 6 * Fenghua Yu <fenghua.yu@intel.com>
7 * Bibo Mao <bibo.mao@intel.com> 7 * Bibo Mao <bibo.mao@intel.com>
8 * Chandramouli Narayanan <mouli@linux.intel.com> 8 * Chandramouli Narayanan <mouli@linux.intel.com>
9 * Huang Ying <ying.huang@intel.com> 9 * Huang Ying <ying.huang@intel.com>
10 * 10 *
11 * Code to convert EFI to E820 map has been implemented in elilo bootloader 11 * Code to convert EFI to E820 map has been implemented in elilo bootloader
12 * based on a EFI patch by Edgar Hucek. Based on the E820 map, the page table 12 * based on a EFI patch by Edgar Hucek. Based on the E820 map, the page table
13 * is setup appropriately for EFI runtime code. 13 * is setup appropriately for EFI runtime code.
14 * - mouli 06/14/2007. 14 * - mouli 06/14/2007.
15 * 15 *
16 */ 16 */
17 17
18 #include <linux/kernel.h> 18 #include <linux/kernel.h>
19 #include <linux/init.h> 19 #include <linux/init.h>
20 #include <linux/mm.h> 20 #include <linux/mm.h>
21 #include <linux/types.h> 21 #include <linux/types.h>
22 #include <linux/spinlock.h> 22 #include <linux/spinlock.h>
23 #include <linux/bootmem.h> 23 #include <linux/bootmem.h>
24 #include <linux/ioport.h> 24 #include <linux/ioport.h>
25 #include <linux/module.h> 25 #include <linux/module.h>
26 #include <linux/efi.h> 26 #include <linux/efi.h>
27 #include <linux/uaccess.h> 27 #include <linux/uaccess.h>
28 #include <linux/io.h> 28 #include <linux/io.h>
29 #include <linux/reboot.h> 29 #include <linux/reboot.h>
30 30
31 #include <asm/setup.h> 31 #include <asm/setup.h>
32 #include <asm/page.h> 32 #include <asm/page.h>
33 #include <asm/e820.h> 33 #include <asm/e820.h>
34 #include <asm/pgtable.h> 34 #include <asm/pgtable.h>
35 #include <asm/tlbflush.h> 35 #include <asm/tlbflush.h>
36 #include <asm/proto.h> 36 #include <asm/proto.h>
37 #include <asm/efi.h> 37 #include <asm/efi.h>
38 #include <asm/cacheflush.h> 38 #include <asm/cacheflush.h>
39 #include <asm/fixmap.h> 39 #include <asm/fixmap.h>
40 40
41 static pgd_t save_pgd __initdata; 41 static pgd_t save_pgd __initdata;
42 static unsigned long efi_flags __initdata; 42 static unsigned long efi_flags __initdata;
43 43
44 static void __init early_code_mapping_set_exec(int executable) 44 static void __init early_code_mapping_set_exec(int executable)
45 { 45 {
46 efi_memory_desc_t *md; 46 efi_memory_desc_t *md;
47 void *p; 47 void *p;
48 48
49 if (!(__supported_pte_mask & _PAGE_NX)) 49 if (!(__supported_pte_mask & _PAGE_NX))
50 return; 50 return;
51 51
52 /* Make EFI service code area executable */ 52 /* Make EFI service code area executable */
53 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { 53 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
54 md = p; 54 md = p;
55 if (md->type == EFI_RUNTIME_SERVICES_CODE || 55 if (md->type == EFI_RUNTIME_SERVICES_CODE ||
56 md->type == EFI_BOOT_SERVICES_CODE) 56 md->type == EFI_BOOT_SERVICES_CODE)
57 efi_set_executable(md, executable); 57 efi_set_executable(md, executable);
58 } 58 }
59 } 59 }
60 60
61 void __init efi_call_phys_prelog(void) 61 void __init efi_call_phys_prelog(void)
62 { 62 {
63 unsigned long vaddress; 63 unsigned long vaddress;
64 64
65 early_code_mapping_set_exec(1); 65 early_code_mapping_set_exec(1);
66 local_irq_save(efi_flags); 66 local_irq_save(efi_flags);
67 vaddress = (unsigned long)__va(0x0UL); 67 vaddress = (unsigned long)__va(0x0UL);
68 save_pgd = *pgd_offset_k(0x0UL); 68 save_pgd = *pgd_offset_k(0x0UL);
69 set_pgd(pgd_offset_k(0x0UL), *pgd_offset_k(vaddress)); 69 set_pgd(pgd_offset_k(0x0UL), *pgd_offset_k(vaddress));
70 __flush_tlb_all(); 70 __flush_tlb_all();
71 } 71 }
72 72
73 void __init efi_call_phys_epilog(void) 73 void __init efi_call_phys_epilog(void)
74 { 74 {
75 /* 75 /*
76 * After the lock is released, the original page table is restored. 76 * After the lock is released, the original page table is restored.
77 */ 77 */
78 set_pgd(pgd_offset_k(0x0UL), save_pgd); 78 set_pgd(pgd_offset_k(0x0UL), save_pgd);
79 __flush_tlb_all(); 79 __flush_tlb_all();
80 local_irq_restore(efi_flags); 80 local_irq_restore(efi_flags);
81 early_code_mapping_set_exec(0); 81 early_code_mapping_set_exec(0);
82 } 82 }
83
84 void __iomem *__init efi_ioremap(unsigned long phys_addr, unsigned long size,
85 u32 type)
86 {
87 unsigned long last_map_pfn;
88
89 if (type == EFI_MEMORY_MAPPED_IO)
90 return ioremap(phys_addr, size);
91
92 last_map_pfn = init_memory_mapping(phys_addr, phys_addr + size);
93 if ((last_map_pfn << PAGE_SHIFT) < phys_addr + size) {
94 unsigned long top = last_map_pfn << PAGE_SHIFT;
95 efi_ioremap(top, size - (top - phys_addr), type);
96 }
97
98 return (void __iomem *)__va(phys_addr);
99 }
100 83