Re: [Crash-utility] [PATCH V2] netdump: fix regression for tiny kdump files
by lijiang
在 2020年12月23日 10:31, crash-utility-request(a)redhat.com 写道:
> Date: Wed, 23 Dec 2020 02:31:24 +0000
> From: ??? <zhaoqianli(a)xiaomi.com>
> To: =?gb2312?B?SEFHSU8gS0FaVUhJVE8oyGPOsqGh0rvIyik=?=
> <k-hagio-ab(a)nec.com>, "Discussion list for crash utility usage,
> maintenance and development" <crash-utility(a)redhat.com>
> Subject: Re: [Crash-utility] [External Mail]RE: [PATCH V2] netdump:
> fix regression for tiny kdump files
> Message-ID: <e4cc6f753b2c428d9f0f0c0362567de5(a)xiaomi.com>
> Content-Type: text/plain; charset="gb2312"
>
> Hi, Lianbo
>
>
>> For the checking condition, I would recommend using the following methods, what do you think?
>>
>> + if (size != SAFE_NETDUMP_ELF_HEADER_SIZE &&
>> + size != MIN_NETDUMP_ELF_HEADER_SIZE) {
> I agrre with Kazu, if use "size != MIN_NETDUMP_ELF_HEADER_SIZE/SAFE_NETDUMP_ELF_HEADER_SIZE" this issue can not be fixed, size is equal to or more than MIN_NETDUMP_ELF_HEADER_SIZE is valid.
>
That's true, I just knew what it happened. Thanks for the explanation.
>> In addition, would you mind updating another error output in the is_netdump()? For example:
>>
>> size = SAFE_NETDUMP_ELF_HEADER_SIZE;
>> if ((eheader = (char *)malloc(size)) == NULL) {
>> - fprintf(stderr, "cannot malloc minimum ELF header buffer\n");
>> + fprintf(stderr, "cannot malloc ELF header buffer\n");
>> clean_exit(1);
>> }
> Ok.
>
> How about below patch set?
>
Looks good to me.
Acked by: Lianbo Jiang <lijian@redhat.>
>>From 5ec6ac06ba7fd32e96463a54ebc3f733f1054a90 Mon Sep 17 00:00:00 2001
> From: Qianli Zhao <zhaoqianli(a)xiaomi.com>
> Date: Mon, 30 Nov 2020 17:17:32 +0800
> Subject: [PATCH] netdump: fix regression for tiny kdump files
>
> Commit f42db6a33f0e ("Support core files with "unusual" layout")
> increased the minimal file size from MIN_NETDUMP_ELF_HEADER_SIZE to
> SAFE_NETDUMP_ELF_HEADER_SIZE which can lead to crash rejecting
> raw RAM dumpfiles
>
> Fix that by erroring out only if we get less than
> MIN_NETDUMP_ELF_HEADER_SIZE bytes.
>
> Signed-off-by: Qianli Zhao <zhaoqianli(a)xiaomi.com>
> ---
> netdump.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/netdump.c b/netdump.c
> index c76d9dd..ca9b459 100644
> --- a/netdump.c
> +++ b/netdump.c
> @@ -119,7 +119,8 @@ is_netdump(char *file, ulong source_query)
> Elf64_Phdr *load64;
> char *eheader, *sect0;
> char buf[BUFSIZE];
> - size_t size, len, tot;
> + ssize_t size;
> + size_t len, tot;
> Elf32_Off offset32;
> Elf64_Off offset64;
> ulong format;
> @@ -134,7 +135,7 @@ is_netdump(char *file, ulong source_query)
>
> size = SAFE_NETDUMP_ELF_HEADER_SIZE;
> if ((eheader = (char *)malloc(size)) == NULL) {
> - fprintf(stderr, "cannot malloc minimum ELF header buffer\n");
> + fprintf(stderr, "cannot malloc ELF header buffer\n");
> clean_exit(1);
> }
>
> @@ -142,10 +143,14 @@ is_netdump(char *file, ulong source_query)
> if (!read_flattened_format(fd, 0, eheader, size))
> goto bailout;
> } else {
> - if (read(fd, eheader, size) != size) {
> + size = read(fd, eheader, size);
> + if (size < 0) {
> sprintf(buf, "%s: ELF header read", file);
> perror(buf);
> goto bailout;
> + } else if (size < MIN_NETDUMP_ELF_HEADER_SIZE) {
> + fprintf(stderr, "%s: file too small!\n", file);
> + goto bailout;
> }
> }
>
> --
> 2.7.4
3 years, 11 months
Re: [Crash-utility] [PATCH V2] netdump: fix regression for tiny kdump files
by lijiang
在 2020年12月23日 01:00, crash-utility-request(a)redhat.com 写道:
>>> Date: Tue, 1 Dec 2020 10:56:02 +0800
>>> From: Qianli Zhao <zhaoqianligood(a)gmail.com>
>>> To: crash-utility(a)redhat.com, minipli(a)grsecurity.net
>>> Subject: [Crash-utility] [PATCH V2] netdump: fix regression for tiny
>>> kdump files
>>> Message-ID:
>>> <1606791362-5604-1-git-send-email-zhaoqianligood(a)gmail.com>
>>> Content-Type: text/plain; charset="US-ASCII"
>>>
>>> From: Qianli Zhao <zhaoqianli(a)xiaomi.com>
>>>
>>> Commit f42db6a33f0e ("Support core files with "unusual" layout")
>>> increased the minimal file size from MIN_NETDUMP_ELF_HEADER_SIZE to
>>> SAFE_NETDUMP_ELF_HEADER_SIZE which lead to crash rejecting very
>>> small kdump files.
>>>
>> Good findings.
>>
>>> Fix that by erroring out only if we get less than
>>> MIN_NETDUMP_ELF_HEADER_SIZE bytes.
>>>
>>> Signed-off-by: Qianli Zhao <zhaoqianli(a)xiaomi.com>
>>> ---
>>> - Update commit message
>>> - Add more accurate judgment of read() return value
>>> ---
>>> netdump.c | 9 +++++++--
>>> 1 file changed, 7 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/netdump.c b/netdump.c
>>> index c76d9dd..9a36931 100644
>>> --- a/netdump.c
>>> +++ b/netdump.c
>>> @@ -119,7 +119,8 @@ is_netdump(char *file, ulong source_query)
>>> Elf64_Phdr *load64;
>>> char *eheader, *sect0;
>>> char buf[BUFSIZE];
>>> - size_t size, len, tot;
>>> + ssize_t size;
>>> + size_t len, tot;
>>> Elf32_Off offset32;
>>> Elf64_Off offset64;
>>> ulong format;
>>> @@ -142,10 +143,14 @@ is_netdump(char *file, ulong source_query)
>>> if (!read_flattened_format(fd, 0, eheader, size))
>>> goto bailout;
>>> } else {
>>> - if (read(fd, eheader, size) != size) {
>>> + size = read(fd, eheader, size);
>>> + if (size < 0) {
>>> sprintf(buf, "%s: ELF header read", file);
>>> perror(buf);
>>> goto bailout;
>>> + } else if (size < MIN_NETDUMP_ELF_HEADER_SIZE) {
>> For the checking condition, I would recommend using the following methods, what do you think?
>>
>> + if (size != SAFE_NETDUMP_ELF_HEADER_SIZE &&
>> + size != MIN_NETDUMP_ELF_HEADER_SIZE) {
>> sprintf(buf, "%s: ELF header read", file);
>> perror(buf);
>> goto bailout;
>> }
> Do you mean putting "size < 0" and "size < MIN_NETDUMP_ELF_HEADER SIZE"
> together? I think it would be good to separate an read error and a format
> error for better debugging.
>
> And according to ramdump_to_elf(), the size of an ELF header from a RAM
> dumpfile varies depending on the number of nodes, and is equal to or more
> than MIN_NETDUMP_ELF_HEADER_SIZE if valid. Actually, the value that Qianli
> showed before was 232 [1], which is not either SAFE_NETDUMP_ELF_HEADER_SIZE(304)
> or MIN_NETDUMP_ELF_HEADER_SIZE(176).
>
> [1] https://www.redhat.com/archives/crash-utility/2020-November/msg00080.html
>
Thank you for sharing the debug information, I already known what it happened.
Thanks.
Lianbo
> Thanks,
3 years, 11 months
Re: [Crash-utility] [PATCH V2] netdump: fix regression for tiny kdump files
by lijiang
Hi, Qianli
Thanks for the patch.
在 2020年12月01日 14:45, crash-utility-request(a)redhat.com 写道:
> Date: Tue, 1 Dec 2020 10:56:02 +0800
> From: Qianli Zhao <zhaoqianligood(a)gmail.com>
> To: crash-utility(a)redhat.com, minipli(a)grsecurity.net
> Subject: [Crash-utility] [PATCH V2] netdump: fix regression for tiny
> kdump files
> Message-ID:
> <1606791362-5604-1-git-send-email-zhaoqianligood(a)gmail.com>
> Content-Type: text/plain; charset="US-ASCII"
>
> From: Qianli Zhao <zhaoqianli(a)xiaomi.com>
>
> Commit f42db6a33f0e ("Support core files with "unusual" layout")
> increased the minimal file size from MIN_NETDUMP_ELF_HEADER_SIZE to
> SAFE_NETDUMP_ELF_HEADER_SIZE which lead to crash rejecting very
> small kdump files.
>
Good findings.
> Fix that by erroring out only if we get less than
> MIN_NETDUMP_ELF_HEADER_SIZE bytes.
>
> Signed-off-by: Qianli Zhao <zhaoqianli(a)xiaomi.com>
> ---
> - Update commit message
> - Add more accurate judgment of read() return value
> ---
> netdump.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/netdump.c b/netdump.c
> index c76d9dd..9a36931 100644
> --- a/netdump.c
> +++ b/netdump.c
> @@ -119,7 +119,8 @@ is_netdump(char *file, ulong source_query)
> Elf64_Phdr *load64;
> char *eheader, *sect0;
> char buf[BUFSIZE];
> - size_t size, len, tot;
> + ssize_t size;
> + size_t len, tot;
> Elf32_Off offset32;
> Elf64_Off offset64;
> ulong format;
> @@ -142,10 +143,14 @@ is_netdump(char *file, ulong source_query)
> if (!read_flattened_format(fd, 0, eheader, size))
> goto bailout;
> } else {
> - if (read(fd, eheader, size) != size) {
> + size = read(fd, eheader, size);
> + if (size < 0) {
> sprintf(buf, "%s: ELF header read", file);
> perror(buf);
> goto bailout;
> + } else if (size < MIN_NETDUMP_ELF_HEADER_SIZE) {
For the checking condition, I would recommend using the following methods, what do you think?
+ if (size != SAFE_NETDUMP_ELF_HEADER_SIZE &&
+ size != MIN_NETDUMP_ELF_HEADER_SIZE) {
sprintf(buf, "%s: ELF header read", file);
perror(buf);
goto bailout;
}
In addition, would you mind updating another error output in the is_netdump()? For example:
size = SAFE_NETDUMP_ELF_HEADER_SIZE;
if ((eheader = (char *)malloc(size)) == NULL) {
- fprintf(stderr, "cannot malloc minimum ELF header buffer\n");
+ fprintf(stderr, "cannot malloc ELF header buffer\n");
clean_exit(1);
}
Thanks.
Lianbo
> + fprintf(stderr, "%s: file too small!\n", file);
> + goto bailout;
> }
> }
>
> -- 2.7.4
3 years, 11 months
Re: [Crash-utility] [PATCH] extensions/eppic.mk: Remove ping check to github.com
by lijiang
Hi, Kazu
在 2020年12月21日 14:18, crash-utility-request(a)redhat.com 写道:
> Date: Mon, 21 Dec 2020 06:18:43 +0000
> From: HAGIO KAZUHITO(?????) <k-hagio-ab(a)nec.com>
> To: "Discussion list for crash utility usage, maintenance and
> development" <crash-utility(a)redhat.com>
> Cc: "lchouinard(a)s2sys.com" <lchouinard(a)s2sys.com>
> Subject: [Crash-utility] [PATCH] extensions/eppic.mk: Remove ping
> check to github.com
> Message-ID:
> <OSBPR01MB19916B18E8F90D393F3839B1DDC00(a)OSBPR01MB1991.jpnprd01.prod.outlook.com>
>
> Content-Type: text/plain; charset="iso-2022-jp"
>
> Without this patch, in an environment where ping to github.com does
> not work, building eppic.so fails with the message "eppic.so: failed
> to pull eppic code from git repo" and "make clean" at the top-level
> crash directory unnecessarily takes about 10 seconds every time.
>
> $ time make clean
> ...
> real 0m10.398s
>
This change is very helpful.
> Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
> ---
> extensions/eppic.mk | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/extensions/eppic.mk b/extensions/eppic.mk
> index c79170a596b7..7486ce46a6b8 100644
> --- a/extensions/eppic.mk
> +++ b/extensions/eppic.mk
> @@ -24,7 +24,6 @@ ifeq ($(TARGET), X86)
> endif
>
> APPFILE=eppic/applications/crash/eppic.c
> -GITHUB := $(shell ping -c 1 github.com | grep "1 received")
BTW: Is it possible to fix this issue with the option -W? For example:
GITHUB := $(shell ping -c 1 -W 2 github.com | grep "1 received")
^^^^
Thanks.
Lianbo
> GIT := $(shell which git 2> /dev/null)
>
> all:
> @@ -38,9 +37,7 @@ all:
> if [ -n "$(EPPIC_GIT_URL)" ]; then \
> git clone "$(EPPIC_GIT_URL)" eppic; \
> else \
> - if [ -n "$(GITHUB)" ] ; then \
> - git clone https://github.com/lucchouina/eppic.git eppic; \
> - fi; \
> + git clone https://github.com/lucchouina/eppic.git eppic; \
> fi; \
> else \
> if [ ! -f "$(GIT)" ]; then \
> -- 2.18.4
3 years, 11 months
[PATCH] extensions/eppic.mk: Remove ping check to github.com
by HAGIO KAZUHITO(萩尾 一仁)
Without this patch, in an environment where ping to github.com does
not work, building eppic.so fails with the message "eppic.so: failed
to pull eppic code from git repo" and "make clean" at the top-level
crash directory unnecessarily takes about 10 seconds every time.
$ time make clean
...
real 0m10.398s
Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
---
extensions/eppic.mk | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/extensions/eppic.mk b/extensions/eppic.mk
index c79170a596b7..7486ce46a6b8 100644
--- a/extensions/eppic.mk
+++ b/extensions/eppic.mk
@@ -24,7 +24,6 @@ ifeq ($(TARGET), X86)
endif
APPFILE=eppic/applications/crash/eppic.c
-GITHUB := $(shell ping -c 1 github.com | grep "1 received")
GIT := $(shell which git 2> /dev/null)
all:
@@ -38,9 +37,7 @@ all:
if [ -n "$(EPPIC_GIT_URL)" ]; then \
git clone "$(EPPIC_GIT_URL)" eppic; \
else \
- if [ -n "$(GITHUB)" ] ; then \
- git clone https://github.com/lucchouina/eppic.git eppic; \
- fi; \
+ git clone https://github.com/lucchouina/eppic.git eppic; \
fi; \
else \
if [ ! -f "$(GIT)" ]; then \
--
2.18.4
3 years, 11 months
[PATCH V2] netdump: fix regression for tiny kdump files
by Qianli Zhao
From: Qianli Zhao <zhaoqianli(a)xiaomi.com>
Commit f42db6a33f0e ("Support core files with "unusual" layout")
increased the minimal file size from MIN_NETDUMP_ELF_HEADER_SIZE to
SAFE_NETDUMP_ELF_HEADER_SIZE which lead to crash rejecting very
small kdump files.
Fix that by erroring out only if we get less than
MIN_NETDUMP_ELF_HEADER_SIZE bytes.
Signed-off-by: Qianli Zhao <zhaoqianli(a)xiaomi.com>
---
- Update commit message
- Add more accurate judgment of read() return value
---
netdump.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/netdump.c b/netdump.c
index c76d9dd..9a36931 100644
--- a/netdump.c
+++ b/netdump.c
@@ -119,7 +119,8 @@ is_netdump(char *file, ulong source_query)
Elf64_Phdr *load64;
char *eheader, *sect0;
char buf[BUFSIZE];
- size_t size, len, tot;
+ ssize_t size;
+ size_t len, tot;
Elf32_Off offset32;
Elf64_Off offset64;
ulong format;
@@ -142,10 +143,14 @@ is_netdump(char *file, ulong source_query)
if (!read_flattened_format(fd, 0, eheader, size))
goto bailout;
} else {
- if (read(fd, eheader, size) != size) {
+ size = read(fd, eheader, size);
+ if (size < 0) {
sprintf(buf, "%s: ELF header read", file);
perror(buf);
goto bailout;
+ } else if (size < MIN_NETDUMP_ELF_HEADER_SIZE) {
+ fprintf(stderr, "%s: file too small!\n", file);
+ goto bailout;
}
}
--
2.7.4
3 years, 11 months
Re: [Crash-utility] [PATCH v3] x86_64: VC exception stack support
by lijiang
在 2020年12月01日 14:45, crash-utility-request(a)redhat.com 写道:
> Message: 1
> Date: Mon, 30 Nov 2020 09:48:29 -0800
> From: Alexey Makhalov <amakhalov(a)vmware.com>
> To: <crash-utility(a)redhat.com>, <k-hagio-ab(a)nec.com>
> Subject: [Crash-utility] [PATCH v3] x86_64: VC exception stack support
> Message-ID: <20201130174829.127345-1-amakhalov(a)vmware.com>
> Content-Type: text/plain
>
> Linux-5.10 has introduced SEV-ES support. New (5th) exception
> stack was added: 'VC_stack'.
>
> 'struct exception_stacks' cannot be used to obtain the size
> of VC stack, as the size of VC stack is zero there. Try
> another structure 'struct cea_exception_stacks' first as it
> represents actual CPU entry area with valid stack sizes and
> guard pages.
>
> Handled the case if VC stack is not mapped (present).
> It happens when SEV-ES is not active or not supported.
>
> Signed-off-by: Alexey Makhalov <amakhalov(a)vmware.com>
> ---
This looks good, thanks for the patch, Alexey.
Acked-by: Lianbo Jiang <lijiang(a)redhat.com>
> defs.h | 1 +
> x86_64.c | 48 ++++++++++++++++++++++++++++++++++++------------
> 2 files changed, 37 insertions(+), 12 deletions(-)
>
> diff --git a/defs.h b/defs.h
> index 9594950..4aeeef5 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -5913,6 +5913,7 @@ struct x86_64_pt_regs_offsets {
> struct x86_64_stkinfo {
> ulong ebase[NR_CPUS][MAX_EXCEPTION_STACKS];
> int esize[MAX_EXCEPTION_STACKS];
> + char available[NR_CPUS][MAX_EXCEPTION_STACKS];
> ulong ibase[NR_CPUS];
> int isize;
> int NMI_stack_index;
> diff --git a/x86_64.c b/x86_64.c
> index 939c8a9..23a40a0 100644
> --- a/x86_64.c
> +++ b/x86_64.c
> @@ -1369,6 +1369,7 @@ x86_64_ist_init(void)
> ulong init_tss;
> struct machine_specific *ms;
> struct syment *boot_sp, *tss_sp, *ist_sp;
> + char *exc_stack_struct_name = NULL;
>
> ms = machdep->machspec;
> if (!(tss_sp = per_cpu_symbol_search("per_cpu__init_tss"))) {
> @@ -1444,25 +1445,40 @@ x86_64_ist_init(void)
> return;
> }
>
> - if (MEMBER_EXISTS("exception_stacks", "NMI_stack")) {
> + if (MEMBER_EXISTS("cea_exception_stacks", "NMI_stack")) {
> + /* The effective cpu entry area mapping with guard pages. */
> + exc_stack_struct_name = "cea_exception_stacks";
> + } else if (MEMBER_EXISTS("exception_stacks", "NMI_stack")) {
> + /* The exception stacks' physical storage. No guard pages and no VC stack. */
> + exc_stack_struct_name = "exception_stacks";
> + }
> + if (exc_stack_struct_name) {
> for (i = 0; i < MAX_EXCEPTION_STACKS; i++) {
> if (STREQ(ms->stkinfo.exception_stacks[i], "DEBUG"))
> - ms->stkinfo.esize[i] = MEMBER_SIZE("exception_stacks", "DB_stack");
> + ms->stkinfo.esize[i] = MEMBER_SIZE(exc_stack_struct_name, "DB_stack");
> else if (STREQ(ms->stkinfo.exception_stacks[i], "NMI"))
> - ms->stkinfo.esize[i] = MEMBER_SIZE("exception_stacks", "NMI_stack");
> + ms->stkinfo.esize[i] = MEMBER_SIZE(exc_stack_struct_name, "NMI_stack");
> else if (STREQ(ms->stkinfo.exception_stacks[i], "DOUBLEFAULT"))
> - ms->stkinfo.esize[i] = MEMBER_SIZE("exception_stacks", "DF_stack");
> + ms->stkinfo.esize[i] = MEMBER_SIZE(exc_stack_struct_name, "DF_stack");
> else if (STREQ(ms->stkinfo.exception_stacks[i], "MCE"))
> - ms->stkinfo.esize[i] = MEMBER_SIZE("exception_stacks", "MCE_stack");
> + ms->stkinfo.esize[i] = MEMBER_SIZE(exc_stack_struct_name, "MCE_stack");
> + else if (STREQ(ms->stkinfo.exception_stacks[i], "VC"))
> + ms->stkinfo.esize[i] = MEMBER_SIZE(exc_stack_struct_name, "VC_stack");
> }
> /*
> - * Adjust the top-of-stack addresses down to the base stack address.
> + * Adjust the top-of-stack addresses down to the base stack address
> + * and set stack page availabilituy flag.
> */
> for (c = 0; c < kt->cpus; c++) {
> for (i = 0; i < MAX_EXCEPTION_STACKS; i++) {
> - if (ms->stkinfo.ebase[c][i] == 0)
> - continue;
> - ms->stkinfo.ebase[c][i] -= ms->stkinfo.esize[i];
> + if (ms->stkinfo.ebase[c][i])
> + ms->stkinfo.ebase[c][i] -= ms->stkinfo.esize[i];
> +
> + ms->stkinfo.available[c][i] = TRUE;
> + /* VC stack can be unmapped if SEV-ES is disabled or not supported. */
> + if (STREQ(ms->stkinfo.exception_stacks[i], "VC") &&
> + !accessible(ms->stkinfo.ebase[c][i]))
> + ms->stkinfo.available[c][i] = FALSE;
> }
> }
>
> @@ -1487,6 +1503,7 @@ x86_64_ist_init(void)
> else
> ms->stkinfo.esize[i] = esize;
> ms->stkinfo.ebase[c][i] -= ms->stkinfo.esize[i];
> + ms->stkinfo.available[c][i] = TRUE;
> }
> }
>
> @@ -2842,7 +2859,8 @@ x86_64_eframe_search(struct bt_info *bt)
> !(NUM_IN_BITMAP(bt->cpumask, c)))
> continue;
> for (i = 0; i < MAX_EXCEPTION_STACKS; i++) {
> - if (ms->stkinfo.ebase[c][i] == 0)
> + if (ms->stkinfo.ebase[c][i] == 0 ||
> + !ms->stkinfo.available[c][i])
> break;
> bt->hp->esp = ms->stkinfo.ebase[c][i];
> fprintf(fp, "CPU %d %s EXCEPTION STACK:",
> @@ -3288,7 +3306,8 @@ x86_64_in_exception_stack(struct bt_info *bt, int *estack_index)
>
> for (c = 0; !estack && (c < kt->cpus); c++) {
> for (i = 0; i < MAX_EXCEPTION_STACKS; i++) {
> - if (ms->stkinfo.ebase[c][i] == 0)
> + if (ms->stkinfo.ebase[c][i] == 0 ||
> + !ms->stkinfo.available[c][i])
> break;
> if ((rsp >= ms->stkinfo.ebase[c][i]) &&
> (rsp < (ms->stkinfo.ebase[c][i] +
> @@ -5097,7 +5116,7 @@ skip_stage:
> ms->stkinfo.esize[estack];
> console("x86_64_get_dumpfile_stack_frame: searching %s estack at %lx\n",
> ms->stkinfo.exception_stacks[estack], bt->stackbase);
> - if (!(bt->stackbase))
> + if (!(bt->stackbase && ms->stkinfo.available[bt->tc->processor][estack]))
> goto skip_stage;
> bt->stackbuf = ms->irqstack;
> alter_stackbuf(bt);
> @@ -5380,6 +5399,8 @@ x86_64_exception_stacks_init(void)
> ms->stkinfo.exception_stacks[ist-1] = "DOUBLEFAULT";
> if (strstr(buf, "machine"))
> ms->stkinfo.exception_stacks[ist-1] = "MCE";
> + if (strstr(buf, "vmm"))
> + ms->stkinfo.exception_stacks[ist-1] = "VC";
> }
> }
>
> @@ -5737,6 +5758,9 @@ x86_64_display_machine_stats(void)
> fprintf(fp, "%22s: %016lx",
> buf, machdep->machspec->stkinfo.ebase[c][i]);
>
> + if (!machdep->machspec->stkinfo.available[c][i])
> + fprintf(fp, " [unavailable]");
> +
> if (hide_offline_cpu(c))
> fprintf(fp, " [OFFLINE]\n");
> else
> -- 2.11.0
3 years, 11 months
Questions related to using crash-utility
by sandeep kumar Mantrala
Hi,
I am having a few questions related to crash utility.
1. How do i measure various times like the following
- When was last time that the task was in Running state
- How much time the task is in its current state(UN, IN etc..)?
2. How do I get register values from the crash dump? All the registers are
generally saved onto the stack when switching from one function to another.
So, ideally at any given time, we should be able to find the register
values.
3. bt -f shows stack data. Any references on how to interpret it? Is there
a more convenient way to get the local variables?
Thank you for your time!
PS: This is my first email to this list. Please let me know if I am
violating any rules.
Best Regards,
Sandeep
3 years, 11 months
[PATCH v3 1/1] Support cross-compilation
by Alexander Egorenkov
In order to support cross-compilation of crash-utilty,
the configure tool compiled from configure.c must be built
for the host architecture where the cross-compilation will run
instead of the target architecture where the crash-utility shall run.
Therefore, we need to support two C compilers in Maklefile,
one for the host and one for the target. The old CC makefile variable
shall represent the compiler for the target architecture and
the new HOSTCC makefile variable shall represent the host compiler.
Both variables differ only when a cross-compilation is performed.
Furthermore, there must be a way to override the target architecture
which is deduced from the preprocessor macros defined by the compiler
used for the compilation of configure.c, because otherwise the configure
tool will deduce host's architecture instead of the desired target.
With the new preprocessor define CONF_DEFAULT_TARGET, it is possible to
set the desired target architecture for the compiled crash-utility.
When cross-compiling, set the makefile variable CROSS_COMPILE
to the prefix of the cross-compiler and the default target
architecture will be deduced from it, e.g. like this:
make CROSS_COMPILE=s390x-linux-
and the default target architecture shall be S390X.
Signed-off-by: Alexander Egorenkov <egorenar-dev(a)posteo.net>
---
v2 -> v3:
* Use CROSS_COMPILE makefile variable to pass cross-compiler prefix
v1 -> v2:
* Improved commit message
* Added a note how to cross-compile crash-utilty to README
* Moved CONF_CC makefile variable to correct place location
Makefile | 53 +++++++++++++++++++++++++++++++++++++++++++++++++----
README | 5 +++++
configure.c | 39 +++------------------------------------
3 files changed, 57 insertions(+), 40 deletions(-)
diff --git a/Makefile b/Makefile
index d185719..7185dcd 100644
--- a/Makefile
+++ b/Makefile
@@ -20,15 +20,60 @@
PROGRAM=crash
#
-# Supported targets: X86 ALPHA PPC IA64 PPC64 SPARC64
+# Supported targets: X86 X86_64 IA64 ALPHA PPC PPC64 ARM ARM64 SPARC64 MIPS S390 S390X
# TARGET and GDB_CONF_FLAGS will be configured automatically by configure
#
TARGET=
GDB_CONF_FLAGS=
-ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
+ifneq ($(CROSS_COMPILE),)
+ARCH := $(shell echo $(CROSS_COMPILE) | sed 's:^.*/::g' | cut -d- -f1)
+else
+ARCH := $(shell uname -m)
+endif
+ARCH := $(shell echo $(ARCH) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
+
+CC = $(CROSS_COMPILE)gcc
+HOSTCC = gcc
+
ifeq (${ARCH}, ppc64)
-CONF_FLAGS = -m64
+CONF_FLAGS += -m64
+endif
+
+ifeq (${ARCH}, i386)
+CONF_DEFAULT_TARGET := X86
+else ifeq (${ARCH}, x86_64)
+CONF_DEFAULT_TARGET := X86_64
+else ifeq (${ARCH}, ia64)
+CONF_DEFAULT_TARGET := IA64
+else ifeq (${ARCH}, alpha)
+CONF_DEFAULT_TARGET := ALPHA
+else ifeq (${ARCH}, ppc)
+CONF_DEFAULT_TARGET := PPC
+else ifeq (${ARCH}, ppc64)
+CONF_DEFAULT_TARGET := PPC64
+else ifeq (${ARCH}, ppc64le)
+CONF_DEFAULT_TARGET := PPC64
+else ifeq (${ARCH}, arm)
+CONF_DEFAULT_TARGET := ARM
+else ifeq (${ARCH}, aarch64)
+CONF_DEFAULT_TARGET := ARM64
+else ifeq (${ARCH}, mips)
+CONF_DEFAULT_TARGET := MIPS
+else ifeq (${ARCH}, sparc64)
+CONF_DEFAULT_TARGET := SPARC64
+else ifeq (${ARCH}, s390)
+CONF_DEFAULT_TARGET := S390
+else ifeq (${ARCH}, s390x)
+CONF_DEFAULT_TARGET := S390X
+else
+$(error unsupported architecture ${ARCH})
+endif
+
+CONF_FLAGS += -DCONF_DEFAULT_TARGET=${CONF_DEFAULT_TARGET}
+
+ifneq ($(CROSS_COMPILE),)
+CONF_FLAGS += -DGDB_TARGET_DEFAULT="\"GDB_CONF_FLAGS=--host=$(shell echo $(CROSS_COMPILE) | sed -e 's:^.*/::g' -e 's/-$$//')\""
endif
#
@@ -288,7 +333,7 @@ force:
make_configure: force
@rm -f configure
- @${CC} ${CONF_FLAGS} -o configure configure.c ${WARNING_ERROR} ${WARNING_OPTIONS}
+ @${HOSTCC} ${CONF_FLAGS} -o configure configure.c ${WARNING_ERROR} ${WARNING_OPTIONS}
clean: make_configure
@./configure ${CONF_TARGET_FLAG} -q -b
diff --git a/README b/README
index bfbaef6..f5bd476 100644
--- a/README
+++ b/README
@@ -100,6 +100,11 @@
o On an x86_64 host, an x86_64 binary that can be used to analyze
ppc64le dumpfiles may be built by typing "make target=PPC64".
+ To cross-compile the crash utility, set the makefile variable CROSS_COMPILE to
+ the prefix of the cross-compiler, e.g. like this:
+
+ $ make CROSS_COMPILE=s390x-linux-
+
Traditionally when vmcores are compressed via the makedumpfile(8) facility
the libz compression library is used, and by default the crash utility
only supports libz. Recently makedumpfile has been enhanced to optionally
diff --git a/configure.c b/configure.c
index 7f6d19e..970a547 100644
--- a/configure.c
+++ b/configure.c
@@ -154,7 +154,9 @@ void add_extra_lib(char *);
#define TARGET_CFLAGS_MIPS_ON_X86_64 "TARGET_CFLAGS=-m32 -D_FILE_OFFSET_BITS=64"
#define TARGET_CFLAGS_SPARC64 "TARGET_CFLAGS="
+#ifndef GDB_TARGET_DEFAULT
#define GDB_TARGET_DEFAULT "GDB_CONF_FLAGS="
+#endif
#define GDB_TARGET_ARM_ON_X86 "GDB_CONF_FLAGS=--target=arm-elf-linux"
#define GDB_TARGET_ARM_ON_X86_64 "GDB_CONF_FLAGS=--target=arm-elf-linux CFLAGS=-m32"
#define GDB_TARGET_X86_ON_X86_64 "GDB_CONF_FLAGS=--target=i686-pc-linux-gnu CFLAGS=-m32"
@@ -349,42 +351,7 @@ get_current_configuration(struct supported_gdb_version *sp)
static char buf[512];
char *p;
-#ifdef __alpha__
- target_data.target = ALPHA;
-#endif
-#ifdef __i386__
- target_data.target = X86;
-#endif
-#ifdef __powerpc__
- target_data.target = PPC;
-#endif
-#ifdef __ia64__
- target_data.target = IA64;
-#endif
-#ifdef __s390__
- target_data.target = S390;
-#endif
-#ifdef __s390x__
- target_data.target = S390X;
-#endif
-#ifdef __powerpc64__
- target_data.target = PPC64;
-#endif
-#ifdef __x86_64__
- target_data.target = X86_64;
-#endif
-#ifdef __arm__
- target_data.target = ARM;
-#endif
-#ifdef __aarch64__
- target_data.target = ARM64;
-#endif
-#ifdef __mips__
- target_data.target = MIPS;
-#endif
-#ifdef __sparc_v9__
- target_data.target = SPARC64;
-#endif
+ target_data.target = CONF_DEFAULT_TARGET;
set_initial_target(sp);
--
2.29.2
3 years, 11 months
crash error out with kernel dump with "cgroup.memory=nokmem"
by Jack Wang
Hi,
Due to a slab memory leak with dying cgroup in 4.19. we disable the
kernel memory accounting for cgroup with kernel with
"cgroup.memory=nokmem", but since that, crash can't parse the crash
dump.
The initial crash version is 7.2.8, but I've tried 7.2.9, got the same error.
The last message is:
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu"...
GETBUF(328 -> 0)
GETBUF(1500 -> 1)
WARNING: kernel relocated [32MB]: patching 92172 gdb minimal_symbol values
please wait... (patching 92172 gdb minimal_symbol values) ^M
^M
FREEBUF(1)
FREEBUF(0)
<readmem: ffffffff84116148, KVADDR, "page_offset_base", 8, (FOE|Q),
5559140624c8>
<read_diskdump: addr: ffffffff84116148 paddr: 36bd116148 cnt: 8>
read_diskdump: PAGE_EXCLUDED: paddr/pfn: 36bd116148/36bd116
crash: page excluded: kernel virtual address: ffffffff84116148 type:
"page_offset_base"
I also attached the full d8 output, I hope it's not too big for the list.
Any hint, how can we fix it?
Thanks
Jack Wang @ IONOS Cloud.
3 years, 11 months