From: Michael Ellerman <mpe@ellerman.id.au> Date: 2019-01-17 13:32:57
Arch code can set a "dump stack arch description string" which is
displayed with oops output to describe the hardware platform.
It is useful to initialise this as early as possible, so that an early
oops will have the hardware description.
However in practice we discover the hardware platform in stages, so it
would be useful to be able to incrementally fill in the hardware
description as we discover it.
This patch adds that ability, by creating dump_stack_add_arch_desc().
If there is no existing string it behaves exactly like
dump_stack_set_arch_desc(). However if there is an existing string it
appends to it, with a leading space.
This makes it easy to call it multiple times from different parts of the
code and get a reasonable looking result.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
include/linux/printk.h | 5 ++++
lib/dump_stack.c | 58 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)
v2: Add a smp_wmb() and comment.
v1 is here for reference https://lore.kernel.org/lkml/1430824337-15339-1-git-send-email-mpe@ellerman.id.au/
I'll take this series via the powerpc tree if no one minds?
@@ -35,6 +35,64 @@ void __init dump_stack_set_arch_desc(const char *fmt, ...)va_end(args);}+/**+*dump_stack_add_arch_desc-addarch-specificinfotoshowwithtaskdumps+*@fmt:printf-styleformatstring+*@...:argumentsfortheformatstring+*+*Seedump_stack_set_arch_desc()forwhyyou'dwanttousethis.+*+*Thisversionaddstoanyexistingstringalreadycreatedwitheither+*dump_stack_set_arch_desc()ordump_stack_add_arch_desc().Ifthereisan+*existingstringaspacewillbeprependedtothepassedstring.+*/+void__initdump_stack_add_arch_desc(constchar*fmt,...)+{+va_listargs;+intpos,len;+char*p;++/*+*Ifthere'sanexistingstringwesnprintf()pasttheendofit,and+*thenturntheterminatingNULLoftheexistingstringintoaspace+*tocreateonestringseparatedbyaspace.+*+*Ifthere'snoexistingstringwejustsnprintf()tothebuffer,like+*dump_stack_set_arch_desc(),butwithoutcallingitbecausewe'dneed+*avarargsversion.+*/+len=strnlen(dump_stack_arch_desc_str,sizeof(dump_stack_arch_desc_str));+pos=len;++if(len)+pos++;++if(pos>=sizeof(dump_stack_arch_desc_str))+return;/* Ran out of space */++p=&dump_stack_arch_desc_str[pos];++va_start(args,fmt);+vsnprintf(p,sizeof(dump_stack_arch_desc_str)-pos,fmt,args);+va_end(args);++if(len){+/*+*Orderthestoresaboveinvsnprintf()vsthestoreofthe+*spacebelowwhichjoinsthetwostrings.Notethisdoesn't+*makethecodetrulyracefreebecausethereisnobarrieron+*thereadside.ie.AnotherCPUmightloadtheuninitialised+*tailofthebufferfirstandthenthespacebelow(rather+*thantheNULLthatwastherepreviously),andsoprintthe+*uninitialisedtail.ButthewholestringlivesinBSSsoin+*practiceitshouldjustseeNULLs.+*/+smp_wmb();++dump_stack_arch_desc_str[len]=' ';+}+}+/***dump_stack_print_info-printgenericdebuginfofordump_stack()*@log_lvl:loglevel
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2019-01-17 13:34:42
As soon as we've done some basic setup, add the PVR and CPU name to
the dump stack arch description, which is printed in case of an oops.
eg: Hardware name: ... POWER8E (raw) pvr:0x4b0201
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kernel/cputable.c | 1 +
arch/powerpc/kernel/prom.c | 4 ++++
2 files changed, 5 insertions(+)
v2: Show the PVR as well.
@@ -761,6 +761,10 @@ void __init early_init_devtree(void *params)dt_cpu_ftrs_scan();+/* We can now set the CPU name & PVR for the oops output */+dump_stack_add_arch_desc("%s pvr:0x%04lx",cur_cpu_spec->cpu_name,+mfspr(SPRN_PVR));+/* Retrieve CPU related informations from the flat tree*(altivecsupport,bootCPUID,...)*/
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2019-01-17 13:36:34
If we detect a logical PVR add that to the dump stack arch
description, which is printed in case of an oops.
eg: Hardware name: ... lpvr:0xf000004
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kernel/prom.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
v2: new.
@@ -371,8 +371,10 @@ static int __init early_init_dt_scan_cpus(unsigned long node,*/if(!dt_cpu_ftrs_in_use()){prop=of_get_flat_dt_prop(node,"cpu-version",NULL);-if(prop&&(be32_to_cpup(prop)&0xff000000)==0x0f000000)+if(prop&&(be32_to_cpup(prop)&0xff000000)==0x0f000000){identify_cpu(0,be32_to_cpup(prop));+dump_stack_add_arch_desc("lpvr:0x%04x",be32_to_cpup(prop));+}check_cpu_feature_properties(node);check_cpu_pa_features(node);
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2019-01-17 13:38:05
As soon as we know the model of the machine we're on, add it to the
dump stack arch description, which is printed in case of an oops.
eg: Hardware name: model:'IBM,8247-22L'
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kernel/prom.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
v2: Qualify the string with 'model'.
@@ -697,6 +715,8 @@ void __init early_init_devtree(void *params)if(!early_init_dt_verify(params))panic("BUG: Failed verifying flat device tree, bad version?");+of_scan_flat_dt(early_init_dt_scan_model,NULL);+#ifdef CONFIG_PPC_RTAS/* Some machines might need RTAS info for debugging, grab it now. */of_scan_flat_dt(early_init_dt_scan_rtas,NULL);
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2019-01-17 13:39:50
As soon as we know the name of the machine description we're using, add
it to the dump stack arch description, which is printed in case of an
oops.
eg: Hardware name: ... machine:pSeries
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kernel/setup-common.c | 3 +++
1 file changed, 3 insertions(+)
v2: Qualify the string with 'machine'.
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2019-01-17 13:41:28
Once we have unflattened the device tree we can easily grab these opal
version details and add them to dump stack arch description, which is
printed in case of an oops.
eg: Hardware name: ... opal:v6.2
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/platforms/powernv/setup.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
v2: Qualify the string with 'opal' and 'mi'. Only use git-id if version
is missing.
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2019-01-17 13:46:09
Once we have unflattened the device tree we can easily grab these
firmware version details and add them to dump stack arch description,
which is printed in case of an oops.
Currently /hypervisor only exists on KVM, so if we don't find that look
for something that suggests we're on phyp and if so that's probably a
good guess. The actual content of the ibm,fw-net-version seems to be
a full path so is too long to add to the description.
Hardware name: ... of:'IBM,FW860.42 (SV860_138)' hv:phyp
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/platforms/pseries/setup.c | 35 ++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
v2: Use 'of' rather than 'prom' for the open firmware value.