Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kexec: move some memembers and definitions within the scope of CONFIG_KEXEC_FILE

Move the stuff currently only used by the kexec file code within
CONFIG_KEXEC_FILE (and CONFIG_KEXEC_VERIFY_SIG).

Also move internal "struct kexec_sha_region" and "struct kexec_buf" into
"kexec_internal.h".

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Dave Young <dyoung@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Xunlei Pang and committed by
Linus Torvalds
978e30c9 2b24692b

+50 -37
+2
arch/x86/kernel/machine_kexec_64.c
··· 385 385 return image->fops->cleanup(image->image_loader_data); 386 386 } 387 387 388 + #ifdef CONFIG_KEXEC_VERIFY_SIG 388 389 int arch_kexec_kernel_verify_sig(struct kimage *image, void *kernel, 389 390 unsigned long kernel_len) 390 391 { ··· 396 395 397 396 return image->fops->verify_sig(kernel, kernel_len); 398 397 } 398 + #endif 399 399 400 400 /* 401 401 * Apply purgatory relocations.
+25 -37
include/linux/kexec.h
··· 109 109 }; 110 110 #endif 111 111 112 - struct kexec_sha_region { 113 - unsigned long start; 114 - unsigned long len; 115 - }; 116 - 112 + #ifdef CONFIG_KEXEC_FILE 117 113 struct purgatory_info { 118 114 /* Pointer to elf header of read only purgatory */ 119 115 Elf_Ehdr *ehdr; ··· 125 129 /* Address where purgatory is finally loaded and is executed from */ 126 130 unsigned long purgatory_load_addr; 127 131 }; 132 + 133 + typedef int (kexec_probe_t)(const char *kernel_buf, unsigned long kernel_size); 134 + typedef void *(kexec_load_t)(struct kimage *image, char *kernel_buf, 135 + unsigned long kernel_len, char *initrd, 136 + unsigned long initrd_len, char *cmdline, 137 + unsigned long cmdline_len); 138 + typedef int (kexec_cleanup_t)(void *loader_data); 139 + 140 + #ifdef CONFIG_KEXEC_VERIFY_SIG 141 + typedef int (kexec_verify_sig_t)(const char *kernel_buf, 142 + unsigned long kernel_len); 143 + #endif 144 + 145 + struct kexec_file_ops { 146 + kexec_probe_t *probe; 147 + kexec_load_t *load; 148 + kexec_cleanup_t *cleanup; 149 + #ifdef CONFIG_KEXEC_VERIFY_SIG 150 + kexec_verify_sig_t *verify_sig; 151 + #endif 152 + }; 153 + #endif 128 154 129 155 struct kimage { 130 156 kimage_entry_t head; ··· 179 161 struct kimage_arch arch; 180 162 #endif 181 163 164 + #ifdef CONFIG_KEXEC_FILE 182 165 /* Additional fields for file based kexec syscall */ 183 166 void *kernel_buf; 184 167 unsigned long kernel_buf_len; ··· 198 179 199 180 /* Information for loading purgatory */ 200 181 struct purgatory_info purgatory_info; 201 - }; 202 - 203 - /* 204 - * Keeps track of buffer parameters as provided by caller for requesting 205 - * memory placement of buffer. 206 - */ 207 - struct kexec_buf { 208 - struct kimage *image; 209 - char *buffer; 210 - unsigned long bufsz; 211 - unsigned long mem; 212 - unsigned long memsz; 213 - unsigned long buf_align; 214 - unsigned long buf_min; 215 - unsigned long buf_max; 216 - bool top_down; /* allocate from top of memory hole */ 217 - }; 218 - 219 - typedef int (kexec_probe_t)(const char *kernel_buf, unsigned long kernel_size); 220 - typedef void *(kexec_load_t)(struct kimage *image, char *kernel_buf, 221 - unsigned long kernel_len, char *initrd, 222 - unsigned long initrd_len, char *cmdline, 223 - unsigned long cmdline_len); 224 - typedef int (kexec_cleanup_t)(void *loader_data); 225 - typedef int (kexec_verify_sig_t)(const char *kernel_buf, 226 - unsigned long kernel_len); 227 - 228 - struct kexec_file_ops { 229 - kexec_probe_t *probe; 230 - kexec_load_t *load; 231 - kexec_cleanup_t *cleanup; 232 - kexec_verify_sig_t *verify_sig; 182 + #endif 233 183 }; 234 184 235 185 /* kexec interface functions */
+2
kernel/kexec_file.c
··· 109 109 return -EINVAL; 110 110 } 111 111 112 + #ifdef CONFIG_KEXEC_VERIFY_SIG 112 113 int __weak arch_kexec_kernel_verify_sig(struct kimage *image, void *buf, 113 114 unsigned long buf_len) 114 115 { 115 116 return -EKEYREJECTED; 116 117 } 118 + #endif 117 119 118 120 /* Apply relocations of type RELA */ 119 121 int __weak
+21
kernel/kexec_internal.h
··· 15 15 extern struct mutex kexec_mutex; 16 16 17 17 #ifdef CONFIG_KEXEC_FILE 18 + struct kexec_sha_region { 19 + unsigned long start; 20 + unsigned long len; 21 + }; 22 + 23 + /* 24 + * Keeps track of buffer parameters as provided by caller for requesting 25 + * memory placement of buffer. 26 + */ 27 + struct kexec_buf { 28 + struct kimage *image; 29 + char *buffer; 30 + unsigned long bufsz; 31 + unsigned long mem; 32 + unsigned long memsz; 33 + unsigned long buf_align; 34 + unsigned long buf_min; 35 + unsigned long buf_max; 36 + bool top_down; /* allocate from top of memory hole */ 37 + }; 38 + 18 39 void kimage_file_post_load_cleanup(struct kimage *image); 19 40 #else /* CONFIG_KEXEC_FILE */ 20 41 static inline void kimage_file_post_load_cleanup(struct kimage *image) { }