kexec.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * kexec for arm64
  3. *
  4. * Copyright (C) Linaro.
  5. * Copyright (C) Huawei Futurewei Technologies.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef _ARM64_KEXEC_H
  12. #define _ARM64_KEXEC_H
  13. /* Maximum physical address we can use pages from */
  14. #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
  15. /* Maximum address we can reach in physical address mode */
  16. #define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
  17. /* Maximum address we can use for the control code buffer */
  18. #define KEXEC_CONTROL_MEMORY_LIMIT (-1UL)
  19. #define KEXEC_CONTROL_PAGE_SIZE 4096
  20. #define KEXEC_ARCH KEXEC_ARCH_AARCH64
  21. #ifndef __ASSEMBLY__
  22. /**
  23. * crash_setup_regs() - save registers for the panic kernel
  24. *
  25. * @newregs: registers are saved here
  26. * @oldregs: registers to be saved (may be %NULL)
  27. */
  28. static inline void crash_setup_regs(struct pt_regs *newregs,
  29. struct pt_regs *oldregs)
  30. {
  31. if (oldregs) {
  32. memcpy(newregs, oldregs, sizeof(*newregs));
  33. } else {
  34. u64 tmp1, tmp2;
  35. __asm__ __volatile__ (
  36. "stp x0, x1, [%2, #16 * 0]\n"
  37. "stp x2, x3, [%2, #16 * 1]\n"
  38. "stp x4, x5, [%2, #16 * 2]\n"
  39. "stp x6, x7, [%2, #16 * 3]\n"
  40. "stp x8, x9, [%2, #16 * 4]\n"
  41. "stp x10, x11, [%2, #16 * 5]\n"
  42. "stp x12, x13, [%2, #16 * 6]\n"
  43. "stp x14, x15, [%2, #16 * 7]\n"
  44. "stp x16, x17, [%2, #16 * 8]\n"
  45. "stp x18, x19, [%2, #16 * 9]\n"
  46. "stp x20, x21, [%2, #16 * 10]\n"
  47. "stp x22, x23, [%2, #16 * 11]\n"
  48. "stp x24, x25, [%2, #16 * 12]\n"
  49. "stp x26, x27, [%2, #16 * 13]\n"
  50. "stp x28, x29, [%2, #16 * 14]\n"
  51. "mov %0, sp\n"
  52. "stp x30, %0, [%2, #16 * 15]\n"
  53. "/* faked current PSTATE */\n"
  54. "mrs %0, CurrentEL\n"
  55. "mrs %1, SPSEL\n"
  56. "orr %0, %0, %1\n"
  57. "mrs %1, DAIF\n"
  58. "orr %0, %0, %1\n"
  59. "mrs %1, NZCV\n"
  60. "orr %0, %0, %1\n"
  61. /* pc */
  62. "adr %1, 1f\n"
  63. "1:\n"
  64. "stp %1, %0, [%2, #16 * 16]\n"
  65. : "=&r" (tmp1), "=&r" (tmp2)
  66. : "r" (newregs)
  67. : "memory"
  68. );
  69. }
  70. }
  71. #if defined(CONFIG_KEXEC_CORE) && defined(CONFIG_HIBERNATION)
  72. extern bool crash_is_nosave(unsigned long pfn);
  73. extern void crash_prepare_suspend(void);
  74. extern void crash_post_resume(void);
  75. #else
  76. static inline bool crash_is_nosave(unsigned long pfn) {return false; }
  77. static inline void crash_prepare_suspend(void) {}
  78. static inline void crash_post_resume(void) {}
  79. #endif
  80. #endif /* __ASSEMBLY__ */
  81. #endif