From: Kees Cook <keescook@chromium.org>
To: Mukesh Ojha <quic_mojha@quicinc.com>
Cc: corbet@lwn.net, agross@kernel.org, andersson@kernel.org,
konrad.dybcio@linaro.org, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
tony.luck@intel.com, gpiccoli@igalia.com,
mathieu.poirier@linaro.org, catalin.marinas@arm.com,
will@kernel.org, linus.walleij@linaro.org,
andy.shevchenko@gmail.com, vigneshr@ti.com, nm@ti.com,
matthias.bgg@gmail.com, kgene@kernel.org,
alim.akhtar@samsung.com, bmasney@redhat.com,
quic_tsoni@quicinc.com, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-hardening@vger.kernel.org,
linux-remoteproc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
linux-mediatek@lists.infradead.org,
linux-samsung-soc@vger.kernel.org, kernel@quicinc.com
Subject: Re: [REBASE PATCH v5 11/17] qcom_minidump: Register ramoops region with minidump
Date: Wed, 13 Sep 2023 16:42:07 -0700 [thread overview]
Message-ID: <202309131632.736914C0A3@keescook> (raw)
In-Reply-To: <202309131624.0371D7E@keescook>
On Wed, Sep 13, 2023 at 04:30:04PM -0700, Kees Cook wrote:
> On Mon, Sep 11, 2023 at 04:23:53PM +0530, Mukesh Ojha wrote:
> > Register all the pstore frontend with minidump, so that they can
> > be dumped as default Linux minidump region to be collected on
> > SoC where minidump is enabled.
> >
> > Helper functions is written in separate file and built along with
> > the minidump driver, since it is client of minidump and also call
> > it at appropriate place from minidump probe so that they always
> > get registered.
> >
> > While at it also rename the out minidump module object name during
> > build as qcom_apss_minidump which basically depicts as Qualcomm
> > Application processor subsystem minidump.
> >
> > Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> > ---
> > drivers/soc/qcom/Kconfig | 1 +
> > drivers/soc/qcom/Makefile | 3 +-
> > drivers/soc/qcom/qcom_minidump.c | 4 ++
> > drivers/soc/qcom/qcom_ramoops_minidump.c | 88 ++++++++++++++++++++++++++++++++
> > drivers/soc/qcom/qcom_ramoops_minidump.h | 10 ++++
> > 5 files changed, 105 insertions(+), 1 deletion(-)
> > create mode 100644 drivers/soc/qcom/qcom_ramoops_minidump.c
> > create mode 100644 drivers/soc/qcom/qcom_ramoops_minidump.h
> >
> > diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
> > index 0ac7afc2c67d..9f1a1e128fef 100644
> > --- a/drivers/soc/qcom/Kconfig
> > +++ b/drivers/soc/qcom/Kconfig
> > @@ -306,6 +306,7 @@ config QCOM_MINIDUMP
> > tristate "QCOM APSS Minidump driver"
> > depends on ARCH_QCOM || COMPILE_TEST
> > depends on QCOM_SMEM
> > + depends on PSTORE
> > help
> > This config enables linux core infrastructure for Application
> > processor subsystem (APSS) minidump collection i.e, it enables
> > diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
> > index 4b5f72f78d3c..69df41aba7a9 100644
> > --- a/drivers/soc/qcom/Makefile
> > +++ b/drivers/soc/qcom/Makefile
> > @@ -33,4 +33,5 @@ obj-$(CONFIG_QCOM_ICC_BWMON) += icc-bwmon.o
> > qcom_ice-objs += ice.o
> > obj-$(CONFIG_QCOM_INLINE_CRYPTO_ENGINE) += qcom_ice.o
> > obj-$(CONFIG_QCOM_RPROC_MINIDUMP) += qcom_rproc_minidump.o
> > -obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o
> > +obj-$(CONFIG_QCOM_MINIDUMP) += qcom_apss_minidump.o
> > +qcom_apss_minidump-objs += qcom_minidump.o qcom_ramoops_minidump.o
> > diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c
> > index 4ce36f154e89..7930a80b9100 100644
> > --- a/drivers/soc/qcom/qcom_minidump.c
> > +++ b/drivers/soc/qcom/qcom_minidump.c
> > @@ -23,6 +23,7 @@
> > #include <soc/qcom/qcom_minidump.h>
> >
> > #include "qcom_minidump_internal.h"
> > +#include "qcom_ramoops_minidump.h"
> >
> > /**
> > * struct minidump_ss_data - Minidump subsystem private data
> > @@ -688,6 +689,8 @@ static int qcom_apss_minidump_probe(struct platform_device *pdev)
> > return ret;
> > }
> >
> > + qcom_ramoops_minidump_register(md->dev);
> > +
> > mutex_lock(&md_plist.plock);
> > platform_set_drvdata(pdev, md);
> > qcom_apss_register_pending_regions(md);
> > @@ -701,6 +704,7 @@ static int qcom_apss_minidump_remove(struct platform_device *pdev)
> > struct minidump *md = platform_get_drvdata(pdev);
> > struct minidump_ss_data *mdss_data;
> >
> > + qcom_ramoops_minidump_unregister();
> > mdss_data = md->apss_data;
> > memset(mdss_data->md_ss_toc, cpu_to_le32(0), sizeof(struct minidump_subsystem));
> > md = NULL;
> > diff --git a/drivers/soc/qcom/qcom_ramoops_minidump.c b/drivers/soc/qcom/qcom_ramoops_minidump.c
> > new file mode 100644
> > index 000000000000..eb97310e3858
> > --- /dev/null
> > +++ b/drivers/soc/qcom/qcom_ramoops_minidump.c
> > @@ -0,0 +1,88 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
> > + */
> > +
> > +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> > +
> > +#include <linux/device.h>
> > +#include <linux/kernel.h>
> > +#include <linux/module.h>
> > +#include <linux/pstore.h>
> > +#include <linux/slab.h>
> > +#include <soc/qcom/qcom_minidump.h>
> > +
> > +#include "qcom_ramoops_minidump.h"
> > +
> > +static LIST_HEAD(ramoops_region_list);
> > +
> > +struct md_region_list {
> > + struct qcom_minidump_region md_region;
> > + struct list_head list;
> > +};
> > +
> > +static int qcom_ramoops_region_register(struct device *dev, int type)
> > +{
> > + struct qcom_minidump_region *md_region;
> > + struct md_region_list *mdr_list;
> > + struct pstore_record record;
> > + unsigned int max_dump_cnt;
> > + phys_addr_t phys;
> > + const char *name;
> > + void *virt;
> > + size_t size;
> > + int ret;
> > +
> > + record.type = type;
> > + record.id = 0;
> > + max_dump_cnt = 0;
> > + name = pstore_type_to_name(record.type);
> > + do {
> > + ret = pstore_region_defined(&record, &virt, &phys, &size, &max_dump_cnt);
>
> I really don't want this happening: you're building your own pstore_record
> (which has a common initializer that isn't used here) and manually
> scraping the ramoops regions.
>
> It looks to me like you just want a way to talk all the records in
> pstore and then export their location to minidump. The record walker
> needs to be in the pstore core, and likely should be shared with
> fs/pstore/inode.c which does the same thing.
>
> Then, in this code, you can just do something like:
>
> for (record = pstore_get_record(NULL); record; record = pstore_get_record(record)) {
I just took another look at how records are stored, and I think the best
API here is going to be something like registering a callback so that
pstore can call into minidump for each record. (i.e. it can do this when
reading the records into the pstore filesystem);
pstore_register_record_watcher(minidump_pstore_record)
Then pstore can make the calls if one is registered, in the middle of
pstore_mkfile(), with all the correct locks held, etc:
if (psi->record_watcher)
psi->record_watcher(record);
And then minidump_pstore_record() can do this part:
> if (ramoops_get_record_details(record, &virt, &phys) < 0)
> continue
> ...
> md_region->virt_addr = virt;
> md_region->phys_addr = phys;
> md_region->size = record->size;
>
> ret = qcom_minidump_region_register(md_region);
-Kees
--
Kees Cook
next prev parent reply other threads:[~2023-09-13 23:42 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-11 10:53 [REBASE PATCH v5 00/17] Add Qualcomm Minidump kernel driver related support Mukesh Ojha
2023-09-11 10:53 ` [REBASE PATCH v5 01/17] docs: qcom: Add qualcomm minidump guide Mukesh Ojha
2023-09-11 11:02 ` Krzysztof Kozlowski
2023-09-13 9:25 ` Bagas Sanjaya
2023-09-13 15:20 ` Mukesh Ojha
2023-09-11 10:53 ` [REBASE PATCH v5 02/17] soc: qcom: Add qcom_rproc_minidump module Mukesh Ojha
2023-09-11 10:53 ` [REBASE PATCH v5 03/17] remoteproc: qcom_q6v5_pas: Use qcom_rproc_minidump() Mukesh Ojha
2023-09-11 10:53 ` [REBASE PATCH v5 04/17] remoteproc: qcom: Remove minidump related data from qcom_common.c Mukesh Ojha
2023-10-06 15:08 ` Mukesh Ojha
2023-10-11 17:48 ` Mathieu Poirier
2023-09-11 10:53 ` [REBASE PATCH v5 05/17] init: export linux_banner data variable Mukesh Ojha
2023-09-11 10:53 ` [REBASE PATCH v5 06/17] soc: qcom: Add Qualcomm APSS minidump kernel driver Mukesh Ojha
2023-09-11 11:03 ` Krzysztof Kozlowski
2023-09-11 10:53 ` [REBASE PATCH v5 07/17] soc: qcom: minidump: Add pending region registration Mukesh Ojha
2023-09-11 10:53 ` [REBASE PATCH v5 08/17] arm64: mm: Add dynamic ramoops region support through command line Mukesh Ojha
2023-09-12 10:18 ` Will Deacon
2023-09-13 7:02 ` Mukesh Ojha
2023-09-13 10:25 ` Will Deacon
2023-09-13 23:17 ` Kees Cook
2023-10-05 11:22 ` Mukesh Ojha
2023-10-05 11:44 ` Pavan Kondeti
2023-10-05 15:42 ` Mukesh Ojha
2023-10-05 15:51 ` Pavan Kondeti
2023-09-11 10:53 ` [REBASE PATCH v5 09/17] pstore/ram: Use dynamic ramoops reserve resource Mukesh Ojha
2023-09-11 10:53 ` [REBASE PATCH v5 10/17] pstore: Add pstore_region_defined() helper and export it Mukesh Ojha
2023-09-13 23:24 ` Kees Cook
2023-10-09 11:59 ` Mukesh Ojha
2023-09-11 10:53 ` [REBASE PATCH v5 11/17] qcom_minidump: Register ramoops region with minidump Mukesh Ojha
2023-09-13 23:30 ` Kees Cook
2023-09-13 23:42 ` Kees Cook [this message]
2023-09-11 10:53 ` [REBASE PATCH v5 12/17] MAINTAINERS: Add entry for minidump related files Mukesh Ojha
2023-09-11 10:53 ` [REBASE PATCH v5 13/17] firmware: qcom_scm: provide a read-modify-write function Mukesh Ojha
2023-09-11 10:53 ` [REBASE PATCH v5 14/17] pinctrl: qcom: Use qcom_scm_io_update_field() Mukesh Ojha
2023-09-12 8:23 ` Linus Walleij
2023-09-11 10:53 ` [REBASE PATCH v5 15/17] firmware: scm: Modify only the download bits in TCSR register Mukesh Ojha
2023-09-11 15:07 ` Kathiravan Thirumoorthy
2023-09-12 9:09 ` Mukesh Ojha
2023-09-11 10:53 ` [REBASE PATCH v5 16/17] firmware: qcom_scm: Refactor code to support multiple download mode Mukesh Ojha
2023-09-11 10:53 ` [REBASE PATCH v5 17/17] firmware: qcom_scm: Add multiple download mode support Mukesh Ojha
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=202309131632.736914C0A3@keescook \
--to=keescook@chromium.org \
--cc=agross@kernel.org \
--cc=alim.akhtar@samsung.com \
--cc=andersson@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=bmasney@redhat.com \
--cc=catalin.marinas@arm.com \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=gpiccoli@igalia.com \
--cc=kernel@quicinc.com \
--cc=kgene@kernel.org \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=matthias.bgg@gmail.com \
--cc=nm@ti.com \
--cc=quic_mojha@quicinc.com \
--cc=quic_tsoni@quicinc.com \
--cc=robh+dt@kernel.org \
--cc=tony.luck@intel.com \
--cc=vigneshr@ti.com \
--cc=will@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).