lkml.org 
[lkml]   [2020]   [Jul]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Subject[PATCH v6 00/11] ppc64: enable kdump support for kexec_file_load syscall
    From
    Date
    Sorry! There was a gateway issue on my system while posting v5, due to
    which some patches did not make it through. Resending...

    This patch series enables kdump support for kexec_file_load system
    call (kexec -s -p) on PPC64. The changes are inspired from kexec-tools
    code but heavily modified for kernel consumption.

    The first patch adds a weak arch_kexec_locate_mem_hole() function to
    override locate memory hole logic suiting arch needs. There are some
    special regions in ppc64 which should be avoided while loading buffer
    & there are multiple callers to kexec_add_buffer making it complicated
    to maintain range sanity and using generic lookup at the same time.

    The second patch marks ppc64 specific code within arch/powerpc/kexec
    and arch/powerpc/purgatory to make the subsequent code changes easy
    to understand.

    The next patch adds helper function to setup different memory ranges
    needed for loading kdump kernel, booting into it and exporting the
    crashing kernel's elfcore.

    The fourth patch overrides arch_kexec_locate_mem_hole() function to
    locate memory hole for kdump segments by accounting for the special
    memory regions, referred to as excluded memory ranges, and sets
    kbuf->mem when a suitable memory region is found.

    The fifth patch moves walk_drmem_lmbs() out of .init section with
    a few changes to reuse it for setting up kdump kernel's usable memory
    ranges. The next patch uses walk_drmem_lmbs() to look up the LMBs
    and set linux,drconf-usable-memory & linux,usable-memory properties
    in order to restrict kdump kernel's memory usage.

    The next patch setups up backup region as a kexec segment while
    loading kdump kernel and teaches purgatory to copy data from source
    to destination.

    Patch 09 builds the elfcore header for the running kernel & passes
    the info to kdump kernel via "elfcorehdr=" parameter to export as
    /proc/vmcore file. The next patch sets up the memory reserve map
    for the kexec kernel and also claims kdump support for kdump as
    all the necessary changes are added.

    The next patch fixes a lookup issue for `kexec -l -s` case when
    memory is reserved for crashkernel.

    The last patch updates purgatory to setup r8 & r9 with opal base
    and opal entry addresses respectively to aid kernels built with
    CONFIG_PPC_EARLY_DEBUG_OPAL enabled.

    Tested the changes successfully on P8, P9 lpars, couple of OpenPOWER
    boxes, one with secureboot enabled, KVM guest and a simulator.

    v5 -> v6:
    * Fixed reference count leak in add_tce_mem_ranges() function and also
    updated error handling in reading tce table base & sizes.
    * Instead of trying to reinvent the wheel with get_node_path() &
    get_node_path_size() functions, used %pOF format as suggested by mpe.
    * Moved patch 07/11 to end of the series for mpe to take a call on
    whether to have it or not.

    v4 -> v5:
    * Dropped patches 07/12 & 08/12 and updated purgatory to do everything
    in assembly.
    * Added a new patch (which was part of patch 08/12 in v4) to update
    r8 & r9 registers with opal base & opal entry addresses as it is
    expected on kernels built with CONFIG_PPC_EARLY_DEBUG_OPAL enabled.
    * Fixed kexec load issue on KVM guest.

    v3 -> v4:
    * Updated get_node_path() function to be iterative instead of a recursive one.
    * Added comment explaining why low memory is added to kdump kernel's usable
    memory ranges though it doesn't fall in crashkernel region.
    * Fixed stack_buf to be quadword aligned in accordance with ABI.
    * Added missing of_node_put() in setup_purgatory_ppc64().
    * Added a FIXME tag to indicate issue in adding opal/rtas regions to
    core image.

    v2 -> v3:
    * Fixed TOC pointer calculation for purgatory by using section info
    that has relocations applied.
    * Fixed arch_kexec_locate_mem_hole() function to fallback to generic
    kexec_locate_mem_hole() lookup if exclude ranges list is empty.
    * Dropped check for backup_start in trampoline_64.S as purgatory()
    function takes care of it anyway.

    v1 -> v2:
    * Introduced arch_kexec_locate_mem_hole() for override and dropped
    weak arch_kexec_add_buffer().
    * Addressed warnings reported by lkp.
    * Added patch to address kexec load issue when memory is reserved
    for crashkernel.
    * Used the appropriate license header for the new files added.
    * Added an option to merge ranges to minimize reallocations while
    adding memory ranges.
    * Dropped within_crashkernel parameter for add_opal_mem_range() &
    add_rtas_mem_range() functions as it is not really needed.

    ---

    Hari Bathini (11):
    kexec_file: allow archs to handle special regions while locating memory hole
    powerpc/kexec_file: mark PPC64 specific code
    powerpc/kexec_file: add helper functions for getting memory ranges
    ppc64/kexec_file: avoid stomping memory used by special regions
    powerpc/drmem: make lmb walk a bit more flexible
    ppc64/kexec_file: restrict memory usage of kdump kernel
    ppc64/kexec_file: setup backup region for kdump kernel
    ppc64/kexec_file: prepare elfcore header for crashing kernel
    ppc64/kexec_file: add appropriate regions for memory reserve map
    ppc64/kexec_file: fix kexec load failure with lack of memory hole
    ppc64/kexec_file: enable early kernel's OPAL calls


    arch/powerpc/include/asm/crashdump-ppc64.h | 19
    arch/powerpc/include/asm/drmem.h | 9
    arch/powerpc/include/asm/kexec.h | 29 +
    arch/powerpc/include/asm/kexec_ranges.h | 25 +
    arch/powerpc/kernel/prom.c | 13
    arch/powerpc/kexec/Makefile | 2
    arch/powerpc/kexec/elf_64.c | 36 +
    arch/powerpc/kexec/file_load.c | 60 +-
    arch/powerpc/kexec/file_load_64.c | 1119 ++++++++++++++++++++++++++++
    arch/powerpc/kexec/ranges.c | 412 ++++++++++
    arch/powerpc/mm/drmem.c | 87 +-
    arch/powerpc/mm/numa.c | 13
    arch/powerpc/purgatory/Makefile | 4
    arch/powerpc/purgatory/trampoline.S | 117 ---
    arch/powerpc/purgatory/trampoline_64.S | 163 ++++
    include/linux/kexec.h | 29 -
    kernel/kexec_file.c | 16
    17 files changed, 1958 insertions(+), 195 deletions(-)
    create mode 100644 arch/powerpc/include/asm/crashdump-ppc64.h
    create mode 100644 arch/powerpc/include/asm/kexec_ranges.h
    create mode 100644 arch/powerpc/kexec/file_load_64.c
    create mode 100644 arch/powerpc/kexec/ranges.c
    delete mode 100644 arch/powerpc/purgatory/trampoline.S
    create mode 100644 arch/powerpc/purgatory/trampoline_64.S


    \
     
     \ /
      Last update: 2020-07-29 13:39    [W:3.155 / U:0.120 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site