powerpc/fadump: make is_fadump_active() visible for exporting vmcore
Subsystems (4)
PATCH v2 1/3 powerpc/fadump: make is_fadump_active() visible for exporting vmcore
Include asm/fadump.h in asm/kexec.h to make it visible while exporting vmcore. Also, update is_fadump_active() to return boolean instead of integer for better readability. The change will be used in the next patch to ensure vmcore is exported when fadump is active.
---
Changes in v2:
* New patch based on Baoquan's suggestion to use is_fadump_active() instead of introducing new function is_crashdump_kernel().
arch/powerpc/include/asm/fadump.h | 4 ++-- arch/powerpc/include/asm/kexec.h | 8 ++++++-- arch/powerpc/kernel/fadump.c | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/fadump.h +2 -2
@@ -15,13 +15,13 @@ extern int crashing_cpu;extern int is_fadump_memory_area (u64 addr,ulong size);extern int setup_fadump (void ); -extern int is_fadump_active (void ); +extern bool is_fadump_active (void );extern int should_fadump_crash (void );extern void crash_fadump (struct pt_regs *,const char *);extern void fadump_cleanup (void );#else /* CONFIG_FA_DUMP */ -static inline int is_fadump_active (void ) {return 0 ; } +static inline bool is_fadump_active (void ) {return false; }static inline int should_fadump_crash (void ) {return 0 ; }static inline void crash_fadump (struct pt_regs *regs,const char *str) { }static inline void fadump_cleanup (void ) { }
arch/powerpc/include/asm/kexec.h +6 -2
@@ -51,6 +51,7 @@#ifndef __ASSEMBLY__#include <asm/reg.h> +#include <asm/fadump.h> typedef void (*crash_shutdown_t )(void );
@@ -99,10 +100,13 @@ void relocate_new_kernel(unsigned long indirection_page, unsigned long reboot_covoid kexec_copy_flush (struct kimage *image); -#if defined(CONFIG_CRASH_DUMP ) && defined(CONFIG_PPC_RTAS ) +#if defined(CONFIG_CRASH_DUMP ) +#define is_fadump_active is_fadump_active +#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 +#endif /* CONFIG_PPC_RTAS */ +#endif /* CONFIG_CRASH_DUMP */ #ifdef CONFIG_KEXEC_FILE extern const struct kexec_file_ops kexec_elf64_ops;
arch/powerpc/kernel/fadump.c +2 -2
@@ -187,9 +187,9 @@ int should_fadump_crash(void)return 1 ; } -int is_fadump_active (void ) +bool is_fadump_active (void ) { -return fw_dump.dump_active; +return !!fw_dump.dump_active; }/*
Signature · 7 lines
2.41.0 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH v2 2/3 vmcore: allow fadump to export vmcore even if is_kdump_kernel() is false
Currently, is_kdump_kernel() returns true when elfcorehdr_addr is set. While elfcorehdr_addr is set for kexec based kernel dump mechanism, alternate dump capturing methods like fadump [1] also set it to export the vmcore. Since, is_kdump_kernel() is used to restrict resources in crash dump capture kernel and such restrictions are not desirable for fadump, allow is_kdump_kernel() to be defined differently for fadump case. With that change, include is_fadump_active() check in functions is_vmcore_usable() & vmcore_unusable() to be able to export vmcore for fadump case too.
[1] https://docs.kernel.org/powerpc/firmware-assisted-dump.html
---
Changes in v2:
* is_fadump_active() check added to is_vmcore_usable() as suggested by Baoquan.
include/linux/crash_dump.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
include/linux/crash_dump.h +17 -2
@@ -50,6 +50,7 @@ void vmcore_cleanup(void);#define vmcore_elf64_check_arch (x) (elf_check_arch(x) || vmcore_elf_check_arch_cross(x))#endif +#ifndef is_kdump_kernel/* * is_kdump_kernel() checks whether this kernel is booting after a panic of * previous kernel or not. This is determined by checking if previous kernel
@@ -64,6 +65,19 @@ static inline bool is_kdump_kernel(void) {return elfcorehdr_addr !=ELFCORE_ADDR_MAX ; } +#endif + +#ifndef is_fadump_active +/* +* If f/w assisted dump capturing mechanism (fadump), instead of kexec based +* dump capturing mechanism (kdump) is exporting the vmcore, then this function +* will be defined in arch specific code to return true, when appropriate. +*/ +static inline bool is_fadump_active (void ) +{ +return false; +} +#endif /* is_vmcore_usable() checks if the kernel is booting after a panic and * the vmcore region is usable.
@@ -75,7 +89,8 @@ static inline bool is_kdump_kernel(void)static inline int is_vmcore_usable (void ) { -return is_kdump_kernel () && elfcorehdr_addr !=ELFCORE_ADDR_ERR ?1 :0 ; +return (is_kdump_kernel () ||is_fadump_active ()) + && elfcorehdr_addr !=ELFCORE_ADDR_ERR ?1 :0 ; }/* vmcore_unusable() marks the vmcore as unusable,
@@ -84,7 +99,7 @@ static inline int is_vmcore_usable(void)static inline void vmcore_unusable (void ) { -if (is_kdump_kernel ()) +if (is_kdump_kernel () ||is_fadump_active ()) elfcorehdr_addr =ELFCORE_ADDR_ERR ; }
Signature · 7 lines
2.41.0 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Michael Ellerman
reviewerRe: [PATCH v2 2/3] vmcore: allow fadump to export vmcore even if is_kdump_kernel() is false
Quoted 9 lines · Hari Bathini
Currently,
is_kdump_kernel()returns true whenelfcorehdr_addris set. Whileelfcorehdr_addris set for kexec based kernel dump mechanism, alternate dump capturing methods like fadump [1] also set it to export the vmcore. Since,is_kdump_kernel()is used to restrict resources in crash dump capture kernel and such restrictions are not desirable for fadump, allowis_kdump_kernel()to be defined differently for fadump case. With that change, includeis_fadump_active()check in functionsis_vmcore_usable()&vmcore_unusable()to be able to export vmcore for fadump case too.
...
Quoted 43 lines
include/linux/crash_dump.h +16
-1@@ -50,6 +50,7 @@ void vmcore_cleanup(void);#define vmcore_elf64_check_arch (x) (elf_check_arch(x) || vmcore_elf_check_arch_cross(x))#endif +#ifndef is_kdump_kernel/* * is_kdump_kernel() checks whether this kernel is booting after a panic of * previous kernel or not. This is determined by checking if previous kernel @@ -64,6 +65,19 @@ static inline bool is_kdump_kernel(void) {return elfcorehdr_addr !=ELFCORE_ADDR_MAX ; } +#endif + +#ifndef is_fadump_active +/* +* If f/w assisted dump capturing mechanism (fadump), instead of kexec based +* dump capturing mechanism (kdump) is exporting the vmcore, then this function +* will be defined in arch specific code to return true, when appropriate. +*/ +static inline bool is_fadump_active (void ) +{ +return false; +} +#endif /* is_vmcore_usable() checks if the kernel is booting after a panic and * the vmcore region is usable. @@ -75,7 +89,8 @@ static inline bool is_kdump_kernel(void)static inline int is_vmcore_usable (void ) { -return is_kdump_kernel () && elfcorehdr_addr !=ELFCORE_ADDR_ERR ?1 :0 ; +return (is_kdump_kernel () ||is_fadump_active ()) + && elfcorehdr_addr !=ELFCORE_ADDR_ERR ?1 :0 ; }/* vmcore_unusable() marks the vmcore as unusable,
include/linux/crash_dump.h static inline int is_vmcore_usable(void) · line 104
Quoted 7 lines
include/linux/crash_dump.h +1
-1@@ -84,7 +99,7 @@ static inline int is_vmcore_usable(void)static inline void vmcore_unusable (void ) { -if (is_kdump_kernel ()) +if (is_kdump_kernel () ||is_fadump_active ()) elfcorehdr_addr =ELFCORE_ADDR_ERR ; }
I think it would be cleaner to decouple is_vmcore_usable() and vmcore_usable() from is_kdump_kernel().
ie, make them operate solely based on the value of elforehdr_addr:
static inline int is_vmcore_usable(void)
{
elfcorehdr_addr != ELFCORE_ADDR_ERR && \
elfcorehdr_addr != ELFCORE_ADDR_MAX;
}static inline void vmcore_unusable(void)
{
elfcorehdr_addr = ELFCORE_ADDR_ERR;
}Then all we need on powerpc is a way to override is_kdump_kernel().
cheers
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v2 2/3] vmcore: allow fadump to export vmcore even if is_kdump_kernel() is false
Quoted 65 lines · Michael Ellerman
Quoted 9 lines · Hari Bathini
Currently,
is_kdump_kernel()returns true whenelfcorehdr_addris set. Whileelfcorehdr_addris set for kexec based kernel dump mechanism, alternate dump capturing methods like fadump [1] also set it to export the vmcore. Since,is_kdump_kernel()is used to restrict resources in crash dump capture kernel and such restrictions are not desirable for fadump, allowis_kdump_kernel()to be defined differently for fadump case. With that change, includeis_fadump_active()check in functionsis_vmcore_usable()&vmcore_unusable()to be able to export vmcore for fadump case too....
Quoted 43 lines
include/linux/crash_dump.h +16
-1@@ -50,6 +50,7 @@ void vmcore_cleanup(void);#define vmcore_elf64_check_arch (x) (elf_check_arch(x) || vmcore_elf_check_arch_cross(x))#endif +#ifndef is_kdump_kernel/* * is_kdump_kernel() checks whether this kernel is booting after a panic of * previous kernel or not. This is determined by checking if previous kernel @@ -64,6 +65,19 @@ static inline bool is_kdump_kernel(void) {return elfcorehdr_addr !=ELFCORE_ADDR_MAX ; } +#endif + +#ifndef is_fadump_active +/* +* If f/w assisted dump capturing mechanism (fadump), instead of kexec based +* dump capturing mechanism (kdump) is exporting the vmcore, then this function +* will be defined in arch specific code to return true, when appropriate. +*/ +static inline bool is_fadump_active (void ) +{ +return false; +} +#endif /* is_vmcore_usable() checks if the kernel is booting after a panic and * the vmcore region is usable. @@ -75,7 +89,8 @@ static inline bool is_kdump_kernel(void)static inline int is_vmcore_usable (void ) { -return is_kdump_kernel () && elfcorehdr_addr !=ELFCORE_ADDR_ERR ?1 :0 ; +return (is_kdump_kernel () ||is_fadump_active ()) + && elfcorehdr_addr !=ELFCORE_ADDR_ERR ?1 :0 ; }/* vmcore_unusable() marks the vmcore as unusable, include/linux/crash_dump.h static inline int is_vmcore_usable(void) · line 104
Quoted 7 lines
include/linux/crash_dump.h +1
-1@@ -84,7 +99,7 @@ static inline int is_vmcore_usable(void)static inline void vmcore_unusable (void ) { -if (is_kdump_kernel ()) +if (is_kdump_kernel () ||is_fadump_active ()) elfcorehdr_addr =ELFCORE_ADDR_ERR ; }I think it would be cleaner to decouple
is_vmcore_usable()andvmcore_usable()fromis_kdump_kernel().
Quoted 6 lines
ie, make them operate solely based on the value of
elforehdr_addr:static inline int
is_vmcore_usable(void){ elfcorehdr_addr != ELFCORE_ADDR_ERR && \ elfcorehdr_addr != ELFCORE_ADDR_MAX;
Agree. I fell into the blind corner of thinking earlier. Above change is better.
Quoted 12 lines
}
static inline void
vmcore_unusable(void){ elfcorehdr_addr = ELFCORE_ADDR_ERR; }Then all we need on powerpc is a way to override
is_kdump_kernel().cheers
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH v2 2/3] vmcore: allow fadump to export vmcore even if is_kdump_kernel() is false
Quoted 68 lines · Baoquan He
Quoted 67 lines · Michael Ellerman
Quoted 9 lines · Hari Bathini
Currently,
is_kdump_kernel()returns true whenelfcorehdr_addris set. Whileelfcorehdr_addris set for kexec based kernel dump mechanism, alternate dump capturing methods like fadump [1] also set it to export the vmcore. Since,is_kdump_kernel()is used to restrict resources in crash dump capture kernel and such restrictions are not desirable for fadump, allowis_kdump_kernel()to be defined differently for fadump case. With that change, includeis_fadump_active()check in functionsis_vmcore_usable()&vmcore_unusable()to be able to export vmcore for fadump case too....
Quoted 43 lines
include/linux/crash_dump.h +16
-1@@ -50,6 +50,7 @@ void vmcore_cleanup(void);#define vmcore_elf64_check_arch (x) (elf_check_arch(x) || vmcore_elf_check_arch_cross(x))#endif +#ifndef is_kdump_kernel/* * is_kdump_kernel() checks whether this kernel is booting after a panic of * previous kernel or not. This is determined by checking if previous kernel @@ -64,6 +65,19 @@ static inline bool is_kdump_kernel(void) {return elfcorehdr_addr !=ELFCORE_ADDR_MAX ; } +#endif + +#ifndef is_fadump_active +/* +* If f/w assisted dump capturing mechanism (fadump), instead of kexec based +* dump capturing mechanism (kdump) is exporting the vmcore, then this function +* will be defined in arch specific code to return true, when appropriate. +*/ +static inline bool is_fadump_active (void ) +{ +return false; +} +#endif /* is_vmcore_usable() checks if the kernel is booting after a panic and * the vmcore region is usable. @@ -75,7 +89,8 @@ static inline bool is_kdump_kernel(void)static inline int is_vmcore_usable (void ) { -return is_kdump_kernel () && elfcorehdr_addr !=ELFCORE_ADDR_ERR ?1 :0 ; +return (is_kdump_kernel () ||is_fadump_active ()) + && elfcorehdr_addr !=ELFCORE_ADDR_ERR ?1 :0 ; }/* vmcore_unusable() marks the vmcore as unusable, include/linux/crash_dump.h static inline int is_vmcore_usable(void) · line 104
Quoted 7 lines
include/linux/crash_dump.h +1
-1@@ -84,7 +99,7 @@ static inline int is_vmcore_usable(void)static inline void vmcore_unusable (void ) { -if (is_kdump_kernel ()) +if (is_kdump_kernel () ||is_fadump_active ()) elfcorehdr_addr =ELFCORE_ADDR_ERR ; }I think it would be cleaner to decouple
is_vmcore_usable()andvmcore_usable()fromis_kdump_kernel().ie, make them operate solely based on the value of
elforehdr_addr:
Quoted 7 lines
Quoted 4 lines
static inline int
is_vmcore_usable(void){ elfcorehdr_addr != ELFCORE_ADDR_ERR && \ elfcorehdr_addr != ELFCORE_ADDR_MAX;Agree. I fell into the blind corner of thinking earlier. Above change is better.
Thanks for the reviews.
Posted v3.
- Hari
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
PATCH v2 3/3 powerpc/fadump: make is_kdump_kernel() return false when fadump is active
In reply to Hari BathiniCurrently, is_kdump_kernel() returns true in crash dump capture kernel for both kdump and fadump crash dump capturing methods, as both these methods set elfcorehdr_addr. Some restrictions enforced for crash dump capture kernel, based on is_kdump_kernel(), are specifically meant for kdump case and not desirable for fadump - eg. IO queues restriction in device drivers. So, define is_kdump_kernel() to return false when f/w assisted dump is active.
--- arch/powerpc/include/asm/kexec.h | 2 ++ arch/powerpc/kernel/crash_dump.c | 11 +++++++++++ 2 files changed, 13 insertions(+)
arch/powerpc/include/asm/kexec.h +2 -0
@@ -101,6 +101,8 @@ void relocate_new_kernel(unsigned long indirection_page, unsigned long reboot_covoid kexec_copy_flush (struct kimage *image);#if defined(CONFIG_CRASH_DUMP ) +bool is_kdump_kernel (void ); +#define is_kdump_kernel is_kdump_kernel#define is_fadump_active is_fadump_active#if defined(CONFIG_PPC_RTAS )void crash_free_reserved_phys_range (unsigned long begin,unsigned long end);
arch/powerpc/kernel/crash_dump.c +11 -0
@@ -92,6 +92,17 @@ ssize_t copy_oldmem_page(struct iov_iter *iter, unsigned long pfn,return csize; } +/* +* Return true only when kexec based kernel dump capturing method is used. +* This ensures all restritions applied for kdump case are not automatically +* applied for fadump case. +*/ +bool is_kdump_kernel (void ) +{ +return !is_fadump_active () && elfcorehdr_addr !=ELFCORE_ADDR_MAX ; +} +EXPORT_SYMBOL_GPL (is_kdump_kernel); +#ifdef CONFIG_PPC_RTAS /* * The crashkernel region will almost always overlap the RTAS region, so
Signature · 7 lines
2.41.0 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Quoted 6 lines · Hari Bathini
Include
asm/fadump.hinasm/kexec.hto make it visible while exporting vmcore. Also, updateis_fadump_active()to return boolean instead of integer for better readability. The change will be used in the next patch to ensure vmcore is exported when fadump is active.Signed-off-by Hari Bathini <[email protected]>
Thanks, Hari. The whole series looks good to me.
Since it's a power specific change, should be picked into powerpc tree?
Thanks
Baoquan
Quoted 79 lines
---
Changes in v2:
* New patch based on Baoquan's suggestion to useis_fadump_active()instead of introducing new functionis_crashdump_kernel().arch/powerpc/include/asm/fadump.h | 4 ++-- arch/powerpc/include/asm/kexec.h | 8 ++++++-- arch/powerpc/kernel/fadump.c | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-)arch/powerpc/include/asm/fadump.h +2
-2@@ -15,13 +15,13 @@ extern int crashing_cpu;extern int is_fadump_memory_area (u64 addr,ulong size);extern int setup_fadump (void ); -extern int is_fadump_active (void ); +extern bool is_fadump_active (void );extern int should_fadump_crash (void );extern void crash_fadump (struct pt_regs *,const char *);extern void fadump_cleanup (void );#else /* CONFIG_FA_DUMP */ -static inline int is_fadump_active (void ) {return 0 ; } +static inline bool is_fadump_active (void ) {return false; }static inline int should_fadump_crash (void ) {return 0 ; }static inline void crash_fadump (struct pt_regs *regs,const char *str) { }static inline void fadump_cleanup (void ) { }arch/powerpc/include/asm/kexec.h +6
-2@@ -51,6 +51,7 @@#ifndef __ASSEMBLY__#include <asm/reg.h> +#include <asm/fadump.h> typedef void (*crash_shutdown_t )(void );@@ -99,10 +100,13 @@ void relocate_new_kernel(unsigned long indirection_page, unsigned long reboot_covoid kexec_copy_flush (struct kimage *image); -#if defined(CONFIG_CRASH_DUMP ) && defined(CONFIG_PPC_RTAS ) +#if defined(CONFIG_CRASH_DUMP ) +#define is_fadump_active is_fadump_active +#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 +#endif /* CONFIG_PPC_RTAS */ +#endif /* CONFIG_CRASH_DUMP */ #ifdef CONFIG_KEXEC_FILE extern const struct kexec_file_ops kexec_elf64_ops;arch/powerpc/kernel/fadump.c +2
-2@@ -187,9 +187,9 @@ int should_fadump_crash(void)return 1 ; } -int is_fadump_active (void ) +bool is_fadump_active (void ) { -return fw_dump.dump_active; +return !!fw_dump.dump_active; }/* Signature · 1 line
2.41.0
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Thanks, Baoquan.
Quoted 6 lines · Baoquan He
Quoted 5 lines · Hari Bathini
Include
asm/fadump.hinasm/kexec.hto make it visible while exporting vmcore. Also, updateis_fadump_active()to return boolean instead of integer for better readability. The change will be used in the next patch to ensure vmcore is exported when fadump is active.
Quoted 7 lines
Quoted 1 line
Signed-off-by Hari Bathini <[email protected]>Thanks, Hari. The whole series looks good to me.
Acked-by Baoquan He <[email protected]>Since it's a power specific change, should be picked into powerpc tree?
Michael, would you mind taking the series via powerpc tree..
Thanks
Hari
Quoted 75 lines
Quoted 75 lines
---
Changes in v2:
* New patch based on Baoquan's suggestion to useis_fadump_active()instead of introducing new functionis_crashdump_kernel().arch/powerpc/include/asm/fadump.h | 4 ++-- arch/powerpc/include/asm/kexec.h | 8 ++++++-- arch/powerpc/kernel/fadump.c | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-)arch/powerpc/include/asm/fadump.h +2
-2@@ -15,13 +15,13 @@ extern int crashing_cpu;extern int is_fadump_memory_area (u64 addr,ulong size);extern int setup_fadump (void ); -extern int is_fadump_active (void ); +extern bool is_fadump_active (void );extern int should_fadump_crash (void );extern void crash_fadump (struct pt_regs *,const char *);extern void fadump_cleanup (void );#else /* CONFIG_FA_DUMP */ -static inline int is_fadump_active (void ) {return 0 ; } +static inline bool is_fadump_active (void ) {return false; }static inline int should_fadump_crash (void ) {return 0 ; }static inline void crash_fadump (struct pt_regs *regs,const char *str) { }static inline void fadump_cleanup (void ) { }arch/powerpc/include/asm/kexec.h +6
-2@@ -51,6 +51,7 @@#ifndef __ASSEMBLY__#include <asm/reg.h> +#include <asm/fadump.h> typedef void (*crash_shutdown_t )(void );@@ -99,10 +100,13 @@ void relocate_new_kernel(unsigned long indirection_page, unsigned long reboot_covoid kexec_copy_flush (struct kimage *image); -#if defined(CONFIG_CRASH_DUMP ) && defined(CONFIG_PPC_RTAS ) +#if defined(CONFIG_CRASH_DUMP ) +#define is_fadump_active is_fadump_active +#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 +#endif /* CONFIG_PPC_RTAS */ +#endif /* CONFIG_CRASH_DUMP */ #ifdef CONFIG_KEXEC_FILE extern const struct kexec_file_ops kexec_elf64_ops;arch/powerpc/kernel/fadump.c +2
-2@@ -187,9 +187,9 @@ int should_fadump_crash(void)return 1 ; } -int is_fadump_active (void ) +bool is_fadump_active (void ) { -return fw_dump.dump_active; +return !!fw_dump.dump_active; }
Quoted 5 lines
Quoted 4 lines
arch/powerpc/kernel/fadump.c +0
-0/* Signature · 1 line
2.41.0
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec