diff options
Diffstat (limited to 'kernel/kexec_file.c')
-rw-r--r-- | kernel/kexec_file.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 269116fd932c..75d8e7cf040e 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c | |||
@@ -730,8 +730,8 @@ static int kexec_purgatory_setup_kbuf(struct purgatory_info *pi, | |||
730 | int i, ret; | 730 | int i, ret; |
731 | 731 | ||
732 | sechdrs = (void *)pi->ehdr + pi->ehdr->e_shoff; | 732 | sechdrs = (void *)pi->ehdr + pi->ehdr->e_shoff; |
733 | bss_align = 1; | 733 | kbuf->buf_align = bss_align = 1; |
734 | bss_sz = 0; | 734 | kbuf->bufsz = bss_sz = 0; |
735 | 735 | ||
736 | for (i = 0; i < pi->ehdr->e_shnum; i++) { | 736 | for (i = 0; i < pi->ehdr->e_shnum; i++) { |
737 | if (!(sechdrs[i].sh_flags & SHF_ALLOC)) | 737 | if (!(sechdrs[i].sh_flags & SHF_ALLOC)) |
@@ -763,7 +763,6 @@ static int kexec_purgatory_setup_kbuf(struct purgatory_info *pi, | |||
763 | ret = kexec_add_buffer(kbuf); | 763 | ret = kexec_add_buffer(kbuf); |
764 | if (ret) | 764 | if (ret) |
765 | goto out; | 765 | goto out; |
766 | pi->purgatory_load_addr = kbuf->mem; | ||
767 | 766 | ||
768 | return 0; | 767 | return 0; |
769 | out: | 768 | out: |
@@ -901,27 +900,32 @@ static int kexec_apply_relocations(struct kimage *image) | |||
901 | return 0; | 900 | return 0; |
902 | } | 901 | } |
903 | 902 | ||
904 | /* Load relocatable purgatory object and relocate it appropriately */ | 903 | /* |
905 | int kexec_load_purgatory(struct kimage *image, unsigned long min, | 904 | * kexec_load_purgatory - Load and relocate the purgatory object. |
906 | unsigned long max, int top_down, | 905 | * @image: Image to add the purgatory to. |
907 | unsigned long *load_addr) | 906 | * @kbuf: Memory parameters to use. |
907 | * | ||
908 | * Allocates the memory needed for image->purgatory_info.sechdrs and | ||
909 | * image->purgatory_info.purgatory_buf/kbuf->buffer. Caller is responsible | ||
910 | * to free the memory after use. | ||
911 | * | ||
912 | * Return: 0 on success, negative errno on error. | ||
913 | */ | ||
914 | int kexec_load_purgatory(struct kimage *image, struct kexec_buf *kbuf) | ||
908 | { | 915 | { |
909 | struct purgatory_info *pi = &image->purgatory_info; | 916 | struct purgatory_info *pi = &image->purgatory_info; |
910 | int ret; | 917 | int ret; |
911 | struct kexec_buf kbuf = { .image = image, .bufsz = 0, .buf_align = 1, | ||
912 | .buf_min = min, .buf_max = max, | ||
913 | .top_down = top_down }; | ||
914 | 918 | ||
915 | if (kexec_purgatory_size <= 0) | 919 | if (kexec_purgatory_size <= 0) |
916 | return -EINVAL; | 920 | return -EINVAL; |
917 | 921 | ||
918 | pi->ehdr = (const Elf_Ehdr *)kexec_purgatory; | 922 | pi->ehdr = (const Elf_Ehdr *)kexec_purgatory; |
919 | 923 | ||
920 | ret = kexec_purgatory_setup_kbuf(pi, &kbuf); | 924 | ret = kexec_purgatory_setup_kbuf(pi, kbuf); |
921 | if (ret) | 925 | if (ret) |
922 | return ret; | 926 | return ret; |
923 | 927 | ||
924 | ret = kexec_purgatory_setup_sechdrs(pi, &kbuf); | 928 | ret = kexec_purgatory_setup_sechdrs(pi, kbuf); |
925 | if (ret) | 929 | if (ret) |
926 | goto out_free_kbuf; | 930 | goto out_free_kbuf; |
927 | 931 | ||
@@ -929,7 +933,6 @@ int kexec_load_purgatory(struct kimage *image, unsigned long min, | |||
929 | if (ret) | 933 | if (ret) |
930 | goto out; | 934 | goto out; |
931 | 935 | ||
932 | *load_addr = pi->purgatory_load_addr; | ||
933 | return 0; | 936 | return 0; |
934 | out: | 937 | out: |
935 | vfree(pi->sechdrs); | 938 | vfree(pi->sechdrs); |