All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: Hari Bathini <hbathini@linux.ibm.com>,
	linuxppc-dev <linuxppc-dev@ozlabs.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.ibm.com>,
	Mahesh J Salgaonkar <mahesh@linux.ibm.com>,
	Vasant Hegde <hegdevasant@linux.ibm.com>,
	Oliver <oohall@gmail.com>, Nicholas Piggin <npiggin@gmail.com>,
	Daniel Axtens <dja@axtens.net>
Subject: Re: [PATCH v5 21/31] powernv/fadump: process architected register state data provided by firmware
Date: Wed, 04 Sep 2019 22:20:56 +1000	[thread overview]
Message-ID: <87sgpcp80n.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <156630280239.8896.11769233860624935762.stgit@hbathini.in.ibm.com>

Hari Bathini <hbathini@linux.ibm.com> writes:

> diff --git a/arch/powerpc/kernel/fadump-common.h b/arch/powerpc/kernel/fadump-common.h
> index 7107cf2..fc408b0 100644
> --- a/arch/powerpc/kernel/fadump-common.h
> +++ b/arch/powerpc/kernel/fadump-common.h
> @@ -98,7 +98,11 @@ struct fw_dump {
>  	/* cmd line option during boot */
>  	unsigned long	reserve_bootvar;
>  
> +	unsigned long	cpu_state_destination_addr;

AFAICS that is only used in two places, and both of them have to call
__va() on it, so why don't we store the virtual address to start with?

> diff --git a/arch/powerpc/platforms/powernv/opal-fadump.c b/arch/powerpc/platforms/powernv/opal-fadump.c
> index f75b861..9a32a7f 100644
> --- a/arch/powerpc/platforms/powernv/opal-fadump.c
> +++ b/arch/powerpc/platforms/powernv/opal-fadump.c
> @@ -282,15 +283,122 @@ static void opal_fadump_cleanup(struct fw_dump *fadump_conf)
>  		pr_warn("Could not reset (%llu) kernel metadata tag!\n", ret);
>  }
>  
> +static inline void opal_fadump_set_regval_regnum(struct pt_regs *regs,
> +						 u32 reg_type, u32 reg_num,
> +						 u64 reg_val)
> +{
> +	if (reg_type == HDAT_FADUMP_REG_TYPE_GPR) {
> +		if (reg_num < 32)
> +			regs->gpr[reg_num] = reg_val;
> +		return;
> +	}
> +
> +	switch (reg_num) {
> +	case SPRN_CTR:
> +		regs->ctr = reg_val;
> +		break;
> +	case SPRN_LR:
> +		regs->link = reg_val;
> +		break;
> +	case SPRN_XER:
> +		regs->xer = reg_val;
> +		break;
> +	case SPRN_DAR:
> +		regs->dar = reg_val;
> +		break;
> +	case SPRN_DSISR:
> +		regs->dsisr = reg_val;
> +		break;
> +	case HDAT_FADUMP_REG_ID_NIP:
> +		regs->nip = reg_val;
> +		break;
> +	case HDAT_FADUMP_REG_ID_MSR:
> +		regs->msr = reg_val;
> +		break;
> +	case HDAT_FADUMP_REG_ID_CCR:
> +		regs->ccr = reg_val;
> +		break;
> +	}
> +}
> +
> +static inline void opal_fadump_read_regs(char *bufp, unsigned int regs_cnt,
> +					 unsigned int reg_entry_size,
> +					 struct pt_regs *regs)
> +{
> +	int i;
> +	struct hdat_fadump_reg_entry *reg_entry;

Where's my christmas tree :)

> +
> +	memset(regs, 0, sizeof(struct pt_regs));
> +
> +	for (i = 0; i < regs_cnt; i++, bufp += reg_entry_size) {
> +		reg_entry = (struct hdat_fadump_reg_entry *)bufp;
> +		opal_fadump_set_regval_regnum(regs,
> +					      be32_to_cpu(reg_entry->reg_type),
> +					      be32_to_cpu(reg_entry->reg_num),
> +					      be64_to_cpu(reg_entry->reg_val));
> +	}
> +}
> +
> +static inline bool __init is_thread_core_inactive(u8 core_state)
> +{
> +	bool is_inactive = false;
> +
> +	if (core_state == HDAT_FADUMP_CORE_INACTIVE)
> +		is_inactive = true;
> +
> +	return is_inactive;

	return core_state == HDAT_FADUMP_CORE_INACTIVE;

??

In fact there's only one caller, so just drop the inline entirely.

> +}
> +
>  /*
>   * Convert CPU state data saved at the time of crash into ELF notes.
> + *
> + * Each register entry is of 16 bytes, A numerical identifier along with
> + * a GPR/SPR flag in the first 8 bytes and the register value in the next
> + * 8 bytes. For more details refer to F/W documentation.
>   */
>  static int __init opal_fadump_build_cpu_notes(struct fw_dump *fadump_conf)
>  {
>  	u32 num_cpus, *note_buf;
>  	struct fadump_crash_info_header *fdh = NULL;
> +	struct hdat_fadump_thread_hdr *thdr;
> +	unsigned long addr;
> +	u32 thread_pir;
> +	char *bufp;
> +	struct pt_regs regs;
> +	unsigned int size_of_each_thread;
> +	unsigned int regs_offset, regs_cnt, reg_esize;
> +	int i;

	unsigned int size_of_each_thread, regs_offset, regs_cnt, reg_esize;
  	struct fadump_crash_info_header *fdh = NULL;
  	u32 num_cpus, thread_pir, *note_buf;
	struct hdat_fadump_thread_hdr *thdr;
	struct pt_regs regs;
	unsigned long addr;
	char *bufp;
	int i;

Ah much better :)

