subcore-asm.S 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright 2013, Michael (Ellerman|Neuling), IBM Corporation.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. #include <asm/asm-offsets.h>
  10. #include <asm/ppc_asm.h>
  11. #include <asm/reg.h>
  12. #include "subcore.h"
  13. _GLOBAL(split_core_secondary_loop)
  14. /*
  15. * r3 = u8 *state, used throughout the routine
  16. * r4 = temp
  17. * r5 = temp
  18. * ..
  19. * r12 = MSR
  20. */
  21. mfmsr r12
  22. /* Disable interrupts so SRR0/1 don't get trashed */
  23. li r4,0
  24. ori r4,r4,MSR_EE|MSR_SE|MSR_BE|MSR_RI
  25. andc r4,r12,r4
  26. sync
  27. mtmsrd r4
  28. /* Switch to real mode and leave interrupts off */
  29. li r5, MSR_IR|MSR_DR
  30. andc r5, r4, r5
  31. LOAD_REG_ADDR(r4, real_mode)
  32. mtspr SPRN_SRR0,r4
  33. mtspr SPRN_SRR1,r5
  34. rfid
  35. b . /* prevent speculative execution */
  36. real_mode:
  37. /* Grab values from unsplit SPRs */
  38. mfspr r6, SPRN_LDBAR
  39. mfspr r7, SPRN_PMMAR
  40. mfspr r8, SPRN_PMCR
  41. mfspr r9, SPRN_RPR
  42. mfspr r10, SPRN_SDR1
  43. /* Order reading the SPRs vs telling the primary we are ready to split */
  44. sync
  45. /* Tell thread 0 we are in real mode */
  46. li r4, SYNC_STEP_REAL_MODE
  47. stb r4, 0(r3)
  48. li r5, (HID0_POWER8_4LPARMODE | HID0_POWER8_2LPARMODE)@highest
  49. sldi r5, r5, 48
  50. /* Loop until we see the split happen in HID0 */
  51. 1: mfspr r4, SPRN_HID0
  52. and. r4, r4, r5
  53. beq 1b
  54. /*
  55. * We only need to initialise the below regs once for each subcore,
  56. * but it's simpler and harmless to do it on each thread.
  57. */
  58. /* Make sure various SPRS have sane values */
  59. li r4, 0
  60. mtspr SPRN_LPID, r4
  61. mtspr SPRN_PCR, r4
  62. mtspr SPRN_HDEC, r4
  63. /* Restore SPR values now we are split */
  64. mtspr SPRN_LDBAR, r6
  65. mtspr SPRN_PMMAR, r7
  66. mtspr SPRN_PMCR, r8
  67. mtspr SPRN_RPR, r9
  68. mtspr SPRN_SDR1, r10
  69. LOAD_REG_ADDR(r5, virtual_mode)
  70. /* Get out of real mode */
  71. mtspr SPRN_SRR0,r5
  72. mtspr SPRN_SRR1,r12
  73. rfid
  74. b . /* prevent speculative execution */
  75. virtual_mode:
  76. blr