[Skiboot] [Crash-utility] [PATCH v2]: Adds support in crash-utility to dump opal console buffer for PPC64
Dave Anderson
anderson at redhat.com
Wed Feb 15 02:13:54 AEDT 2017
----- Original Message -----
> This patch adds support in crash-utility to dump opal console buffer for PPC64
> by adding -o option in mach command. Currently start address and size of opal
> console log buffer is hard-coded.
> As this option is specific to POWER, it is coded as such.
Hello Ankit,
OK, this looks good. I went ahead and addressed these compiler warnings:
$ make warn
TARGET: PPC64
CRASH: 7.1.8rc19
GDB: 7.6
cc -c -g -DPPC64 -DGDB_7_6 build_data.c -Wall -O2 -Wstrict-prototypes -Wmissing-prototypes -fstack-protector -Wformat-security
cc -c -g -DPPC64 -DGDB_7_6 ppc64.c -Wall -O2 -Wstrict-prototypes -Wmissing-prototypes -fstack-protector -Wformat-security
ppc64.c:2747:1: warning: no previous prototype for ‘opalmsg’ [-Wmissing-prototypes]
opalmsg(void)
^
ppc64.c: In function ‘opalmsg’:
ppc64.c:2815:3: warning: implicit declaration of function ‘isprint’ [-Wimplicit-function-declaration]
if (isprint(mem.u8)) {
^
ppc64.c:2764:8: warning: unused variable ‘addrtype’ [-Wunused-variable]
char *addrtype;
^
ppc64.c:2761:17: warning: unused variable ‘sz’ [-Wunused-variable]
size_t typesz, sz;
^
I also fixed up the help page a bit, and replaced the fprintf(fp) error
messages in ppc64_cmd_mach() with error(FATAL) calls. The borrowing of
the memloc structure from the generic display_memory() function is
overkill, but I left it alone in case you ever want extend the function
to read non-ASCII data (?).
Queued for crash-7.1.8:
https://github.com/crash-utility/crash/commit/1a4af84dbda299bcf0a54b1e76eb963f3bbff98b
Thanks,
Dave
>
> Here is the sample output of 'mach' command with '-o' option:
> crash> mach -o
> [ 65.219056911,5] SkiBoot skiboot-5.4.0-218-ge0225cc-mukesh-dirty-df9a248
> starting...
> [ 65.219065872,5] initial console log level: memory 7, driver 5
> [ 65.219068917,6] CPU: P8 generation processor(max 8 threads/core)
> [ 65.219071681,7] CPU: Boot CPU PIR is 0x0060 PVR is 0x004d0200
> [ 65.219074685,7] CPU: Initial max PIR set to 0x1fff
> [ 65.219602559,5] OPAL table: 0x300c7440 .. 0x300c78d0, branch table:
> 0x30002000
> [ 65.219607955,5] FDT: Parsing fdt @0xff00000
> [ 65.225380389,5] XSCOM: chip 0x8 at 0x3fc4000000000 [P8 DD2.0]
> [ 65.225387919,6] XSTOP: XSCOM addr = 0x2010c82, FIR bit = 31
> [ 491.377710151,7] PHB#0022: LINK: Link is up
> [ 494.026291523,7] BT: seq 0x25 netfn 0x0a cmd 0x48: Message sent to host
> [ 494.027636927,7] BT: seq 0x25 netfn 0x0a cmd 0x48: IPMI MSG done
>
> Log for dump collected on non OPAL ppc machine:
> crash> mach -o
> Dump was not captured on an OPAL based machine
>
> crash> help mach
>
> NAME
> mach - machine specific data
>
> SYNOPSIS
> mach [-m | -c | -o -[xd]]
>
> DESCRIPTION
> This command displays data specific to a machine type.
> ...
> -o Display opal console log in crash (ppc64 only).
>
> Display opal console log in crash:
>
> crash> mach -o
> [ 65.219056911,5] SkiBoot skiboot-5.4.0-218-ge0225cc-df9a248
> starting...
> [ 65.219065872,5] initial console log level: memory 7, driver 5
> [ 65.219068917,6] CPU: P8 generation processor(max 8 threads/core)
> [ 65.219071681,7] CPU: Boot CPU PIR is 0x0060 PVR is 0x004d0200
> [ 65.219074685,7] CPU: Initial max PIR set to 0x1fff
> [ 65.219607955,5] FDT: Parsing fdt @0xff00000
> [ 494.026291523,7] BT: seq 0x25 netfn 0x0a cmd 0x48: Message sent to
> host
> [ 494.027636927,7] BT: seq 0x25 netfn 0x0a cmd 0x48: IPMI MSG done
>
> Signed-off-by: Ankit Kumar <ankit at linux.vnet.ibm.com>
> ---
>
> Changelog since v1:(Worked on suggestion given by Dave Anderson)
> - Implemented opalmsg as part of 'mach -o' option.
>
> help.c | 14 ++++++++-
> ppc64.c | 104
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 116 insertions(+), 2 deletions(-)
>
> diff --git a/help.c b/help.c
> index 1503a7c..45890b2 100644
> --- a/help.c
> +++ b/help.c
> @@ -2290,7 +2290,7 @@ NULL
> char *help_mach[] = {
> "mach",
> "machine specific data",
> -"[-m | -c -[xd]]",
> +"[-m | -c | -o -[xd]]",
> " This command displays data specific to a machine type.\n",
> " -m Display the physical memory map (x86, x86_64 and ia64 only).",
> " -c Display each cpu's cpuinfo structure (x86, x86_64 and ia64 only).",
> @@ -2298,6 +2298,7 @@ char *help_mach[] = {
> " Display the hwrpb_struct, and each cpu's percpu_struct (alpha
> only).",
> " -x override default output format with hexadecimal format.",
> " -d override default output format with decimal format.",
> +" -o Display opal console log in crash (ppc64 only).",
> "\nEXAMPLES",
> " %s> mach",
> " MACHINE TYPE: i686",
> @@ -2324,6 +2325,17 @@ char *help_mach[] = {
> " 00000000fec00000 - 00000000fec90000 E820_RESERVED",
> " 00000000fee00000 - 00000000fee10000 E820_RESERVED",
> " 00000000ffb00000 - 0000000100000000 E820_RESERVED",
> +" ",
> +" Display opal console log in crash:\n",
> +" %s> mach -o",
> +" [ 65.219056911,5] SkiBoot skiboot-5.4.0-218-ge0225cc-df9a248
> starting...",
> +" [ 65.219065872,5] initial console log level: memory 7, driver 5",
> +" [ 65.219068917,6] CPU: P8 generation processor(max 8 threads/core)",
> +" [ 65.219071681,7] CPU: Boot CPU PIR is 0x0060 PVR is 0x004d0200",
> +" [ 65.219074685,7] CPU: Initial max PIR set to 0x1fff",
> +" [ 65.219607955,5] FDT: Parsing fdt @0xff00000",
> +" [ 494.026291523,7] BT: seq 0x25 netfn 0x0a cmd 0x48: Message sent to
> host",
> +" [ 494.027636927,7] BT: seq 0x25 netfn 0x0a cmd 0x48: IPMI MSG done",
> NULL
> };
>
> diff --git a/ppc64.c b/ppc64.c
> index 8dd0465..21c9827 100644
> --- a/ppc64.c
> +++ b/ppc64.c
> @@ -2733,6 +2733,106 @@ ppc64_get_smp_cpus(void)
> return get_cpus_online();
> }
>
> +
> +/*
> + * Definitions derived from OPAL. These need to track corresponding values
> in
> + * https://github.com/open-power/skiboot/blob/master/include/mem-map.h
> + */
> +#define SKIBOOT_CONSOLE_DUMP_START 0x31000000
> +#define SKIBOOT_CONSOLE_DUMP_SIZE 0x40000
> +#define SKIBOOT_BASE 0x30000000
> +#define ASCII_UNLIMITED ((ulong)(-1) >> 1)
> +
> +void
> +opalmsg(void)
> +{
> + struct memloc {
> + uint8_t u8;
> + uint16_t u16;
> + uint32_t u32;
> + uint64_t u64;
> + uint64_t limit64;
> + };
> + struct opal {
> + unsigned long long base;
> + unsigned long long entry;
> + } opal;
> + int i, a;
> + size_t typesz, sz;
> + void *location;
> + char readtype[20];
> + char *addrtype;
> + struct memloc mem;
> + int displayed, per_line;
> + int lost;
> + ulong error_handle;
> + long count = SKIBOOT_CONSOLE_DUMP_SIZE;
> + ulonglong addr = SKIBOOT_CONSOLE_DUMP_START;
> +
> + if (CRASHDEBUG(4))
> + fprintf(fp, "<addr: %llx count: %ld (%s)>\n",
> + addr, count, "PHYSADDR");
> +
> + /*
> + * OPAL based platform check
> + * struct opal of BSS section and hence default value will be ZERO(0)
> + * opal_init() in the kernel initializes this structure based on
> + * the platform. Use it as a key to determine whether the dump
> + * was taken on an OPAL based system or not.
> + */
> + if (symbol_exists("opal")) {
> + get_symbol_data("opal", sizeof(struct opal), &opal);
> + if (opal.base != SKIBOOT_BASE) {
> + fprintf(fp, "Dump was captured on Non PowerNV Machine");
> + return;
> + }
> + } else {
> + fprintf(fp, "Dump was captured on Non PowerNV Machine");
> + return;
> + }
> +
> + BZERO(&mem, sizeof(struct memloc));
> + lost = typesz = per_line = 0;
> + location = NULL;
> +
> + /* ASCII */
> + typesz = SIZEOF_8BIT;
> + location = &mem.u8;
> + sprintf(readtype, "ascii");
> + per_line = 256;
> + displayed = 0;
> +
> + error_handle = FAULT_ON_ERROR;
> +
> + for (i = a = 0; i < count; i++) {
> + if (!readmem(addr, PHYSADDR, location, typesz,
> + readtype, error_handle)) {
> + addr += typesz;
> + lost += 1;
> + continue;
> + }
> +
> + if (isprint(mem.u8)) {
> + if ((a % per_line) == 0) {
> + if (displayed && i)
> + fprintf(fp, "\n");
> + }
> + fprintf(fp, "%c", mem.u8);
> + displayed++;
> + a++;
> + } else {
> + if (count == ASCII_UNLIMITED)
> + return;
> + a = 0;
> + }
> +
> + addr += typesz;
> + }
> +
> + if (lost != count)
> + fprintf(fp, "\n");
> +}
> +
> /*
> * Machine dependent command.
> */
> @@ -2741,7 +2841,7 @@ ppc64_cmd_mach(void)
> {
> int c;
>
> - while ((c = getopt(argcnt, args, "cm")) != EOF) {
> + while ((c = getopt(argcnt, args, "cmo")) != EOF) {
> switch(c)
> {
> case 'c':
> @@ -2749,6 +2849,8 @@ ppc64_cmd_mach(void)
> fprintf(fp, "PPC64: '-%c' option is not supported\n",
> c);
> break;
> + case 'o':
> + return opalmsg();
> default:
> argerrs++;
> break;
> --
> 2.7.4
>
More information about the Skiboot
mailing list