Re: [Crash-utility] [PATCH v2] defs.h: Fix the value of TIF_SIGPENDING macro
by lijiang
> Date: Thu, 3 Jun 2021 16:07:41 +0800
> From: Youling Tang <tangyouling(a)loongson.cn>
> To: HAGIO KAZUHITO(?????) <k-hagio-ab(a)nec.com>
> Cc: "crash-utility(a)redhat.com" <crash-utility(a)redhat.com>
> Subject: [Crash-utility] [PATCH v2] defs.h: Fix the value of
> TIF_SIGPENDING macro
> Message-ID:
> <1622707661-29691-1-git-send-email-tangyouling(a)loongson.cn>
> Content-Type: text/plain; charset="US-ASCII"
>
> Correct the change of the value of TIF_SIGPENDING macro between
> different kernel versions.
>
> TIF_SIGPENDING changes with the kernel version as follows:
> ARM 2 -> 0 at v2.6.23
> MIPS 2 -> 1 at v2.6.23
> MIPS64 2 -> 1 at v2.6.23
> PPC 2 -> 1 at v2.6.23
> IA64 1 -> 0 at v2.6.23
> PPC64 2 -> 1 at v2.6.23
> S390 2 -> 1 at v3.16
> S390X 2 -> 1 at v3.16
>
For the patch series: Acked-by: Lianbo Jiang <lijiang(a)redhat.com>
[PATCH v2 1/3] defs.h: Fix the value of TIF_SIGPENDING macro
[PATCH 2/3] MIPS64: Modify the comment of mips64_register structure
[PATCH 3/3] MIPS64: Add support for ramdump type
> Signed-off-by: Youling Tang <tangyouling(a)loongson.cn>
> ---
> defs.h | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/defs.h b/defs.h
> index 396d61a..3502c6d 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -2997,7 +2997,7 @@ typedef struct QEMUCPUState QEMUCPUState;
> #define __swp_type(entry) SWP_TYPE(entry)
> #define __swp_offset(entry) SWP_OFFSET(entry)
>
> -#define TIF_SIGPENDING (2)
> +#define TIF_SIGPENDING (THIS_KERNEL_VERSION >= LINUX(2,6,23) ? 0 : 2)
>
> #define _SECTION_SIZE_BITS 28
> #define _MAX_PHYSMEM_BITS 32
> @@ -3377,7 +3377,7 @@ struct arm64_stackframe {
> #define __swp_type(entry) SWP_TYPE(entry)
> #define __swp_offset(entry) SWP_OFFSET(entry)
>
> -#define TIF_SIGPENDING (2)
> +#define TIF_SIGPENDING (THIS_KERNEL_VERSION >= LINUX(2,6,23) ? 1 : 2)
>
> #define _SECTION_SIZE_BITS 26
> #define _MAX_PHYSMEM_BITS 32
> @@ -3416,7 +3416,7 @@ struct arm64_stackframe {
> #define __swp_type(entry) SWP_TYPE(entry)
> #define __swp_offset(entry) SWP_OFFSET(entry)
>
> -#define TIF_SIGPENDING (2)
> +#define TIF_SIGPENDING (THIS_KERNEL_VERSION >= LINUX(2,6,23) ? 1 : 2)
>
> #define _SECTION_SIZE_BITS 28
> #define _MAX_PHYSMEM_BITS 48
> @@ -3884,7 +3884,7 @@ struct machine_specific {
> #define __swp_type(entry) SWP_TYPE(entry)
> #define __swp_offset(entry) SWP_OFFSET(entry)
>
> -#define TIF_SIGPENDING (2)
> +#define TIF_SIGPENDING (THIS_KERNEL_VERSION >= LINUX(2,6,23) ? 1 : 2)
>
> #define _SECTION_SIZE_BITS 24
> #define _MAX_PHYSMEM_BITS 44
> @@ -4079,7 +4079,7 @@ struct efi_memory_desc_t {
> #define __swp_type(entry) ((entry >> 2) & 0x7f)
> #define __swp_offset(entry) ((entry << 1) >> 10)
>
> -#define TIF_SIGPENDING (1)
> +#define TIF_SIGPENDING (THIS_KERNEL_VERSION >= LINUX(2,6,23) ? 0 : 1)
>
> #define KERNEL_TR_PAGE_SIZE (1 << _PAGE_SIZE_64M)
> #define KERNEL_TR_PAGE_MASK (~(KERNEL_TR_PAGE_SIZE - 1))
> @@ -4219,7 +4219,7 @@ struct efi_memory_desc_t {
> #define PTE_RPN_MASK (machdep->machspec->pte_rpn_mask)
> #define PTE_RPN_SHIFT (machdep->machspec->pte_rpn_shift)
>
> -#define TIF_SIGPENDING (2)
> +#define TIF_SIGPENDING (THIS_KERNEL_VERSION >= LINUX(2,6,23) ? 1 : 2)
>
> #define SWP_TYPE(entry) (((entry) >> 1) & 0x7f)
> #define SWP_OFFSET(entry) ((entry) >> 8)
> @@ -4259,7 +4259,7 @@ struct efi_memory_desc_t {
> #define __swp_type(entry) SWP_TYPE(entry)
> #define __swp_offset(entry) SWP_OFFSET(entry)
>
> -#define TIF_SIGPENDING (2)
> +#define TIF_SIGPENDING (THIS_KERNEL_VERSION >= LINUX(3,16,0) ? 1 : 2)
>
> #define _SECTION_SIZE_BITS 25
> #define _MAX_PHYSMEM_BITS 31
> @@ -4284,7 +4284,7 @@ struct efi_memory_desc_t {
> #define __swp_type(entry) SWP_TYPE(entry)
> #define __swp_offset(entry) SWP_OFFSET(entry)
>
> -#define TIF_SIGPENDING (2)
> +#define TIF_SIGPENDING (THIS_KERNEL_VERSION >= LINUX(3,16,0) ? 1 : 2)
>
> #define _SECTION_SIZE_BITS 28
> #define _MAX_PHYSMEM_BITS_OLD 42
> --
> 2.1.0
>
3 years, 6 months
Re: [Crash-utility] [PATCH 1/2] diskdump: Fail readmem() early if dump is incomplete
by lijiang
> Date: Wed, 2 Jun 2021 18:56:50 +0300
> From: Roman Bolshakov <r.bolshakov(a)yadro.com>
> To: <crash-utility(a)redhat.com>
> Cc: linux(a)yadro.com
> Subject: [Crash-utility] [PATCH 1/2] diskdump: Fail readmem() early if
> dump is incomplete
> Message-ID: <20210602155650.86202-2-r.bolshakov(a)yadro.com>
> Content-Type: text/plain
>
Hi, Roman
Thank you for the improvement.
> kdump format description [1] says:
>
> [...] zero page has its own offset not equal 0. So when reading page
> from incomplete core, only the page lost by ENOSPACE errors has 0 in its
> corresponding page descriptor's member offset.
>
> crash has special treatment for page descriptors with zero offset only if
> DUMP_DH_COMPRESSED_INCOMPLETE is set in dump header. However,
> makedumpfile places the flag after ENOSPC is hit and only if dump header
> modification went without errors.
>
> In case if crashkernel environment was terminated early (e.g. by BMC) or
> some other reason, DUMP_DH_COMPRESSED_INCOMPLETE won't be set on the
> dump header. Then cache_page() would be performed on pages with
> pd.offset == 0 and due to pd.size == 0 it'll skip read into
> compressed_page and then non related pre-existing contents of
> compressed_page will copied into page cache for the non-present page.
>
> Ultimately, it'll lead to a cryptic failure, like:
>
> crash: invalid kernel virtual address: 72288cacacf427f8 [...]
>
> The failure would be a bit cleaner if crash explicitly fails on the page
> that is an outcome of incomplete dump:
>
> crash: page incomplete: kernel virtual address: c000003fff9d17e8 [...]
>
> Debugging level 8 would also produce exact offset from data_offset to
> print descriptor value with ease:
>
> read_diskdump/cache_page: descriptor with zero offset found at paddr/pfn/pos: 3fff9d0000/3fff9d/743dd
>
> That helps in inspecting broken descriptor with hexdump or similar tools:
>
> hexdump -s (data_offset + pos * 0x18) -n 0x18
>
> 1. https://github.com/makedumpfile/makedumpfile/blob/master/IMPLEMENTATION
>
> Signed-off-by: Roman Bolshakov <r.bolshakov(a)yadro.com>
> ---
> defs.h | 1 +
> diskdump.c | 13 ++++++++++---
> memory.c | 7 +++++++
> 3 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/defs.h b/defs.h
> index 396d61a..8418da2 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -361,6 +361,7 @@ struct number_option {
> #define READ_ERROR (-2)
> #define WRITE_ERROR (-3)
> #define PAGE_EXCLUDED (-4)
> +#define PAGE_INCOMPLETE (-5)
>
> #define RESTART() (longjmp(pc->main_loop_env, 1))
> #define RESUME_FOREACH() (longjmp(pc->foreach_loop_env, 1))
> diff --git a/diskdump.c b/diskdump.c
> index 3effb52..c05f1ec 100644
> --- a/diskdump.c
> +++ b/diskdump.c
> @@ -1146,7 +1146,7 @@ cache_page(physaddr_t paddr)
> if (FLAT_FORMAT()) {
> if (!read_flattened_format(dd->dfd, pd.offset, dd->compressed_page, pd.size))
> return READ_ERROR;
> - } else if (is_incomplete_dump() && (0 == pd.offset)) {
> + } else if (0 == pd.offset) {
> /*
> * If the incomplete flag has been set in the header,
> * first check whether zero_excluded has been set.
Does it still make sense to check the incomplete flag for the
zero_excluded case? Otherwise, the above code comment will be
outdated.
+ } else if (0 == pd.offset) {
...
- if (*diskdump_flags & ZERO_EXCLUDED) {
+ if (is_incomplete_dump() && (*diskdump_flags & ZERO_EXCLUDED)) {
Thanks.
Lianbo
> @@ -1158,8 +1158,15 @@ cache_page(physaddr_t paddr)
> "paddr/pfn: %llx/%lx\n",
> (ulonglong)paddr, pfn);
> memset(dd->compressed_page, 0, dd->block_size);
> - } else
> - return READ_ERROR;
> + } else {
> + if (CRASHDEBUG(8))
> + fprintf(fp,
> + "read_diskdump/cache_page: "
> + "descriptor with zero offset found at "
> + "paddr/pfn/pos: %llx/%lx/%lx\n",
> + (ulonglong)paddr, pfn, desc_pos);
> + return PAGE_INCOMPLETE;
> + }
> } else {
> if (lseek(dd->dfd, pd.offset, SEEK_SET) == failed)
> return SEEK_ERROR;
> diff --git a/memory.c b/memory.c
> index 8c6bbe4..5d7eee6 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -2211,6 +2211,7 @@ accessible(ulong kva)
> #define READ_ERRMSG "read error: %s address: %llx type: \"%s\"\n"
> #define WRITE_ERRMSG "write error: %s address: %llx type: \"%s\"\n"
> #define PAGE_EXCLUDED_ERRMSG "page excluded: %s address: %llx type: \"%s\"\n"
> +#define PAGE_INCOMPLETE_ERRMSG "page incomplete: %s address: %llx type: \"%s\"\n"
>
> #define RETURN_ON_PARTIAL_READ() \
> if ((error_handle & RETURN_PARTIAL) && (size < orig_size)) { \
> @@ -2376,6 +2377,12 @@ readmem(ulonglong addr, int memtype, void *buffer, long size,
> error(INFO, PAGE_EXCLUDED_ERRMSG, memtype_string(memtype, 0), addr, type);
> goto readmem_error;
>
> + case PAGE_INCOMPLETE:
> + RETURN_ON_PARTIAL_READ();
> + if (PRINT_ERROR_MESSAGE)
> + error(INFO, PAGE_INCOMPLETE_ERRMSG, memtype_string(memtype, 0), addr, type);
> + goto readmem_error;
> +
> default:
> break;
> }
> --
> 2.31.1
3 years, 6 months
[PATCH 0/2] diskdump: Improve handling of incomplete dumps
by Roman Bolshakov
Hi,
makedumpfile may produce an incomplete dump if interrupted early or in
case if an unrecoverable I/O error happens during the execution of
makedumpfile. As of now crash begins analysis of such incomplete dump
and fails in some misleading way.
The series helps crash to avoid going too far with incomplete dumps
while provides means to localize how much data is lost in the core.
Thanks,
Roman
Roman Bolshakov (2):
diskdump: Fail readmem() early if dump is incomplete
diskdump: Print total number of dumpable pages
defs.h | 1 +
diskdump.c | 20 ++++++++++++++++----
memory.c | 7 +++++++
3 files changed, 24 insertions(+), 4 deletions(-)
--
2.31.1
3 years, 6 months
[PATCHv7 0/4] crash-utility/arm64: memory layout bug fixes
by Pingfan Liu
This series fix the bug caused by arm64 kernel memory layout changes
base on commit ec44b90 memory: Fix for "kmem -n" option to display NID correctly
Cc: HAGIO KAZUHITO <k-hagio-ab(a)nec.com>
Cc: Lianbo Jiang <lijiang(a)redhat.com>
Cc: Bhupesh Sharma <bhupesh.sharma(a)linaro.org>
To: crash-utility(a)redhat.com
Pingfan Liu (4):
crash-utility/arm64: introduce a dedicated field to record the mem
layout changes
crash-utility/arm64: store phy_offset and memstart_addr separately
crash-utility/arm64: rename ARM64_PAGE_OFFSET_ACTUAL as
ARM64_FLIP_PAGE_OFFSET_ACTUAL
crash-utility/arm64: assign page_offset with kernel configure value
arm64.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++------
defs.h | 22 ++++++++++----
2 files changed, 101 insertions(+), 15 deletions(-)
--
2.29.2
3 years, 6 months
[PATCH] MIPS64: Get the correct dump NOTE offsets
by Youling Tang
When using the dump compressed file dumpfile compressed by makedumpfile,
use the following command:
# crash vmlinux dumpfile -d 1
When you add the "-d num" option and want to view the debugging information,
it is found that you cannot enter the crash> command line normally, and stay
in the following position:
...
notes[3]: 20ec075fc (NT_PRSTATUS)
snapshot_task: 0
num_qemu_notes: 0
The reason is that it is stuck in the dump_note_offsets(fp) call, because the
MIPS64 match is not added, so that the NOTE offsets cannot be obtained.
When the match of MIPS64 is added, it can successfully enter the crash> command
line.
Signed-off-by: Youling Tang <tangyouling(a)loongson.cn>
---
diskdump.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/diskdump.c b/diskdump.c
index 3effb52..6680695 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -1700,7 +1700,7 @@ dump_note_offsets(FILE *fp)
qemu = FALSE;
if (machine_type("X86_64") || machine_type("S390X") ||
machine_type("ARM64") || machine_type("PPC64") ||
- machine_type("SPARC64")) {
+ machine_type("SPARC64") || machine_type("MIPS64")) {
note64 = (void *)dd->notes_buf + tot;
len = sizeof(Elf64_Nhdr);
if (STRNEQ((char *)note64 + len, "QEMU"))
--
2.1.0
3 years, 6 months
[PATCH] crash: fix a segment fault
by Wengang Wang
There could be something wrong in the symbol name buffer for
a kernel module. That could lead to reading from outside of
"strbuf" in crash util code.
Fix:
Theck the index VS strbuf size and skip that symbol in case of
out of band.
Signed-off-by: Wengang Wang <wen.gang.wang(a)oracle.com>
---
symbols.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/symbols.c b/symbols.c
index 5d7da6e..0b68ba9 100644
--- a/symbols.c
+++ b/symbols.c
@@ -1965,12 +1965,20 @@ store_module_symbols_v2(ulong total, int mods_installed)
BZERO(buf1, BUFSIZE);
- if (strbuf)
- strcpy(buf1,
- &strbuf[modsym_name(gpl_syms, modsym, i) - first]);
- else
+ if (strbuf) {
+ unsigned long addr = modsym_name(gpl_syms, modsym, i);
+ unsigned long index = addr - first;
+
+ if (index < strbuflen)
+ strncpy(buf1,
+ &strbuf[index], BUFSIZE - 1);
+ else
+ fprintf(fp, "\nWarning: module \"%s\" has invalid address %lx for %dth symbol\n",
+ lm->mod_name, addr, i);
+ } else {
read_string(modsym_name(gpl_syms, modsym, i), buf1,
BUFSIZE-1);
+ }
if (strlen(buf1)) {
st->ext_module_symtable[mcnt].value =
--
2.21.0 (Apple Git-122.2)
3 years, 6 months
[PATCHv6 0/4] crash-utility/arm64: memory layout bug fixes
by Pingfan Liu
This series fix the bug caused by arm64 kernel memory layout changes
Cc: HAGIO KAZUHITO <k-hagio-ab(a)nec.com>
Cc: Lianbo Jiang <lijiang(a)redhat.com>
Cc: Bhupesh Sharma <bhupesh.sharma(a)linaro.org>
To: crash-utility(a)redhat.com
Pingfan Liu (4):
crash-utility/arm64: introduce a dedicated field to record the mem
layout changes
crash-utility/arm64: store phy_offset and memstart_addr separately
crash-utility/arm64: rename ARM64_PAGE_OFFSET_ACTUAL as
ARM64_FLIP_PAGE_OFFSET_ACTUAL
crash-utility/arm64: assign page_offset with kernel configure value
arm64.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++------
defs.h | 22 ++++++++++----
2 files changed, 101 insertions(+), 15 deletions(-)
--
2.29.2
3 years, 6 months
[PATCHv5 0/3] crash-utility/arm64: 52 bits VA fixes
by Pingfan Liu
These are 2 groups closely related patchset, so I send them in a series.
[1/3]: resolve PTOV(), VTOP() issue due the kernel's new formula to
calculate pa and va translation.
[2-3/3]: fix wrong page_offset value when 52 bits kernel on 48 bits
platform
Cc: HAGIO KAZUHITO <k-hagio-ab(a)nec.com>
Cc: Lianbo Jiang <lijiang(a)redhat.com>
Cc: Bhupesh Sharma <bhupesh.sharma(a)linaro.org>
To: crash-utility(a)redhat.com
Pingfan Liu (3):
crash-utility/arm64: store phy_offset and memstart_addr separately
crash-utility/arm64: rename ARM64_PAGE_OFFSET_ACTUAL as
ARM64_FLIP_PAGE_OFFSET_ACTUAL
crash-utility/arm64: assign page_offset with kernel configure value
arm64.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++---------
defs.h | 21 +++++++++++++------
2 files changed, 68 insertions(+), 16 deletions(-)
--
2.29.2
3 years, 6 months
[PATCH v2] defs.h: Fix the value of TIF_SIGPENDING macro
by Youling Tang
Correct the change of the value of TIF_SIGPENDING macro between
different kernel versions.
TIF_SIGPENDING changes with the kernel version as follows:
ARM 2 -> 0 at v2.6.23
MIPS 2 -> 1 at v2.6.23
MIPS64 2 -> 1 at v2.6.23
PPC 2 -> 1 at v2.6.23
IA64 1 -> 0 at v2.6.23
PPC64 2 -> 1 at v2.6.23
S390 2 -> 1 at v3.16
S390X 2 -> 1 at v3.16
Signed-off-by: Youling Tang <tangyouling(a)loongson.cn>
---
defs.h | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/defs.h b/defs.h
index 396d61a..3502c6d 100644
--- a/defs.h
+++ b/defs.h
@@ -2997,7 +2997,7 @@ typedef struct QEMUCPUState QEMUCPUState;
#define __swp_type(entry) SWP_TYPE(entry)
#define __swp_offset(entry) SWP_OFFSET(entry)
-#define TIF_SIGPENDING (2)
+#define TIF_SIGPENDING (THIS_KERNEL_VERSION >= LINUX(2,6,23) ? 0 : 2)
#define _SECTION_SIZE_BITS 28
#define _MAX_PHYSMEM_BITS 32
@@ -3377,7 +3377,7 @@ struct arm64_stackframe {
#define __swp_type(entry) SWP_TYPE(entry)
#define __swp_offset(entry) SWP_OFFSET(entry)
-#define TIF_SIGPENDING (2)
+#define TIF_SIGPENDING (THIS_KERNEL_VERSION >= LINUX(2,6,23) ? 1 : 2)
#define _SECTION_SIZE_BITS 26
#define _MAX_PHYSMEM_BITS 32
@@ -3416,7 +3416,7 @@ struct arm64_stackframe {
#define __swp_type(entry) SWP_TYPE(entry)
#define __swp_offset(entry) SWP_OFFSET(entry)
-#define TIF_SIGPENDING (2)
+#define TIF_SIGPENDING (THIS_KERNEL_VERSION >= LINUX(2,6,23) ? 1 : 2)
#define _SECTION_SIZE_BITS 28
#define _MAX_PHYSMEM_BITS 48
@@ -3884,7 +3884,7 @@ struct machine_specific {
#define __swp_type(entry) SWP_TYPE(entry)
#define __swp_offset(entry) SWP_OFFSET(entry)
-#define TIF_SIGPENDING (2)
+#define TIF_SIGPENDING (THIS_KERNEL_VERSION >= LINUX(2,6,23) ? 1 : 2)
#define _SECTION_SIZE_BITS 24
#define _MAX_PHYSMEM_BITS 44
@@ -4079,7 +4079,7 @@ struct efi_memory_desc_t {
#define __swp_type(entry) ((entry >> 2) & 0x7f)
#define __swp_offset(entry) ((entry << 1) >> 10)
-#define TIF_SIGPENDING (1)
+#define TIF_SIGPENDING (THIS_KERNEL_VERSION >= LINUX(2,6,23) ? 0 : 1)
#define KERNEL_TR_PAGE_SIZE (1 << _PAGE_SIZE_64M)
#define KERNEL_TR_PAGE_MASK (~(KERNEL_TR_PAGE_SIZE - 1))
@@ -4219,7 +4219,7 @@ struct efi_memory_desc_t {
#define PTE_RPN_MASK (machdep->machspec->pte_rpn_mask)
#define PTE_RPN_SHIFT (machdep->machspec->pte_rpn_shift)
-#define TIF_SIGPENDING (2)
+#define TIF_SIGPENDING (THIS_KERNEL_VERSION >= LINUX(2,6,23) ? 1 : 2)
#define SWP_TYPE(entry) (((entry) >> 1) & 0x7f)
#define SWP_OFFSET(entry) ((entry) >> 8)
@@ -4259,7 +4259,7 @@ struct efi_memory_desc_t {
#define __swp_type(entry) SWP_TYPE(entry)
#define __swp_offset(entry) SWP_OFFSET(entry)
-#define TIF_SIGPENDING (2)
+#define TIF_SIGPENDING (THIS_KERNEL_VERSION >= LINUX(3,16,0) ? 1 : 2)
#define _SECTION_SIZE_BITS 25
#define _MAX_PHYSMEM_BITS 31
@@ -4284,7 +4284,7 @@ struct efi_memory_desc_t {
#define __swp_type(entry) SWP_TYPE(entry)
#define __swp_offset(entry) SWP_OFFSET(entry)
-#define TIF_SIGPENDING (2)
+#define TIF_SIGPENDING (THIS_KERNEL_VERSION >= LINUX(3,16,0) ? 1 : 2)
#define _SECTION_SIZE_BITS 28
#define _MAX_PHYSMEM_BITS_OLD 42
--
2.1.0
3 years, 6 months