1. 19 May, 2022 3 commits
    • Liao Chang's avatar
      RISC-V: Add kexec_file support · 6261586e
      Liao Chang authored
      This patch adds support for kexec_file on RISC-V. I tested it on riscv64
      QEMU with busybear-linux and single core along with the OpenSBI firmware
      fw_jump.bin for generic platform.
      
      On SMP system, it depends on CONFIG_{HOTPLUG_CPU, RISCV_SBI} to
      resume/stop hart through OpenSBI firmware, it also needs a OpenSBI that
      support the HSM extension.
      Signed-off-by: default avatarLiao Chang <liaochang1@huawei.com>
      Signed-off-by: default avatarLi Zhengyu <lizhengyu3@huawei.com>
      Link: https://lore.kernel.org/r/20220408100914.150110-4-lizhengyu3@huawei.com
      [Palmer: Make 64-bit only]
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      6261586e
    • Liao Chang's avatar
      RISC-V: use memcpy for kexec_file mode · b7fb4d78
      Liao Chang authored
      The pointer to buffer loading kernel binaries is in kernel space for
      kexec_fil mode, When copy_from_user copies data from pointer to a block
      of memory, it checkes that the pointer is in the user space range, on
      RISCV-V that is:
      
      static inline bool __access_ok(unsigned long addr, unsigned long size)
      {
      	return size <= TASK_SIZE && addr <= TASK_SIZE - size;
      }
      
      and TASK_SIZE is 0x4000000000 for 64-bits, which now causes
      copy_from_user to reject the access of the field 'buf' of struct
      kexec_segment that is in range [CONFIG_PAGE_OFFSET - VMALLOC_SIZE,
      CONFIG_PAGE_OFFSET), is invalid user space pointer.
      
      This patch fixes this issue by skipping access_ok(), use mempcy() instead.
      Signed-off-by: default avatarLiao Chang <liaochang1@huawei.com>
      Link: https://lore.kernel.org/r/20220408100914.150110-3-lizhengyu3@huawei.comSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      b7fb4d78
    • Liao Chang's avatar
      kexec_file: Fix kexec_file.c build error for riscv platform · 4853f68d
      Liao Chang authored
      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: default avatarLiao Chang <liaochang1@huawei.com>
      Link: https://lore.kernel.org/r/20220408100914.150110-2-lizhengyu3@huawei.comSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      4853f68d
  2. 03 Apr, 2022 8 commits
  3. 02 Apr, 2022 29 commits