lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 21 Feb 2023 16:55:13 +0530
From:   Mukesh Ojha <quic_mojha@...cinc.com>
To:     <agross@...nel.org>, <andersson@...nel.org>,
        <konrad.dybcio@...aro.org>, <keescook@...omium.org>,
        <tony.luck@...el.com>, <gpiccoli@...lia.com>,
        <catalin.marinas@....com>, <will@...nel.org>
CC:     <linux-arm-msm@...r.kernel.org>,
        <linux-remoteproc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <linux-hardening@...r.kernel.org>,
        <linux-arm-kernel@...ts.infradead.org>,
        Mukesh Ojha <quic_mojha@...cinc.com>
Subject: [RFC PATCH 6/6] pstore/ram: Register context with minidump

There are system which does not uses pstore directly but
may have the interest in the context saved by pstore.
Register pstore regions with minidump so that it get
dumped on minidump collection.

Signed-off-by: Mukesh Ojha <quic_mojha@...cinc.com>
---
 fs/pstore/ram.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index ade66db..038da1a 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -20,6 +20,7 @@
 #include <linux/compiler.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <soc/qcom/minidump.h>
 
 #include "internal.h"
 #include "ram_internal.h"
@@ -714,6 +715,74 @@ static int ramoops_parse_dt(struct platform_device *pdev,
 	return 0;
 }
 
+#if IS_ENABLED(CONFIG_QCOM_MINIDUMP)
+static int ramoops_qcom_minidump_register(struct ramoops_context *cxt)
+{
+	struct qcom_minidump_region pstore_entry;
+	struct persistent_ram_zone *prz;
+	int ret = 0;
+	int i;
+
+	for (i = 0; i < cxt->max_dump_cnt; i++) {
+		prz = cxt->dprzs[i];
+		scnprintf(pstore_entry.name, sizeof(pstore_entry.name),
+				"KDMESG%d", i);
+		pstore_entry.virt_addr = prz->vaddr;
+		pstore_entry.phys_addr = prz->paddr;
+		pstore_entry.size = prz->size;
+		ret = qcom_minidump_region_register(&pstore_entry);
+		if (ret < 0) {
+			pr_err("failed to add dmesg in minidump: err: %d\n", ret);
+			return ret;
+		}
+	}
+
+	if (cxt->console_size) {
+		prz = cxt->cprz;
+		strlcpy(pstore_entry.name, "KCONSOLE", sizeof(pstore_entry.name));
+		pstore_entry.virt_addr = prz->vaddr;
+		pstore_entry.phys_addr = prz->paddr;
+		pstore_entry.size = prz->size;
+		ret = qcom_minidump_region_register(&pstore_entry);
+		if (ret < 0) {
+			pr_err("failed to add console in minidump: err: %d\n", ret);
+			return ret;
+		}
+	}
+
+	for (i = 0; i < cxt->max_ftrace_cnt; i++) {
+		prz = cxt->fprzs[i];
+		scnprintf(pstore_entry.name, sizeof(pstore_entry.name),
+					"KFTRACE%d", i);
+		pstore_entry.virt_addr = prz->vaddr;
+		pstore_entry.phys_addr = prz->paddr;
+		pstore_entry.size = prz->size;
+		ret = qcom_minidump_region_register(&pstore_entry);
+		if (ret < 0) {
+			pr_err("failed to add ftrace in minidump: err: %d\n", ret);
+			return ret;
+		}
+	}
+
+	if (cxt->pmsg_size) {
+		prz = cxt->mprz;
+		strlcpy(pstore_entry.name, "KPMSG", sizeof(pstore_entry.name));
+		pstore_entry.virt_addr = prz->vaddr;
+		pstore_entry.phys_addr = prz->paddr;
+		pstore_entry.size = prz->size;
+		ret = qcom_minidump_region_register(&pstore_entry);
+		if (ret < 0) {
+			pr_err("failed to add pmsg in minidump: err: %d\n", ret);
+			return ret;
+		}
+	}
+
+	return ret;
+}
+#else
+static int ramoops_qcom_minidump_register(struct ramoops_context *cxt) { return 0; }
+#endif
+
 static int ramoops_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -724,6 +793,10 @@ static int ramoops_probe(struct platform_device *pdev)
 	phys_addr_t paddr;
 	int err = -EINVAL;
 
+	err = qcom_minidump_ready();
+	if (err && err != -ENODEV)
+		return -EPROBE_DEFER;
+
 	/*
 	 * Only a single ramoops area allowed at a time, so fail extra
 	 * probes.
@@ -841,6 +914,10 @@ static int ramoops_probe(struct platform_device *pdev)
 		}
 	}
 
+	err = ramoops_qcom_minidump_register(cxt);
+	if (err < 0)
+		goto fail_buf;
+
 	err = pstore_register(&cxt->pstore);
 	if (err) {
 		pr_err("registering with pstore failed\n");
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