Though the number of variables might be an indication that this function
could be split into smaller parts.

> @@ -473,6 +627,26 @@ int __init opal_fadump_dt_scan(struct fw_dump *fadump_conf, ulong node)
>  			return 1;
>  		}
>  
> +		ret = opal_mpipl_query_tag(OPAL_MPIPL_TAG_CPU, &addr);
> +		if ((ret != OPAL_SUCCESS) || !addr) {
> +			pr_err("Failed to get CPU metadata (%lld)\n", ret);
> +			return 1;
> +		}
> +
> +		addr = be64_to_cpu(addr);
> +		pr_debug("CPU metadata addr: %llx\n", addr);
> +
> +		opal_cpu_metadata = __va(addr);
> +		r_opal_cpu_metadata = (void *)addr;

Another r_ variable I don't understand.

> diff --git a/arch/powerpc/platforms/powernv/opal-fadump.h b/arch/powerpc/platforms/powernv/opal-fadump.h
> index 19cac1f..ce4c522 100644
> --- a/arch/powerpc/platforms/powernv/opal-fadump.h
> +++ b/arch/powerpc/platforms/powernv/opal-fadump.h
> @@ -30,4 +30,43 @@ struct opal_fadump_mem_struct {
>  	struct opal_mpipl_region	rgn[OPAL_FADUMP_MAX_MEM_REGS];
>  } __attribute__((packed));
>  
> +/*
> + * CPU state data is provided by f/w. Below are the definitions
> + * provided in HDAT spec. Refer to latest HDAT specification for
> + * any update to this format.
> + */

How is this meant to work? If HDAT ever changes the format they will
break all existing kernels in the field.

