From: Krzysztof Kozlowski <krzk@kernel.org>
To: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Cc: Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Eugen Hristev <eugen.hristev@linaro.org>,
Arnd Bergmann <arnd@arndb.de>, Dennis Zhou <dennis@kernel.org>,
Tejun Heo <tj@kernel.org>, Christoph Lameter <cl@gentwo.org>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Anna-Maria Behnsen <anna-maria@linutronix.de>,
Frederic Weisbecker <frederic@kernel.org>,
Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Kees Cook <kees@kernel.org>,
Brendan Jackman <jackmanb@google.com>,
Johannes Weiner <hannes@cmpxchg.org>, Zi Yan <ziy@nvidia.com>,
Chris Li <chrisl@kernel.org>, Kairui Song <kasong@tencent.com>,
Kemeng Shi <shikemeng@huaweicloud.com>,
Nhat Pham <nphamcs@gmail.com>, Baoquan He <bhe@redhat.com>,
Barry Song <baohua@kernel.org>,
Youngjun Park <youngjun.park@lge.com>,
Petr Mladek <pmladek@suse.com>,
John Ogness <john.ogness@linutronix.de>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Bjorn Andersson <andersson@kernel.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Saravana Kannan <saravanak@kernel.org>,
workflows@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
linux-mm@kvack.org, linux-arm-msm@vger.kernel.org,
linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 25/25] meminspect: Add debug kinfo compatible driver
Date: Wed, 11 Mar 2026 10:09:19 +0100 [thread overview]
Message-ID: <20260311-poetic-transparent-barracuda-b7a3ab@quoll> (raw)
In-Reply-To: <20260311-minidump-v2-v2-25-f91cedc6f99e@oss.qualcomm.com>
On Wed, Mar 11, 2026 at 01:46:09AM +0530, Mukesh Ojha wrote:
> From: Eugen Hristev <eugen.hristev@linaro.org>
>
> With this driver, the registered regions are copied to a shared memory
> zone at register time. The shared memory zone is supplied via OF. This
> driver will select only regions that are of interest, and keep only
> addresses. The format of the list is Kinfo compatible, with devices like
> Google Pixel phone. The firmware is only interested in some symbols'
> addresses.
>
> Signed-off-by: Eugen Hristev <eugen.hristev@linaro.org>
> Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
> ---
> MAINTAINERS | 1 +
> drivers/of/platform.c | 1 +
> kernel/meminspect/Kconfig | 11 ++
> kernel/meminspect/Makefile | 1 +
> kernel/meminspect/kinfo.c | 284 +++++++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 298 insertions(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 2504b7df0e7d..48b5457fae98 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -16597,6 +16597,7 @@ M: Eugen Hristev <eugen.hristev@linaro.org>
> M: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
> S: Maintained
> F: Documentation/devicetree/bindings/reserved-memory/google,kinfo.yaml
> +F: kernel/meminspect/kinfo.c
>
> MEMBLOCK AND MEMORY MANAGEMENT INITIALIZATION
> M: Mike Rapoport <rppt@kernel.org>
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index 2a7111e8354d..09047e021de4 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -495,6 +495,7 @@ static const struct of_device_id reserved_mem_matches[] = {
> { .compatible = "ramoops" },
> { .compatible = "nvmem-rmem" },
> { .compatible = "google,open-dice" },
> + { .compatible = "google,debug-kinfo" },
place it before open-dice
> {}
> };
>
> diff --git a/kernel/meminspect/Kconfig b/kernel/meminspect/Kconfig
> index fa2b5a84b251..396510908e47 100644
> --- a/kernel/meminspect/Kconfig
> +++ b/kernel/meminspect/Kconfig
> @@ -17,3 +17,14 @@ config MEMINSPECT
>
> Note that modules using this feature must be rebuilt if option
> changes.
> +
> +config MEMINSPECT_KINFO
> + tristate "Shared memory KInfo compatible driver"
> + depends on MEMINSPECT
> + help
> + Say y here to enable the Shared memory KInfo compatible driver
> + With this driver, the registered regions are copied to a shared
> + memory zone at register time.
> + The shared memory zone is supplied via OF.
> + This driver will select only regions that are of interest,
> + and keep only addresses. The format of the list is Kinfo compatible.
> diff --git a/kernel/meminspect/Makefile b/kernel/meminspect/Makefile
> index 09fd55e6d9cf..283604d892e5 100644
> --- a/kernel/meminspect/Makefile
> +++ b/kernel/meminspect/Makefile
> @@ -1,3 +1,4 @@
> # SPDX-License-Identifier: GPL-2.0
>
> obj-$(CONFIG_MEMINSPECT) += meminspect.o
> +obj-$(CONFIG_MEMINSPECT_KINFO) += kinfo.o
> diff --git a/kernel/meminspect/kinfo.c b/kernel/meminspect/kinfo.c
> new file mode 100644
> index 000000000000..79918908968d
> --- /dev/null
> +++ b/kernel/meminspect/kinfo.c
> @@ -0,0 +1,284 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + *
> + * Copyright 2002 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation
> + * Copyright 2021 Google LLC
> + * Copyright 2025 Linaro Ltd. Eugen Hristev <eugen.hristev@linaro.org>
> + */
> +#include <linux/container_of.h>
> +#include <linux/kallsyms.h>
> +#include <linux/meminspect.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_reserved_mem.h>
> +#include <linux/platform_device.h>
> +#include <linux/utsname.h>
> +
> +#define BUILD_INFO_LEN 256
> +#define DEBUG_KINFO_MAGIC 0xcceeddff
> +
> +/*
> + * Header structure must be byte-packed, since the table is provided to
> + * bootloader.
> + */
> +struct kernel_info {
> + /* For kallsyms */
> + u8 enabled_all;
> + u8 enabled_base_relative;
> + u8 enabled_absolute_percpu;
> + u8 enabled_cfi_clang;
> + u32 num_syms;
> + u16 name_len;
> + u16 bit_per_long;
> + u16 module_name_len;
> + u16 symbol_len;
> + u64 _relative_pa;
> + u64 _text_pa;
> + u64 _stext_pa;
> + u64 _etext_pa;
> + u64 _sinittext_pa;
> + u64 _einittext_pa;
> + u64 _end_pa;
> + u64 _offsets_pa;
> + u64 _names_pa;
> + u64 _token_table_pa;
> + u64 _token_index_pa;
> + u64 _markers_pa;
> + u64 _seqs_of_names_pa;
> +
> + /* For frame pointer */
> + u32 thread_size;
> +
> + /* For virt_to_phys */
> + u64 swapper_pg_dir_pa;
> +
> + /* For linux banner */
> + u8 last_uts_release[__NEW_UTS_LEN];
> +
> + /* Info of running build */
> + u8 build_info[BUILD_INFO_LEN];
> +
> + /* For module kallsyms */
> + u32 enabled_modules_tree_lookup;
> + u32 mod_mem_offset;
> + u32 mod_kallsyms_offset;
> +} __packed;
> +
> +struct kernel_all_info {
> + u32 magic_number;
> + u32 combined_checksum;
> + struct kernel_info info;
> +} __packed;
> +
> +struct debug_kinfo {
> + struct device *dev;
> + void *all_info_addr;
> + size_t all_info_size;
> + struct notifier_block nb;
> +};
> +
> +static void update_kernel_all_info(struct kernel_all_info *all_info)
> +{
> + struct kernel_info *info;
> + u32 *checksum_info;
> + int index;
> +
> + all_info->magic_number = DEBUG_KINFO_MAGIC;
> + all_info->combined_checksum = 0;
> +
> + info = &all_info->info;
> + checksum_info = (u32 *)info;
> + for (index = 0; index < sizeof(*info) / sizeof(u32); index++)
> + all_info->combined_checksum ^= checksum_info[index];
> +}
> +
> +static u8 global_build_info[BUILD_INFO_LEN];
Don't create singletons. That's a driver so you can have multiple
instances of it.
> +
> +static int build_info_set(const char *str, const struct kernel_param *kp)
> +{
> + size_t build_info_size = sizeof(global_build_info);
> +
> + if (strlen(str) > build_info_size)
> + return -ENOMEM;
> + memcpy(global_build_info, str, min(build_info_size - 1, strlen(str)));
> + return 0;
> +}
> +
> +static const struct kernel_param_ops build_info_op = {
> + .set = build_info_set,
> +};
> +
> +module_param_cb(build_info, &build_info_op, NULL, 0200);
> +MODULE_PARM_DESC(build_info, "Write build info to field 'build_info' of debug kinfo.");
Drop. Build info is a static, fixed information, there is no need to write it
from user-space.
...
> + memset(all_info, 0, sizeof(struct kernel_all_info));
> + info = &all_info->info;
> + info->enabled_all = IS_ENABLED(CONFIG_KALLSYMS_ALL);
> + info->enabled_absolute_percpu = IS_ENABLED(CONFIG_KALLSYMS_ABSOLUTE_PERCPU);
> + info->enabled_base_relative = IS_ENABLED(CONFIG_KALLSYMS_BASE_RELATIVE);
> + info->enabled_cfi_clang = IS_ENABLED(CONFIG_CFI_CLANG);
> + info->name_len = KSYM_NAME_LEN;
> + info->bit_per_long = BITS_PER_LONG;
> + info->module_name_len = MODULE_NAME_LEN;
> + info->symbol_len = KSYM_SYMBOL_LEN;
> + info->thread_size = THREAD_SIZE;
> + info->enabled_modules_tree_lookup = IS_ENABLED(CONFIG_MODULES_TREE_LOOKUP);
> + info->mod_mem_offset = offsetof(struct module, mem);
> + info->mod_kallsyms_offset = offsetof(struct module, kallsyms);
> +
> + memcpy(info->build_info, global_build_info, strlen(global_build_info));
> +
> + kinfo->nb.notifier_call = kinfo_notifier_cb;
> +
> + meminspect_notifier_register(&kinfo->nb);
> + meminspect_lock_traverse(kinfo, register_kinfo_region);
> +
> + return 0;
> +}
> +
> +static void debug_kinfo_remove(struct platform_device *pdev)
> +{
> + struct debug_kinfo *kinfo = platform_get_drvdata(pdev);
> +
> + meminspect_notifier_unregister(&kinfo->nb);
> +}
> +
> +static const struct of_device_id debug_kinfo_of_match[] = {
> + { .compatible = "google,debug-kinfo" },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, debug_kinfo_of_match);
> +
> +static struct platform_driver debug_kinfo_driver = {
> + .probe = debug_kinfo_probe,
> + .remove = debug_kinfo_remove,
> + .driver = {
> + .name = "debug-kinfo",
> + .of_match_table = of_match_ptr(debug_kinfo_of_match),
Drop of_match_ptr, you have warning here.
> + },
> +};
> +module_platform_driver(debug_kinfo_driver);
> +
> +MODULE_AUTHOR("Eugen Hristev <eugen.hristev@linaro.org>");
> +MODULE_AUTHOR("Jone Chou <jonechou@google.com>");
> +MODULE_DESCRIPTION("meminspect Kinfo Driver");
> +MODULE_LICENSE("GPL");
>
> --
> 2.50.1
>
next prev parent reply other threads:[~2026-03-11 9:09 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 20:15 [PATCH v2 00/25] Introduce meminspect Mukesh Ojha
2026-03-10 20:15 ` [PATCH v2 01/25] kernel: " Mukesh Ojha
2026-03-12 4:33 ` Randy Dunlap
2026-03-12 4:46 ` Randy Dunlap
2026-03-16 8:31 ` Mukesh Ojha
2026-03-10 20:15 ` [PATCH v2 02/25] init/version: Annotate static information into meminspect Mukesh Ojha
2026-03-10 20:15 ` [PATCH v2 03/25] mm/percpu: " Mukesh Ojha
2026-03-10 20:15 ` [PATCH v2 04/25] cpu: " Mukesh Ojha
2026-03-10 20:15 ` [PATCH v2 05/25] genirq/irqdesc: " Mukesh Ojha
2026-03-10 20:15 ` [PATCH v2 06/25] timers: " Mukesh Ojha
2026-03-10 20:15 ` [PATCH v2 07/25] kernel/fork: " Mukesh Ojha
2026-03-10 20:15 ` [PATCH v2 08/25] mm/page_alloc: " Mukesh Ojha
2026-03-10 20:15 ` [PATCH v2 09/25] mm/show_mem: " Mukesh Ojha
2026-03-10 20:15 ` [PATCH v2 10/25] mm/swapfile: " Mukesh Ojha
2026-03-10 20:15 ` [PATCH v2 11/25] kernel/vmcore_info: Register dynamic " Mukesh Ojha
2026-03-10 20:15 ` [PATCH v2 12/25] kernel/configs: " Mukesh Ojha
2026-03-10 20:15 ` [PATCH v2 13/25] mm/init-mm: Annotate static " Mukesh Ojha
2026-03-10 20:15 ` [PATCH v2 14/25] panic: " Mukesh Ojha
2026-03-10 20:15 ` [PATCH v2 15/25] kallsyms: " Mukesh Ojha
2026-03-10 20:16 ` [PATCH v2 16/25] mm/mm_init: " Mukesh Ojha
2026-03-10 20:16 ` [PATCH v2 17/25] sched/core: Annotate runqueues " Mukesh Ojha
2026-03-10 20:16 ` [PATCH v2 18/25] mm/numa: Register node data information " Mukesh Ojha
2026-03-10 20:16 ` [PATCH v2 19/25] mm/sparse: Register " Mukesh Ojha
2026-03-10 20:16 ` [PATCH v2 20/25] printk: " Mukesh Ojha
2026-03-16 9:39 ` John Ogness
2026-03-16 10:24 ` Eugen Hristev
2026-03-10 20:16 ` [PATCH v2 21/25] remoteproc: qcom: Move minidump data structures into its own header Mukesh Ojha
2026-03-10 20:16 ` [PATCH v2 22/25] soc: qcom: Add minidump backend driver Mukesh Ojha
2026-03-10 20:16 ` [PATCH v2 23/25] soc: qcom: smem: Add minidump platform device Mukesh Ojha
2026-03-10 20:16 ` [PATCH v2 24/25] dt-bindings: reserved-memory: Add Google Kinfo Pixel reserved memory Mukesh Ojha
2026-03-11 9:05 ` Krzysztof Kozlowski
2026-03-16 11:12 ` Mukesh Ojha
2026-03-10 20:16 ` [PATCH v2 25/25] meminspect: Add debug kinfo compatible driver Mukesh Ojha
2026-03-11 9:09 ` Krzysztof Kozlowski [this message]
2026-03-11 22:07 ` Randy Dunlap
2026-03-16 2:24 ` [PATCH v2 00/25] Introduce meminspect Bjorn Andersson
2026-03-16 18:16 ` Mukesh Ojha
2026-03-19 2:55 ` Bjorn Andersson
2026-03-19 7:33 ` Eugen Hristev
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=20260311-poetic-transparent-barracuda-b7a3ab@quoll \
--to=krzk@kernel.org \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=andersson@kernel.org \
--cc=anna-maria@linutronix.de \
--cc=arnd@arndb.de \
--cc=baohua@kernel.org \
--cc=bhe@redhat.com \
--cc=bsegall@google.com \
--cc=chrisl@kernel.org \
--cc=cl@gentwo.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=david@kernel.org \
--cc=dennis@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=eugen.hristev@linaro.org \
--cc=frederic@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=john.ogness@linutronix.de \
--cc=juri.lelli@redhat.com \
--cc=kasong@tencent.com \
--cc=kees@kernel.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=mukesh.ojha@oss.qualcomm.com \
--cc=nphamcs@gmail.com \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=robh@kernel.org \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=saravanak@kernel.org \
--cc=senozhatsky@chromium.org \
--cc=shikemeng@huaweicloud.com \
--cc=skhan@linuxfoundation.org \
--cc=surenb@google.com \
--cc=tglx@kernel.org \
--cc=tj@kernel.org \
--cc=vbabka@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=workflows@vger.kernel.org \
--cc=youngjun.park@lge.com \
--cc=ziy@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox