Skip to content

Commit 4853f68

Browse files
Liao Changpalmer-dabbelt
authored andcommitted
kexec_file: Fix kexec_file.c build error for riscv platform
When CONFIG_KEXEC_FILE is set for riscv platform, the compilation of kernel/kexec_file.c generate build error: kernel/kexec_file.c: In function 'crash_prepare_elf64_headers': ./arch/riscv/include/asm/page.h:110:71: error: request for member 'virt_addr' in something not a structure or union 110 | ((x) >= PAGE_OFFSET && (!IS_ENABLED(CONFIG_64BIT) || (x) < kernel_map.virt_addr)) | ^ ./arch/riscv/include/asm/page.h:131:2: note: in expansion of macro 'is_linear_mapping' 131 | is_linear_mapping(_x) ? \ | ^~~~~~~~~~~~~~~~~ ./arch/riscv/include/asm/page.h:140:31: note: in expansion of macro '__va_to_pa_nodebug' 140 | #define __phys_addr_symbol(x) __va_to_pa_nodebug(x) | ^~~~~~~~~~~~~~~~~~ ./arch/riscv/include/asm/page.h:143:24: note: in expansion of macro '__phys_addr_symbol' 143 | #define __pa_symbol(x) __phys_addr_symbol(RELOC_HIDE((unsigned long)(x), 0)) | ^~~~~~~~~~~~~~~~~~ kernel/kexec_file.c:1327:36: note: in expansion of macro '__pa_symbol' 1327 | phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); This occurs is because the "kernel_map" referenced in macro is_linear_mapping() is suppose to be the one of struct kernel_mapping defined in arch/riscv/mm/init.c, but the 2nd argument of crash_prepare_elf64_header() has same symbol name, in expansion of macro is_linear_mapping in function crash_prepare_elf64_header(), "kernel_map" actually is the local variable. Signed-off-by: Liao Chang <liaochang1@huawei.com> Link: https://lore.kernel.org/r/20220408100914.150110-2-lizhengyu3@huawei.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 3123109 commit 4853f68

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

include/linux/kexec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ struct crash_mem {
227227
extern int crash_exclude_mem_range(struct crash_mem *mem,
228228
unsigned long long mstart,
229229
unsigned long long mend);
230-
extern int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map,
230+
extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map,
231231
void **addr, unsigned long *sz);
232232
#endif /* CONFIG_KEXEC_FILE */
233233

kernel/kexec_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ int crash_exclude_mem_range(struct crash_mem *mem,
12601260
return 0;
12611261
}
12621262

1263-
int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map,
1263+
int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map,
12641264
void **addr, unsigned long *sz)
12651265
{
12661266
Elf64_Ehdr *ehdr;
@@ -1324,7 +1324,7 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int kernel_map,
13241324
phdr++;
13251325

13261326
/* Prepare PT_LOAD type program header for kernel text region */
1327-
if (kernel_map) {
1327+
if (need_kernel_map) {
13281328
phdr->p_type = PT_LOAD;
13291329
phdr->p_flags = PF_R|PF_W|PF_X;
13301330
phdr->p_vaddr = (unsigned long) _text;

0 commit comments

Comments
 (0)