> +#define HDAT_FADUMP_CPU_DATA_VERSION		1
> +
> +#define HDAT_FADUMP_CORE_INACTIVE		(0x0F)
> +
> +/* HDAT thread header for register entries */
> +struct hdat_fadump_thread_hdr {
> +	__be32  pir;
> +	/* 0x00 - 0x0F - The corresponding stop state of the core */
> +	u8      core_state;
> +	u8      reserved[3];
> +
> +	__be32	offset;	/* Offset to Register Entries array */
> +	__be32	ecnt;	/* Number of entries */
> +	__be32	esize;	/* Alloc size of each array entry in bytes */
> +	__be32	eactsz;	/* Actual size of each array entry in bytes */
> +} __attribute__((packed));
> +
> +/* Register types populated by f/w */
> +#define HDAT_FADUMP_REG_TYPE_GPR		0x01
> +#define HDAT_FADUMP_REG_TYPE_SPR		0x02
> +
> +/* ID numbers used by f/w while populating certain registers */
> +#define HDAT_FADUMP_REG_ID_NIP			0x7D0
> +#define HDAT_FADUMP_REG_ID_MSR			0x7D1
> +#define HDAT_FADUMP_REG_ID_CCR			0x7D2
> +
> +/* HDAT register entry. */
> +struct hdat_fadump_reg_entry {
> +	__be32		reg_type;
> +	__be32		reg_num;
> +	__be64		reg_val;
> +} __attribute__((packed));

