~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/kexec.h

Version: ~ [ linux-5.4.2 ] ~ [ linux-5.3.15 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.88 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.158 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.206 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.206 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.78 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef LINUX_KEXEC_H
  2 #define LINUX_KEXEC_H
  3 
  4 #ifdef CONFIG_KEXEC
  5 #include <linux/types.h>
  6 #include <linux/list.h>
  7 #include <linux/linkage.h>
  8 #include <linux/compat.h>
  9 #include <linux/ioport.h>
 10 #include <linux/elfcore.h>
 11 #include <linux/elf.h>
 12 #include <asm/kexec.h>
 13 
 14 /* Verify architecture specific macros are defined */
 15 
 16 #ifndef KEXEC_SOURCE_MEMORY_LIMIT
 17 #error KEXEC_SOURCE_MEMORY_LIMIT not defined
 18 #endif
 19 
 20 #ifndef KEXEC_DESTINATION_MEMORY_LIMIT
 21 #error KEXEC_DESTINATION_MEMORY_LIMIT not defined
 22 #endif
 23 
 24 #ifndef KEXEC_CONTROL_MEMORY_LIMIT
 25 #error KEXEC_CONTROL_MEMORY_LIMIT not defined
 26 #endif
 27 
 28 #ifndef KEXEC_CONTROL_PAGE_SIZE
 29 #error KEXEC_CONTROL_PAGE_SIZE not defined
 30 #endif
 31 
 32 #ifndef KEXEC_ARCH
 33 #error KEXEC_ARCH not defined
 34 #endif
 35 
 36 #define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
 37 #define KEXEC_CORE_NOTE_NAME "CORE"
 38 #define KEXEC_CORE_NOTE_NAME_BYTES ALIGN(sizeof(KEXEC_CORE_NOTE_NAME), 4)
 39 #define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
 40 /*
 41  * The per-cpu notes area is a list of notes terminated by a "NULL"
 42  * note header.  For kdump, the code in vmcore.c runs in the context
 43  * of the second kernel to combine them into one note.
 44  */
 45 #define KEXEC_NOTE_BYTES ( (KEXEC_NOTE_HEAD_BYTES * 2) +                \
 46                             KEXEC_CORE_NOTE_NAME_BYTES +                \
 47                             KEXEC_CORE_NOTE_DESC_BYTES )
 48 
 49 /*
 50  * This structure is used to hold the arguments that are used when loading
 51  * kernel binaries.
 52  */
 53 
 54 typedef unsigned long kimage_entry_t;
 55 #define IND_DESTINATION  0x1
 56 #define IND_INDIRECTION  0x2
 57 #define IND_DONE         0x4
 58 #define IND_SOURCE       0x8
 59 
 60 #define KEXEC_SEGMENT_MAX 16
 61 struct kexec_segment {
 62         void __user *buf;
 63         size_t bufsz;
 64         unsigned long mem;      /* User space sees this as a (void *) ... */
 65         size_t memsz;
 66 };
 67 
 68 #ifdef CONFIG_COMPAT
 69 struct compat_kexec_segment {
 70         compat_uptr_t buf;
 71         compat_size_t bufsz;
 72         compat_ulong_t mem;     /* User space sees this as a (void *) ... */
 73         compat_size_t memsz;
 74 };
 75 #endif
 76 
 77 struct kimage {
 78         kimage_entry_t head;
 79         kimage_entry_t *entry;
 80         kimage_entry_t *last_entry;
 81 
 82         unsigned long destination;
 83 
 84         unsigned long start;
 85         struct page *control_code_page;
 86         struct page *swap_page;
 87 
 88         unsigned long nr_segments;
 89         struct kexec_segment segment[KEXEC_SEGMENT_MAX];
 90 
 91         struct list_head control_pages;
 92         struct list_head dest_pages;
 93         struct list_head unuseable_pages;
 94 
 95         /* Address of next control page to allocate for crash kernels. */
 96         unsigned long control_page;
 97 
 98         /* Flags to indicate special processing */
 99         unsigned int type : 1;
100 #define KEXEC_TYPE_DEFAULT 0
101 #define KEXEC_TYPE_CRASH   1
102         unsigned int preserve_context : 1;
103 
104 #ifdef ARCH_HAS_KIMAGE_ARCH
105         struct kimage_arch arch;
106 #endif
107 };
108 
109 
110 
111 /* kexec interface functions */
112 extern void machine_kexec(struct kimage *image);
113 extern int machine_kexec_prepare(struct kimage *image);
114 extern void machine_kexec_cleanup(struct kimage *image);
115 extern asmlinkage long sys_kexec_load(unsigned long entry,
116                                         unsigned long nr_segments,
117                                         struct kexec_segment __user *segments,
118                                         unsigned long flags);
119 extern int kernel_kexec(void);
120 #ifdef CONFIG_COMPAT
121 extern asmlinkage long compat_sys_kexec_load(unsigned long entry,
122                                 unsigned long nr_segments,
123                                 struct compat_kexec_segment __user *segments,
124                                 unsigned long flags);
125 #endif
126 extern struct page *kimage_alloc_control_pages(struct kimage *image,
127                                                 unsigned int order);
128 extern void crash_kexec(struct pt_regs *);
129 int kexec_should_crash(struct task_struct *);
130 void crash_save_cpu(struct pt_regs *regs, int cpu);
131 void crash_save_vmcoreinfo(void);
132 void arch_crash_save_vmcoreinfo(void);
133 void vmcoreinfo_append_str(const char *fmt, ...)
134         __attribute__ ((format (printf, 1, 2)));
135 unsigned long paddr_vmcoreinfo_note(void);
136 
137 #define VMCOREINFO_OSRELEASE(value) \
138         vmcoreinfo_append_str("OSRELEASE=%s\n", value)
139 #define VMCOREINFO_PAGESIZE(value) \
140         vmcoreinfo_append_str("PAGESIZE=%ld\n", value)
141 #define VMCOREINFO_SYMBOL(name) \
142         vmcoreinfo_append_str("SYMBOL(%s)=%lx\n", #name, (unsigned long)&name)
143 #define VMCOREINFO_SIZE(name) \
144         vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \
145                               (unsigned long)sizeof(name))
146 #define VMCOREINFO_STRUCT_SIZE(name) \
147         vmcoreinfo_append_str("SIZE(%s)=%lu\n", #name, \
148                               (unsigned long)sizeof(struct name))
149 #define VMCOREINFO_OFFSET(name, field) \
150         vmcoreinfo_append_str("OFFSET(%s.%s)=%lu\n", #name, #field, \
151                               (unsigned long)offsetof(struct name, field))
152 #define VMCOREINFO_LENGTH(name, value) \
153         vmcoreinfo_append_str("LENGTH(%s)=%lu\n", #name, (unsigned long)value)
154 #define VMCOREINFO_NUMBER(name) \
155         vmcoreinfo_append_str("NUMBER(%s)=%ld\n", #name, (long)name)
156 #define VMCOREINFO_CONFIG(name) \
157         vmcoreinfo_append_str("CONFIG_%s=y\n", #name)
158 
159 extern struct kimage *kexec_image;
160 extern struct kimage *kexec_crash_image;
161 
162 #ifndef kexec_flush_icache_page
163 #define kexec_flush_icache_page(page)
164 #endif
165 
166 #define KEXEC_ON_CRASH          0x00000001
167 #define KEXEC_PRESERVE_CONTEXT  0x00000002
168 #define KEXEC_ARCH_MASK         0xffff0000
169 
170 /* These values match the ELF architecture values.
171  * Unless there is a good reason that should continue to be the case.
172  */
173 #define KEXEC_ARCH_DEFAULT ( 0 << 16)
174 #define KEXEC_ARCH_386     ( 3 << 16)
175 #define KEXEC_ARCH_X86_64  (62 << 16)
176 #define KEXEC_ARCH_PPC     (20 << 16)
177 #define KEXEC_ARCH_PPC64   (21 << 16)
178 #define KEXEC_ARCH_IA_64   (50 << 16)
179 #define KEXEC_ARCH_ARM     (40 << 16)
180 #define KEXEC_ARCH_S390    (22 << 16)
181 #define KEXEC_ARCH_SH      (42 << 16)
182 #define KEXEC_ARCH_MIPS_LE (10 << 16)
183 #define KEXEC_ARCH_MIPS    ( 8 << 16)
184 
185 /* List of defined/legal kexec flags */
186 #ifndef CONFIG_KEXEC_JUMP
187 #define KEXEC_FLAGS    KEXEC_ON_CRASH
188 #else
189 #define KEXEC_FLAGS    (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT)
190 #endif
191 
192 #define VMCOREINFO_BYTES           (4096)
193 #define VMCOREINFO_NOTE_NAME       "VMCOREINFO"
194 #define VMCOREINFO_NOTE_NAME_BYTES ALIGN(sizeof(VMCOREINFO_NOTE_NAME), 4)
195 #define VMCOREINFO_NOTE_SIZE       (KEXEC_NOTE_HEAD_BYTES*2 + VMCOREINFO_BYTES \
196                                     + VMCOREINFO_NOTE_NAME_BYTES)
197 
198 /* Location of a reserved region to hold the crash kernel.
199  */
200 extern struct resource crashk_res;
201 typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4];
202 extern note_buf_t *crash_notes;
203 extern u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];
204 extern size_t vmcoreinfo_size;
205 extern size_t vmcoreinfo_max_size;
206 
207 int __init parse_crashkernel(char *cmdline, unsigned long long system_ram,
208                 unsigned long long *crash_size, unsigned long long *crash_base);
209 
210 #else /* !CONFIG_KEXEC */
211 struct pt_regs;
212 struct task_struct;
213 static inline void crash_kexec(struct pt_regs *regs) { }
214 static inline int kexec_should_crash(struct task_struct *p) { return 0; }
215 #endif /* CONFIG_KEXEC */
216 #endif /* LINUX_KEXEC_H */
217 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp