setup_64.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. /*
  2. *
  3. * Common boot and setup code.
  4. *
  5. * Copyright (C) 2001 PPC64 Team, IBM Corp
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. */
  12. #define DEBUG
  13. #include <linux/export.h>
  14. #include <linux/string.h>
  15. #include <linux/sched.h>
  16. #include <linux/init.h>
  17. #include <linux/kernel.h>
  18. #include <linux/reboot.h>
  19. #include <linux/delay.h>
  20. #include <linux/initrd.h>
  21. #include <linux/seq_file.h>
  22. #include <linux/ioport.h>
  23. #include <linux/console.h>
  24. #include <linux/utsname.h>
  25. #include <linux/tty.h>
  26. #include <linux/root_dev.h>
  27. #include <linux/notifier.h>
  28. #include <linux/cpu.h>
  29. #include <linux/unistd.h>
  30. #include <linux/serial.h>
  31. #include <linux/serial_8250.h>
  32. #include <linux/bootmem.h>
  33. #include <linux/pci.h>
  34. #include <linux/lockdep.h>
  35. #include <linux/memblock.h>
  36. #include <linux/memory.h>
  37. #include <linux/nmi.h>
  38. #include <asm/io.h>
  39. #include <asm/kdump.h>
  40. #include <asm/prom.h>
  41. #include <asm/processor.h>
  42. #include <asm/pgtable.h>
  43. #include <asm/smp.h>
  44. #include <asm/elf.h>
  45. #include <asm/machdep.h>
  46. #include <asm/paca.h>
  47. #include <asm/time.h>
  48. #include <asm/cputable.h>
  49. #include <asm/sections.h>
  50. #include <asm/btext.h>
  51. #include <asm/nvram.h>
  52. #include <asm/setup.h>
  53. #include <asm/rtas.h>
  54. #include <asm/iommu.h>
  55. #include <asm/serial.h>
  56. #include <asm/cache.h>
  57. #include <asm/page.h>
  58. #include <asm/mmu.h>
  59. #include <asm/firmware.h>
  60. #include <asm/xmon.h>
  61. #include <asm/udbg.h>
  62. #include <asm/kexec.h>
  63. #include <asm/code-patching.h>
  64. #include <asm/livepatch.h>
  65. #include <asm/opal.h>
  66. #include <asm/cputhreads.h>
  67. #ifdef DEBUG
  68. #define DBG(fmt...) udbg_printf(fmt)
  69. #else
  70. #define DBG(fmt...)
  71. #endif
  72. int spinning_secondaries;
  73. u64 ppc64_pft_size;
  74. /* Pick defaults since we might want to patch instructions
  75. * before we've read this from the device tree.
  76. */
  77. struct ppc64_caches ppc64_caches = {
  78. .dline_size = 0x40,
  79. .log_dline_size = 6,
  80. .iline_size = 0x40,
  81. .log_iline_size = 6
  82. };
  83. EXPORT_SYMBOL_GPL(ppc64_caches);
  84. /*
  85. * These are used in binfmt_elf.c to put aux entries on the stack
  86. * for each elf executable being started.
  87. */
  88. int dcache_bsize;
  89. int icache_bsize;
  90. int ucache_bsize;
  91. #if defined(CONFIG_PPC_BOOK3E) && defined(CONFIG_SMP)
  92. void __init setup_tlb_core_data(void)
  93. {
  94. int cpu;
  95. BUILD_BUG_ON(offsetof(struct tlb_core_data, lock) != 0);
  96. for_each_possible_cpu(cpu) {
  97. int first = cpu_first_thread_sibling(cpu);
  98. /*
  99. * If we boot via kdump on a non-primary thread,
  100. * make sure we point at the thread that actually
  101. * set up this TLB.
  102. */
  103. if (cpu_first_thread_sibling(boot_cpuid) == first)
  104. first = boot_cpuid;
  105. paca[cpu].tcd_ptr = &paca[first].tcd;
  106. /*
  107. * If we have threads, we need either tlbsrx.
  108. * or e6500 tablewalk mode, or else TLB handlers
  109. * will be racy and could produce duplicate entries.
  110. */
  111. if (smt_enabled_at_boot >= 2 &&
  112. !mmu_has_feature(MMU_FTR_USE_TLBRSRV) &&
  113. book3e_htw_mode != PPC_HTW_E6500) {
  114. /* Should we panic instead? */
  115. WARN_ONCE("%s: unsupported MMU configuration -- expect problems\n",
  116. __func__);
  117. }
  118. }
  119. }
  120. #endif
  121. #ifdef CONFIG_SMP
  122. static char *smt_enabled_cmdline;
  123. /* Look for ibm,smt-enabled OF option */
  124. void __init check_smt_enabled(void)
  125. {
  126. struct device_node *dn;
  127. const char *smt_option;
  128. /* Default to enabling all threads */
  129. smt_enabled_at_boot = threads_per_core;
  130. /* Allow the command line to overrule the OF option */
  131. if (smt_enabled_cmdline) {
  132. if (!strcmp(smt_enabled_cmdline, "on"))
  133. smt_enabled_at_boot = threads_per_core;
  134. else if (!strcmp(smt_enabled_cmdline, "off"))
  135. smt_enabled_at_boot = 0;
  136. else {
  137. int smt;
  138. int rc;
  139. rc = kstrtoint(smt_enabled_cmdline, 10, &smt);
  140. if (!rc)
  141. smt_enabled_at_boot =
  142. min(threads_per_core, smt);
  143. }
  144. } else {
  145. dn = of_find_node_by_path("/options");
  146. if (dn) {
  147. smt_option = of_get_property(dn, "ibm,smt-enabled",
  148. NULL);
  149. if (smt_option) {
  150. if (!strcmp(smt_option, "on"))
  151. smt_enabled_at_boot = threads_per_core;
  152. else if (!strcmp(smt_option, "off"))
  153. smt_enabled_at_boot = 0;
  154. }
  155. of_node_put(dn);
  156. }
  157. }
  158. }
  159. /* Look for smt-enabled= cmdline option */
  160. static int __init early_smt_enabled(char *p)
  161. {
  162. smt_enabled_cmdline = p;
  163. return 0;
  164. }
  165. early_param("smt-enabled", early_smt_enabled);
  166. #endif /* CONFIG_SMP */
  167. /** Fix up paca fields required for the boot cpu */
  168. static void __init fixup_boot_paca(void)
  169. {
  170. /* The boot cpu is started */
  171. get_paca()->cpu_start = 1;
  172. /* Allow percpu accesses to work until we setup percpu data */
  173. get_paca()->data_offset = 0;
  174. }
  175. static void __init configure_exceptions(void)
  176. {
  177. /*
  178. * Setup the trampolines from the lowmem exception vectors
  179. * to the kdump kernel when not using a relocatable kernel.
  180. */
  181. setup_kdump_trampoline();
  182. /* Under a PAPR hypervisor, we need hypercalls */
  183. if (firmware_has_feature(FW_FEATURE_SET_MODE)) {
  184. /* Enable AIL if possible */
  185. pseries_enable_reloc_on_exc();
  186. /*
  187. * Tell the hypervisor that we want our exceptions to
  188. * be taken in little endian mode.
  189. *
  190. * We don't call this for big endian as our calling convention
  191. * makes us always enter in BE, and the call may fail under
  192. * some circumstances with kdump.
  193. */
  194. #ifdef __LITTLE_ENDIAN__
  195. pseries_little_endian_exceptions();
  196. #endif
  197. } else {
  198. /* Set endian mode using OPAL */
  199. if (firmware_has_feature(FW_FEATURE_OPAL))
  200. opal_configure_cores();
  201. /* AIL on native is done in cpu_ready_for_interrupts() */
  202. }
  203. }
  204. static void cpu_ready_for_interrupts(void)
  205. {
  206. /*
  207. * Enable AIL if supported, and we are in hypervisor mode. This
  208. * is called once for every processor.
  209. *
  210. * If we are not in hypervisor mode the job is done once for
  211. * the whole partition in configure_exceptions().
  212. */
  213. if (early_cpu_has_feature(CPU_FTR_HVMODE) &&
  214. early_cpu_has_feature(CPU_FTR_ARCH_207S)) {
  215. unsigned long lpcr = mfspr(SPRN_LPCR);
  216. mtspr(SPRN_LPCR, lpcr | LPCR_AIL_3);
  217. }
  218. /*
  219. * Fixup HFSCR:TM based on CPU features. The bit is set by our
  220. * early asm init because at that point we haven't updated our
  221. * CPU features from firmware and device-tree. Here we have,
  222. * so let's do it.
  223. */
  224. if (cpu_has_feature(CPU_FTR_HVMODE) && !cpu_has_feature(CPU_FTR_TM_COMP))
  225. mtspr(SPRN_HFSCR, mfspr(SPRN_HFSCR) & ~HFSCR_TM);
  226. /* Set IR and DR in PACA MSR */
  227. get_paca()->kernel_msr = MSR_KERNEL;
  228. }
  229. /*
  230. * Early initialization entry point. This is called by head.S
  231. * with MMU translation disabled. We rely on the "feature" of
  232. * the CPU that ignores the top 2 bits of the address in real
  233. * mode so we can access kernel globals normally provided we
  234. * only toy with things in the RMO region. From here, we do
  235. * some early parsing of the device-tree to setup out MEMBLOCK
  236. * data structures, and allocate & initialize the hash table
  237. * and segment tables so we can start running with translation
  238. * enabled.
  239. *
  240. * It is this function which will call the probe() callback of
  241. * the various platform types and copy the matching one to the
  242. * global ppc_md structure. Your platform can eventually do
  243. * some very early initializations from the probe() routine, but
  244. * this is not recommended, be very careful as, for example, the
  245. * device-tree is not accessible via normal means at this point.
  246. */
  247. void __init early_setup(unsigned long dt_ptr)
  248. {
  249. static __initdata struct paca_struct boot_paca;
  250. /* -------- printk is _NOT_ safe to use here ! ------- */
  251. /* Identify CPU type */
  252. identify_cpu(0, mfspr(SPRN_PVR));
  253. /* Assume we're on cpu 0 for now. Don't write to the paca yet! */
  254. initialise_paca(&boot_paca, 0);
  255. setup_paca(&boot_paca);
  256. fixup_boot_paca();
  257. /* -------- printk is now safe to use ------- */
  258. /* Enable early debugging if any specified (see udbg.h) */
  259. udbg_early_init();
  260. DBG(" -> early_setup(), dt_ptr: 0x%lx\n", dt_ptr);
  261. /*
  262. * Do early initialization using the flattened device
  263. * tree, such as retrieving the physical memory map or
  264. * calculating/retrieving the hash table size.
  265. */
  266. early_init_devtree(__va(dt_ptr));
  267. /* Now we know the logical id of our boot cpu, setup the paca. */
  268. setup_paca(&paca[boot_cpuid]);
  269. fixup_boot_paca();
  270. /*
  271. * Configure exception handlers. This include setting up trampolines
  272. * if needed, setting exception endian mode, etc...
  273. */
  274. configure_exceptions();
  275. /* Apply all the dynamic patching */
  276. apply_feature_fixups();
  277. setup_feature_keys();
  278. /* Initialize the hash table or TLB handling */
  279. early_init_mmu();
  280. /*
  281. * At this point, we can let interrupts switch to virtual mode
  282. * (the MMU has been setup), so adjust the MSR in the PACA to
  283. * have IR and DR set and enable AIL if it exists
  284. */
  285. cpu_ready_for_interrupts();
  286. DBG(" <- early_setup()\n");
  287. #ifdef CONFIG_PPC_EARLY_DEBUG_BOOTX
  288. /*
  289. * This needs to be done *last* (after the above DBG() even)
  290. *
  291. * Right after we return from this function, we turn on the MMU
  292. * which means the real-mode access trick that btext does will
  293. * no longer work, it needs to switch to using a real MMU
  294. * mapping. This call will ensure that it does
  295. */
  296. btext_map();
  297. #endif /* CONFIG_PPC_EARLY_DEBUG_BOOTX */
  298. }
  299. #ifdef CONFIG_SMP
  300. void early_setup_secondary(void)
  301. {
  302. /* Mark interrupts disabled in PACA */
  303. get_paca()->soft_enabled = 0;
  304. /* Initialize the hash table or TLB handling */
  305. early_init_mmu_secondary();
  306. /*
  307. * At this point, we can let interrupts switch to virtual mode
  308. * (the MMU has been setup), so adjust the MSR in the PACA to
  309. * have IR and DR set.
  310. */
  311. cpu_ready_for_interrupts();
  312. }
  313. #endif /* CONFIG_SMP */
  314. #if defined(CONFIG_SMP) || defined(CONFIG_KEXEC)
  315. static bool use_spinloop(void)
  316. {
  317. if (!IS_ENABLED(CONFIG_PPC_BOOK3E))
  318. return true;
  319. /*
  320. * When book3e boots from kexec, the ePAPR spin table does
  321. * not get used.
  322. */
  323. return of_property_read_bool(of_chosen, "linux,booted-from-kexec");
  324. }
  325. void smp_release_cpus(void)
  326. {
  327. unsigned long *ptr;
  328. int i;
  329. if (!use_spinloop())
  330. return;
  331. DBG(" -> smp_release_cpus()\n");
  332. /* All secondary cpus are spinning on a common spinloop, release them
  333. * all now so they can start to spin on their individual paca
  334. * spinloops. For non SMP kernels, the secondary cpus never get out
  335. * of the common spinloop.
  336. */
  337. ptr = (unsigned long *)((unsigned long)&__secondary_hold_spinloop
  338. - PHYSICAL_START);
  339. *ptr = ppc_function_entry(generic_secondary_smp_init);
  340. /* And wait a bit for them to catch up */
  341. for (i = 0; i < 100000; i++) {
  342. mb();
  343. HMT_low();
  344. if (spinning_secondaries == 0)
  345. break;
  346. udelay(1);
  347. }
  348. DBG("spinning_secondaries = %d\n", spinning_secondaries);
  349. DBG(" <- smp_release_cpus()\n");
  350. }
  351. #endif /* CONFIG_SMP || CONFIG_KEXEC */
  352. /*
  353. * Initialize some remaining members of the ppc64_caches and systemcfg
  354. * structures
  355. * (at least until we get rid of them completely). This is mostly some
  356. * cache informations about the CPU that will be used by cache flush
  357. * routines and/or provided to userland
  358. */
  359. void __init initialize_cache_info(void)
  360. {
  361. struct device_node *np;
  362. unsigned long num_cpus = 0;
  363. DBG(" -> initialize_cache_info()\n");
  364. for_each_node_by_type(np, "cpu") {
  365. num_cpus += 1;
  366. /*
  367. * We're assuming *all* of the CPUs have the same
  368. * d-cache and i-cache sizes... -Peter
  369. */
  370. if (num_cpus == 1) {
  371. const __be32 *sizep, *lsizep;
  372. u32 size, lsize;
  373. size = 0;
  374. lsize = cur_cpu_spec->dcache_bsize;
  375. sizep = of_get_property(np, "d-cache-size", NULL);
  376. if (sizep != NULL)
  377. size = be32_to_cpu(*sizep);
  378. lsizep = of_get_property(np, "d-cache-block-size",
  379. NULL);
  380. /* fallback if block size missing */
  381. if (lsizep == NULL)
  382. lsizep = of_get_property(np,
  383. "d-cache-line-size",
  384. NULL);
  385. if (lsizep != NULL)
  386. lsize = be32_to_cpu(*lsizep);
  387. if (sizep == NULL || lsizep == NULL)
  388. DBG("Argh, can't find dcache properties ! "
  389. "sizep: %p, lsizep: %p\n", sizep, lsizep);
  390. ppc64_caches.dsize = size;
  391. ppc64_caches.dline_size = lsize;
  392. ppc64_caches.log_dline_size = __ilog2(lsize);
  393. ppc64_caches.dlines_per_page = PAGE_SIZE / lsize;
  394. size = 0;
  395. lsize = cur_cpu_spec->icache_bsize;
  396. sizep = of_get_property(np, "i-cache-size", NULL);
  397. if (sizep != NULL)
  398. size = be32_to_cpu(*sizep);
  399. lsizep = of_get_property(np, "i-cache-block-size",
  400. NULL);
  401. if (lsizep == NULL)
  402. lsizep = of_get_property(np,
  403. "i-cache-line-size",
  404. NULL);
  405. if (lsizep != NULL)
  406. lsize = be32_to_cpu(*lsizep);
  407. if (sizep == NULL || lsizep == NULL)
  408. DBG("Argh, can't find icache properties ! "
  409. "sizep: %p, lsizep: %p\n", sizep, lsizep);
  410. ppc64_caches.isize = size;
  411. ppc64_caches.iline_size = lsize;
  412. ppc64_caches.log_iline_size = __ilog2(lsize);
  413. ppc64_caches.ilines_per_page = PAGE_SIZE / lsize;
  414. }
  415. }
  416. /* For use by binfmt_elf */
  417. dcache_bsize = ppc64_caches.dline_size;
  418. icache_bsize = ppc64_caches.iline_size;
  419. DBG(" <- initialize_cache_info()\n");
  420. }
  421. /* This returns the limit below which memory accesses to the linear
  422. * mapping are guarnateed not to cause a TLB or SLB miss. This is
  423. * used to allocate interrupt or emergency stacks for which our
  424. * exception entry path doesn't deal with being interrupted.
  425. */
  426. static __init u64 safe_stack_limit(void)
  427. {
  428. #ifdef CONFIG_PPC_BOOK3E
  429. /* Freescale BookE bolts the entire linear mapping */
  430. if (mmu_has_feature(MMU_FTR_TYPE_FSL_E))
  431. return linear_map_top;
  432. /* Other BookE, we assume the first GB is bolted */
  433. return 1ul << 30;
  434. #else
  435. /* BookS, the first segment is bolted */
  436. if (mmu_has_feature(MMU_FTR_1T_SEGMENT))
  437. return 1UL << SID_SHIFT_1T;
  438. return 1UL << SID_SHIFT;
  439. #endif
  440. }
  441. void __init irqstack_early_init(void)
  442. {
  443. u64 limit = safe_stack_limit();
  444. unsigned int i;
  445. /*
  446. * Interrupt stacks must be in the first segment since we
  447. * cannot afford to take SLB misses on them.
  448. */
  449. for_each_possible_cpu(i) {
  450. softirq_ctx[i] = (struct thread_info *)
  451. __va(memblock_alloc_base(THREAD_SIZE,
  452. THREAD_SIZE, limit));
  453. hardirq_ctx[i] = (struct thread_info *)
  454. __va(memblock_alloc_base(THREAD_SIZE,
  455. THREAD_SIZE, limit));
  456. }
  457. }
  458. #ifdef CONFIG_PPC_BOOK3E
  459. void __init exc_lvl_early_init(void)
  460. {
  461. unsigned int i;
  462. unsigned long sp;
  463. for_each_possible_cpu(i) {
  464. sp = memblock_alloc(THREAD_SIZE, THREAD_SIZE);
  465. critirq_ctx[i] = (struct thread_info *)__va(sp);
  466. paca[i].crit_kstack = __va(sp + THREAD_SIZE);
  467. sp = memblock_alloc(THREAD_SIZE, THREAD_SIZE);
  468. dbgirq_ctx[i] = (struct thread_info *)__va(sp);
  469. paca[i].dbg_kstack = __va(sp + THREAD_SIZE);
  470. sp = memblock_alloc(THREAD_SIZE, THREAD_SIZE);
  471. mcheckirq_ctx[i] = (struct thread_info *)__va(sp);
  472. paca[i].mc_kstack = __va(sp + THREAD_SIZE);
  473. }
  474. if (cpu_has_feature(CPU_FTR_DEBUG_LVL_EXC))
  475. patch_exception(0x040, exc_debug_debug_book3e);
  476. }
  477. #endif
  478. /*
  479. * Stack space used when we detect a bad kernel stack pointer, and
  480. * early in SMP boots before relocation is enabled. Exclusive emergency
  481. * stack for machine checks.
  482. */
  483. void __init emergency_stack_init(void)
  484. {
  485. u64 limit;
  486. unsigned int i;
  487. /*
  488. * Emergency stacks must be under 256MB, we cannot afford to take
  489. * SLB misses on them. The ABI also requires them to be 128-byte
  490. * aligned.
  491. *
  492. * Since we use these as temporary stacks during secondary CPU
  493. * bringup, we need to get at them in real mode. This means they
  494. * must also be within the RMO region.
  495. */
  496. limit = min(safe_stack_limit(), ppc64_rma_size);
  497. for_each_possible_cpu(i) {
  498. struct thread_info *ti;
  499. ti = __va(memblock_alloc_base(THREAD_SIZE, THREAD_SIZE, limit));
  500. klp_init_thread_info(ti);
  501. paca[i].emergency_sp = (void *)ti + THREAD_SIZE;
  502. #ifdef CONFIG_PPC_BOOK3S_64
  503. /* emergency stack for machine check exception handling. */
  504. ti = __va(memblock_alloc_base(THREAD_SIZE, THREAD_SIZE, limit));
  505. klp_init_thread_info(ti);
  506. paca[i].mc_emergency_sp = (void *)ti + THREAD_SIZE;
  507. #endif
  508. }
  509. }
  510. #ifdef CONFIG_SMP
  511. #define PCPU_DYN_SIZE ()
  512. static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, size_t align)
  513. {
  514. return __alloc_bootmem_node(NODE_DATA(cpu_to_node(cpu)), size, align,
  515. __pa(MAX_DMA_ADDRESS));
  516. }
  517. static void __init pcpu_fc_free(void *ptr, size_t size)
  518. {
  519. free_bootmem(__pa(ptr), size);
  520. }
  521. static int pcpu_cpu_distance(unsigned int from, unsigned int to)
  522. {
  523. if (cpu_to_node(from) == cpu_to_node(to))
  524. return LOCAL_DISTANCE;
  525. else
  526. return REMOTE_DISTANCE;
  527. }
  528. unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;
  529. EXPORT_SYMBOL(__per_cpu_offset);
  530. void __init setup_per_cpu_areas(void)
  531. {
  532. const size_t dyn_size = PERCPU_MODULE_RESERVE + PERCPU_DYNAMIC_RESERVE;
  533. size_t atom_size;
  534. unsigned long delta;
  535. unsigned int cpu;
  536. int rc;
  537. /*
  538. * Linear mapping is one of 4K, 1M and 16M. For 4K, no need
  539. * to group units. For larger mappings, use 1M atom which
  540. * should be large enough to contain a number of units.
  541. */
  542. if (mmu_linear_psize == MMU_PAGE_4K)
  543. atom_size = PAGE_SIZE;
  544. else
  545. atom_size = 1 << 20;
  546. rc = pcpu_embed_first_chunk(0, dyn_size, atom_size, pcpu_cpu_distance,
  547. pcpu_fc_alloc, pcpu_fc_free);
  548. if (rc < 0)
  549. panic("cannot initialize percpu area (err=%d)", rc);
  550. delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
  551. for_each_possible_cpu(cpu) {
  552. __per_cpu_offset[cpu] = delta + pcpu_unit_offsets[cpu];
  553. paca[cpu].data_offset = __per_cpu_offset[cpu];
  554. }
  555. }
  556. #endif
  557. #ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
  558. unsigned long memory_block_size_bytes(void)
  559. {
  560. if (ppc_md.memory_block_size)
  561. return ppc_md.memory_block_size();
  562. return MIN_MEMORY_BLOCK_SIZE;
  563. }
  564. #endif
  565. #if defined(CONFIG_PPC_INDIRECT_PIO) || defined(CONFIG_PPC_INDIRECT_MMIO)
  566. struct ppc_pci_io ppc_pci_io;
  567. EXPORT_SYMBOL(ppc_pci_io);
  568. #endif
  569. #ifdef CONFIG_HARDLOCKUP_DETECTOR
  570. u64 hw_nmi_get_sample_period(int watchdog_thresh)
  571. {
  572. return ppc_proc_freq * watchdog_thresh;
  573. }
  574. /*
  575. * The hardlockup detector breaks PMU event based branches and is likely
  576. * to get false positives in KVM guests, so disable it by default.
  577. */
  578. static int __init disable_hardlockup_detector(void)
  579. {
  580. hardlockup_detector_disable();
  581. return 0;
  582. }
  583. early_initcall(disable_hardlockup_detector);
  584. #endif