mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-25 16:11:45 +00:00
kexec_file,x86,powerpc: factor out kexec_file_ops functions
As arch_kexec_kernel_image_{probe,load}(), arch_kimage_file_post_load_cleanup() and arch_kexec_kernel_verify_sig() are almost duplicated among architectures, they can be commonalized with an architecture-defined kexec_file_ops array. So let's factor them out. Link: http://lkml.kernel.org/r/20180306102303.9063-3-takahiro.akashi@linaro.org Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Acked-by: Dave Young <dyoung@redhat.com> Tested-by: Dave Young <dyoung@redhat.com> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: Baoquan He <bhe@redhat.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
b799a09f63
commit
9ec4ecef0a
8 changed files with 71 additions and 94 deletions
|
@ -28,28 +28,80 @@
|
|||
|
||||
static int kexec_calculate_store_digests(struct kimage *image);
|
||||
|
||||
/*
|
||||
* Currently this is the only default function that is exported as some
|
||||
* architectures need it to do additional handlings.
|
||||
* In the future, other default functions may be exported too if required.
|
||||
*/
|
||||
int kexec_image_probe_default(struct kimage *image, void *buf,
|
||||
unsigned long buf_len)
|
||||
{
|
||||
const struct kexec_file_ops * const *fops;
|
||||
int ret = -ENOEXEC;
|
||||
|
||||
for (fops = &kexec_file_loaders[0]; *fops && (*fops)->probe; ++fops) {
|
||||
ret = (*fops)->probe(buf, buf_len);
|
||||
if (!ret) {
|
||||
image->fops = *fops;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Architectures can provide this probe function */
|
||||
int __weak arch_kexec_kernel_image_probe(struct kimage *image, void *buf,
|
||||
unsigned long buf_len)
|
||||
{
|
||||
return -ENOEXEC;
|
||||
return kexec_image_probe_default(image, buf, buf_len);
|
||||
}
|
||||
|
||||
static void *kexec_image_load_default(struct kimage *image)
|
||||
{
|
||||
if (!image->fops || !image->fops->load)
|
||||
return ERR_PTR(-ENOEXEC);
|
||||
|
||||
return image->fops->load(image, image->kernel_buf,
|
||||
image->kernel_buf_len, image->initrd_buf,
|
||||
image->initrd_buf_len, image->cmdline_buf,
|
||||
image->cmdline_buf_len);
|
||||
}
|
||||
|
||||
void * __weak arch_kexec_kernel_image_load(struct kimage *image)
|
||||
{
|
||||
return ERR_PTR(-ENOEXEC);
|
||||
return kexec_image_load_default(image);
|
||||
}
|
||||
|
||||
static int kexec_image_post_load_cleanup_default(struct kimage *image)
|
||||
{
|
||||
if (!image->fops || !image->fops->cleanup)
|
||||
return 0;
|
||||
|
||||
return image->fops->cleanup(image->image_loader_data);
|
||||
}
|
||||
|
||||
int __weak arch_kimage_file_post_load_cleanup(struct kimage *image)
|
||||
{
|
||||
return -EINVAL;
|
||||
return kexec_image_post_load_cleanup_default(image);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KEXEC_VERIFY_SIG
|
||||
static int kexec_image_verify_sig_default(struct kimage *image, void *buf,
|
||||
unsigned long buf_len)
|
||||
{
|
||||
if (!image->fops || !image->fops->verify_sig) {
|
||||
pr_debug("kernel loader does not support signature verification.\n");
|
||||
return -EKEYREJECTED;
|
||||
}
|
||||
|
||||
return image->fops->verify_sig(buf, buf_len);
|
||||
}
|
||||
|
||||
int __weak arch_kexec_kernel_verify_sig(struct kimage *image, void *buf,
|
||||
unsigned long buf_len)
|
||||
{
|
||||
return -EKEYREJECTED;
|
||||
return kexec_image_verify_sig_default(image, buf, buf_len);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue