lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1893a74b-693e-4734-8029-795e68e57734@linux.ibm.com>
Date: Mon, 26 Feb 2024 11:53:48 +0530
From: Hari Bathini <hbathini@...ux.ibm.com>
To: Sourabh Jain <sourabhjain@...ux.ibm.com>,
        linuxppc-dev <linuxppc-dev@...ts.ozlabs.org>,
        Kexec-ml <kexec@...ts.infradead.org>
Cc: Baoquan He <bhe@...hat.com>, lkml <linux-kernel@...r.kernel.org>,
        Nicholas Piggin <npiggin@...il.com>,
        Mahesh J Salgaonkar <mahesh@...ux.ibm.com>,
        "Naveen N. Rao" <naveen.n.rao@...ux.ibm.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Dave Young <dyoung@...hat.com>
Subject: Re: [PATCH linux-next 3/3] powerpc/kdump: Split KEXEC_CORE and
 CRASH_DUMP dependency



On 23/02/24 1:05 pm, Sourabh Jain wrote:
> Hello Hari,

Hi Sourabh,

> 
> Build failure detected.

Thanks for trying out the patches.

> 
> On 13/02/24 17:01, Hari Bathini wrote:
>> 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 CONFIG_CRASH_DUMP to avoid unmet dependencies for FA_DUMP
>> with !CONFIG_KEXEC_CORE configuration option.
>>
>> Signed-off-by: Hari Bathini <hbathini@...ux.ibm.com>
>> ---
>>   arch/powerpc/Kconfig               |  9 +--
>>   arch/powerpc/include/asm/kexec.h   | 98 +++++++++++++++---------------
>>   arch/powerpc/kernel/prom.c         |  2 +-
>>   arch/powerpc/kernel/setup-common.c |  2 +-
>>   arch/powerpc/kernel/smp.c          |  4 +-
>>   arch/powerpc/kexec/Makefile        |  3 +-
>>   arch/powerpc/kexec/core.c          |  4 ++
>>   7 files changed, 60 insertions(+), 62 deletions(-)
>>
>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>> index 5cf8ad8d7e8e..e377deefa2dc 100644
>> --- a/arch/powerpc/Kconfig
>> +++ b/arch/powerpc/Kconfig
>> @@ -607,11 +607,6 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
>>   config ARCH_SUPPORTS_KEXEC
>>       def_bool PPC_BOOK3S || PPC_E500 || (44x && !SMP)
>> -config ARCH_SELECTS_KEXEC
>> -    def_bool y
>> -    depends on KEXEC
>> -    select CRASH_DUMP
>> -
>>   config ARCH_SUPPORTS_KEXEC_FILE
>>       def_bool PPC64
>> @@ -622,7 +617,6 @@ config ARCH_SELECTS_KEXEC_FILE
>>       def_bool y
>>       depends on KEXEC_FILE
>>       select KEXEC_ELF
>> -    select CRASH_DUMP
>>       select HAVE_IMA_KEXEC if IMA
>>   config PPC64_BIG_ENDIAN_ELF_ABI_V2
>> @@ -694,8 +688,7 @@ config ARCH_SELECTS_CRASH_DUMP
>>   config FA_DUMP
>>       bool "Firmware-assisted dump"
>> -    depends on PPC64 && (PPC_RTAS || PPC_POWERNV)
>> -    select CRASH_DUMP
>> +    depends on CRASH_DUMP && PPC64 && (PPC_RTAS || PPC_POWERNV)
>>       help
>>         A robust mechanism to get reliable kernel crash dump with
>>         assistance from firmware. This approach does not use kexec,
>> diff --git a/arch/powerpc/include/asm/kexec.h 
>> b/arch/powerpc/include/asm/kexec.h
>> index e1b43aa12175..fdb90e24dc74 100644
>> --- a/arch/powerpc/include/asm/kexec.h
>> +++ b/arch/powerpc/include/asm/kexec.h
>> @@ -55,59 +55,18 @@
>>   typedef void (*crash_shutdown_t)(void);
>>   #ifdef CONFIG_KEXEC_CORE
>> -
>> -/*
>> - * This function is responsible for capturing register states if coming
>> - * via panic or invoking dump using sysrq-trigger.
>> - */
>> -static inline void crash_setup_regs(struct pt_regs *newregs,
>> -                    struct pt_regs *oldregs)
>> -{
>> -    if (oldregs)
>> -        memcpy(newregs, oldregs, sizeof(*newregs));
>> -    else
>> -        ppc_save_regs(newregs);
>> -}
>> +struct kimage;
>> +struct pt_regs;
>>   extern void kexec_smp_wait(void);    /* get and clear naca physid, 
>> wait for
>>                         master to copy new code to 0 */
>> -extern int crashing_cpu;
>> -extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs 
>> *));
>> -extern void crash_ipi_callback(struct pt_regs *);
>> -extern int crash_wake_offline;
>> -
>> -struct kimage;
>> -struct pt_regs;
>>   extern void default_machine_kexec(struct kimage *image);
>> -extern void default_machine_crash_shutdown(struct pt_regs *regs);
>> -extern int crash_shutdown_register(crash_shutdown_t handler);
>> -extern int crash_shutdown_unregister(crash_shutdown_t handler);
>> -
>> -extern void crash_kexec_prepare(void);
>> -extern void crash_kexec_secondary(struct pt_regs *regs);
>> -int __init overlaps_crashkernel(unsigned long start, unsigned long 
>> size);
>> -extern void reserve_crashkernel(void);
>>   extern void machine_kexec_mask_interrupts(void);
>> -static inline bool kdump_in_progress(void)
>> -{
>> -    return crashing_cpu >= 0;
>> -}
>> -
>>   void relocate_new_kernel(unsigned long indirection_page, unsigned 
>> long reboot_code_buffer,
>>                unsigned long start_address) __noreturn;
>> -
>>   void kexec_copy_flush(struct kimage *image);
>> -#if defined(CONFIG_CRASH_DUMP)
>> -bool is_kdump_kernel(void);
>> -#define is_kdump_kernel            is_kdump_kernel
>> -#if defined(CONFIG_PPC_RTAS)
>> -void crash_free_reserved_phys_range(unsigned long begin, unsigned 
>> long end);
>> -#define crash_free_reserved_phys_range crash_free_reserved_phys_range
>> -#endif /* CONFIG_PPC_RTAS */
>> -#endif /* CONFIG_CRASH_DUMP */
>> -
>>   #ifdef CONFIG_KEXEC_FILE
>>   extern const struct kexec_file_ops kexec_elf64_ops;
>> @@ -152,15 +111,56 @@ int setup_new_fdt_ppc64(const struct kimage 
>> *image, void *fdt,
>>   #endif /* CONFIG_KEXEC_FILE */
>> -#else /* !CONFIG_KEXEC_CORE */
>> -static inline void crash_kexec_secondary(struct pt_regs *regs) { }
>> +#endif /* CONFIG_KEXEC_CORE */
>> +
>> +#ifdef CONFIG_CRASH_RESERVE
>> +int __init overlaps_crashkernel(unsigned long start, unsigned long 
>> size);
>> +extern void reserve_crashkernel(void);
>> +#else
>> +static inline void reserve_crashkernel(void) {}
>> +static inline int overlaps_crashkernel(unsigned long start, unsigned 
>> long size) { return 0; }
>> +#endif
>> -static inline int overlaps_crashkernel(unsigned long start, unsigned 
>> long size)
>> +#if defined(CONFIG_CRASH_DUMP)
>> +/*
>> + * This function is responsible for capturing register states if coming
>> + * via panic or invoking dump using sysrq-trigger.
>> + */
>> +static inline void crash_setup_regs(struct pt_regs *newregs,
>> +                    struct pt_regs *oldregs)
>>   {
>> -    return 0;
>> +    if (oldregs)
>> +        memcpy(newregs, oldregs, sizeof(*newregs));
>> +    else
>> +        ppc_save_regs(newregs);
>> +}
>> +
>> +extern int crashing_cpu;
>> +extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs 
>> *));
>> +extern void crash_ipi_callback(struct pt_regs *regs);
>> +extern int crash_wake_offline;
>> +
>> +extern int crash_shutdown_register(crash_shutdown_t handler);
>> +extern int crash_shutdown_unregister(crash_shutdown_t handler);
>> +extern void default_machine_crash_shutdown(struct pt_regs *regs);
>> +
>> +extern void crash_kexec_prepare(void);
>> +extern void crash_kexec_secondary(struct pt_regs *regs);
>> +
>> +static inline bool kdump_in_progress(void)
>> +{
>> +    return crashing_cpu >= 0;
>>   }
>> -static inline void reserve_crashkernel(void) { ; }
>> +bool is_kdump_kernel(void);
>> +#define is_kdump_kernel            is_kdump_kernel
>> +#if defined(CONFIG_PPC_RTAS)
>> +void crash_free_reserved_phys_range(unsigned long begin, unsigned 
>> long end);
>> +#define crash_free_reserved_phys_range crash_free_reserved_phys_range
>> +#endif /* CONFIG_PPC_RTAS */
>> +
>> +#else /* !CONFIG_CRASH_DUMP */
>> +static inline void crash_kexec_secondary(struct pt_regs *regs) { }
>>   static inline int crash_shutdown_register(crash_shutdown_t handler)
>>   {
>> @@ -183,7 +183,7 @@ static inline void crash_send_ipi(void 
>> (*crash_ipi_callback)(struct pt_regs *))
>>   {
>>   }
>> -#endif /* CONFIG_KEXEC_CORE */
>> +#endif /* CONFIG_CRASH_DUMP */
>>   #ifdef CONFIG_PPC_BOOK3S_64
>>   #include <asm/book3s/64/kexec.h>
>> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
>> index 0b5878c3125b..1edc34b711ba 100644
>> --- a/arch/powerpc/kernel/prom.c
>> +++ b/arch/powerpc/kernel/prom.c
>> @@ -453,7 +453,7 @@ static int __init 
>> early_init_dt_scan_chosen_ppc(unsigned long node,
>>           tce_alloc_end = *lprop;
>>   #endif
>> -#ifdef CONFIG_KEXEC_CORE
>> +#ifdef CONFIG_CRASH_RESERVE
>>       lprop = of_get_flat_dt_prop(node, "linux,crashkernel-base", NULL);
>>       if (lprop)
>>           crashk_res.start = *lprop;
>> diff --git a/arch/powerpc/kernel/setup-common.c 
>> b/arch/powerpc/kernel/setup-common.c
>> index 733f210ffda1..35cac3eaaf75 100644
>> --- a/arch/powerpc/kernel/setup-common.c
>> +++ b/arch/powerpc/kernel/setup-common.c
>> @@ -109,7 +109,7 @@ int ppc_do_canonicalize_irqs;
>>   EXPORT_SYMBOL(ppc_do_canonicalize_irqs);
>>   #endif
>> -#ifdef CONFIG_VMCORE_INFO
>> +#ifdef CONFIG_CRASH_DUMP
>>   /* This keeps a track of which one is the crashing cpu. */
>>   int crashing_cpu = -1;
>>   #endif
>> diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
>> index 693334c20d07..aa81c95c73a4 100644
>> --- a/arch/powerpc/kernel/smp.c
>> +++ b/arch/powerpc/kernel/smp.c
>> @@ -588,7 +588,7 @@ void smp_send_debugger_break(void)
>>   }
>>   #endif
>> -#ifdef CONFIG_KEXEC_CORE
>> +#ifdef CONFIG_CRASH_DUMP
>>   void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *))
>>   {
>>       int cpu;
>> @@ -631,7 +631,7 @@ void crash_smp_send_stop(void)
>>       stopped = true;
>> -#ifdef CONFIG_KEXEC_CORE
>> +#ifdef CONFIG_CRASH_DUMP
>>       if (kexec_crash_image) {
>>           crash_kexec_prepare();
>>           return;
>> diff --git a/arch/powerpc/kexec/Makefile b/arch/powerpc/kexec/Makefile
>> index 91e96f5168b7..8e469c4da3f8 100644
>> --- a/arch/powerpc/kexec/Makefile
>> +++ b/arch/powerpc/kexec/Makefile
>> @@ -3,12 +3,13 @@
>>   # Makefile for the linux kernel.
>>   #
>> -obj-y                += core.o crash.o core_$(BITS).o
>> +obj-y                += core.o core_$(BITS).o
>>   obj-$(CONFIG_PPC32)        += relocate_32.o
>>   obj-$(CONFIG_KEXEC_FILE)    += file_load.o ranges.o 
>> file_load_$(BITS).o elf_$(BITS).o
>>   obj-$(CONFIG_VMCORE_INFO)    += vmcore_info.o
>> +obj-$(CONFIG_CRASH_DUMP)    += crash.o
> 
> 
> Observed a build failure with this patch.
> 
> arch/powerpc/platforms/powernv/smp.c: In function ‘pnv_smp_init’:
> arch/powerpc/platforms/powernv/smp.c:438:2: error: ‘crash_wake_offline’ 
> undeclared (first use in this function); did you mean ‘cpu_is_offline’?
>    crash_wake_offline = 1;
>    ^~~~~~~~~~~~~~~~~~
>    cpu_is_offline
> arch/powerpc/platforms/powernv/smp.c:438:2: note: each undeclared 
> identifier is reported only once for each function it appears in
> make[5]: *** [scripts/Makefile.build:244: 
> arch/powerpc/platforms/powernv/smp.o] Error 1
> 
> CONFIG:
> 
> CONFIG_KEXEC=y
> CONFIG_KEXEC_FILE=y
> # CONFIG_CRASH_DUMP is not set
> 
> Below changes fixes the above issue:
> 
> diff --git a/arch/powerpc/platforms/powernv/smp.c 
> b/arch/powerpc/platforms/powernv/smp.c
> index 9e1a25398f98..8f14f0581a21 100644
> --- a/arch/powerpc/platforms/powernv/smp.c
> +++ b/arch/powerpc/platforms/powernv/smp.c
> @@ -434,7 +434,7 @@ void __init pnv_smp_init(void)
>          smp_ops = &pnv_smp_ops;
> 
>   #ifdef CONFIG_HOTPLUG_CPU
> -#ifdef CONFIG_KEXEC_CORE
> +#ifdef CONFIG_CRASH_DUMP
>          crash_wake_offline = 1;
>   #endif
>   #endif

Right. Missed testing with CONFIG_PPC_POWERNV.
Will post v2.

Thanks
Hari

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