Skip to content

Commit

Permalink
From patchwork series 372639
Browse files Browse the repository at this point in the history
  • Loading branch information
Fox Snowpatch committed Sep 12, 2023
1 parent d774975 commit 7b771b5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
8 changes: 6 additions & 2 deletions arch/powerpc/include/asm/kexec.h
Expand Up @@ -99,10 +99,14 @@ void relocate_new_kernel(unsigned long indirection_page, unsigned long reboot_co

void kexec_copy_flush(struct kimage *image);

#if defined(CONFIG_CRASH_DUMP) && defined(CONFIG_PPC_RTAS)
#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
#endif /* CONFIG_PPC_RTAS */
#endif /* CONFIG_CRASH_DUMP */

#ifdef CONFIG_KEXEC_FILE
extern const struct kexec_file_ops kexec_elf64_ops;
Expand Down
12 changes: 12 additions & 0 deletions arch/powerpc/kernel/crash_dump.c
Expand Up @@ -19,6 +19,7 @@
#include <linux/uio.h>
#include <asm/rtas.h>
#include <asm/inst.h>
#include <asm/fadump.h>

#ifdef DEBUG
#include <asm/udbg.h>
Expand Down Expand Up @@ -92,6 +93,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
Expand Down
8 changes: 5 additions & 3 deletions include/linux/crash_dump.h
Expand Up @@ -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
Expand All @@ -64,6 +65,7 @@ static inline bool is_kdump_kernel(void)
{
return elfcorehdr_addr != ELFCORE_ADDR_MAX;
}
#endif

/* is_vmcore_usable() checks if the kernel is booting after a panic and
* the vmcore region is usable.
Expand All @@ -75,7 +77,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 elfcorehdr_addr != ELFCORE_ADDR_ERR &&
elfcorehdr_addr != ELFCORE_ADDR_MAX ? 1 : 0;
}

/* vmcore_unusable() marks the vmcore as unusable,
Expand All @@ -84,8 +87,7 @@ static inline int is_vmcore_usable(void)

static inline void vmcore_unusable(void)
{
if (is_kdump_kernel())
elfcorehdr_addr = ELFCORE_ADDR_ERR;
elfcorehdr_addr = ELFCORE_ADDR_ERR;
}

/**
Expand Down

0 comments on commit 7b771b5

Please sign in to comment.