[PATCH v2] crash_core: export vmemmap when CONFIG_SPARSEMEM_VMEMMAP is enabled

2024-02-26 Thread Huang Shijie
In memory_model.h, if CONFIG_SPARSEMEM_VMEMMAP is configed, kernel will use vmemmap to do the __pfn_to_page/page_to_pfn, and kernel will not use the "classic sparse" to do the __pfn_to_page/page_to_pfn. So export the vmemmap when CONFIG_SPARSEMEM_VMEMMAP is configed. This makes the user applicatio

Re: [PATCH RESEND] crash_core: export vmemmap when CONFIG_SPARSEMEM_VMEMMAP is enabled

2024-02-26 Thread Andrew Morton
On Mon, 26 Feb 2024 10:04:33 +0800 Huang Shijie wrote: > In memory_model.h, if CONFIG_SPARSEMEM_VMEMMAP is configed, > kernel will use vmemmap to do the __pfn_to_page/page_to_pfn, > and kernel will not use the "classic sparse" to do the > __pfn_to_page/page_to_pfn. > > So export the vmemmap whe

Re: [PATCHv7 10/16] x86/tdx: Convert shared memory back to private on kexec

2024-02-26 Thread Dave Hansen
On 2/25/24 06:58, Kirill A. Shutemov wrote: > On Fri, Feb 23, 2024 at 11:39:07AM -0800, Dave Hansen wrote: ... >> I'd really prefer we find a way to do this with actual locks, especially >> 'conversion_allowed'. >> >> This is _awfully_ close to being able to be handled by a rwsem where the >> reade

Re: [PATCHv7 10/16] x86/tdx: Convert shared memory back to private on kexec

2024-02-26 Thread Kirill A. Shutemov
On Sun, Feb 25, 2024 at 04:58:46PM +0200, Kirill A. Shutemov wrote: > On Fri, Feb 23, 2024 at 11:39:07AM -0800, Dave Hansen wrote: > > On 2/12/24 02:44, Kirill A. Shutemov wrote: > > > +static void tdx_kexec_stop_conversion(bool crash) > > > +{ > > > + /* Stop new private<->shared conversions */ >

[PATCH linux-next v2 2/3] powerpc/kexec: split CONFIG_KEXEC_FILE and CONFIG_CRASH_DUMP

2024-02-26 Thread Hari Bathini
CONFIG_KEXEC_FILE does not have to select CONFIG_CRASH_DUMP. Move some code under CONFIG_CRASH_DUMP to support CONFIG_KEXEC_FILE and !CONFIG_CRASH_DUMP case. Signed-off-by: Hari Bathini --- * No changes in v2. arch/powerpc/kexec/elf_64.c | 4 +- arch/powerpc/kexec/file_load_64.c | 269

[PATCH linux-next v2 3/3] powerpc/kdump: Split KEXEC_CORE and CRASH_DUMP dependency

2024-02-26 Thread Hari Bathini
Remove CONFIG_CRASH_DUMP dependency on CONFIG_KEXEC. CONFIG_KEXEC_CORE was used at places where CONFIG_CRASH_DUMP or CONFIG_CRASH_RESERVE was appropriate. Replace with appropriate #ifdefs to support CONFIG_KEXEC and !CONFIG_CRASH_DUMP configuration option. Also, make CONFIG_FA_DUMP dependent on CON

[PATCH linux-next v2 0/3] powerpc/kexec: split CONFIG_CRASH_DUMP out from CONFIG_KEXEC_CORE

2024-02-26 Thread Hari Bathini
This patch series is a follow-up to [1] based on discussions at [2] about additional work needed to get it working on powerpc. The first patch in the series makes struct crash_mem available with or without CONFIG_CRASH_DUMP enabled. The next patch moves kdump specific code for kexec_file_load sysc

[PATCH linux-next v2 1/3] kexec/kdump: make struct crash_mem available without CONFIG_CRASH_DUMP

2024-02-26 Thread Hari Bathini
struct crash_mem defined under include/linux/crash_core.h represents a list of memory ranges. While it is used to represent memory ranges for kdump kernel, it can also be used for other kind of memory ranges. In fact, KEXEC_FILE_LOAD syscall in powerpc uses this structure to represent reserved memo

[PATCH v17 6/6] powerpc/crash: add crash memory hotplug support

2024-02-26 Thread Sourabh Jain
Extend the arch crash hotplug handler, as introduced by the patch title ("powerpc: add crash CPU hotplug support"), to also support memory add/remove events. Elfcorehdr describes the memory of the crash kernel to capture the kernel; hence, it needs to be updated if memory resources change due to m

[PATCH v17 5/6] powerpc/crash: add crash CPU hotplug support

2024-02-26 Thread Sourabh Jain
Due to CPU/Memory hotplug or online/offline events, the elfcorehdr (which describes the CPUs and memory of the crashed kernel) and FDT (Flattened Device Tree) of kdump image becomes outdated. Consequently, attempting dump collection with an outdated elfcorehdr or FDT can lead to failed or inaccurat

[PATCH v17 3/6] powerpc/kexec: move *_memory_ranges functions to ranges.c

2024-02-26 Thread Sourabh Jain
Move the following functions form kexec/{file_load_64.c => ranges.c} and make them public so that components other KEXEC_FILE can also use these functions. 1. get_exclude_memory_ranges 2. get_reserved_memory_ranges 3. get_crash_memory_ranges 4. get_usable_memory_ranges Later in the series get_cras

[PATCH v17 4/6] PowerPC/kexec: make the update_cpus_node() function public

2024-02-26 Thread Sourabh Jain
Move the update_cpus_node() from kexec/{file_load_64.c => core_64.c} to allow other kexec components to use it. Later in the series, this function is used for in-kernel updates to the kdump image during CPU/memory hotplug or online/offline events for both kexec_load and kexec_file_load syscalls.

[PATCH v17 2/6] crash: add a new kexec flag for hotplug support

2024-02-26 Thread Sourabh Jain
Commit a72bbec70da2 ("crash: hotplug support for kexec_load()") introduced a new kexec flag, `KEXEC_UPDATE_ELFCOREHDR`. Kexec tool uses this flag to indicate to the kernel that it is safe to modify the elfcorehdr of the kdump image loaded using the kexec_load system call. However, it is possible t

[PATCH v17 0/6] powerpc/crash: Kernel handling of CPU and memory hotplug

2024-02-26 Thread Sourabh Jain
Commit 247262756121 ("crash: add generic infrastructure for crash hotplug support") added a generic infrastructure that allows architectures to selectively update the kdump image component during CPU or memory add/remove events within the kernel itself. This patch series adds crash hotplug handler

[PATCH v17 1/6] crash: forward memory_notify arg to arch crash hotplug handler

2024-02-26 Thread Sourabh Jain
In the event of memory hotplug or online/offline events, the crash memory hotplug notifier `crash_memhp_notifier()` receives a `memory_notify` object but doesn't forward that object to the generic and architecture-specific crash hotplug handler. The `memory_notify` object contains the starting PFN