[Skiboot] [PATCH v2]: Adds support in crash-utility to dump opal console buffer for PPC64

Vipin K Parashar vipin at linux.vnet.ibm.com
Wed Feb 15 19:41:07 AEDT 2017


Hi Ankit,

Few input as below:


On Tuesday 14 February 2017 10:49 AM, Ankit Kumar wrote:
> 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.
>
> 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).",

At first glance, -o seems to signify octal here and an extension to previous
-x (hexadecimal) and -d (decimal) options. So would be good to choose
something more intuitive apart from -o for opal logs ?

Also any particular reason for choosing "mach" command for adding
support for displaying OPAL logs. Currently crash utility has 'log' command
for dumping kernel logs, and how about adding a new command say 'fwlog'
altogether for this ?
A new command (may be ppc64 only for now) might be a good idea here,
as it will enable us to add more options into it in future.


>   "\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;



More information about the Skiboot mailing list