summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXunlei Pang <xlpang@redhat.com>2016-01-20 18:00:36 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-20 20:09:18 -0500
commit978e30c9b46161c792ecdad0091fd017b21b8ca5 (patch)
tree2b9f2190bf48d175be825f5d48743b8defb3aab8
parent2b24692b9235cb82b6f735b7a4c4137211ddf005 (diff)
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>
-rw-r--r--arch/x86/kernel/machine_kexec_64.c2
-rw-r--r--include/linux/kexec.h62
-rw-r--r--kernel/kexec_file.c2
-rw-r--r--kernel/kexec_internal.h21
4 files changed, 50 insertions, 37 deletions
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index 819ab3f9c9c7..ba7fbba9831b 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -385,6 +385,7 @@ int arch_kimage_file_post_load_cleanup(struct kimage *image)
385 return image->fops->cleanup(image->image_loader_data); 385 return image->fops->cleanup(image->image_loader_data);
386} 386}
387 387
388#ifdef CONFIG_KEXEC_VERIFY_SIG
388int arch_kexec_kernel_verify_sig(struct kimage *image, void *kernel, 389int arch_kexec_kernel_verify_sig(struct kimage *image, void *kernel,
389 unsigned long kernel_len) 390 unsigned long kernel_len)
390{ 391{
@@ -395,6 +396,7 @@ int arch_kexec_kernel_verify_sig(struct kimage *image, void *kernel,
395 396
396 return image->fops->verify_sig(kernel, kernel_len); 397 return image->fops->verify_sig(kernel, kernel_len);
397} 398}
399#endif
398 400
399/* 401/*
400 * Apply purgatory relocations. 402 * Apply purgatory relocations.
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 7b68d2788a56..2cc643c6e870 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -109,11 +109,7 @@ struct compat_kexec_segment {
109}; 109};
110#endif 110#endif
111 111
112struct kexec_sha_region { 112#ifdef CONFIG_KEXEC_FILE
113 unsigned long start;
114 unsigned long len;
115};
116
117struct purgatory_info { 113struct purgatory_info {
118 /* Pointer to elf header of read only purgatory */ 114 /* Pointer to elf header of read only purgatory */
119 Elf_Ehdr *ehdr; 115 Elf_Ehdr *ehdr;
@@ -130,6 +126,28 @@ struct purgatory_info {
130 unsigned long purgatory_load_addr; 126 unsigned long purgatory_load_addr;
131}; 127};
132 128
129typedef int (kexec_probe_t)(const char *kernel_buf, unsigned long kernel_size);
130typedef void *(kexec_load_t)(struct kimage *image, char *kernel_buf,
131 unsigned long kernel_len, char *initrd,
132 unsigned long initrd_len, char *cmdline,
133 unsigned long cmdline_len);
134typedef int (kexec_cleanup_t)(void *loader_data);
135
136#ifdef CONFIG_KEXEC_VERIFY_SIG
137typedef int (kexec_verify_sig_t)(const char *kernel_buf,
138 unsigned long kernel_len);
139#endif
140
141struct kexec_file_ops {
142 kexec_probe_t *probe;
143 kexec_load_t *load;
144 kexec_cleanup_t *cleanup;
145#ifdef CONFIG_KEXEC_VERIFY_SIG
146 kexec_verify_sig_t *verify_sig;
147#endif
148};
149#endif
150
133struct kimage { 151struct kimage {
134 kimage_entry_t head; 152 kimage_entry_t head;
135 kimage_entry_t *entry; 153 kimage_entry_t *entry;
@@ -161,6 +179,7 @@ struct kimage {
161 struct kimage_arch arch; 179 struct kimage_arch arch;
162#endif 180#endif
163 181
182#ifdef CONFIG_KEXEC_FILE
164 /* Additional fields for file based kexec syscall */ 183 /* Additional fields for file based kexec syscall */
165 void *kernel_buf; 184 void *kernel_buf;
166 unsigned long kernel_buf_len; 185 unsigned long kernel_buf_len;
@@ -179,38 +198,7 @@ struct kimage {
179 198
180 /* Information for loading purgatory */ 199 /* Information for loading purgatory */
181 struct purgatory_info purgatory_info; 200 struct purgatory_info purgatory_info;
182}; 201#endif
183
184/*
185 * Keeps track of buffer parameters as provided by caller for requesting
186 * memory placement of buffer.
187 */
188struct kexec_buf {
189 struct kimage *image;
190 char *buffer;
191 unsigned long bufsz;
192 unsigned long mem;
193 unsigned long memsz;
194 unsigned long buf_align;
195 unsigned long buf_min;
196 unsigned long buf_max;
197 bool top_down; /* allocate from top of memory hole */
198};
199
200typedef int (kexec_probe_t)(const char *kernel_buf, unsigned long kernel_size);
201typedef void *(kexec_load_t)(struct kimage *image, char *kernel_buf,
202 unsigned long kernel_len, char *initrd,
203 unsigned long initrd_len, char *cmdline,
204 unsigned long cmdline_len);
205typedef int (kexec_cleanup_t)(void *loader_data);
206typedef int (kexec_verify_sig_t)(const char *kernel_buf,
207 unsigned long kernel_len);
208
209struct kexec_file_ops {
210 kexec_probe_t *probe;
211 kexec_load_t *load;
212 kexec_cleanup_t *cleanup;
213 kexec_verify_sig_t *verify_sig;
214}; 202};
215 203
216/* kexec interface functions */ 204/* kexec interface functions */
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index b70ada0028d2..007b791f676d 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -109,11 +109,13 @@ int __weak arch_kimage_file_post_load_cleanup(struct kimage *image)
109 return -EINVAL; 109 return -EINVAL;
110} 110}
111 111
112#ifdef CONFIG_KEXEC_VERIFY_SIG
112int __weak arch_kexec_kernel_verify_sig(struct kimage *image, void *buf, 113int __weak arch_kexec_kernel_verify_sig(struct kimage *image, void *buf,
113 unsigned long buf_len) 114 unsigned long buf_len)
114{ 115{
115 return -EKEYREJECTED; 116 return -EKEYREJECTED;
116} 117}
118#endif
117 119
118/* Apply relocations of type RELA */ 120/* Apply relocations of type RELA */
119int __weak 121int __weak
diff --git a/kernel/kexec_internal.h b/kernel/kexec_internal.h
index e4392a698ad4..0a52315d9c62 100644
--- a/kernel/kexec_internal.h
+++ b/kernel/kexec_internal.h
@@ -15,6 +15,27 @@ int kimage_is_destination_range(struct kimage *image,
15extern struct mutex kexec_mutex; 15extern struct mutex kexec_mutex;
16 16
17#ifdef CONFIG_KEXEC_FILE 17#ifdef CONFIG_KEXEC_FILE
18struct 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 */
27struct 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
18void kimage_file_post_load_cleanup(struct kimage *image); 39void kimage_file_post_load_cleanup(struct kimage *image);
19#else /* CONFIG_KEXEC_FILE */ 40#else /* CONFIG_KEXEC_FILE */
20static inline void kimage_file_post_load_cleanup(struct kimage *image) { } 41static inline void kimage_file_post_load_cleanup(struct kimage *image) { }