cheers

  reply	other threads:[~2019-09-04 13:06 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-20 12:04 [PATCH v5 00/31] Add FADump support on PowerNV platform Hari Bathini
2019-08-20 12:04 ` [PATCH v5 01/31] powerpc/fadump: move internal macros/definitions to a new header Hari Bathini
2019-09-03 11:09   ` Michael Ellerman
2019-09-03 16:05     ` Hari Bathini
2019-08-20 12:04 ` [PATCH v5 02/31] powerpc/fadump: move internal code to a new file Hari Bathini
2019-09-03 11:09   ` Michael Ellerman
2019-09-03 16:05     ` Hari Bathini
2019-09-04  9:02       ` Mahesh Jagannath Salgaonkar
2019-09-04 18:26         ` Hari Bathini
2019-08-20 12:04 ` [PATCH v5 03/31] powerpc/fadump: Improve fadump documentation Hari Bathini
2019-08-20 12:04 ` [PATCH v5 04/31] pseries/fadump: move rtas specific definitions to platform code Hari Bathini
2019-08-20 12:04 ` [PATCH v5 05/31] pseries/fadump: introduce callbacks for platform specific operations Hari Bathini
2019-09-03 11:10   ` Michael Ellerman
2019-09-03 16:06     ` Hari Bathini
2019-09-06  6:39       ` Hari Bathini
2019-08-20 12:04 ` [PATCH v5 06/31] pseries/fadump: define register/un-register callback functions Hari Bathini
2019-09-03 11:10   ` Michael Ellerman
2019-09-03 17:15     ` Hari Bathini
2019-08-20 12:04 ` [PATCH v5 07/31] powerpc/fadump: release all the memory above boot memory size Hari Bathini
2019-09-03 11:10   ` Michael Ellerman
2019-09-03 16:27     ` Hari Bathini
2019-08-20 12:05 ` [PATCH v5 08/31] pseries/fadump: move out platform specific support from generic code Hari Bathini
2019-08-20 12:05 ` [PATCH v5 09/31] powerpc/fadump: use FADump instead of fadump for how it is pronounced Hari Bathini
2019-08-20 12:05 ` [PATCH v5 10/31] opal: add MPIPL interface definitions Hari Bathini
2019-09-03 11:10   ` Michael Ellerman
2019-09-03 16:28     ` Hari Bathini
2019-09-04 11:03       ` Michael Ellerman
2019-09-04 11:05   ` Michael Ellerman
2019-08-20 12:05 ` [PATCH v5 11/31] powernv/fadump: add fadump support on powernv Hari Bathini
2019-09-03 11:10   ` Michael Ellerman
2019-09-03 16:31     ` Hari Bathini
2019-09-04 14:33       ` Hari Bathini
2019-09-05  3:11         ` Michael Ellerman
2019-08-20 12:05 ` [PATCH v5 12/31] powernv/fadump: register kernel metadata address with opal Hari Bathini
2019-09-04 11:25   ` Michael Ellerman
2019-08-20 12:05 ` [PATCH v5 13/31] powernv/fadump: reset metadata address during clean up Hari Bathini
2019-08-27 12:00   ` Hari Bathini
2019-08-20 12:05 ` [PATCH v5 14/31] powernv/fadump: define register/un-register callback functions Hari Bathini
2019-09-05  4:15   ` Michael Ellerman
2019-09-05  7:23   ` Michael Ellerman
2019-09-05  9:54     ` Hari Bathini
2019-08-20 12:05 ` [PATCH v5 15/31] powernv/fadump: support copying multiple kernel boot memory regions Hari Bathini
2019-09-04 11:30   ` Michael Ellerman
2019-09-04 20:20     ` Hari Bathini
2019-09-05  3:13       ` Michael Ellerman
2019-08-20 12:06 ` [PATCH v5 16/31] powernv/fadump: process the crashdump by exporting it as /proc/vmcore Hari Bathini
2019-09-04 11:42   ` Michael Ellerman
2019-09-04 21:01     ` Hari Bathini
2019-08-20 12:06 ` [PATCH v5 17/31] powernv/fadump: Warn before processing partial crashdump Hari Bathini
2019-09-04 11:48   ` Michael Ellerman
2019-08-20 12:06 ` [PATCH v5 18/31] powernv/fadump: handle invalidation of crashdump and re-registraion Hari Bathini
2019-08-20 12:06 ` [PATCH v5 19/31] powerpc/fadump: Update documentation about OPAL platform support Hari Bathini
2019-09-04 11:51   ` Michael Ellerman
2019-09-04 12:08     ` Oliver O'Halloran
2019-09-05  3:15       ` Michael Ellerman
2019-08-20 12:06 ` [PATCH v5 20/31] powerpc/fadump: use smaller offset while finding memory for reservation Hari Bathini
2019-09-04 11:54   ` Michael Ellerman
2019-08-20 12:06 ` [PATCH v5 21/31] powernv/fadump: process architected register state data provided by firmware Hari Bathini
2019-09-04 12:20   ` Michael Ellerman [this message]
2019-09-09 13:23     ` Hari Bathini
2019-09-09 15:33       ` Oliver O'Halloran
2019-09-10  8:48         ` Hari Bathini
2019-09-10 14:05           ` Michael Ellerman
2019-09-10 16:10             ` Hari Bathini
2019-08-20 12:06 ` [PATCH v5 22/31] powerpc/fadump: make crash memory ranges array allocation generic Hari Bathini
2019-08-20 12:06 ` [PATCH v5 23/31] powerpc/fadump: consider reserved ranges while releasing memory Hari Bathini
2019-08-20 12:07 ` [PATCH v5 24/31] powerpc/fadump: improve how crashed kernel's memory is reserved Hari Bathini
2019-08-20 12:07 ` [PATCH v5 25/31] powernv/fadump: add support to preserve crash data on FADUMP disabled kernel Hari Bathini
2019-08-20 12:07 ` [PATCH v5 26/31] powerpc/fadump: update documentation about CONFIG_PRESERVE_FA_DUMP Hari Bathini
2019-08-20 12:07 ` [PATCH v5 27/31] powernv/opalcore: export /sys/firmware/opal/core for analysing opal crashes Hari Bathini
2019-08-20 12:07 ` [PATCH v5 28/31] powernv/opalcore: provide an option to invalidate /sys/firmware/opal/core file Hari Bathini
2019-08-20 12:07 ` [PATCH v5 29/31] powerpc/fadump: consider f/w load area Hari Bathini
2019-08-20 12:07 ` [PATCH v5 30/31] powernv/fadump: update documentation about option to release opalcore Hari Bathini
2019-08-20 12:07 ` [PATCH v5 31/31] powernv/fadump: support holes in kernel boot memory area Hari Bathini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sgpcp80n.fsf@mpe.ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=ananth@linux.ibm.com \
    --cc=dja@axtens.net \
    --cc=hbathini@linux.ibm.com \
    --cc=hegdevasant@linux.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mahesh@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=oohall@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.