----- Original Message -----
>
> From: Hari Bathini <hbath...@linux.ibm.com>
>
> Add PPC64 specific flag for kernels running on platforms based on
> OPAL firmware. Use this flag before processing commands specific to
> OPAL based systems.
Thanks Hari -- queued for crash-7.2.5:
https://github.com/crash-utility/crash/commit/72cc0cba8a6cab14ca0961dff062d0384d307ce5
Dave
>
> Signed-off-by: Hari Bathini <hbathini linux ibm com>
> ---
> defs.h | 8 ++++++++
> ppc64.c | 36 ++++++++++++++++--------------------
> 2 files changed, 24 insertions(+), 20 deletions(-)
>
> diff --git a/defs.h b/defs.h
> index 5b64bb7..567992e 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -5963,6 +5963,12 @@ struct ppc64_elf_prstatus {
>
> #ifdef PPC64
>
> +struct ppc64_opal {
> + uint64_t base;
> + uint64_t entry;
> + uint64_t size;
> +};
> +
> struct ppc64_vmemmap {
> unsigned long phys;
> unsigned long virt;
> @@ -6013,6 +6019,7 @@ struct machine_specific {
> ulong _page_accessed;
> int (*is_kvaddr)(ulong);
> int (*is_vmaddr)(ulong);
> + struct ppc64_opal opal;
> };
>
> void ppc64_init(int);
> @@ -6030,6 +6037,7 @@ void ppc64_dump_machdep_table(ulong);
> * in the kernel is also 0x40.
> */
> #define RADIX_MMU (0x40)
> +#define OPAL_FW (0x80)
>
> #define REGION_SHIFT (60UL)
> #define REGION_ID(addr) (((unsigned long)(addr)) >> REGION_SHIFT)
> diff --git a/ppc64.c b/ppc64.c
> index ee2f76f..cf41765 100644
> --- a/ppc64.c
> +++ b/ppc64.c
> @@ -241,6 +241,7 @@ struct machine_specific book3e_machine_specific = {
> .is_vmaddr = book3e_is_vmaddr,
> };
>
> +#define SKIBOOT_BASE 0x30000000
>
> /*
> * Do all necessary machine-specific setup here. This is called several
> @@ -362,6 +363,16 @@ ppc64_init(int when)
> struct machine_specific *m = machdep->machspec;
>
> /*
> + * To determine if the kernel was running on OPAL based
> platform,
> + * use struct opal, which is populated with relevant
> values.
> + */
> + if (symbol_exists("opal")) {
> + get_symbol_data("opal", sizeof(struct
> ppc64_opal), &(m->opal));
> + if (m->opal.base == SKIBOOT_BASE)
> + machdep->flags |= OPAL_FW;
> + }
> +
> + /*
> * On Power ISA 3.0 based server processors, a kernel
> can
> * run with radix MMU or standard MMU. Set the flag,
> * if it is radix MMU.
> @@ -712,6 +723,8 @@ ppc64_dump_machdep_table(ulong arg)
> fprintf(fp, "%sSWAP_ENTRY_L4", others++ ? "|" : "");
> if (machdep->flags & RADIX_MMU)
> fprintf(fp, "%sRADIX_MMU", others++ ? "|" : "");
> + if (machdep->flags & OPAL_FW)
> + fprintf(fp, "%sOPAL_FW", others++ ? "|" : "");
> fprintf(fp, ")\n");
>
> fprintf(fp, " kvbase: %lx\n", machdep->kvbase);
> @@ -2828,7 +2841,6 @@ ppc64_get_smp_cpus(void)
> */
> #define SKIBOOT_CONSOLE_DUMP_START 0x31000000
> #define SKIBOOT_CONSOLE_DUMP_SIZE 0x100000
> -#define SKIBOOT_BASE 0x30000000
> #define ASCII_UNLIMITED ((ulong)(-1) >> 1)
>
> void
> @@ -2841,10 +2853,6 @@ opalmsg(void)
> uint64_t u64;
> uint64_t limit64;
> };
> - struct opal {
> - unsigned long long base;
> - unsigned long long entry;
> - } opal;
> int i, a;
> size_t typesz;
> void *location;
> @@ -2856,25 +2864,13 @@ opalmsg(void)
> long count = SKIBOOT_CONSOLE_DUMP_SIZE;
> ulonglong addr = SKIBOOT_CONSOLE_DUMP_START;
>
> + if (!(machdep->flags & OPAL_FW))
> + error(FATAL, "dump was not captured on OPAL based system");
> +
> 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)
> - error(FATAL, "dump was captured on non-PowerNV
> machine");
> - } else {
> - error(FATAL, "dump was captured on non-PowerNV machine");
> - }
> -
> BZERO(&mem, sizeof(struct memloc));
> lost = typesz = per_line = 0;
> location = NULL;
>
--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility