kexec.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef _I386_KEXEC_H
  2. #define _I386_KEXEC_H
  3. #include <asm/fixmap.h>
  4. #include <asm/ptrace.h>
  5. #include <asm/string.h>
  6. /*
  7. * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
  8. * I.e. Maximum page that is mapped directly into kernel memory,
  9. * and kmap is not required.
  10. *
  11. * Someone correct me if FIXADDR_START - PAGEOFFSET is not the correct
  12. * calculation for the amount of memory directly mappable into the
  13. * kernel memory space.
  14. */
  15. /* Maximum physical address we can use pages from */
  16. #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
  17. /* Maximum address we can reach in physical address mode */
  18. #define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
  19. /* Maximum address we can use for the control code buffer */
  20. #define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
  21. #define KEXEC_CONTROL_CODE_SIZE 4096
  22. /* The native architecture */
  23. #define KEXEC_ARCH KEXEC_ARCH_386
  24. #define MAX_NOTE_BYTES 1024
  25. /* CPU does not save ss and esp on stack if execution is already
  26. * running in kernel mode at the time of NMI occurrence. This code
  27. * fixes it.
  28. */
  29. static inline void crash_fixup_ss_esp(struct pt_regs *newregs,
  30. struct pt_regs *oldregs)
  31. {
  32. memcpy(newregs, oldregs, sizeof(*newregs));
  33. newregs->esp = (unsigned long)&(oldregs->esp);
  34. __asm__ __volatile__(
  35. "xorl %%eax, %%eax\n\t"
  36. "movw %%ss, %%ax\n\t"
  37. :"=a"(newregs->xss));
  38. }
  39. /*
  40. * This function is responsible for capturing register states if coming
  41. * via panic otherwise just fix up the ss and esp if coming via kernel
  42. * mode exception.
  43. */
  44. static inline void crash_setup_regs(struct pt_regs *newregs,
  45. struct pt_regs *oldregs)
  46. {
  47. if (oldregs)
  48. crash_fixup_ss_esp(newregs, oldregs);
  49. else {
  50. __asm__ __volatile__("movl %%ebx,%0" : "=m"(newregs->ebx));
  51. __asm__ __volatile__("movl %%ecx,%0" : "=m"(newregs->ecx));
  52. __asm__ __volatile__("movl %%edx,%0" : "=m"(newregs->edx));
  53. __asm__ __volatile__("movl %%esi,%0" : "=m"(newregs->esi));
  54. __asm__ __volatile__("movl %%edi,%0" : "=m"(newregs->edi));
  55. __asm__ __volatile__("movl %%ebp,%0" : "=m"(newregs->ebp));
  56. __asm__ __volatile__("movl %%eax,%0" : "=m"(newregs->eax));
  57. __asm__ __volatile__("movl %%esp,%0" : "=m"(newregs->esp));
  58. __asm__ __volatile__("movw %%ss, %%ax;" :"=a"(newregs->xss));
  59. __asm__ __volatile__("movw %%cs, %%ax;" :"=a"(newregs->xcs));
  60. __asm__ __volatile__("movw %%ds, %%ax;" :"=a"(newregs->xds));
  61. __asm__ __volatile__("movw %%es, %%ax;" :"=a"(newregs->xes));
  62. __asm__ __volatile__("pushfl; popl %0" :"=m"(newregs->eflags));
  63. newregs->eip = (unsigned long)current_text_addr();
  64. }
  65. }
  66. #endif /* _I386_KEXEC_H */