.. | .. |
---|
343 | 343 | |
---|
344 | 344 | image = NULL; |
---|
345 | 345 | |
---|
346 | | - if (!mutex_trylock(&kexec_mutex)) |
---|
| 346 | + if (!kexec_trylock()) |
---|
347 | 347 | return -EBUSY; |
---|
348 | 348 | |
---|
349 | 349 | dest_image = &kexec_image; |
---|
.. | .. |
---|
415 | 415 | if ((flags & KEXEC_FILE_ON_CRASH) && kexec_crash_image) |
---|
416 | 416 | arch_kexec_protect_crashkres(); |
---|
417 | 417 | |
---|
418 | | - mutex_unlock(&kexec_mutex); |
---|
| 418 | + kexec_unlock(); |
---|
419 | 419 | kimage_free(image); |
---|
420 | 420 | return ret; |
---|
421 | 421 | } |
---|
.. | .. |
---|
910 | 910 | } |
---|
911 | 911 | |
---|
912 | 912 | offset = ALIGN(offset, align); |
---|
| 913 | + |
---|
| 914 | + /* |
---|
| 915 | + * Check if the segment contains the entry point, if so, |
---|
| 916 | + * calculate the value of image->start based on it. |
---|
| 917 | + * If the compiler has produced more than one .text section |
---|
| 918 | + * (Eg: .text.hot), they are generally after the main .text |
---|
| 919 | + * section, and they shall not be used to calculate |
---|
| 920 | + * image->start. So do not re-calculate image->start if it |
---|
| 921 | + * is not set to the initial value, and warn the user so they |
---|
| 922 | + * have a chance to fix their purgatory's linker script. |
---|
| 923 | + */ |
---|
913 | 924 | if (sechdrs[i].sh_flags & SHF_EXECINSTR && |
---|
914 | 925 | pi->ehdr->e_entry >= sechdrs[i].sh_addr && |
---|
915 | 926 | pi->ehdr->e_entry < (sechdrs[i].sh_addr |
---|
916 | | - + sechdrs[i].sh_size)) { |
---|
| 927 | + + sechdrs[i].sh_size) && |
---|
| 928 | + !WARN_ON(kbuf->image->start != pi->ehdr->e_entry)) { |
---|
917 | 929 | kbuf->image->start -= sechdrs[i].sh_addr; |
---|
918 | 930 | kbuf->image->start += kbuf->mem + offset; |
---|
919 | 931 | } |
---|