Commit c72c7e67 authored by AKASHI Takahiro's avatar AKASHI Takahiro Committed by Linus Torvalds

x86: kexec_file: remove X86_64 dependency from prepare_elf64_headers()

The code guarded by CONFIG_X86_64 is necessary on some architectures
which have a dedicated kernel mapping outside of linear memory mapping.
(arm64 is among those.)

In this patch, an additional argument, kernel_map, is added to enable/
disable the code removing #ifdef.

Link: http://lkml.kernel.org/r/20180306102303.9063-5-takahiro.akashi@linaro.orgSigned-off-by: default avatarAKASHI Takahiro <takahiro.akashi@linaro.org>
Acked-by: default avatarDave Young <dyoung@redhat.com>
Tested-by: default avatarDave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Baoquan He <bhe@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent cbe66016
...@@ -348,7 +348,7 @@ static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg) ...@@ -348,7 +348,7 @@ static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg)
return 0; return 0;
} }
static int prepare_elf64_headers(struct crash_elf_data *ced, static int prepare_elf64_headers(struct crash_elf_data *ced, bool kernel_map,
void **addr, unsigned long *sz) void **addr, unsigned long *sz)
{ {
Elf64_Ehdr *ehdr; Elf64_Ehdr *ehdr;
...@@ -415,17 +415,17 @@ static int prepare_elf64_headers(struct crash_elf_data *ced, ...@@ -415,17 +415,17 @@ static int prepare_elf64_headers(struct crash_elf_data *ced,
phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE; phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE;
(ehdr->e_phnum)++; (ehdr->e_phnum)++;
#ifdef CONFIG_X86_64
/* Prepare PT_LOAD type program header for kernel text region */ /* Prepare PT_LOAD type program header for kernel text region */
phdr = (Elf64_Phdr *)bufp; if (kernel_map) {
bufp += sizeof(Elf64_Phdr); phdr = (Elf64_Phdr *)bufp;
phdr->p_type = PT_LOAD; bufp += sizeof(Elf64_Phdr);
phdr->p_flags = PF_R|PF_W|PF_X; phdr->p_type = PT_LOAD;
phdr->p_vaddr = (Elf64_Addr)_text; phdr->p_flags = PF_R|PF_W|PF_X;
phdr->p_filesz = phdr->p_memsz = _end - _text; phdr->p_vaddr = (Elf64_Addr)_text;
phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); phdr->p_filesz = phdr->p_memsz = _end - _text;
(ehdr->e_phnum)++; phdr->p_offset = phdr->p_paddr = __pa_symbol(_text);
#endif (ehdr->e_phnum)++;
}
/* Go through all the ranges in cmem->ranges[] and prepare phdr */ /* Go through all the ranges in cmem->ranges[] and prepare phdr */
for (i = 0; i < cmem->nr_ranges; i++) { for (i = 0; i < cmem->nr_ranges; i++) {
...@@ -478,7 +478,7 @@ static int prepare_elf_headers(struct kimage *image, void **addr, ...@@ -478,7 +478,7 @@ static int prepare_elf_headers(struct kimage *image, void **addr,
goto out; goto out;
/* By default prepare 64bit headers */ /* By default prepare 64bit headers */
ret = prepare_elf64_headers(ced, addr, sz); ret = prepare_elf64_headers(ced, IS_ENABLED(CONFIG_X86_64), addr, sz);
if (ret) if (ret)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment