From nobody Mon Oct 6 04:56:06 2025 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2C182DE1ED for ; Thu, 24 Jul 2025 13:56:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365386; cv=none; b=UeYlSL2ToCjgZ0TTw7akhho69elY41ZezpFS/qqIeHxl7oridav4pBs9bMNGjcgO+dCI09jSe4U7dC68aPGKkayT49w5QgKupaMVFdxULfD+DxIPWnSNigwxaZLDQDSZeIFwWb9iySjoWaL1wuppr2ppBPObyaTKzBf7Sjfvgio= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365386; c=relaxed/simple; bh=pR8R1VGCZlGNtznMO1/mkl55J+MjIdrJJJqQz17xvb4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ecs/TkziNdu/4WXHl6P6CapA34eVNpX7Mvw0tSB53uB5ILZcGNJ3kP7lMLULQYVRTnpqCwwYgu744T/75awolYuji09zbtOIthpB6IxZBabqWt3D20e3TPeocQg8x+6os2sMQgwrOFnfe/3dLc5GHGCD7q0xNaiHHdcl+63mU4M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=AbnWXcrm; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AbnWXcrm" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3a6e8b1fa37so850178f8f.2 for ; Thu, 24 Jul 2025 06:56:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365381; x=1753970181; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GN2zEFDyKGDBFhODZpN5vP0Lq5DSvoJDRdz0YaUUvGk=; b=AbnWXcrmkrGSJqGTnB8bNlVUsCpEuhREjWU5eIx5jI7WqwLiIBWWA8BZznvQ8Fg3CI pMKR42Zd7zindJ3bgpxZEux7cx6C1TEbAx26vMFWTfP4bYCu43Xh4deh/WTJIW7KpcXA 8BWkXZ54F4uqfKjwiNVKYNMFGxCcFH0+3tO86D8ONQrwM9kZgN8bYZWYAjm/Z5HeDg+T 83IS/mOP0/khcLFylAOUxldt6mRS73O1WIdpEzYuQPazjccG+XZjuvsrN4tocDWLrkJR D8/wIJNF6Eym+tJH7N2/b3UyE73AZy6mKKan9VvaDOYeEY61JxyDd+2hBKsXY2T3ZymW HArA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365381; x=1753970181; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GN2zEFDyKGDBFhODZpN5vP0Lq5DSvoJDRdz0YaUUvGk=; b=vtYRsMnCrEczlKV9rIVvSGBQMylYQD+YaeIweX6jffTyKGJgeSlNMlskUme8v2YHAr X9YpAxETc3xShMCTCv901D7RH3NZPan2GNnD6DUka+zzmNmhOeqUICag4qqTBkBhPkRW TbLgCt7YiUqiEBAKY8zvod7LOz0frsUpXKrlwD1CkBlCHVexHK0taZQX0bk8S3sMsUDM aF1Gv8PdMagBMF4Om3rDhiry+Z276eZeQLJx9xhQFt9QGBv/WuToXwV5VcJygF4cmZtI qO9rcLtPVNCyV0ry0ZNeGBy3BHkhIJYvoCGtOikb48KPqDDNUipIkOo50UVXbrniBicv /09w== X-Gm-Message-State: AOJu0YxV3VNe7KCz478g1CMk5kNVZAp3iyxVNdSl0VnZva0iDyRJtXnP n9QF5CcJ1/2UO/i/NtPP0tidItGcfaNdWSh8C0SnQLD0Jct8qN705VpWp22hgMcEPp5bpVx3xnJ 7Bk4mb0k= X-Gm-Gg: ASbGncuTQxzkb3NReY/x+j/ZD46u9A1r7yhzaAa/myeXTvajn1tnodM/dFYrMOAKAeS +4oKxe8TXm/X9lh8/8q244CdmfUK9MUDFRj58ehA74HXeO7565PSPdzJyq8SmcgG+klvQVWlRgG Z0EPNH4qpG7oGBt5GH/3uO/BGrUac6C3AIrkTDyzzG5tnkwcICJ1daC1+YvfYum419a0YLE3Tg1 4etyFcVLKfKgJ7q8Bk8FswPl9b3r6FP6vUfSQxyTQYSnhLZFKwLTHBk3klQBV1XPDqvUPJ2GB0s omR2OWk5w9i573XVmOwrhxelJ4EF2ishxtTUl7N1KbI8T6zG5HkRTDzDlm33U3nSfQdzcUTHHKd SxX3ZKdx5o+544r15e2RZmaM/+fapXU/Xdm6kr0+g1bX5VXZWOHK5F4ScQgigrCyFosqGI53juV QBPz9mWzVQileKogaY/6beO74= X-Google-Smtp-Source: AGHT+IHTmHRuZDTBifWGKFIc3eVCp5M+8i6pzB5UkemP/rWgYq+QJTPTzxAD1akVwZJswOYtPp8y1A== X-Received: by 2002:a05:6000:144c:b0:3b5:dc2a:ee74 with SMTP id ffacd0b85a97d-3b768eb427amr6529079f8f.24.1753365381251; Thu, 24 Jul 2025 06:56:21 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:20 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 01/29] kmemdump: introduce kmemdump Date: Thu, 24 Jul 2025 16:54:44 +0300 Message-ID: <20250724135512.518487-2-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Kmemdump mechanism allows any driver to mark a specific memory area for later dumping purpose, depending on the functionality of the attached backend. The backend would interface any hardware mechanism that will allow dumping to complete regardless of the state of the kernel (running, frozen, crashed, or any particular state). Signed-off-by: Eugen Hristev --- MAINTAINERS | 6 + drivers/Kconfig | 4 + drivers/Makefile | 2 + drivers/debug/Kconfig | 16 +++ drivers/debug/Makefile | 3 + drivers/debug/kmemdump.c | 214 ++++++++++++++++++++++++++++++ include/asm-generic/vmlinux.lds.h | 13 ++ include/linux/kmemdump.h | 135 +++++++++++++++++++ 8 files changed, 393 insertions(+) create mode 100644 drivers/debug/Kconfig create mode 100644 drivers/debug/Makefile create mode 100644 drivers/debug/kmemdump.c create mode 100644 include/linux/kmemdump.h diff --git a/MAINTAINERS b/MAINTAINERS index 70d1a0a62a8e..7e8da575025c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13617,6 +13617,12 @@ L: linux-iio@vger.kernel.org S: Supported F: drivers/iio/accel/kionix-kx022a* =20 +KMEMDUMP +M: Eugen Hristev +S: Maintained +F: drivers/debug/kmemdump.c +F: include/linux/kmemdump.h + KMEMLEAK M: Catalin Marinas S: Maintained diff --git a/drivers/Kconfig b/drivers/Kconfig index e0777f5ed543..412ef182d5c2 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -245,4 +245,8 @@ source "drivers/hte/Kconfig" =20 source "drivers/cdx/Kconfig" =20 +source "drivers/dpll/Kconfig" + +source "drivers/debug/Kconfig" + endmenu diff --git a/drivers/Makefile b/drivers/Makefile index b5749cf67044..e4cc23f4aba2 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -196,3 +196,5 @@ obj-$(CONFIG_CDX_BUS) +=3D cdx/ obj-$(CONFIG_DPLL) +=3D dpll/ =20 obj-$(CONFIG_S390) +=3D s390/ + +obj-y +=3D debug/ diff --git a/drivers/debug/Kconfig b/drivers/debug/Kconfig new file mode 100644 index 000000000000..b86585c5d621 --- /dev/null +++ b/drivers/debug/Kconfig @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0 +menu "Generic Debug Options" + +config KMEMDUMP + bool "Allow the kernel to register memory regions for dumping purpose" + help + Kmemdump mechanism allows any driver to register a specific memory + area for later dumping purpose, depending on the functionality + of the attached backend. The backend would interface any hardware + mechanism that will allow dumping to happen regardless of the + state of the kernel (running, frozen, crashed, or any particular + state). + + Note that modules using this feature must be rebuilt if option + changes. +endmenu diff --git a/drivers/debug/Makefile b/drivers/debug/Makefile new file mode 100644 index 000000000000..8ed6ec2d8a0d --- /dev/null +++ b/drivers/debug/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_KMEMDUMP) +=3D kmemdump.o diff --git a/drivers/debug/kmemdump.c b/drivers/debug/kmemdump.c new file mode 100644 index 000000000000..b6d418aafbef --- /dev/null +++ b/drivers/debug/kmemdump.c @@ -0,0 +1,214 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include + +#define MAX_ZONES 201 + +static int default_register_region(const struct kmemdump_backend *be, + enum kmemdump_uid id, void *area, size_t sz) +{ + return 0; +} + +static int default_unregister_region(const struct kmemdump_backend *be, + enum kmemdump_uid id) +{ + return 0; +} + +static const struct kmemdump_backend kmemdump_default_backend =3D { + .name =3D "default", + .register_region =3D default_register_region, + .unregister_region =3D default_unregister_region, +}; + +static const struct kmemdump_backend *backend =3D &kmemdump_default_backen= d; +static DEFINE_MUTEX(kmemdump_lock); +static struct kmemdump_zone kmemdump_zones[MAX_ZONES]; + +static int __init init_kmemdump(void) +{ + const struct kmemdump_zone *e; + + /* Walk the kmemdump section for static variables and register them */ + for_each_kmemdump_entry(e) + kmemdump_register_id(e->id, e->zone, e->size); + + return 0; +} +late_initcall(init_kmemdump); + +/** + * kmemdump_register_id() - Register region into kmemdump with given ID. + * @req_id: Requested unique kmemdump_uid that identifies the region + * This can be KMEMDUMP_ID_NO_ID, in which case the function will + * find an unused ID and return it. + * @zone: pointer to the zone of memory + * @size: region size + * + * Return: On success, it returns the unique id for the region. + * On failure, it returns negative error value. + */ +int kmemdump_register_id(enum kmemdump_uid req_id, void *zone, size_t size) +{ + struct kmemdump_zone *z; + enum kmemdump_uid uid =3D req_id; + int ret; + + if (uid < KMEMDUMP_ID_START) + return -EINVAL; + + if (uid >=3D MAX_ZONES) + return -ENOSPC; + + mutex_lock(&kmemdump_lock); + + if (uid =3D=3D KMEMDUMP_ID_NO_ID) + while (uid < MAX_ZONES) { + if (!kmemdump_zones[uid].id) + break; + uid++; + } + + if (uid =3D=3D MAX_ZONES) { + mutex_unlock(&kmemdump_lock); + return -ENOSPC; + } + + z =3D &kmemdump_zones[uid]; + + if (z->id) { + mutex_unlock(&kmemdump_lock); + return -EALREADY; + } + + ret =3D backend->register_region(backend, uid, zone, size); + if (ret) { + mutex_unlock(&kmemdump_lock); + return ret; + } + + z->zone =3D zone; + z->size =3D size; + z->id =3D uid; + + mutex_unlock(&kmemdump_lock); + + return uid; +} +EXPORT_SYMBOL_GPL(kmemdump_register_id); + +/** + * kmemdump_unregister() - Unregister region from kmemdump. + * @id: unique id that was returned when this region was successfully + * registered initially. + * + * Return: None + */ +void kmemdump_unregister(enum kmemdump_uid id) +{ + struct kmemdump_zone *z =3D NULL; + + mutex_lock(&kmemdump_lock); + + z =3D &kmemdump_zones[id]; + if (!z->id) { + mutex_unlock(&kmemdump_lock); + return; + } + + backend->unregister_region(backend, z->id); + + memset(z, 0, sizeof(*z)); + + mutex_unlock(&kmemdump_lock); +} +EXPORT_SYMBOL_GPL(kmemdump_unregister); + +/** + * kmemdump_register_backend() - Register a backend into kmemdump. + * @be: Pointer to a driver allocated backend. This backend must have + * two callbacks for registering and deregistering a zone from the + * backend. + * + * Only one backend is supported at a time. + * + * Return: On success, it returns 0, negative error value otherwise. + */ +int kmemdump_register_backend(const struct kmemdump_backend *be) +{ + enum kmemdump_uid uid; + int ret; + + if (!be || !be->register_region || !be->unregister_region) + return -EINVAL; + + mutex_lock(&kmemdump_lock); + + /* Try to call the old backend for all existing regions */ + for (uid =3D KMEMDUMP_ID_START; uid < MAX_ZONES; uid++) + if (kmemdump_zones[uid].id) + backend->unregister_region(backend, + kmemdump_zones[uid].id); + + backend =3D be; + pr_debug("kmemdump backend %s registered successfully.\n", + backend->name); + + /* Call the new backend for all existing regions */ + for (uid =3D KMEMDUMP_ID_START; uid < MAX_ZONES; uid++) { + if (!kmemdump_zones[uid].id) + continue; + ret =3D backend->register_region(backend, + kmemdump_zones[uid].id, + kmemdump_zones[uid].zone, + kmemdump_zones[uid].size); + if (ret) + pr_debug("register region failed with %d\n", ret); + } + + mutex_unlock(&kmemdump_lock); + + return 0; +} +EXPORT_SYMBOL_GPL(kmemdump_register_backend); + +/** + * kmemdump_unregister_backend() - Unregister the backend from kmemdump. + * @be: Pointer to a driver allocated backend. This backend must match + * the initially registered backend. + * + * Only one backend is supported at a time. + * Before deregistering, this will call the backend to unregister all the + * previously registered zones. + * + * Return: None + */ +void kmemdump_unregister_backend(const struct kmemdump_backend *be) +{ + enum kmemdump_uid uid; + + mutex_lock(&kmemdump_lock); + + if (backend !=3D be) { + mutex_unlock(&kmemdump_lock); + return; + } + + /* Try to call the old backend for all existing regions */ + for (uid =3D KMEMDUMP_ID_START; uid < MAX_ZONES; uid++) + if (kmemdump_zones[uid].id) + backend->unregister_region(backend, + kmemdump_zones[uid].id); + + pr_debug("kmemdump backend %s removed successfully.\n", be->name); + + backend =3D &kmemdump_default_backend; + + mutex_unlock(&kmemdump_lock); +} +EXPORT_SYMBOL_GPL(kmemdump_unregister_backend); + diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index fa5f19b8d53a..433719442a5e 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -488,6 +488,8 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELL= ER_CLANG) FW_LOADER_BUILT_IN_DATA \ TRACEDATA \ \ + KMEMDUMP_TABLE \ + \ PRINTK_INDEX \ \ /* Kernel symbol table: Normal symbols */ \ @@ -891,6 +893,17 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPEL= LER_CLANG) #define TRACEDATA #endif =20 +#ifdef CONFIG_KMEMDUMP +#define KMEMDUMP_TABLE \ + . =3D ALIGN(8); \ + .kmemdump : AT(ADDR(.kmemdump) - LOAD_OFFSET) { \ + BOUNDED_SECTION_POST_LABEL(.kmemdump, __kmemdump_table, \ + , _end) \ + } +#else +#define KMEMDUMP_TABLE +#endif + #ifdef CONFIG_PRINTK_INDEX #define PRINTK_INDEX \ .printk_index : AT(ADDR(.printk_index) - LOAD_OFFSET) { \ diff --git a/include/linux/kmemdump.h b/include/linux/kmemdump.h new file mode 100644 index 000000000000..c3690423a347 --- /dev/null +++ b/include/linux/kmemdump.h @@ -0,0 +1,135 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _KMEMDUMP_H +#define _KMEMDUMP_H + +enum kmemdump_uid { + KMEMDUMP_ID_START =3D 0, + KMEMDUMP_ID_USER_START, + KMEMDUMP_ID_USER_END, + KMEMDUMP_ID_NO_ID, +}; + +#ifdef CONFIG_KMEMDUMP +/** + * struct kmemdump_zone - region mark zone information + * @id: unique id for this zone + * @zone: pointer to the memory area for this zone + * @size: size of the memory area of this zone + */ +struct kmemdump_zone { + enum kmemdump_uid id; + void *zone; + size_t size; +}; + +/* kmemdump section table markers*/ +extern const struct kmemdump_zone __kmemdump_table[]; +extern const struct kmemdump_zone __kmemdump_table_end[]; + +/* Annotate a variable into the given kmemdump UID */ +#define KMEMDUMP_VAR_ID(idx, sym, sz) \ + static const struct kmemdump_zone __UNIQUE_ID(__kmemdump_entry_##sym) \ + __used __section(".kmemdump") =3D { .id =3D idx, \ + .zone =3D (void *)&(sym), \ + .size =3D (sz), \ + } + +/* Iterate through kmemdump section entries */ +#define for_each_kmemdump_entry(__entry) \ + for (__entry =3D __kmemdump_table; \ + __entry < __kmemdump_table_end; \ + __entry++) + +#else +#define KMEMDUMP_VAR_ID(...) +#endif +/* + * Wrapper over an existing fn allocator + * It will : + * - unregister the memory already registered into kmemdump at the given U= ID + * - register the memory into kmemdump at the given UID + * - take an argument for the ID and the wanted size + */ +#define kmemdump_alloc_id_size_replace(id, sz, fn, ...) \ + ({ \ + void *__p =3D fn(__VA_ARGS__); \ + \ + if (__p) { \ + kmemdump_unregister(id); \ + kmemdump_register_id(id, __p, sz); \ + } \ + __p; \ + }) +/* + * Wrapper over an existing fn allocator + * It will : + * - fail if the given UID is already registered + * - register the memory into kmemdump at the given UID + * - take an argument for the ID and the wanted size + */ + +#define kmemdump_alloc_id_size(id, sz, fn, ...) \ + ({ \ + void *__p =3D fn(__VA_ARGS__); \ + \ + if (__p) \ + kmemdump_register_id(id, __p, sz); \ + __p; \ + }) + +#define kmemdump_alloc_size(...) \ + kmemdump_alloc_id_size(KMEMDUMP_ID_NO_ID, __VA_ARGS__) + +#define kmemdump_phys_alloc_id_size(id, sz, fn, ...) \ + ({ \ + phys_addr_t __p =3D fn(__VA_ARGS__); \ + \ + if (__p) \ + kmemdump_register_id(id, __va(__p), sz); \ + __p; \ + }) + +#define kmemdump_phys_alloc_size(...) \ + kmemdump_phys_alloc_id_size(KMEMDUMP_ID_NO_ID, __VA_ARGS__) + +#define kmemdump_free_id(id, fn, ...) \ + ({ \ + kmemdump_unregister(id); \ + fn(__VA_ARGS__); \ + }) + +#ifdef CONFIG_KMEMDUMP + +#define KMEMDUMP_BACKEND_MAX_NAME 128 +/** + * struct kmemdump_backend - region mark backend information + * @name: the name of the backend + * @register_region: callback to register region in the backend + * @unregister_region: callback to unregister region in the backend + */ +struct kmemdump_backend { + char name[KMEMDUMP_BACKEND_MAX_NAME]; + int (*register_region)(const struct kmemdump_backend *be, + enum kmemdump_uid uid, void *vaddr, size_t size); + int (*unregister_region)(const struct kmemdump_backend *be, + enum kmemdump_uid uid); +}; + +int kmemdump_register_backend(const struct kmemdump_backend *backend); +void kmemdump_unregister_backend(const struct kmemdump_backend *backend); + +int kmemdump_register_id(enum kmemdump_uid id, void *zone, size_t size); +void kmemdump_unregister(enum kmemdump_uid id); +#else +static inline int kmemdump_register_id(enum kmemdump_uid uid, void *area, + size_t size) +{ + return 0; +} + +static inline void kmemdump_unregister(enum kmemdump_uid id) +{ +} +#endif + +#endif --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B8E92DCBFC for ; Thu, 24 Jul 2025 13:56:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365387; cv=none; b=F9ytMckN+FRgDyLORjXIytf0qpvHwpxi+XbIP58vtdn1I5VFatCN8aULLB0UfuSvuzzEFlhOXeWMkqsa4nywHA2NYqG/ssTwDawm3OdKo5OevdBV0Xf1qJ6pR84wJqbn+Vmdd5tTs0ZDOZUYid/bJvKEVmRT4IWRUJHF8K41Og0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365387; c=relaxed/simple; bh=PINfP31Uv54+8D72YX70+7lUeVH3jRfFjtvMSeM9ulU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d+qEOzDNYTBtA9gQVCle09SQQUz3z+ZaejuvGFT00Agk4XhRzcx8W4tJjrZom83ZEI9FxPbwab7cZJk7yjeeR+jjMadDjJnqOYbM8ayKHaE6WcBwMs0KReL8QeRhz0LznBFcFM6vCpYoy2atHlYQ0jB8Ss/CeLZRGAEGW6E5ho8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Bp7O1/Q3; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Bp7O1/Q3" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-451d3f72391so10094475e9.3 for ; Thu, 24 Jul 2025 06:56:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365383; x=1753970183; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E5bTh+3Vvg3yCOBzS0gI9x4Skq8JpHTqDTkP6m6Co9I=; b=Bp7O1/Q3xvPEVICeaOTeyvLwuJmcqeC6zqp6qljZd4e8DpedmERDcwLOVnUVDnHqE2 vwsEWtJGw9MtgtqxByfudKP1LWy+zCilrblNqpWH0i4+J5r36qMVtI/vcPrI3OarHxaF aCZZabPT6gCXK7tdLIkqSttj30JiVCZ8lIxpO+5yd/PLXSYC0HfLNu0vSIVSq0bOm0La Li/7IyOC0ncduiJZ87UI5oh7+LJWRSbqzUmaADu8dJDSUGC2/VKq4gaHzE9R/LPm3p5E 722gEpNB4LzPNtfrzZ6W4+dthepbkpmdeMMUr02SzvjhIvjbZjX5U2wQKt0KfYJ3tnFz Grgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365383; x=1753970183; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E5bTh+3Vvg3yCOBzS0gI9x4Skq8JpHTqDTkP6m6Co9I=; b=rO69v5Jjx99zCiYyRHACJat1ZoSksTD5lYo8apjEYx+zs1U/XC9voFmruQZQO84t0n 0pAml0wG8zK3jIaanKPSv4QYVmgxYIjejNhE09t/I+mFo7NrS06Apdpo10Nn6vVtosR9 tuiY1cF4T/TflwhTK4dRuRHFuV+ANXC3FzBvMtwIpJIWhJT9DUr5w5vgJEkY3ewMzKIm XJDITXO2Goq1mUgVfiTwYIf0vZbqNjacZjQ2igB0bZd0pSTdKzgTYhnsBaKr8PJETqt8 bEJIuB7DjbWX4eBZAzIdphrYEKx9X30mluwsCpTNs861DUKcf9Rzv2o7y652G9wBW8wm S91g== X-Gm-Message-State: AOJu0Yz4WGp0gbDn+FE/RcoCc9wYR2Mx238HHs8uB6M3fQCWWs73yJID AZFAZUxB1/A86o0YPneOdbB2qSmQ5E6vn7Qwb6ncsVBP1MdGpLYDF40DZBMbr6p59DCMGEuifFz fEMQJHFo= X-Gm-Gg: ASbGncsUUCR6VC7xCsouwZmohxuNqBat5X3qLXCsfypy1VtMdCMTAH04BPyy/SPLzUK 2faAXcXXcgHEf9/FOriv50cKwb8oPcXx1cNuHsvEOGsKNrCDRRlmX9wS9lw4/c2nSmTN5ejfqzp SJwMqJbJomFF5oFq5vLYs6qCMTY1lL/1e2a55SUHugnaI30CAsAI2MdiCI+Gta7mKMvccyQuV/G dM+IAlhuPmGJJ9J/Cr3+cXIvbEztaTG1C5mcJlBTroVJWtFY8DOVJFOgzTGyLAFMMwKXxiZ6kbX Lvh/MI1Oy1OnEfl1rW0TH8oFAnzVNZQ+v8FunmWzhc3mCQgQ+ELqljCidx2tXwcMM9w1BRdHTvi QtqXt4Wv4PsrLV7rzjF2b56O6ynu7bguPLn3uRdSyz2BS521BjS5W0zyZtZCjxJmp+usjVcxYrj Bq9LaK14nKWA0j X-Google-Smtp-Source: AGHT+IEIzq0FBEBm3LdZcFOEY9/KwPes9i1IaDCT4onRneKKA+Xc4u6PgwWHdq2thr0dEpYstk90ZQ== X-Received: by 2002:a05:600c:4586:b0:450:d4a6:799d with SMTP id 5b1f17b1804b1-4586a8ce621mr55841895e9.7.1753365383404; Thu, 24 Jul 2025 06:56:23 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:23 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 02/29] Documentation: add kmemdump Date: Thu, 24 Jul 2025 16:54:45 +0300 Message-ID: <20250724135512.518487-3-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document the new kmemdump kernel feature. Signed-off-by: Eugen Hristev --- Documentation/debug/index.rst | 17 ++++++ Documentation/debug/kmemdump.rst | 98 ++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + 3 files changed, 116 insertions(+) create mode 100644 Documentation/debug/index.rst create mode 100644 Documentation/debug/kmemdump.rst diff --git a/Documentation/debug/index.rst b/Documentation/debug/index.rst new file mode 100644 index 000000000000..9a9365c62f02 --- /dev/null +++ b/Documentation/debug/index.rst @@ -0,0 +1,17 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=3D=3D=3D +kmemdump +=3D=3D=3D + +.. toctree:: + :maxdepth: 1 + + kmemdump + +.. only:: subproject and html + + Indices + =3D=3D=3D=3D=3D=3D=3D + + * :ref:`genindex` diff --git a/Documentation/debug/kmemdump.rst b/Documentation/debug/kmemdum= p.rst new file mode 100644 index 000000000000..3301abcaed7e --- /dev/null +++ b/Documentation/debug/kmemdump.rst @@ -0,0 +1,98 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D +kmemdump +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D + +This document provides information about the kmemdump feature. + +Overview +=3D=3D=3D=3D=3D=3D=3D=3D + +kmemdump is a mechanism that allows any driver or producer to register a +chunk of memory into kmemdump, to be used at a later time for a specific +purpose like debugging or memory dumping. + +kmemdump allows a backend to be connected, this backend interfaces a +specific hardware that can debug or dump the memory registered into +kmemdump. + +kmemdump Internals +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +API +---- + +A memory region is being registered with a call to `kmemdump_register` whi= ch +takes as parameters the ID of the region, a pointer to the virtual memory +start address and the size. If successful, this call returns an unique ID = for +the allocated zone (either the requested ID or an allocated ID). +IDs are predefined in the kmemdump header. A second registration with the +same ID is not allowed, the caller needs to deregister first. +A dedicated NO_ID is defined, which has kmemdump allocate a new unique ID +for the request and return it. This case is useful with multiple dynamic +loop allocations where ID is not significant. + +The region would be registered with a call to `kmemdump_unregister` which +takes the id as a parameter. + +For dynamically allocated memory, kmemdump defines a variety of wrappers +on top of allocation functions which are given as parameters. +This makes the dynamic allocation easy to use without additional calls +to registration functions. However kmemdump still exposes the register API +for cases where it may be needed (e.g. size is not exactly known at alloca= tion +time). + +For static variables, a variety of annotation macros are provided. These +macros will create an annotation struct inside a separate section. + + +Backend +------- + +Backend is represented by a `struct kmemdump_backend` which has to be fill= ed +in by the backend driver. Further, this struct is being passed to kmemdump +with a `backend_register` call. `backend_unregister` will remove the backe= nd +from kmemdump. + +Once a backend is being registered, all previously registered regions are +being sent to the backend for registration. + +When the backend is being removed, all regions are being first deregistered +from the backend. + +kmemdump will request the backend to register a region with `register_regi= on` +call, and deregister a region with `unregister_region` call. These two +functions are mandatory to be provided by a backend at registration time. + +Data structures +--------------- + +`struct kmemdump_backend` represents the kmemdump backend and it has two +function pointers, one called `register_region` and the other +`unregister_region`. +There is a default backend that does a no-op that is initially registered +and is registered back if the current working backend is being removed. + +The regions are being stored in a simple fixed size array. It avoids +memory allocation overhead. This is not performance critical nor does +allocating a few hundred entries create a memory consumption problem. + +The static variables registered into kmemdump are being annotated into +a dedicated `.kemdump` memory section. This is then walked by kmemdump +at a later time and each variable is registered. + +kmemdump Initialization +------------------ + +After system boots, kmemdump will be ready to accept region registration +from producer drivers. Even if the backend may not be registered yet, +there is a default no-op backend that is registered. At any time the backe= nd +can be changed with a real backend in which case all regions are being +registered to the new backend. + +backend functionality +----------------- + +kmemdump backend can keep it's own list of regions and use the specific +hardware available to dump the memory regions or use them for debugging. diff --git a/MAINTAINERS b/MAINTAINERS index 7e8da575025c..ef0ffdfaf3de 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13620,6 +13620,7 @@ F: drivers/iio/accel/kionix-kx022a* KMEMDUMP M: Eugen Hristev S: Maintained +F: Documentation/debug/kmemdump.rst F: drivers/debug/kmemdump.c F: include/linux/kmemdump.h =20 --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 512352E03EC for ; Thu, 24 Jul 2025 13:56:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365389; cv=none; b=CrXYcRiO5r11jTBdsoFu/o8JvqBHqPjy/qiycez7LjW0drCUXUYNVlRSxGTnqxtgRXDUCdDhY64LDmF23oaNI7Qw1eNLe1VFB71XiG5n4OzwFwLrkD3xhD7y3O8ic2u+W1Auy+tCWGKS4+8PF834MRBJx7EdjMNr5qPcIAbM9Vk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365389; c=relaxed/simple; bh=++DNfnXyQWdsETwYm6bgVDRBrywEMYhV87J4dW4JDIY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d0eiD1/mcB1Swv03Jt5sgdXVH93Eor2DI4OaHDZIRamvswqFJh2JHVs6aZu+DX341CSjlm1rEislL3R2Y96F1v/UuwvLsRLfwTwZWhZvM/Gv4wesuH04kBwcTtvC9hWFGX4irrBBRt8wrkOOCRA/xBQmNzWZh6+yGP6VOH3HIOs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=lblUVM3P; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="lblUVM3P" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-455fdfb5d04so5768955e9.2 for ; Thu, 24 Jul 2025 06:56:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365384; x=1753970184; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XG4UpkMMVRYtGXT6cuR8yNOWitjMYnN9sl4ER5EV3F0=; b=lblUVM3PxYfoa8+UR7+g7MngEyZ+MFxCyP7gS9jtyW93UvIp+IQdkUY63jbgGfDnCs +nSPrbY3qKwSW36QRm2/7FA5LwTVT6VkOxvSfry+NNfao9spwyo7rJA2OYSYyv316/J9 mMEthMZiK/KwyhZDaCKOeQfBcp7UfmoE/o0iVHAdKi+xSB3Ivy9ny2Ehim9Dzk+4/cVy py+BeenSIfLXiVK/mVjOxASqdJx8VFCsx064OoZaa2QWRrZKh/Bo/8Acbx7OONhR5VYY Jzr+MgWSIZsgLeIC/RrGFCpPO2r65onKoGtJVod6rfv30clTiGvqy4cgXfT/iedFCbz5 eF1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365384; x=1753970184; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XG4UpkMMVRYtGXT6cuR8yNOWitjMYnN9sl4ER5EV3F0=; b=TlN/51R3LGWsul1Cdngdavf7j9nzBwqe+DnGJvExcAJjZp30ZUYZCFzOt8D1uw4Knv 01mckbdIIJcI0CgcpJw+bLUc7dRPe2pB9ADrOrm94REABWrvQpCz6GYIZhU2mZ1o9KXi wGEZIjpKyolmVOuF+fQGQmF98/ZBLybkRHE8ZITfm0NssLqDHeDO8x5DDMKh2hRJM2+E htHch0IvDbkwVpr0TsfDaymPkTw/I+XUZQ+VmHGsLyuBReNv/XXQpuLXzPaWWRLv5fD2 T9sucMJAiq4D0ls8DdZ1Z8+bM/qYqWJAMXtdQdZLoUwOPwfu/V9sV/a+qMsoDdK022P7 9+pg== X-Gm-Message-State: AOJu0Yyf7ThzK27u/BtYaGBcTcSVo4ojqxJJOF+zE7rlhjewihs7UOno zlhexAHU614XEpsDGT+UYdDVATU6QE5ngTkU1s9ecwFfFvbV6v0nF/in/Zc+5SM8HWIuGDUoSNM HUh5oTaE= X-Gm-Gg: ASbGncswnRbBlQLWFmFRYTIUzg1aMvla42PKwpncaYaSaWRiiaAAfMXA5rg6v2oPo/u 9Dpl8okFh5mwZvhWFM+31g8LPZAi1a9oQwDSgM5AcU4r9ZeDxrnGdlJCp3jOB2gNch0ipuY83d2 rEvxcopuK1/x0neQ9DXUjA3BFmVFRGBYUlVDE1gWcnxDqqojzjlPkKu2tK2KMNQMV7RjQPmnegM cx7fOSoem/D/qF/qWzw+PZpvLbgzugkrsU0L8FFATNL22fv00qpNgwUaatVeH37s1bq+eJdp7pf +bKUOigHxMY9Lj7ruleY2dN+4x4GjYVeJn3ce9Gj9utO24cAD6MugAIZ/TascHt9RB5RYaoebCs TCK+n728Q42L7brf8mv2Tv8lxw3BAQgGDL+fwW8ShDasnct9Pssg75MjUflHwbctryVErb+OMEy Faz4rNmZkAVBrG X-Google-Smtp-Source: AGHT+IFk0XSSRo6IltEN054dyX/SHvso8FPYoVfVtJ49vV2Kf2bz+TLyXa3T3TxRoIm60B1Sl6dIGg== X-Received: by 2002:a05:600c:621b:b0:455:ed48:144f with SMTP id 5b1f17b1804b1-4586f218339mr27655495e9.14.1753365384388; Thu, 24 Jul 2025 06:56:24 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:24 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 03/29] kmemdump: add coreimage ELF layer Date: Thu, 24 Jul 2025 16:54:46 +0300 Message-ID: <20250724135512.518487-4-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Implement kmemdumping into an ELF coreimage. With this feature enabled, kmemdump will assemble all the regions into a coreimage, by having an initial first region with an ELF header, a second region with vmcoreinfo data, and then register vital kernel information in the subsequent regions. This image can then be dumped, assembled into a single file and loaded into debugging tools like crash/gdb. Signed-off-by: Eugen Hristev --- MAINTAINERS | 1 + drivers/debug/Kconfig | 14 ++ drivers/debug/Makefile | 1 + drivers/debug/kmemdump.c | 25 ++++ drivers/debug/kmemdump_coreimage.c | 223 +++++++++++++++++++++++++++++ include/linux/kmemdump.h | 70 ++++++++- 6 files changed, 333 insertions(+), 1 deletion(-) create mode 100644 drivers/debug/kmemdump_coreimage.c diff --git a/MAINTAINERS b/MAINTAINERS index ef0ffdfaf3de..b43a43b61e19 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13622,6 +13622,7 @@ M: Eugen Hristev S: Maintained F: Documentation/debug/kmemdump.rst F: drivers/debug/kmemdump.c +F: drivers/debug/kmemdump_coreimage.c F: include/linux/kmemdump.h =20 KMEMLEAK diff --git a/drivers/debug/Kconfig b/drivers/debug/Kconfig index b86585c5d621..903e3e2805b7 100644 --- a/drivers/debug/Kconfig +++ b/drivers/debug/Kconfig @@ -13,4 +13,18 @@ config KMEMDUMP =20 Note that modules using this feature must be rebuilt if option changes. + +config KMEMDUMP_COREIMAGE + depends on KMEMDUMP + select VMCORE_INFO + bool "Assemble memory regions into a coredump readable with debuggers" + help + Enabling this will assemble all the memory regions into a + core ELF file. The first region will include program headers for + all the regions. The second region is the vmcoreinfo and specific + coredump structures. + All the other regions follow. Specific kernel variables required + for debug tools are being registered. + The coredump file can then be loaded into GDB or crash tool and + further inspected. endmenu diff --git a/drivers/debug/Makefile b/drivers/debug/Makefile index 8ed6ec2d8a0d..2b67673393a6 100644 --- a/drivers/debug/Makefile +++ b/drivers/debug/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 =20 obj-$(CONFIG_KMEMDUMP) +=3D kmemdump.o +obj-$(CONFIG_KMEMDUMP_COREIMAGE) +=3D kmemdump_coreimage.o diff --git a/drivers/debug/kmemdump.c b/drivers/debug/kmemdump.c index b6d418aafbef..6dd49359d8ef 100644 --- a/drivers/debug/kmemdump.c +++ b/drivers/debug/kmemdump.c @@ -28,15 +28,34 @@ static const struct kmemdump_backend kmemdump_default_b= ackend =3D { static const struct kmemdump_backend *backend =3D &kmemdump_default_backen= d; static DEFINE_MUTEX(kmemdump_lock); static struct kmemdump_zone kmemdump_zones[MAX_ZONES]; +static bool kmemdump_initialized; =20 static int __init init_kmemdump(void) { const struct kmemdump_zone *e; + enum kmemdump_uid uid; + + init_elfheader(); =20 /* Walk the kmemdump section for static variables and register them */ for_each_kmemdump_entry(e) kmemdump_register_id(e->id, e->zone, e->size); =20 + mutex_lock(&kmemdump_lock); + /* + * Some regions may have been registered very early. + * Update the elf header for all existing regions, + * except for KMEMDUMP_ID_COREIMAGE_ELF and + * KMEMDUMP_ID_COREIMAGE_VMCOREINFO, those are included in the + * ELF header upon its creation. + */ + for (uid =3D KMEMDUMP_ID_COREIMAGE_CONFIG; uid < MAX_ZONES; uid++) + if (kmemdump_zones[uid].id) + update_elfheader(&kmemdump_zones[uid]); + + kmemdump_initialized =3D true; + mutex_unlock(&kmemdump_lock); + return 0; } late_initcall(init_kmemdump); @@ -95,6 +114,9 @@ int kmemdump_register_id(enum kmemdump_uid req_id, void = *zone, size_t size) z->size =3D size; z->id =3D uid; =20 + if (kmemdump_initialized) + update_elfheader(z); + mutex_unlock(&kmemdump_lock); =20 return uid; @@ -122,6 +144,9 @@ void kmemdump_unregister(enum kmemdump_uid id) =20 backend->unregister_region(backend, z->id); =20 + if (kmemdump_initialized) + clear_elfheader(z); + memset(z, 0, sizeof(*z)); =20 mutex_unlock(&kmemdump_lock); diff --git a/drivers/debug/kmemdump_coreimage.c b/drivers/debug/kmemdump_co= reimage.c new file mode 100644 index 000000000000..2cdab22d0c5c --- /dev/null +++ b/drivers/debug/kmemdump_coreimage.c @@ -0,0 +1,223 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include + +#define CORE_STR "CORE" + +#define MAX_NUM_ENTRIES 201 + +static struct elfhdr *ehdr; +static size_t elf_offset; + +static void append_kcore_note(char *notes, size_t *i, const char *name, + unsigned int type, const void *desc, + size_t descsz) +{ + struct elf_note *note =3D (struct elf_note *)¬es[*i]; + + note->n_namesz =3D strlen(name) + 1; + note->n_descsz =3D descsz; + note->n_type =3D type; + *i +=3D sizeof(*note); + memcpy(¬es[*i], name, note->n_namesz); + *i =3D ALIGN(*i + note->n_namesz, 4); + memcpy(¬es[*i], desc, descsz); + *i =3D ALIGN(*i + descsz, 4); +} + +static void append_kcore_note_nodesc(char *notes, size_t *i, const char *n= ame, + unsigned int type, size_t descsz) +{ + struct elf_note *note =3D (struct elf_note *)¬es[*i]; + + note->n_namesz =3D strlen(name) + 1; + note->n_descsz =3D descsz; + note->n_type =3D type; + *i +=3D sizeof(*note); + memcpy(¬es[*i], name, note->n_namesz); + *i =3D ALIGN(*i + note->n_namesz, 4); +} + +static struct elf_phdr *elf_phdr_entry_addr(struct elfhdr *ehdr, int idx) +{ + struct elf_phdr *ephdr =3D (struct elf_phdr *)((size_t)ehdr + ehdr->e_pho= ff); + + return &ephdr[idx]; +} + +/** + * clear_elfheader() - Remove the program header for a specific memory zone + * @z: pointer to the kmemdump zone + * + * Return: On success, it returns 0, errno otherwise + */ +int clear_elfheader(const struct kmemdump_zone *z) +{ + struct elf_phdr *phdr; + struct elf_phdr *tmp_phdr; + unsigned int phidx; + unsigned int i; + + for (i =3D 0; i < ehdr->e_phnum; i++) { + phdr =3D elf_phdr_entry_addr(ehdr, i); + if (phdr->p_paddr =3D=3D virt_to_phys(z->zone) && + phdr->p_memsz =3D=3D ALIGN(z->size, 4)) + break; + } + + if (i =3D=3D ehdr->e_phnum) { + pr_debug("Cannot find program header entry in elf\n"); + return -EINVAL; + } + + phidx =3D i; + + /* Clear program header */ + tmp_phdr =3D elf_phdr_entry_addr(ehdr, phidx); + for (i =3D phidx; i < ehdr->e_phnum - 1; i++) { + tmp_phdr =3D elf_phdr_entry_addr(ehdr, i + 1); + phdr =3D elf_phdr_entry_addr(ehdr, i); + memcpy(phdr, tmp_phdr, sizeof(*phdr)); + phdr->p_offset =3D phdr->p_offset - ALIGN(z->size, 4); + } + memset(tmp_phdr, 0, sizeof(*tmp_phdr)); + ehdr->e_phnum--; + + elf_offset -=3D ALIGN(z->size, 4); + + return 0; +} + +/** + * update_elfheader() - Add the program header for a specific memory zone + * @z: pointer to the kmemdump zone + * + * Return: None + */ +void update_elfheader(const struct kmemdump_zone *z) +{ + struct elf_phdr *phdr; + + phdr =3D elf_phdr_entry_addr(ehdr, ehdr->e_phnum++); + + phdr->p_type =3D PT_LOAD; + phdr->p_offset =3D elf_offset; + phdr->p_vaddr =3D (elf_addr_t)z->zone; + phdr->p_paddr =3D (elf_addr_t)virt_to_phys(z->zone); + phdr->p_filesz =3D phdr->p_memsz =3D ALIGN(z->size, 4); + phdr->p_flags =3D PF_R | PF_W; + + elf_offset +=3D ALIGN(z->size, 4); +} + +/** + * init_elfheader() - Prepare coreinfo elf header + * This function prepares the elf header for the coredump image. + * Initially there is a single program header for the elf NOTE. + * The note contains the usual core dump information, and the + * vmcoreinfo. + * + * Return: 0 on success, errno otherwise + */ +int init_elfheader(void) +{ + struct elf_phdr *phdr; + void *notes; + unsigned int elfh_size; + unsigned int phdr_off; + size_t note_len, i =3D 0; + + struct elf_prstatus prstatus =3D {}; + struct elf_prpsinfo prpsinfo =3D { + .pr_sname =3D 'R', + .pr_fname =3D "vmlinux", + }; + + /* + * Header buffer contains: + * ELF header, Note entry with PR status, PR ps info, and vmcoreinfo + * MAX_NUM_ENTRIES Program headers, + */ + elfh_size =3D sizeof(*ehdr); + elfh_size +=3D sizeof(struct elf_prstatus); + elfh_size +=3D sizeof(struct elf_prpsinfo); + elfh_size +=3D sizeof(VMCOREINFO_NOTE_NAME); + elfh_size +=3D ALIGN(vmcoreinfo_size, 4); + elfh_size +=3D (sizeof(*phdr)) * (MAX_NUM_ENTRIES); + + elfh_size =3D ALIGN(elfh_size, 4); + + /* Never freed */ + ehdr =3D kzalloc(elfh_size, GFP_KERNEL); + if (!ehdr) + return -ENOMEM; + + /* Assign Program headers offset, it's right after the elf header. */ + phdr =3D (struct elf_phdr *)(ehdr + 1); + phdr_off =3D sizeof(*ehdr); + + memcpy(ehdr->e_ident, ELFMAG, SELFMAG); + ehdr->e_ident[EI_CLASS] =3D ELF_CLASS; + ehdr->e_ident[EI_DATA] =3D ELF_DATA; + ehdr->e_ident[EI_VERSION] =3D EV_CURRENT; + ehdr->e_ident[EI_OSABI] =3D ELF_OSABI; + ehdr->e_type =3D ET_CORE; + ehdr->e_machine =3D ELF_ARCH; + ehdr->e_version =3D EV_CURRENT; + ehdr->e_ehsize =3D sizeof(*ehdr); + ehdr->e_phentsize =3D sizeof(*phdr); + + elf_offset =3D elfh_size; + + notes =3D (void *)(((char *)ehdr) + elf_offset); + + /* we have a single program header now */ + ehdr->e_phnum =3D 1; + + /* Length of the note is made of : + * 3 elf notes structs (prstatus, prpsinfo, vmcoreinfo) + * 3 notes names (2 core strings, 1 vmcoreinfo name) + * sizeof each note + */ + note_len =3D (3 * sizeof(struct elf_note) + + 2 * ALIGN(sizeof(CORE_STR), 4) + + VMCOREINFO_NOTE_NAME_BYTES + + ALIGN(sizeof(struct elf_prstatus), 4) + + ALIGN(sizeof(struct elf_prpsinfo), 4) + + ALIGN(vmcoreinfo_size, 4)); + + phdr->p_type =3D PT_NOTE; + phdr->p_offset =3D elf_offset; + phdr->p_filesz =3D note_len; + + /* advance elf offset */ + elf_offset +=3D note_len; + + strscpy(prpsinfo.pr_psargs, saved_command_line, + sizeof(prpsinfo.pr_psargs)); + + append_kcore_note(notes, &i, CORE_STR, NT_PRSTATUS, &prstatus, + sizeof(prstatus)); + append_kcore_note(notes, &i, CORE_STR, NT_PRPSINFO, &prpsinfo, + sizeof(prpsinfo)); + append_kcore_note_nodesc(notes, &i, VMCOREINFO_NOTE_NAME, 0, + ALIGN(vmcoreinfo_size, 4)); + + ehdr->e_phoff =3D phdr_off; + + /* This is the first kmemdump region, the ELF header */ + kmemdump_register_id(KMEMDUMP_ID_COREIMAGE_ELF, ehdr, + elfh_size + note_len - ALIGN(vmcoreinfo_size, 4)); + + /* + * The second region is the vmcoreinfo, which goes right after. + * It's being registered through vmcoreinfo. + */ + + return 0; +} + diff --git a/include/linux/kmemdump.h b/include/linux/kmemdump.h index c3690423a347..7933915c2c78 100644 --- a/include/linux/kmemdump.h +++ b/include/linux/kmemdump.h @@ -4,6 +4,37 @@ =20 enum kmemdump_uid { KMEMDUMP_ID_START =3D 0, + KMEMDUMP_ID_COREIMAGE_ELF, + KMEMDUMP_ID_COREIMAGE_VMCOREINFO, + KMEMDUMP_ID_COREIMAGE_CONFIG, + KMEMDUMP_ID_COREIMAGE_MEMSECT, + KMEMDUMP_ID_COREIMAGE__totalram_pages, + KMEMDUMP_ID_COREIMAGE___cpu_possible_mask, + KMEMDUMP_ID_COREIMAGE___cpu_present_mask, + KMEMDUMP_ID_COREIMAGE___cpu_online_mask, + KMEMDUMP_ID_COREIMAGE___cpu_active_mask, + KMEMDUMP_ID_COREIMAGE_jiffies_64, + KMEMDUMP_ID_COREIMAGE_linux_banner, + KMEMDUMP_ID_COREIMAGE_nr_threads, + KMEMDUMP_ID_COREIMAGE_nr_irqs, + KMEMDUMP_ID_COREIMAGE_tainted_mask, + KMEMDUMP_ID_COREIMAGE_taint_flags, + KMEMDUMP_ID_COREIMAGE_mem_section, + KMEMDUMP_ID_COREIMAGE_node_data, + KMEMDUMP_ID_COREIMAGE_node_states, + KMEMDUMP_ID_COREIMAGE___per_cpu_offset, + KMEMDUMP_ID_COREIMAGE_nr_swapfiles, + KMEMDUMP_ID_COREIMAGE_init_uts_ns, + KMEMDUMP_ID_COREIMAGE_printk_rb_static, + KMEMDUMP_ID_COREIMAGE_printk_rb_dynamic, + KMEMDUMP_ID_COREIMAGE_prb, + KMEMDUMP_ID_COREIMAGE_prb_descs, + KMEMDUMP_ID_COREIMAGE_prb_infos, + KMEMDUMP_ID_COREIMAGE_prb_data, + KMEMDUMP_ID_COREIMAGE_runqueues, + KMEMDUMP_ID_COREIMAGE_high_memory, + KMEMDUMP_ID_COREIMAGE_init_mm, + KMEMDUMP_ID_COREIMAGE_init_mm_pgd, KMEMDUMP_ID_USER_START, KMEMDUMP_ID_USER_END, KMEMDUMP_ID_NO_ID, @@ -33,7 +64,20 @@ extern const struct kmemdump_zone __kmemdump_table_end[]; .zone =3D (void *)&(sym), \ .size =3D (sz), \ } - +/* Annotate a variable into the KMEMDUMP_ID_COREIMAGE_sym UID */ +#define KMEMDUMP_VAR_CORE(sym, sz) \ + static const struct kmemdump_zone __UNIQUE_ID(__kmemdump_entry_##sym) \ + __used __section(".kmemdump") =3D { .id =3D KMEMDUMP_ID_COREIMAGE_##sym, \ + .zone =3D (void *)&(sym), \ + .size =3D (sz), \ + } +/* Annotate a variable into the KMEMDUMP_ID_COREIMAGE_name UID */ +#define KMEMDUMP_VAR_CORE_NAMED(name, sym, sz) \ + static const struct kmemdump_zone __UNIQUE_ID(__kmemdump_entry_##name) \ + __used __section(".kmemdump") =3D { .id =3D KMEMDUMP_ID_COREIMAGE_##name,= \ + .zone =3D (void *)&(sym), \ + .size =3D (sz), \ + } /* Iterate through kmemdump section entries */ #define for_each_kmemdump_entry(__entry) \ for (__entry =3D __kmemdump_table; \ @@ -42,6 +86,9 @@ extern const struct kmemdump_zone __kmemdump_table_end[]; =20 #else #define KMEMDUMP_VAR_ID(...) +#define KMEMDUMP_VAR_CORE(...) +#define KMEMDUMP_VAR_CORE_NAMED(...) +#define KMEMDUMP_VAR_CORE_NAMED(...) #endif /* * Wrapper over an existing fn allocator @@ -132,4 +179,25 @@ static inline void kmemdump_unregister(enum kmemdump_u= id id) } #endif =20 +#ifdef CONFIG_KMEMDUMP +#ifdef CONFIG_KMEMDUMP_COREIMAGE +int init_elfheader(void); +void update_elfheader(const struct kmemdump_zone *z); +int clear_elfheader(const struct kmemdump_zone *z); +#else +static inline int init_elfheader(void) +{ + return 0; +} + +static inline void update_elfheader(const struct kmemdump_zone *z) +{ +} + +static inline int clear_elfheader(const struct kmemdump_zone *z) +{ + return 0; +} +#endif +#endif #endif --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C3D62DC325 for ; Thu, 24 Jul 2025 13:56:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365389; cv=none; b=DmZ5RQstPLZ7zRKXb4h+rbI9s6KwbO+xeNC8362qbZohLJ/pd0rqiMCRNsgVKRGbhAQJFNSMcwZvwza9q2QeqtWXVk5L3pxWebSS4TFw+rWd8ZlRtPiM/t1aixh6Np8ttPwKe+yq/95iBTO1qW64Kp6Ows65LyqLp9u8EIeKNKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365389; c=relaxed/simple; bh=I45+7S3jIU0dNMjyY0XWrWua5DCAvAPB8OAPs7f8VDQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LZarstr3a1Nu5W19HIHSZN7FXNAb9r2sOpAgf1w1RswTHUqbRCCVP99f17TGlx5DRtxR8Kba+MyUu/1pQHYCLkwL2YZXVzMh/QLgKWnYS/qJWkT/Oa9nyY7fizkXeexj1JnaxhWYb3MeXuQF21clK0zG2tjgyFKj7co4jRQNhys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=NnjTYfIk; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NnjTYfIk" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4537edf2c3cso10991205e9.3 for ; Thu, 24 Jul 2025 06:56:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365385; x=1753970185; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F6vaDGqz93WFfpGOQ4UOrak1EBQhkmEoatVxlVsxTPs=; b=NnjTYfIkoofWBpyRAUQVrPINFMHx6ciLZrAV3551c/s6Bj1eu732dX5Sw4jJritVva fnALdGP4ixmhlSo2YP+i2J5UVqKiq4Z/HvlNvym7QH1ERjo6JRMClZDHb2+uCVkKv6qA SSgQ/q3VMTU/BUyiKphTinzhE987stIVuRh59Nv/roytHJcP8ZDeI5/sX1+TRYO94HbO zkCevDJTtJIdsndC2GstqBIpVfeDvKB35SSg28H7MZ0nxa7MNiJzIka4YGQvxums+hZA uLxS0NOrEzL1WroNaPvAzx7yd1q0ilyUzo8DK6if+U60oMf010Icukd9OPspDyfp1CPG Zp/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365385; x=1753970185; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F6vaDGqz93WFfpGOQ4UOrak1EBQhkmEoatVxlVsxTPs=; b=Ma3EUWUU0mtztKzjnQQXeDjbZYt5vAdOx/fwIv1dz5En9m+9RO+3yDO75lnuKLnO40 /MSAydD6oeE1ljyFAe6p8HjGce7af/BVM4Ij7CZoNh0KQauRSphUNn3MrLzQxIkXbYhd 35AE5OAtP9vxoMizyqgeVwa+FrhvtdMHQEvz+7pVN8NaRKQkOtIz3eSuHmUc6KZvZZEg mYDu7Yqckuco9dZDg3osur056uUupKGY9hIYctrHmN8hTb3R/HuQ9mpy0dmto/q9EfLq TiQNB+e1oxQQtFNKQvTCKXMRj/xBHyv26n2f3842t3sadQ04FqvF4cQbP/DSKJb+cS6F 6Eog== X-Gm-Message-State: AOJu0YwmsuVHTOR5W1U5sEKYgGXxudFFGx0TcWmC3DA8rGpg1EdAA++3 /uy4SiJAbTV3Qm2vh0v60fjL6rIY8DLfQhyDq2iIIXRdVIZAx3UzMu7tsA7P7jkRI1xzd/Uk62w XQZ4osH8= X-Gm-Gg: ASbGnctHgAUnQPt8M9ionpdqOxu8kQpNpV1eYBDzjM9/GR762sOlgG0Qilmx9b4vQwc OZJQxiTlpupZ7UhjNzzXVKAok0SAdpoeRiaDNlvCIQKM+1AweBJMR30KfUFogBmbqawRfZFYozQ 00jwUHRpn1kYa2oBY3gZ/youGNjuteHlnhpWEtD1xK3mR6fDDjqYbGklEw2Ye0zIYGZwC7DMiCR JnJEHQqG4U5NNaYyAHZPDO/mugEQfTP5MmrrUmWL6oNRPiXfjDORVBX+te7FOWnBn4csV8zloi7 BF+7tPeKbDv9ay250r2MhNJvDp3QXVBNuJcTew462jMbNfWNgax//dafZEZG9qQkpRJhlGMjHcZ E3iV3qHLPrRAzWXhS7w0D1Jrmgy5W+NCh/GBINMXvNb+lfuHN5fNRG3g8C+l6eYqfleCxbZ1CB/ v4jq+UZaPMltdp X-Google-Smtp-Source: AGHT+IHYnD8d7A8aBh+5tnrqY0LYzarTFZbBZJYJd44Ilh6yiLc/UVbK9j+FmYRR9VqOWZQpLWbc7Q== X-Received: by 2002:a05:600c:500d:b0:441:a715:664a with SMTP id 5b1f17b1804b1-45868d3289cmr52540145e9.20.1753365385393; Thu, 24 Jul 2025 06:56:25 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:25 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 04/29] Documentation: kmemdump: add section for coreimage ELF Date: Thu, 24 Jul 2025 16:54:47 +0300 Message-ID: <20250724135512.518487-5-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add section describing the utility of coreimage ELF generation for kmemdump. Signed-off-by: Eugen Hristev --- Documentation/debug/kmemdump.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/debug/kmemdump.rst b/Documentation/debug/kmemdum= p.rst index 3301abcaed7e..9c2c23911242 100644 --- a/Documentation/debug/kmemdump.rst +++ b/Documentation/debug/kmemdump.rst @@ -17,6 +17,12 @@ kmemdump allows a backend to be connected, this backend = interfaces a specific hardware that can debug or dump the memory registered into kmemdump. =20 +kmemdump can also prepare specific regions of the kernel that can be +put together to form a minimal core image file. To achieve this, the first +region is an ELF header with program headers for each region, and specific +ELF NOTE section with vmcoreinfo. To enable this feature, use +`CONFIG_KMEMDUMP_COREIMAGE`. + kmemdump Internals =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62DA72E11B9 for ; Thu, 24 Jul 2025 13:56:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365391; cv=none; b=g0WuniV7jojw4Dmm1gpNzvPrlvUwbtnoHey+4Sl9/yvwSBinpdWGgNaKOKSZJUaqVODeAXps7WCzb1seARpJIWZtaVJTI5zrKl6bC9QVCjZ7LfPKcw5pl587Vk0i/crN/RUtj/juoqGr2IVSWuDjujeeNyRugUWPdr+LaPZfNJI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365391; c=relaxed/simple; bh=6Ns4vogZCrsB3rJa9oLf8qL6Hp/YwjVe6Wk7Ylk4d2s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lUPZ2IHShAC6dytb15JsANE/K9gfFvQo8yA8J3Kmapx16/mc9Qzat9yx/05q43fTcUm/bVVPSMCapB0llxJKKHRTEiCw8f1cWDAJvJ1x3YAvHsshesfPJeN4rWbGYIWHMC0mD2paihdbPR0faCrQZErrQCDAvV7kMKR70eCOCKQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=SQhir9Ah; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SQhir9Ah" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4561ca74829so10970875e9.0 for ; Thu, 24 Jul 2025 06:56:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365387; x=1753970187; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XAxMtA+w51S3PCwT+VkkNqGhee+g4ma13WDPbYgGlss=; b=SQhir9Ah5noeTJ/p4o8RkFRRs5QuVtYfriSjddHj5mwIQX3ot1/GCvSDkDEftpzEM3 uSv4i2zWgnitJ0xbN7pAca74kkMytryLcNTV3s9a5pxoBxF3LYqOkDlOBHK5pvYMtSSt LEJBwrJOuKNQiARAMp4IaV0erMR5PqeFE9tsoaYrTL4beHzR8bhOg5sLk7c4OJiP59Va klFXay56iHqwNihkKLWNOXqF4RkzlRazlZ0KPa+9pOzaUc/jcU3Rf4tinjI1WndzGeTh CRrqNYhVYgd/fBTui6ZedN9Q8X329j0Ug90qXgXjuKmhFXBkEcUgT2mYYZb4/s4X1uZ9 nadQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365387; x=1753970187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XAxMtA+w51S3PCwT+VkkNqGhee+g4ma13WDPbYgGlss=; b=ewe7mR5wWGeGtDazkClL/V9DC4H5u/xTpk7IiB7P0kp+jcEU7As7A5qszmBSM0Z+tW VDFyssx135oG5OAn0M6oem/sV+aRGMEYTtsrDelUAaTSA6VfQ66mjBLniR0R59Nbw3r3 WFE42rCLi6ipIBKeBjoysc2MSnAhkKDbTrOP0nHbcCom6JfcBTnPHlmfyC+SEpvE1OnM r6cmsbVTmNuLi+GQAlhb1sYodYNqzNdS8XrrXPf5zI4zeq0qtHX1lMVZc6rcD95ZuOmD XMydGjTZ+aZ4ap94QdXvbiQYm4zIYcDDCx9oF5LNiv+seeLIg9vl/a1qb4ayec5iPm/q ZupA== X-Gm-Message-State: AOJu0Yx7uitKW2npcCwgtkNc7TADS1A2VSO9dBOz73h2h1LlqPrrw6ot 2KWo8yuJk5xilMTK6tuck/KUP40cFaepi8EEfzogk8ltDUPVvYPM5KFBG9UK/1F7VhhmJwcnlT3 vW6Kife4= X-Gm-Gg: ASbGnct7f5gYQ/J0p/hHvFbcPRU3wKbuJ8txuozau8O4EtdrUGTqbXFqt2Zm0hhG/YC SixyqcXykU7EZuS4/6POj6nW22Y8Tuv2VkzvRExzOFQjpoJrttgcyA8heRh0RU8tfo/eRG8QCyY 0F4oQGTka3OFAe3R3lGyA3Rb3Q4SEhgMQk1npfz9vtRxY+CionrTh5w12yLFEDdROJKjA0q4jS5 sap9VUTZtGaG57tXtRtPfIFh1cSrbrWt9VOqGSO1gQTXeGRiqETZwV+YfqdhjmCw4IHonFzxoe/ wh/IYjnaTDd3UZcubtm9rDOmZSJPx6ZfHLUC4s/s2gJ4kO3T1c6tbFGSlJu2AjygBzFvhuPlYZJ FH11Rd3fM4gMbaduVBshOZnKQ+cuyJhGIhOQtLBuTxy8hykB7e9oVAzLr8F+XW/2N8WIfholvxg LXA9+tZvnuAuNS X-Google-Smtp-Source: AGHT+IExCYO6BdC37olS+pAbSHh4fE6RM/f8mJb61ZeZpT0dRv6iCU18YgCf/SbYinZayjVuWPfYqw== X-Received: by 2002:a05:6000:2586:b0:3a6:e6c3:6d95 with SMTP id ffacd0b85a97d-3b768f2681fmr5379673f8f.41.1753365386507; Thu, 24 Jul 2025 06:56:26 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:26 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 05/29] kmemdump: introduce qcom-minidump backend driver Date: Thu, 24 Jul 2025 16:54:48 +0300 Message-ID: <20250724135512.518487-6-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Qualcomm Minidump is a backend driver for kmemdump. Regions are being registered into the shared memory on Qualcomm platforms and into the table of contents. Further, the firmware can read the table of contents and dump the memory accordingly. Signed-off-by: Eugen Hristev --- MAINTAINERS | 5 + drivers/debug/Kconfig | 12 ++ drivers/debug/Makefile | 1 + drivers/debug/qcom_minidump.c | 353 ++++++++++++++++++++++++++++++++++ 4 files changed, 371 insertions(+) create mode 100644 drivers/debug/qcom_minidump.c diff --git a/MAINTAINERS b/MAINTAINERS index b43a43b61e19..68797717175c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13625,6 +13625,11 @@ F: drivers/debug/kmemdump.c F: drivers/debug/kmemdump_coreimage.c F: include/linux/kmemdump.h =20 +KMEMDUMP QCOM MINIDUMP BACKEND DRIVER +M: Eugen Hristev +S: Maintained +F: drivers/debug/qcom_minidump.c + KMEMLEAK M: Catalin Marinas S: Maintained diff --git a/drivers/debug/Kconfig b/drivers/debug/Kconfig index 903e3e2805b7..d34ceaf99bd8 100644 --- a/drivers/debug/Kconfig +++ b/drivers/debug/Kconfig @@ -27,4 +27,16 @@ config KMEMDUMP_COREIMAGE for debug tools are being registered. The coredump file can then be loaded into GDB or crash tool and further inspected. + +config KMEMDUMP_QCOM_MINIDUMP_BACKEND + tristate "Qualcomm Minidump kmemdump backend driver" + depends on ARCH_QCOM || COMPILE_TEST + depends on KMEMDUMP + help + Say y here to enable the Qualcomm Minidump kmemdump backend + driver. + With this backend, the registered regions are being linked + into the minidump table of contents. Further on, the firmware + will be able to read the table of contents and extract the + memory regions on case-by-case basis. endmenu diff --git a/drivers/debug/Makefile b/drivers/debug/Makefile index 2b67673393a6..7f70b84049cb 100644 --- a/drivers/debug/Makefile +++ b/drivers/debug/Makefile @@ -2,3 +2,4 @@ =20 obj-$(CONFIG_KMEMDUMP) +=3D kmemdump.o obj-$(CONFIG_KMEMDUMP_COREIMAGE) +=3D kmemdump_coreimage.o +obj-$(CONFIG_KMEMDUMP_QCOM_MINIDUMP_BACKEND) +=3D qcom_minidump.o diff --git a/drivers/debug/qcom_minidump.c b/drivers/debug/qcom_minidump.c new file mode 100644 index 000000000000..49b0b6ef193b --- /dev/null +++ b/drivers/debug/qcom_minidump.c @@ -0,0 +1,353 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Qualcomm Minidump backend driver for Kmemdump + * Copyright (C) 2016,2024-2025 Linaro Ltd + * Copyright (C) 2015 Sony Mobile Communications Inc + * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * In some of the Old Qualcomm devices, boot firmware statically allocates= 300 + * as total number of supported region (including all co-processors) in + * minidump table out of which linux was using 201. In future, this limita= tion + * from boot firmware might get removed by allocating the region dynamical= ly. + * So, keep it compatible with older devices, we can keep the current limi= t for + * Linux to 201. + */ +#define MAX_NUM_REGIONS 201 + +#define MAX_NUM_SUBSYSTEMS 10 +#define MAX_REGION_NAME_LENGTH 16 +#define SBL_MINIDUMP_SMEM_ID 602 +#define MINIDUMP_REGION_VALID ('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0) +#define MINIDUMP_SS_ENCR_DONE ('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0) +#define MINIDUMP_SS_ENABLED ('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0) + +#define MINIDUMP_SS_ENCR_NOTREQ (0 << 24 | 0 << 16 | 'N' << 8 | 'R' << 0) + +#define MINIDUMP_SUBSYSTEM_APSS 0 + +const char *kmemdump_id_to_md_string[] =3D { + "", + "ELF", + "vmcoreinfo", + "config", + "memsect", + "totalram", + "cpu_possible", + "cpu_present", + "cpu_online", + "cpu_active", + "jiffies", + "linux_banner", + "nr_threads", + "nr_irqs", + "tainted_mask", + "taint_flags", + "mem_section", + "node_data", + "node_states", + "__per_cpu_offset", + "nr_swapfiles", + "init_uts_ns", + "printk_rb_static", + "printk_rb_dynamic", + "prb", + "prb_descs", + "prb_infos", + "prb_data", + "runqueues", + "high_memory", + "init_mm", + "init_mm_pgd", +}; + +/** + * struct minidump_region - Minidump region + * @name : Name of the region to be dumped + * @seq_num: : Use to differentiate regions with same name. + * @valid : This entry to be dumped (if set to 1) + * @address : Physical address of region to be dumped + * @size : Size of the region + */ +struct minidump_region { + char name[MAX_REGION_NAME_LENGTH]; + __le32 seq_num; + __le32 valid; + __le64 address; + __le64 size; +}; + +/** + * struct minidump_subsystem - Subsystem's SMEM Table of content + * @status : Subsystem toc init status + * @enabled : if set to 1, this region would be copied during coredump + * @encryption_status: Encryption status for this subsystem + * @encryption_required : Decides to encrypt the subsystem regions or not + * @region_count : Number of regions added in this subsystem toc + * @regions_baseptr : regions base pointer of the subsystem + */ +struct minidump_subsystem { + __le32 status; + __le32 enabled; + __le32 encryption_status; + __le32 encryption_required; + __le32 region_count; + __le64 regions_baseptr; +}; + +/** + * struct minidump_global_toc - Global Table of Content + * @status : Global Minidump init status + * @revision : Minidump revision + * @enabled : Minidump enable status + * @subsystems : Array of subsystems toc + */ +struct minidump_global_toc { + __le32 status; + __le32 revision; + __le32 enabled; + struct minidump_subsystem subsystems[MAX_NUM_SUBSYSTEMS]; +}; + +#define MINIDUMP_MAX_NAME_LENGTH 12 +/** + * struct qcom_minidump_region - Minidump region information + * + * @name: Minidump region name + * @virt_addr: Virtual address of the entry. + * @phys_addr: Physical address of the entry to dump. + * @size: Number of bytes to dump from @address location, + * and it should be 4 byte aligned. + * @id: Region id. + */ +struct qcom_minidump_region { + char name[MINIDUMP_MAX_NAME_LENGTH]; + void *virt_addr; + phys_addr_t phys_addr; + size_t size; + unsigned int id; +}; + +/** + * struct minidump - Minidump driver data information + * + * @dev: Minidump device struct. + * @toc: Minidump table of contents subsystem. + * @regions: Minidump regions array. + * @md_be: Minidump backend. + */ +struct minidump { + struct device *dev; + struct minidump_subsystem *toc; + struct minidump_region *regions; + struct kmemdump_backend md_be; +}; + +static struct minidump *md; + +#define be_to_minidump(be) container_of(be, struct minidump, md_be) + +/** + * qcom_apss_md_table_init() - Initialize the minidump table + * @md: minidump data + * @mdss_toc: minidump subsystem table of contents + * + * Return: On success, it returns 0 and negative error value on failure. + */ +static int qcom_apss_md_table_init(struct minidump *md, + struct minidump_subsystem *mdss_toc) +{ + md->toc =3D mdss_toc; + md->regions =3D devm_kcalloc(md->dev, MAX_NUM_REGIONS, + sizeof(*md->regions), GFP_KERNEL); + if (!md->regions) + return -ENOMEM; + + md->toc->regions_baseptr =3D cpu_to_le64(virt_to_phys(md->regions)); + md->toc->enabled =3D cpu_to_le32(MINIDUMP_SS_ENABLED); + md->toc->status =3D cpu_to_le32(1); + md->toc->region_count =3D cpu_to_le32(0); + + /* Tell bootloader not to encrypt the regions of this subsystem */ + md->toc->encryption_status =3D cpu_to_le32(MINIDUMP_SS_ENCR_DONE); + md->toc->encryption_required =3D cpu_to_le32(MINIDUMP_SS_ENCR_NOTREQ); + + return 0; +} + +/** + * qcom_md_get_region_index() - Lookup minidump region by kmemdump id + * @md: minidump data + * @id: minidump region id + * + * Return: On success, it returns the internal region index, on failure, + * returns negative error value + */ +static int qcom_md_get_region_index(struct minidump *md, int id) +{ + unsigned int count =3D le32_to_cpu(md->toc->region_count); + unsigned int i; + + for (i =3D 0; i < count; i++) + if (md->regions[i].seq_num =3D=3D id) + return i; + + return -ENOENT; +} + +/** + * register_md_region() - Register a new minidump region + * @be: kmemdump backend, this should be the minidump backend + * @id: unique id to identify the region + * @vaddr: virtual memory address of the region start + * @size: size of the region + * + * Return: On success, it returns 0 and negative error value on failure. + */ +static int register_md_region(const struct kmemdump_backend *be, + enum kmemdump_uid id, void *vaddr, size_t size) +{ + struct minidump *md =3D be_to_minidump(be); + struct minidump_region *mdr; + unsigned int num_region, region_cnt; + const char *name =3D "unknown"; + + if (!vaddr || !size) + return -EINVAL; + + if (id < ARRAY_SIZE(kmemdump_id_to_md_string)) + name =3D kmemdump_id_to_md_string[id]; + + if (qcom_md_get_region_index(md, id) >=3D 0) { + dev_dbg(md->dev, "%s:%d region is already registered\n", + name, id); + return -EEXIST; + } + + /* Check if there is a room for a new entry */ + num_region =3D le32_to_cpu(md->toc->region_count); + if (num_region >=3D MAX_NUM_REGIONS) { + dev_err(md->dev, "maximum region limit %u reached\n", + num_region); + return -ENOSPC; + } + + region_cnt =3D le32_to_cpu(md->toc->region_count); + mdr =3D &md->regions[region_cnt]; + scnprintf(mdr->name, MAX_REGION_NAME_LENGTH, "K%.8s", name); + mdr->seq_num =3D id; + mdr->address =3D cpu_to_le64(__pa(vaddr)); + mdr->size =3D cpu_to_le64(ALIGN(size, 4)); + mdr->valid =3D cpu_to_le32(MINIDUMP_REGION_VALID); + region_cnt++; + md->toc->region_count =3D cpu_to_le32(region_cnt); + + return 0; +} + +/** + * unregister_md_region() - Unregister a previously registered minidump re= gion + * @be: pointer to backend + * @id: unique id to identify the region + * + * Return: On success, it returns 0 and negative error value on failure. + */ +static int unregister_md_region(const struct kmemdump_backend *be, + unsigned int id) +{ + struct minidump *md =3D be_to_minidump(be); + struct minidump_region *mdr; + unsigned int region_cnt; + unsigned int idx; + + idx =3D qcom_md_get_region_index(md, id); + if (idx < 0) { + dev_err(md->dev, "%d region is not present\n", id); + return idx; + } + + mdr =3D &md->regions[0]; + region_cnt =3D le32_to_cpu(md->toc->region_count); + /* + * Left shift all the regions exist after this removed region + * index by 1 to fill the gap and zero out the last region + * present at the end. + */ + memmove(&mdr[idx], &mdr[idx + 1], (region_cnt - idx - 1) * sizeof(*mdr)); + memset(&mdr[region_cnt - 1], 0, sizeof(*mdr)); + region_cnt--; + md->toc->region_count =3D cpu_to_le32(region_cnt); + + return 0; +} + +static int qcom_md_probe(struct platform_device *pdev) +{ + struct minidump_global_toc *mdgtoc; + size_t size; + int ret; + + md =3D kzalloc(sizeof(*md), GFP_KERNEL); + if (!md) + return -ENOMEM; + + md->dev =3D &pdev->dev; + + strscpy(md->md_be.name, "qcom_minidump"); + md->md_be.register_region =3D register_md_region; + md->md_be.unregister_region =3D unregister_md_region; + + mdgtoc =3D qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, &size); + if (IS_ERR(mdgtoc)) { + ret =3D PTR_ERR(mdgtoc); + dev_err(md->dev, "Couldn't find minidump smem item %d\n", ret); + goto qcom_md_probe_fail; + } + + if (size < sizeof(*mdgtoc) || !mdgtoc->status) { + dev_err(md->dev, "minidump table is not initialized %d\n", ret); + ret =3D -ENAVAIL; + goto qcom_md_probe_fail; + } + + ret =3D qcom_apss_md_table_init(md, &mdgtoc->subsystems[MINIDUMP_SUBSYSTE= M_APSS]); + if (ret) + goto qcom_md_probe_fail; + + return kmemdump_register_backend(&md->md_be); + +qcom_md_probe_fail: + kfree(md); + return ret; +} + +static void qcom_md_remove(struct platform_device *pdev) +{ + kfree(md); + kmemdump_unregister_backend(&md->md_be); +} + +static struct platform_driver qcom_md_driver =3D { + .probe =3D qcom_md_probe, + .remove =3D qcom_md_remove, + .driver =3D { + .name =3D "qcom-minidump", + }, +}; + +module_platform_driver(qcom_md_driver); + +MODULE_AUTHOR("Eugen Hristev "); +MODULE_AUTHOR("Mukesh Ojha "); +MODULE_DESCRIPTION("Qualcomm kmemdump minidump backend driver"); +MODULE_LICENSE("GPL"); --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65BA92E175D for ; Thu, 24 Jul 2025 13:56:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365392; cv=none; b=eS2+93aulmvcDmlmKoGAMqORN/wkGVlxD/tsjD1hcL5BDbiwWeNfVvu9kmHUNb58zDKKhBunX/+2kzFxNZBvZpC2Ukf9fdMsnSnRb/3GNi+oeZ4E2h3Gjj3co0ku3YwkVezh4yoKYZkJwB7gUvciMeSsJARTNLzbtpkfBUE9YDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365392; c=relaxed/simple; bh=Vzp3U7aGndkyJ82EgcFvHbZjMAKNTPgILqBaVa9ZKKE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WZQawGqZNtmTMMey7jm9hXkkPhlev2aWPE/QjjKo0zpKxegJSQUhV19xRBrqJ4l+PGuJLXKN2qJFf0cmbv/9JR8YBX27DWX3H+yyKnIAKLP3FwQyovrdQ7cYjHB6m+ciRhceECmsot0qA2Bltl0dNXmtNcGIHuCm2Cpmnqa1ab0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=RHROcwon; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="RHROcwon" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-455ecacfc32so4577075e9.3 for ; Thu, 24 Jul 2025 06:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365387; x=1753970187; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wXG7080vUoTS71soVhA4Gbq56Ym56pqDEVpEhL2XCIg=; b=RHROcwon2Ud+HX/4JYfbI8AeIlRPuE37aGaORXuyjeuCK/5tKW2uS7682GhreQmJfy qSgjbAlw6xuO2e7ct5d6oRHucze+NlfN9iQuh/n9nVkLmQSo705NqE4p2jsK//pIXT1R FWR6LLd2cmYFXEebAjCGRR+N1I2TqAayaMGiXUNn0iudgrZLXParpU8hWN3n8bVbvlSq HofZDgHCJIKBBaZGQhprxt13iG6iTTDJrYWOtdsFQYzkJamAZrXBklaWNqmMzHOGbUpD 2T2KJz5gkBfibeHVzVokkFEhJ8pS4WsK6UPNZRE+Y9DsNQlJI8e67jM1BpTQ8B4Tqiwr mYdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365387; x=1753970187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wXG7080vUoTS71soVhA4Gbq56Ym56pqDEVpEhL2XCIg=; b=u0AiLbdoag8nkNjuZSwNd5r5ecl9u1Pi2kFynew/UgIrzauhiu4g+a0EZ7zzgW5clh XuXm7DAXo/ee7+3WiZJErTyS/s+Emp9PMz4BiDvVOg+Rpm15CCxWum8cxqD+U/b7rQp7 eqPSlfNl9DYOIFCoNLgoV7F62UGZ1Wdey6Hjcd2WKXqr36hxjuWMZczD+/ebQ6tRJQ5X YMqRs1L/Lc7SPHWfwT1kMl+wess6j5ygDmqSNy+bQ6Vw4AAFDoBczjp3euAlVxKUd2jA Rcw2ahyvChGTbt0bxYcgraIz68nnDnSsxRT6iBd1cvanH3NdicPJd4uqfbLMgRePJNxI 3RSw== X-Gm-Message-State: AOJu0YwrY0skCwDsrv+CMhrPnB7t5NvbDhBpAbHv0iEKsBi+rjHbSspE Ygn7K+iRWsZg59rVWQe7rAE2UCcywR/a11/yiaDkpuW56QqEPZWRxx3DAgdtfv9Ju6QBwJSwGtM 2sgeTsBs= X-Gm-Gg: ASbGncuo01kzpIEhdsDugD6j57y8Y0qZKuxvaAe8EuZqbZTmiqY5n2GGat6gT61uPFR 0ups1QvoAph2320Zcc7nfUDlY5ABNKBLIPJB5ew6+ktkm9WQrbyTMCPc7WGNW8/is9OscJUgbdE 6GpHwRR3LxUUHEGRmv/to8Q4BXA7ynNjsz8a+ZPYjK6jQNmvvo+GAIAoSpsvFCHMo6h3Qslrcuf +qasn7XaHRzwtR0dhCjEKaHOBxd0Dxku4i+BeThPi4OZbGW3AnldZqr1gs2JmHnK6SHucYtgehF yCycWzHb9h0g5gJ2zuypfWFt+GzjL+JWTIL2CJghaNz+yeCQsFCqqx55SBy2xs7MiSVLTo+GBZA /Czs+d3PAB/yGyqnsLqbrwJTd3LfIl4GF1944AxvNNaZONLRL6K+ETSEOKA9KdBP94SgbJp1fvB bMQ+eUe8EIMvD8 X-Google-Smtp-Source: AGHT+IGoSF/EqSdGIwDb9gZl52m8tCgkgoHOuTGrpWGU+P8oq0e6jpOpRi4GM0HClIhflbnZpXQODA== X-Received: by 2002:a05:600c:630f:b0:43b:ca39:6c75 with SMTP id 5b1f17b1804b1-4586a7df4e9mr64595105e9.16.1753365387527; Thu, 24 Jul 2025 06:56:27 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:27 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 06/29] soc: qcom: smem: add minidump device Date: Thu, 24 Jul 2025 16:54:49 +0300 Message-ID: <20250724135512.518487-7-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a minidump platform device. Minidump can collect various memory snippets using dedicated firmware. To know which snippets to collect, each snippet must be registered by the kernel into a specific shared memory table which is controlled by the qcom smem driver. To instantiate the minidump platform driver, register its data using platform_device_register_data. Later on, the minidump driver will probe and register itself into kmemdump as a backend Signed-off-by: Eugen Hristev --- drivers/soc/qcom/smem.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index cf425930539e..2aae0e696150 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -270,6 +270,7 @@ struct smem_region { * @partitions: list of partitions of current processor/host * @item_count: max accepted item number * @socinfo: platform device pointer + * @mdinfo: minidump device pointer * @num_regions: number of @regions * @regions: list of the memory regions defining the shared memory */ @@ -280,6 +281,7 @@ struct qcom_smem { =20 u32 item_count; struct platform_device *socinfo; + struct platform_device *mdinfo; struct smem_ptable *ptable; struct smem_partition global_partition; struct smem_partition partitions[SMEM_HOST_COUNT]; @@ -1236,12 +1238,20 @@ static int qcom_smem_probe(struct platform_device *= pdev) if (IS_ERR(smem->socinfo)) dev_dbg(&pdev->dev, "failed to register socinfo device\n"); =20 + smem->mdinfo =3D platform_device_register_data(&pdev->dev, "qcom-minidump= ", + PLATFORM_DEVID_AUTO, NULL, + 0); + if (IS_ERR(smem->mdinfo)) + dev_err(&pdev->dev, "failed to register platform md device\n"); + return 0; } =20 static void qcom_smem_remove(struct platform_device *pdev) { platform_device_unregister(__smem->socinfo); + if (!IS_ERR(__smem->mdinfo)) + platform_device_unregister(__smem->mdinfo); =20 hwspin_lock_free(__smem->hwlock); __smem =3D NULL; --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 535472E2F03 for ; Thu, 24 Jul 2025 13:56:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365393; cv=none; b=EwWbpskLK9saMhyVngMZiTRP9gk0xHcki3U9Lf+/gLL5Qii4FZmGxVdQ2k76d2Xi6GJc8ogF7OfeJi5d11qWij+i/yFc2l+x2BeQ+W0rQl1OsBJ8oJT1QAGcYeLgQZMuj/7XWAjE5Zs5pYH2wTacZ7KawUvhK8mi32F3wAQMrnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365393; c=relaxed/simple; bh=MqHhOcNuXJ5oZB2p2GySncf4wGrMH13kPtoLfjjbjDA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Eo5NhSxmNXlsxNmPEb/w5XUEJZ8N1+mEcmCihpTbw0A5oU9ihh1M85ybEXsx68DJCOy0tOKsvKvPOM+4NqhfvAHgvagLQcX/H3VNJLVECk+92QGy4YpqYnJpoeIbWc4+8fpZGiKec0g/bTAVkqhk3JkjReP0I75pqAM6f69UcLY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=o06eEJlu; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="o06eEJlu" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-451dbe494d6so10697535e9.1 for ; Thu, 24 Jul 2025 06:56:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365388; x=1753970188; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=o/nDqiXo0oPmiwRgkXmDbqPxo4RR6UizLNSv2BWaLmE=; b=o06eEJluMpAq6dy3fOCgn7NAaSzuSdLBhZBZaMD6U2xLGIldpXohgymHLeLK9+xWTN 9+x0DVM9KcOW0fY4UPa1AaD5nV7oIzwVpF86Ej2cHoXm1zIYpl5+rvdOgT3Nwm//QP27 byvBAXdS/Fi5AYtUoXybNwolzf07pLMWW2vPPD0u5s2YcKeuBP0MFfJcWjzmtYUZSWbZ m7kL2edMOTv0Q7FZaKNHgT8kD4xvBPzICoJsgGAxesIxE7W+mMeflzXYeWut6unLzIP9 NnwKtQwIthA7zFhcSIuGq9GPzo7rCpXXzNpyZyLhxNRncTKJhsKt2uydcdTkW4BEbf9W bZiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365388; x=1753970188; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o/nDqiXo0oPmiwRgkXmDbqPxo4RR6UizLNSv2BWaLmE=; b=Owo0lHTo6r9aOF2MBk4v2TLvkKr6MwbK/qGXATUGUC7Im92JJpbRxD+nbTp335lKYH CuWm3+6pSEGKzXLDG/JuYvssaDZyS1czIC9f284du3biW34CiIUDTyHhlpjM873Fzpts PGA0M3W0vnudiMwsvQbmURjz5jf4qFfqGRlflZ0T5fsVUx8o5k2cWGxR4ykWGkMH0NhM 8iDbQ75YfO4Vs19uwJIxBfLLvykkvGgofv4aBVMLd+ky7UwPlnugq5TWaNtUf8PiD/Rq 4TNh1xnx9CTpfvJLJGFBvydKC8N5RUiSEa9suwopfKZGwLoOtcjaN87O2OE84IUPs2kR 9y7A== X-Gm-Message-State: AOJu0Yw1B6vP4N3K92lXrly7DwWz3Vu5MRIY6zLD6tFDvaQIy1dUb14h LrFgWTlCk5RhXuSF+j7/oo49t3DwLfPqOAbwuwp7sP1XDZ6tYmV7Oi4UMvk1BNoigLr8hGku40C PCndarSE= X-Gm-Gg: ASbGnctwM2v147JeSOEtstQhBWIo1cqXVMvG0vO2e8x4cstEk0Kravb32q5cBMYSdFj HalTi8UjYwRMkNPmnwX2hK0SHDNDapbcClKHg1ZcOrSvq8Un47WAyVT4ysmbYD0FBPFzLfeUo8g CgpiWYyN4jaO7rLddmRMmamWjHjAsnZKpOAPE7qZWseJIxU2DuL7OfDnlBcM3GdpnjPr4k06YbJ xtaJtCV9k6GWMhcr4zYpsaUkf7uPBF8m+CylyuaJBp1Cm2JwwuuLHU4SHSMIRPyk8G/3B33J03O 1sQpr8rW6QJiVjWlll5+HoVU7E68n6gpGKhfvVTkC16hCCbBPPzoluSxKybgn9IpfsfxKBnqXzL DUnzUz2DgGwqenKRrAO68z74JK4jN7WZlZyUbFujJOXsExlTZPcjaChvGrmkxrpveuH7F4lEZIY 5OonZrJlv8yhO0 X-Google-Smtp-Source: AGHT+IFsfIJWNObH04glJtR4VMihBKDX2X1KMe4027IfQD5dai+xqhfpETfw7nG5oExxx5Qg+IUmng== X-Received: by 2002:a05:600c:8719:b0:456:2ce8:b341 with SMTP id 5b1f17b1804b1-45868d47860mr71077715e9.17.1753365388431; Thu, 24 Jul 2025 06:56:28 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:28 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 07/29] init/version: Annotate static information into Kmemdump Date: Thu, 24 Jul 2025 16:54:50 +0300 Message-ID: <20250724135512.518487-8-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - init_uts_ns - linux_banner Information on these variables is stored into dedicated kmemdump section. Signed-off-by: Eugen Hristev --- init/version.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/init/version.c b/init/version.c index 94c96f6fbfe6..f5910c027948 100644 --- a/init/version.c +++ b/init/version.c @@ -16,6 +16,7 @@ #include #include #include +#include =20 static int __init early_hostname(char *arg) { @@ -51,4 +52,7 @@ const char linux_banner[] __weak; =20 #include "version-timestamp.c" =20 +KMEMDUMP_VAR_CORE(init_uts_ns, sizeof(init_uts_ns)); +KMEMDUMP_VAR_CORE(linux_banner, sizeof(linux_banner)); + EXPORT_SYMBOL_GPL(init_uts_ns); --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 217C42E3B1E for ; Thu, 24 Jul 2025 13:56:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365395; cv=none; b=VQvlaah8BnliGbIjWvNwV8+XHAkw9GzPhPhFdDx5NCp3HXEr3sgkRpqyQGUJg2+SrV70CVC9imgcZ+A592egSnnFHpyZ55yHivXZwI3lPbSVgzCsCEBaTFwyXt1sNO5qURapgji+BsjDtuVTDVDaxHRtboKOSIZmmrDPFZ7j1tA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365395; c=relaxed/simple; bh=WYZcYfuknZj3jTFjyz/2YrsteC6Vf4UuZMKZmSw4y2w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oj5RgZZYsT7m6X0DTn9/+o0EmOT14sPY9+jVBf2XRkrdv7dv5Kb5hF3rZkEj3uRGvkKt6qDJgjmdQZ6E1nLBuuDjKhjmWrcuusig4W1Cj2A0/F+RjbQBVZMIntilMDyGHPFtBRA+rfOgjwNSIkdoh59RbgYisQrBgltkVlZm8IY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Th3aUFFI; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Th3aUFFI" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3a531fcaa05so491264f8f.3 for ; Thu, 24 Jul 2025 06:56:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365389; x=1753970189; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=754ZhLeV6aTccnAi72YeZAlKqe4sOON/R6H0mwMKOfI=; b=Th3aUFFIQkGTV6sknzNIOajf27et1WQfLB29fQi7HkufV807DZOWxXheL4MoEi3zZ3 g902QOkIy0IAJTWMNe5iSjJJUGhTKHuis+4rkDDgWUm27kzTq5615hdX0D1j2gyCp+eK JFh39ehqr0lZ6HQkTVfimzsFXYG/ZBJZAkPt/FFTfoekOqtl1ud7Ru6xpM/402OFXp9m X9UfeqYaRwjAmhvhFYd2MPMKeq9sZTcWxGXXIrwQsMItziTSrEtm9pWWla2DI0cmEc69 B2qYsUcWWtp123urQK3cXCBMbWlYXXo8Vvip0LCdwhqw7XcijWppADMQJftEF70WvlZP JxTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365389; x=1753970189; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=754ZhLeV6aTccnAi72YeZAlKqe4sOON/R6H0mwMKOfI=; b=cXdNwKyrXJitbae6BirWXm1+r1FAatIPnEmEyHd+BL2Puy8XfrAe1Wr1c2v2O9FhnS zUTfRRLxpWippZY/MAwiN2bmaGzDvc2reBP+z8t9GRlK+eBADesi7ezoLmcKeaYz/g2i MzrweOCmavwRNaBk+jeauzwugJtlve+Cr7d7kBDDUo3saXBAkij92qKycHMqySGwNtRb Z0ylHSsYyd1/SdM2whTYcOBjH+5slm4lxn2x4U4FQ8ABzbkroj0FaCMe21jB7CLO5lrL HgtWxwEP/1P387H/0JDuvslU0l9+QwtMMLCGRXciY6K5Y60xO9UBPWaZDSRPlRv1sfSh WXOg== X-Gm-Message-State: AOJu0YyAxHJGBz6iuX+OKMkzO0hcvmNxQR3cEQWoGO1U2HeksqolRUhj dMYAgLahtSJ1Guxfvrogu2iqOHWQPdpvQ5ddDnn2wav1YBP1vBAFnwucWLTzKLeurBS4CletrzW sjAxW3nA= X-Gm-Gg: ASbGncsRw6IL2+ZgpkrBAZ3E8Gkucr6DEPyUB2M/lFnz9FskW5uBJ4tUU+9p2LNsVk4 oFVMzzY1R2DcEsRGXTjwwZKLz4QAczMzMvsOgZqfWg2c0pgTH6ltFk56rr5owQP43zq0nR2+JdS 1G/i9/suxyOHK8RrA2Ahjw3bTwt2FA9OUfQkNjemkuVbZCdF52qLmBpywK4FTW7GMk4EVwe/uVV WVcQUJLxBbwJineO9PSc3lNU4u1judXdsbydCYpfKVoHZWwPS0XKwuFX29IF+637FfOp9eo3DU2 RO4zoGWSbjYfIwZm+2Wg4uays8lbn/3EpPoc3frxXXMuhxZMYykTACKxsCaoSILVKP/O0gQyJT0 nnuxfgkny5gnfi0RqERXKVDv+OKIwRsqyF5sy8IvZo9H1Npm1gMYQjuAgDVJ8zyl3TUDC0owQqT /oql+KlFDCEkRPXOETQVot/LQ= X-Google-Smtp-Source: AGHT+IHl6TFfQx8To8y+XEm2d27DSKV0h+MO3rvshokYEfPVyki8zgMiinC0EkzG8gsJheCG6bV65Q== X-Received: by 2002:a05:6000:188b:b0:3a8:2f65:3745 with SMTP id ffacd0b85a97d-3b768f11dfbmr6433064f8f.51.1753365389405; Thu, 24 Jul 2025 06:56:29 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:29 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 08/29] cpu: Annotate static information into Kmemdump Date: Thu, 24 Jul 2025 16:54:51 +0300 Message-ID: <20250724135512.518487-9-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - __cpu_present_mask - __cpu_online_mask - __cpu_possible_mask - __cpu_active_mask Information on these variables is stored into dedicated kmemdump section. Signed-off-by: Eugen Hristev --- kernel/cpu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/cpu.c b/kernel/cpu.c index faf0f23fc5d8..d48e4dd979e9 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -38,6 +38,7 @@ #include #include #include +#include =20 #include #define CREATE_TRACE_POINTS @@ -3092,18 +3093,22 @@ struct cpumask __cpu_possible_mask __ro_after_init struct cpumask __cpu_possible_mask __ro_after_init; #endif EXPORT_SYMBOL(__cpu_possible_mask); +KMEMDUMP_VAR_CORE(__cpu_possible_mask, sizeof(__cpu_possible_mask)); =20 struct cpumask __cpu_online_mask __read_mostly; EXPORT_SYMBOL(__cpu_online_mask); +KMEMDUMP_VAR_CORE(__cpu_online_mask, sizeof(__cpu_online_mask)); =20 struct cpumask __cpu_enabled_mask __read_mostly; EXPORT_SYMBOL(__cpu_enabled_mask); =20 struct cpumask __cpu_present_mask __read_mostly; EXPORT_SYMBOL(__cpu_present_mask); +KMEMDUMP_VAR_CORE(__cpu_present_mask, sizeof(__cpu_present_mask)); =20 struct cpumask __cpu_active_mask __read_mostly; EXPORT_SYMBOL(__cpu_active_mask); +KMEMDUMP_VAR_CORE(__cpu_active_mask, sizeof(__cpu_active_mask)); =20 struct cpumask __cpu_dying_mask __read_mostly; EXPORT_SYMBOL(__cpu_dying_mask); --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 425702E425F for ; Thu, 24 Jul 2025 13:56:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365395; cv=none; b=ccy6zXw6covwm9uBh9POwH8Z+cTNp6VoswutHm3juQ/subQBS6G5JZzOcVzgT5nZkHZ7dqulYDoIYV10fnDVfpsk6VXMxcRlZnirJ44z9EGE9lcJ859m5M5qu2O/YIr3yWzUQC3EgTELhRo2gDE8F7BYWi9885o+YFtjU5agNOg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365395; c=relaxed/simple; bh=ghY+GwpjKzXQo2zgURX2uB3oB2874ijEbWShVaN08k0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GdcH/o0yjCVk74vo8ZFhoO5juFjhwbPc+MN7YHCJdg0qNHvuam3AbNeVp40q5oOVdyD6TferWJcHFg6rHoXnvqh1M9w2Tia5WvC8pyqmQ1EVbJ5IClGGup/gwLgLg+9XP8S0oA2vG/HNiIttQPUSaRFN+nwj36z/nMnHWzRsXyU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=rEOHDd7Q; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rEOHDd7Q" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-3b49ffbb31bso722751f8f.3 for ; Thu, 24 Jul 2025 06:56:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365390; x=1753970190; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SReSPaHbR3saXb697Yp9wPF5rwCm4qBMUK6NGh7oWew=; b=rEOHDd7Q8N2mYG5T6Unnixnoe176QqAN/bsTATidQzaTXYl8x6Fl7kfvxRo+ZWK4pc qMPiNcCtEXI/oOonec1lsGzrOXHoDqJ3VDuKDkuiRI9iifVqADHi3VMHybE8rEeRnfT2 craY5TpZD6e5/X0OKbBzvy6zU6R5MiPYMHWfNs9a8ertibJByaQ1NYIaJ6koM5ZnZ0Sn 7NpwjIqHtMAAtK6Y5G8b20QQ9wWOoneaAVnyoKgbSWe+n7xqx4hzWKiNTIIeQU3fJn6l eshPWsHMwEdHl5/6TtzTyIIVGndSQqVeaTyF7w88+qvU/tpL7QZ0qI2fL+YnilChs3qE Y+qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365390; x=1753970190; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SReSPaHbR3saXb697Yp9wPF5rwCm4qBMUK6NGh7oWew=; b=PQ5WiPsdK2DFxfHTPYiouJsL+za4+sW7q66VBylV4yyuyUKmNiDHzZT0+2fb0YMuEI SPm7R+ZQxyGDxn4+F4RhqL0AXZt1neIx8dOK7UtVvng1MXGdWggH5aCw+0yMkVq/FudZ SZeBZ0repHYNis/VCd6E2tJ93DbET2pQAELZtMqHpJ+4ERp7sNCTq1sOMYGTF8gofhy3 8yVP6d7q2yA1vGF4170ABsCu7wDQh9LWBzM/e27B2NlFR0NGv7rDEgCpRR/OkppBhWYS OWe8Ti2z+FPYL5cZV/ZvjTwoxAef/bRRDkq4ZMm9iWk0crBsNG39AS9SEAMKmNKa1u3r /R5g== X-Gm-Message-State: AOJu0YzEQh4G4RtEYWbxMiKcZ/HGIFF7zI81HR7+PqPDx0G0Zz49AZTM FRDv5n29eTTyKhA3oth+//bhVIdh+vqXy3EyiMwk7hbTQVz1ShS//srMQ2RM1/ThYFFzatAAvTs MhQEuBR0= X-Gm-Gg: ASbGncsZ+exwnCfhkDWMVwP4MpKWLMsH8Kqnu9mFHuyc5DeO2l6infxQurA5LbCSeF9 ERXKAEv+LRy1KTs94g0pRBzsPVrpd1r3jnvuDXeVx1uXVDsx2ZuoqwsEJsDa/sxCMDAI08PDtxZ u4qn1MEl7Tq9dXw59NW/3uTahigE/+ZYTlbaQhVHyP/NIwYSphlOjm06iVXT0rN7M3pbvfKAt3O PRHMFFq9sH6wfapr1GKBTozLKF/rDW6+xaS/ojFw5BLQIpEHEfWe5ZDwAof40GSUDQpA3Zx21kq pB+qw2N1mZkql0k6g/CebnQx0LGe4ySbCsSrMtFjvrWxqdGSKkANSw20oKit28D3BTWyhkP+XN7 3iDXXyisWYN8mCp9nBgeov7s76dX+Cym+S5FMU4T9pVBOdQFn79LDN1XxRWNsS1V9h/a2KvBbAO /A3F48pokbzDBG X-Google-Smtp-Source: AGHT+IE5OpzTZyLft1dF8PAF1zWD0A9y1GJkIKlmiY5JcqmC3+aHq3C9hKZiU8MWr3uj6ilv3EjyHA== X-Received: by 2002:a05:6000:2c0c:b0:3b6:333:256f with SMTP id ffacd0b85a97d-3b768f27e15mr5395112f8f.58.1753365390310; Thu, 24 Jul 2025 06:56:30 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:30 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 09/29] genirq/irqdesc: Annotate static information into Kmemdump Date: Thu, 24 Jul 2025 16:54:52 +0300 Message-ID: <20250724135512.518487-10-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - nr_irqs Information on these variables is stored into dedicated kmemdump section. Signed-off-by: Eugen Hristev --- kernel/irq/irqdesc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index b64c57b44c20..6d11b85be2b3 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -140,6 +141,7 @@ static void desc_set_defaults(unsigned int irq, struct = irq_desc *desc, int node, } =20 static unsigned int nr_irqs =3D NR_IRQS; +KMEMDUMP_VAR_CORE(nr_irqs, sizeof(nr_irqs)); =20 /** * irq_get_nr_irqs() - Number of interrupts supported by the system. --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BEA82E49B7 for ; Thu, 24 Jul 2025 13:56:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365397; cv=none; b=oMCoGgV40nB52K8l3gadRtIkgZKz2Nhw1DdLPDYNUm9sSKtxakJqAs5MiorAvNTy/9Ugbfu7x9d4WZXADlwJk5kNWxBGbSzl2ohvowqM0JKD8gTlRzK6n0s4yUVOSJa9GepcgMT2teu9Uim3W3mg4KYuattgDz76h+Ptgd6jyM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365397; c=relaxed/simple; bh=YrGjiFMH/zlkC3aj1afXt5OiVcA/uj0LuVvyhAgKIeA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AG0V0I8moZcIvYGFutY9DbFzZO4Za747Uf7vQ9WeOi74UmdlBPs9z47FUK8t3oI4mNLA2w1ovzcDNSrBmbby1b5COQlZe0x8LJwtet3AKdXaZ+aoeqp3H2iFy0vk7gQ7mUIiTMlJaWwULTcyA8hRvMhvjZAtiD9Xd79tdFGIEOs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=hL+cbu6y; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hL+cbu6y" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4561607166aso7021895e9.2 for ; Thu, 24 Jul 2025 06:56:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365391; x=1753970191; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cFMrD7tjY0571sMCF+ur1VmM8eA36pvQygKXmIz05uw=; b=hL+cbu6yP6EjGyJww08MbKFjb+YHPqZ7YRN2X+iaJQSFXXSoejFtRUQUISGeGk3bnT l4Mf3gBSOeQVUcf3zkL0cuXVrR7T6m6I5BZmiqKv0e63ju/1voNOkmgIC5khxZFfZqcp 6kMDmBdL5IZuYb0WxFzgvRnu3IMyj+HXD2LjI44tjwIJoOS/cZ8FclMf9WupAvrKNtza Mlx4V53ttJVOdBW+tWvRS2uZhgZ0UsJpdg+juC7/+pzmSFpUq2azjNcvDQmjqA0NuGng w7rYBsSgNtZJISnIcSBRNSMSguYIQCYYRDLA25r1LhK5sR2dkhetmsbw9M++vwI5m0vi syMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365391; x=1753970191; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cFMrD7tjY0571sMCF+ur1VmM8eA36pvQygKXmIz05uw=; b=kRw5Mi15IFTtAeBHgCYISS36kzFHpWhC+bhuXs2o4nSPTOp9oUabLfaR9iWSBzYkR3 L2vq+ohO77GkMQgO78fRpCk1ie628qjcKJCsexbVdNFcgCadACyun2RTbKDDUaf18vG7 IDSSCOJ6dd9hzSLeLTE7s5g1Dghc8NcEh6sC6y0RH+M6FqRHLR1ztn7Vuu/jJ+P3P4vi KLLuQBUvgLD6LzFdeOQ39ruUJPETyIOuLER3uuouGCYQ0NEHukI5DnZYsq3+kcANSGKj RB4gBUU9gyMZru2ZeXzsVrJ5XRTzTEurDZHZ1Mra/uKLUXhOpQ2hwUbZnW0Za1BUGwWH YHHg== X-Gm-Message-State: AOJu0Yx1gC36/A1NYR770/E0MHGXWQrU3EadGVZ09lYVbfsv6UHL2kEA HaE6NWSIlXuXnNjSenA3Mx1YaOuklXbu98boYm04Jt8X8QbxTYhz15imd1NX5EqvEGrRIGIxcxE 9FN/5VG4= X-Gm-Gg: ASbGncsttCzitSdmIr1aqnHyCRUv4K2foKV+dygn/Pf3Dh+aD4D82zhVLtSCbHAXi5J 0jVfiAU0pR4TMJZWj7pUggfVquO0RpQNg7l/1VHvcpqBUXJJ9lSpCo12PYFl/s51EEIIkLhKhHm jjh8+A6S7oEL/+nGbN+XcMGH9Yz2UBuNVURFQo4mz0iGh8aTq6DdDa2xMgKWBFFuLVeLpK2b8rJ UsNkgvYCaQyrPIyVffSlRiJkT19+kRU5ROfcpROwiIHGjgVWhVnCJE1QmsW28grnLkr4XSfvTMc fexRLsObzb9icPL5hRPF2hqUdF1uPP491PtH/e3Ir8SieJAUQAY2tD4cUgV0pjovWR4/csLP+de TLzD5+X3cArl9rXd7FnAnEZWOTSU9zrQ/mYj4fIYCxXMo/kpPZpq99yHiVbObq+L9FXMvv2BQCj mK3IQY7h8B2MlLRlRr3ERuppQ= X-Google-Smtp-Source: AGHT+IHYV/rdyT8foqBo51VlSPNSFrqLVd1yTjWzm4T+7ubMqxXGaXLoYsD4QdIBTbjTZBYyuCKPkw== X-Received: by 2002:a05:600c:3f07:b0:456:1d61:b0f2 with SMTP id 5b1f17b1804b1-45868d80dd4mr72372095e9.30.1753365391122; Thu, 24 Jul 2025 06:56:31 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:30 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 10/29] panic: Annotate static information into Kmemdump Date: Thu, 24 Jul 2025 16:54:53 +0300 Message-ID: <20250724135512.518487-11-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - tainted_mask - taint_flags Information on these variables is stored into dedicated kmemdump section. Signed-off-by: Eugen Hristev --- kernel/panic.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/panic.c b/kernel/panic.c index ccee04378d2e..fb561a2fdb59 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -39,6 +39,7 @@ #include #include #include +#include =20 #define PANIC_TIMER_STEP 100 #define PANIC_BLINK_SPD 18 @@ -56,6 +57,7 @@ static unsigned int __read_mostly sysctl_oops_all_cpu_bac= ktrace; int panic_on_oops =3D CONFIG_PANIC_ON_OOPS_VALUE; static unsigned long tainted_mask =3D IS_ENABLED(CONFIG_RANDSTRUCT) ? (1 << TAINT_RANDSTRUCT) : 0; +KMEMDUMP_VAR_CORE(tainted_mask, sizeof(tainted_mask)); static int pause_on_oops; static int pause_on_oops_flag; static DEFINE_SPINLOCK(pause_on_oops_lock); @@ -601,6 +603,8 @@ const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = =3D { TAINT_FLAG(FWCTL, 'J', ' ', true), }; =20 +KMEMDUMP_VAR_CORE(taint_flags, sizeof(taint_flags)); + #undef TAINT_FLAG =20 static void print_tainted_seq(struct seq_buf *s, bool verbose) --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E1202E54B4 for ; Thu, 24 Jul 2025 13:56:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365396; cv=none; b=nGi2rDUx/W1WdVdWLN6HjQRRRgxEeWScUbuBMmXUbvSwVohgrGtPytvX7CSLldvgyeuNTvjU5jILeIAG2ZsbtvqnMuqj2edLQv5swPaYvIS02y9lOSuiGaXQhVEBTd/1nnygWoJPkY9Mqlc0DCdjRrW9v2PB/zOlad7SUKlM8SE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365396; c=relaxed/simple; bh=lInkchUokjBe+FHAH3BxBiq6Y7tXF29NidQLxKe+PNs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kVjB7PyOiKrulKZk6aJ1OPfj//RQqzzQuzol0hM6QvO1KoL3R2rwtm4DbxVhYmgF//NIhLfv+Tzq6PxwJ3dEuFYfuQm9erOrD/nxNNcF+5dW9HSYHs7+E6zwqfLkr5ZbtPa47GcwUptElHKhDQl8Bodeugeaj8tmRBrJK0ju4w8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=gW9AcyqK; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="gW9AcyqK" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4538bc52a8dso7181785e9.2 for ; Thu, 24 Jul 2025 06:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365392; x=1753970192; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rl7MPjMQQR9YynEjNt+gG293fesASKmyZt5GnlBVdKk=; b=gW9AcyqKuSMhUqviT/CaEES5gWyFk0OxnCjCR0DV8Rfx02S0IQgPMd6CCa6dOcVh30 63+5SGga433jpyLCKRIXeF4x+RONQMfgfnRhuEXYSrdOc15P7ZP6knymrDIPSnlOXUbc zFBeJYEvIP+0Q6l8vESKKOH7mvgMS3go6yHjeswsqDv5pCRNkBsMaFUpGolOHFcK9KIp B6bRuQK/BFUJdswR5pSmYLkG3M9hemjwfzoAjOdEICNheo8uqwkwqNhLV8X2BZObm5mV YQDLMYBBmiQ1th6CMa1aSDiOzN50Af38DcFCS6QDL1+4TAlQC9tZri6Kb23R6heF4d/x wrYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365392; x=1753970192; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rl7MPjMQQR9YynEjNt+gG293fesASKmyZt5GnlBVdKk=; b=Uf+Ua3yaquKBylOeJLs3etWBu4wxm6y9C5kXvuLwAst7VQ+e7/Ut/khoLqIzskCUPM iBAMrIOs79J4qQhF5/NGOjk2yh/2T75fhvyezZZtgbk+CcVduMTvKNTkRUFQZVxOTW8y wJ9EjoZrSMmzjZIfDhEmDHosMo/cWtKTwm7IfKkOTDUTOM+a9KAtQ+2LBG5pk6SPUOZi wNxJgv48e5gsFJhqMEnwBquLdifySbyMOusksN3hNUBHR2FTbygzBWtYmHHMKG0IGx8D PxD3y7zYv/BzRxyEjLpZ6l+UOY6LB1L6AKIwSb2SgI+v4KsaHNLlQvD5I/SBrImgeRu0 /GkQ== X-Gm-Message-State: AOJu0YyBo36eNnR9DNivBnEZCFJ/oa9uZW+aucnR5/d0wyokErDHPo77 6BgcirkfkA3XujE1p0f9CnUo5me/LfoGY03cHIfwM0PJH6ruVvww1a+jPGO1N012c8C25j8TzIL vRmY3UEE= X-Gm-Gg: ASbGncsp5fqyGpvSsfzE/qKMbb2I2f92MEARp/cDvu2OsIMz5OV6KevD4SXlautOzGx NvFvssEmLKvrF7z/rKoWN+x+/+Rd2x5yFDa52zme2+RVcyVe4G/kOSZvb+vXkGBkXp+OSXvbBsK gXZTPOYEG0OKqcrfRcIQIh9PFWzrbU7UI+BZAOJSyxzxbwmTp0Wa4zll4PT7t+8fIHDYyIRcF4Y OUmbY5tet1beZN5iDg9OXMSbNFaczGTJA+k+dNn8Z+q0alMvoL29H33wBAe/4JfXkT7ml6/Znfa c2AMD00BybUbQufIdekSixwy57nzZyoQiUVzm/J9Nt6i1SW+4/H6dIofffJQE/5ZB7JeAHoXmI7 FG5Z2XuntxtQNwpxLyzyRgKm63yEDoDQbhU/VUGUa9FHXIjCYhJx0nkLqWDDcHkEVVzyzGE4bWY uBnOMOpBlGGdr4 X-Google-Smtp-Source: AGHT+IHonQ82jnLO0p5HYq/pDMzB+6N1t6DWFVzcA1CVX2U3nXqH6sJ8SaBoH0rb44h0xr8LW+w4sw== X-Received: by 2002:a05:600c:6992:b0:43d:46de:b0eb with SMTP id 5b1f17b1804b1-45868c99c85mr63756925e9.12.1753365392038; Thu, 24 Jul 2025 06:56:32 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:31 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 11/29] sched/core: Annotate static information into Kmemdump Date: Thu, 24 Jul 2025 16:54:54 +0300 Message-ID: <20250724135512.518487-12-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - runqueues Information on these variables is stored into dedicated kmemdump section. Signed-off-by: Eugen Hristev --- kernel/sched/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 2343f5691c54..18ba6c1e174f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -67,6 +67,7 @@ #include #include #include +#include =20 #ifdef CONFIG_PREEMPT_DYNAMIC # ifdef CONFIG_GENERIC_IRQ_ENTRY @@ -119,6 +120,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_update_nr_running_tp= ); EXPORT_TRACEPOINT_SYMBOL_GPL(sched_compute_energy_tp); =20 DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); +KMEMDUMP_VAR_CORE(runqueues, sizeof(runqueues)); =20 #ifdef CONFIG_SCHED_PROXY_EXEC DEFINE_STATIC_KEY_TRUE(__sched_proxy_exec); --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00DA42E2F04 for ; Thu, 24 Jul 2025 13:56:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365397; cv=none; b=sycRZifbfInFLuJX8S6YznFTNYpzruRgcakR/S7QY1wOFJ+QWV0tjHsH3ayJEgTTIbpytCXzA8amywF9QGmI0jpqHMF/T9Ixcr1b9MHcmnIlC+6lDCRi0tU++TU57/cqvwO8nfwdOVR9JKnxDOue4ApafDRqXjFomukTpM/00ew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365397; c=relaxed/simple; bh=Yxy1SBIj1dJtqJdo+SY4u8s4+niserlLQYp3eIctd7c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h5wRr9IHkBlYEntnViGPPRRaqml3Ozvhn0ezVtRIqP640uYARnnj3pk12bc5KDLCehawi5MJGXa4Q9l3vlhY8VqdonxLqf0bShny/yCLEezGgDVyEDTE0epaGOtJTYY68n8QZIqH5pbnbjU8leeniMdeEdRW6ShXRBAA0WmAiwk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ARqjK83l; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ARqjK83l" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-45634205adaso5030405e9.2 for ; Thu, 24 Jul 2025 06:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365393; x=1753970193; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3t+kxQ7dPGtocO2eml/1QU47n2YVx1Ic6Vfv+oiY3pc=; b=ARqjK83lvYxNl8Lne8lZX/A7LtPSOrgVphMfQnIg2EwWyTqXQeJG6JHMqN6ytAYYmh PswH3oHdlWDuPJh8SsW+P3uquLU81BpG58SddVBBy0Nn8UlmV2OzuK68hgaO7EUDF6LJ TEnEdrn82pEYtS/XaaL9kdhATZdZC9Yw/1tiUmuiGTcBB9senuRHJzm2RSlloQfSC0KV 7x+0pMdY5UUIr/s/6C3/n1DWlOmWVWTwWt0PTsVKNnVd5GC2vbkt0wmv2vzKtUF+G6LF Oke0h4sskYOveHCn+yARbBb6k9QMauq0FguiI1vkdtqyFqf6DOk2AZaUxJEtoIPheBc7 +uWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365393; x=1753970193; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3t+kxQ7dPGtocO2eml/1QU47n2YVx1Ic6Vfv+oiY3pc=; b=BX/vgBzRFZiRMddBsI4JD1piw5fMfuFam7XUGh4PgrJ7sRoK8IVbMFB9Sw7tLcyOSL s17v5jN8wRxRHAAp14StR4h1KdQL6obE12btJLg2CXCs8G+qAWDH3I2GcYwLsqQuM4lC gmS3VYLOheTgy/7r2nYCd2NI7yIKa892iKith3InYidG937gKbFFy0/Lv6I3HZikk+oq hR7N9IXH39T89epYbNatzvjrUiOC6xB9buH+nCtZMbjGWP5jjKpvDdKtSQSZl+rxnmPk 6q5rJjXzK1UqCToAdNXcLpX4TL85PZSaDto2fz2yHuQQQ3Xwdf4I3rUi+oI/yi63LKs1 Nh1g== X-Gm-Message-State: AOJu0YzySB+crvr6O+xB8+I6v9n92NyuHMXzfNmaxtuC2g1zv2jzfz9N 2vLTCC9Jgn9oiOA3zDlvRMOv0fQqqhjkPefhhvIAcsCOao7NFJQ25DiP4ZYO/va3QiLTUZn7Ujk htfk4N10= X-Gm-Gg: ASbGnctGJBJYhRofTxULbmvcwT9nsC92DLEknnrGk5vRYMpc0m9qCEplWAb3kq2cy7U qYCOW2tJy+QLZ6x8s7vUqONnlhAlruSDSqUmeA+WosF2wSws8z7lm1SvEoNCTUYm6wVdtnJTyaU osAZ48Fm54S4SfGVYiXmXzDPerh2qLtSeQRTOaVfGeEYfFtQ91TCdkM0EHhPfMLhChnz3NDuexu v1yYFgCPIoZ4xG0q322p1eLrUwMf1E7S3M0UEMskD+o5mXdhovDBI7s7spLKnlSqiIxFhdOKq9r GIcSVgpnr8DIMwOWmNGMaVaAOJB6GWX46nSh6Ce7Ou52NB33muv1/710A3RpwzYqorInx0huNCB l26/CE4djxgcccwuZ8emdPMF2y44zEc2TyAbkdikbf7Hed4sf4mHOHa3lji31Ca8yYiZ29oIUjq 0fKXmbzEKbbqni72ZeMo5lVNw= X-Google-Smtp-Source: AGHT+IFgnp7J9pcZF45aCSKJ4GVrrhV0572AUoK1dVlyY1LCSR/mU9Z7mKYUQBRdiPhCDw14ZigOTA== X-Received: by 2002:a05:600c:a0c:b0:456:19be:5cc with SMTP id 5b1f17b1804b1-45868ca72d1mr74457525e9.14.1753365392991; Thu, 24 Jul 2025 06:56:32 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:32 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 12/29] timers: Annotate static information into Kmemdump Date: Thu, 24 Jul 2025 16:54:55 +0300 Message-ID: <20250724135512.518487-13-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - jiffies_64 Information on these variables is stored into dedicated kmemdump section. Signed-off-by: Eugen Hristev --- kernel/time/timer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 553fa469d7cc..a5698e3ace2d 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -44,6 +44,7 @@ #include #include #include +#include =20 #include #include @@ -60,7 +61,7 @@ __visible u64 jiffies_64 __cacheline_aligned_in_smp =3D INITIAL_JIFFIES; =20 EXPORT_SYMBOL(jiffies_64); - +KMEMDUMP_VAR_CORE(jiffies_64, sizeof(jiffies_64)); /* * The timer wheel has LVL_DEPTH array levels. Each level provides an arra= y of * LVL_SIZE buckets. Each level is driven by its own clock and therefore e= ach --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F13212E6108 for ; Thu, 24 Jul 2025 13:56:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365399; cv=none; b=dYxBNGiNvNuBgcRb/v36ob9uAtQuRZIit+5z6YLw+yGR7Ny7T89147YFZhmYGQyhYaJDYjNdmDcWgs+++JwtHhxNbO76y3MKWiejZOopv3JKVeGhjvH/PtOCsB0wt8Ng1Nh5iHbtzUq3oVLCol4DjJEK109BIiBkcOMKJIAUmgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365399; c=relaxed/simple; bh=QpOyX3O1zVluz5hSldO4dnPU9Pz5bkE/gs9RkenFruo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UibORWmlQfeDUfu2LI2oZK5zHxVQop1VSDnnk6otDEf/Z3Cvel8T1HCL45kre3o1AmaymHrHh5jtBPnlv2DtMnob0yfX5t1bI6rkizMuip/rPa451xYuLFLwYv/Dbnvq4cmrXUYvWIYDN+dnK3m5eU1TxHBOt4ks8sh4LMBOkSg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=NhHBBf8J; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NhHBBf8J" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-455b00283a5so6422395e9.0 for ; Thu, 24 Jul 2025 06:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365394; x=1753970194; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/6EjHBZibILbBUp2qJIWYHcXS7kn/hLDSQS+TJg877Y=; b=NhHBBf8Jzh2UWPCgsbFcY8aPFwvtxFOq737cLLsrQCZmRgkKkfwMJqNysXsBL8QsXC qmzgwjtJVYsVGW89ouotrXqKPHH++Kh+n8fzAJGfeTQQgN3xUx8umehWdVe6hxnncmui vMMx7OFls9lkmSMYrkbutgmBveGsrwvyQbxtNkw54UmbUH8TGVbf+pntg0yVwqDgKKpp sW91XbQn7lQRduhAgmkL+m0wfWr/G35EOLGF3ls9tPJArHfaRx2kec+lQcZd5sYG22Ty VQjkDwvKt34FiJcreuIkEXHvXuP69LMFBp1pM/55KiGjJ4nmzQMUSN1xoQGuC6LmZbcE fGNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365394; x=1753970194; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/6EjHBZibILbBUp2qJIWYHcXS7kn/hLDSQS+TJg877Y=; b=CZrp6fprjPTz1zLhxhdThXJq7p3T01NXwxc/XBt6UF6vXvFVhODKzZ3diHjdXhTDah jZ3vatPBLgitK6TB3jwwPSP1NecThLXnE65r1xbPFuH7yBexKJB8wejnyEURG5dOs9kP q6VTAa2S61YbltL/ec3iWE8KMk6sbufQT+g1TjjOxSa2qEg0Oz0FOc9YUvhiGFUppmcg mYGrobc/9xvDc+D0i7CkaXStvSj0ByEiuAVuo9YAkC+1l60sX3FtymGIAgVVrdg9t/3C urR2eObhCA0rMTA7cBq35qrAfmZ27FPXbuMmJtBBsV0UMBD5gWKZG35icb9f+lbLHaWG X0Zg== X-Gm-Message-State: AOJu0YxrxOuzJWQN1T5h0fu/k5FguapJTxV1D5qEENbQdl7A94+2FZno UWbZA4zEqgHsVHOvd/zBbbtdJsrRs+/tx9UmBYf/XDCOJynV0UJSTCZLUfyqazywINQGmxxXm43 hD5xAL/k= X-Gm-Gg: ASbGnct4QW0TJZomvgueA9R5jDRq8+AT9EE8Cf1Ov824E1MowcJZvt6xiduB/dOeOJB 8yCnEMyVyeDqQi2SXu9vp5X8PPX2uy3ju48pkx32KbWKWmVm0dzoby78iaEbcwTqY4+RMcexz6U gczHx76l1v1lYq15GcrZshPPcSOD/BoGL0Yr9SMDtuHzMOa9Y7YMQ/AkvJPcaiOIWpllCPwIU3C UwrXpSStrIs/MumlQUbPxGQYB9s4FRyYQbCrEO3eE+Y0DoxlF7m3yFdENaszuapCB28jLtj9+/7 n4/0LK341CXQPwRwt7s3YbZEZGyNsVemGfJVz07LSPfTuP0ZqNHL47C2EEtUHxfYa13K5fvH70a sKj48sk5ZRY2AVMqxL1oUFWAWP71BIjX8Iz0xYUJwHl5CE9DTilqHdVJbLL19GNGzCnV4UJeBrF BmwY8l7M6QTgBx X-Google-Smtp-Source: AGHT+IGRlGdpZ28v11nrKuEy26SoaDmKeIQI1w12F1VyMMK6OUtkgi6ZkZkyO989nTl8PB59Q+K5gg== X-Received: by 2002:a05:6000:290e:b0:3a6:d7ec:c701 with SMTP id ffacd0b85a97d-3b768f1ab39mr5321094f8f.30.1753365393821; Thu, 24 Jul 2025 06:56:33 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:33 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 13/29] kernel/fork: Annotate static information into Kmemdump Date: Thu, 24 Jul 2025 16:54:56 +0300 Message-ID: <20250724135512.518487-14-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - nr_threads Information on these variables is stored into dedicated kmemdump section. Signed-off-by: Eugen Hristev --- kernel/fork.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/fork.c b/kernel/fork.c index edc6579f736b..ae8ae9b9180b 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -105,6 +105,7 @@ #include #include #include +#include =20 #include #include @@ -137,6 +138,7 @@ */ unsigned long total_forks; /* Handle normal Linux uptimes. */ int nr_threads; /* The idle threads do not count.. */ +KMEMDUMP_VAR_CORE(nr_threads, sizeof(nr_threads)); =20 static int max_threads; /* tunable limit on nr_threads */ =20 --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2EDC2E62AD for ; Thu, 24 Jul 2025 13:56:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365399; cv=none; b=IkL6k/znRmKn/Tb6DEkLc0FL4pqjLUWDJdoccVcYFnWNV/m0Adjtz4S/q08jQ+AKvs/bmz5pGeRfBjORS614W7vC5EBdAeKFy6qvhQjbklaPIusCdFKanb6X4iwXk1EZ6nvDRZ+i+PR5hTRDthv4vlBmdTDFgUy8rKLMpj67gH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365399; c=relaxed/simple; bh=Zu6zHICMsbDr9iEKVVQXs5NvRmjCVnu1EFLIYvz+qoQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nZQ1q7YHO0HKjTejnRBs/eTevJV6VvgMmXzqK1JHVpFRUnqwEAIW/KwrL8VOEqUF9EPOl8K1gXAQyk05XQFTgbeR8vhYQ7jEY8jePYPLOtjhrysg0L8+ZRj+D9cVX1jAjBVasTu+sstBMuwyrzqueP0wjNC6SHagMnaWhNwHHp4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=UKo7RQFf; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="UKo7RQFf" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4561a4a8bf2so11782555e9.1 for ; Thu, 24 Jul 2025 06:56:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365395; x=1753970195; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hQxVhQs93RF2j5r69/kyB3XsN/D2SLMeChyoBk7vwm4=; b=UKo7RQFf1yxGOBkJXGeh+sfBmBXkK1H+4dY0li35Yw+u8GlIDgctfLJSJ4gGAGBQ2e GpkP54mAuQWTEzVRa637gLECXTG4LBD+H2Zf/5hnwBXl+0qVNriDWLr6BaX2ks2iEWBV Mv0LJV9V0FGC4soAaRZCjk8RfDbvKEMAJLRjcque3PsP8alr8TJvWdUYjSqS+DRr7vxH eLswUfmFOgcFn+aCBJClnkAnPFfGh/e2rEOVqJpIN08L56pFgqzxoVpF4AU3+fyoZ+1U +4/H2qvGelbzeKomwnogICW0n8OA9YwHGMszLF3omZ4MskFKLs2D5R7Q/FM2tWps4Txx N1Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365395; x=1753970195; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hQxVhQs93RF2j5r69/kyB3XsN/D2SLMeChyoBk7vwm4=; b=F6nTQEaY+61XU5j/D3nXcMSUk+B90gFYm5mPBaQiz7NPtGtk/J4Ob4xHe77hm50dnZ NI6ejeYVDwwtUzmDa9W+6aONaIqbx9EpPVOk9pfVClJHAosa6dXsqK+7XY2QhojXm3q7 QXHu0quTSZlTDSbR57CrDpRzGLAgSjJlzykNPzcC7QvYFxQIBsL1LKevy3EI7hjE39gC s+jFyjfhBUgki8GMUCcJyG0ELrRlmSuqNGd+YWGX9l5aF3ALvqNrUz+I5RXlQhNW6ljc 04+35M14TMtD8VyEr95ju2ZHjBqxU3zoiDp/En635RfBnDixKHWCW73eYJGvdYtLNLPj 3KOw== X-Gm-Message-State: AOJu0Yyr7cWwcNHJtt9BGZa1UO0M0n9hL5h9xkoJDjrU29glNa04Hozc +3qjhBGlObrN7IKZifwmvumin71XeVbYaLIhskUazjB1cJOFz49KQmQ5ntI9lq56YIpAzAi6rLt zAlOYcQo= X-Gm-Gg: ASbGncvWJhlZbpoR3w6SjB6YRzE3HDWgl7wfRTg8DR6/GiFLhmOzKlgz4nz1YdNNeAP l3fnEmBRLD3K0qkBsVCVPNi6CrGP/AsGLVPApi7HiWaeIHS5eYJQS3M/wkFOzneCyPseZNu9oTi kL7VVDLk5L8sDZcuQhVVCX6ZQ1TrAGLkmDrTLhRucxtQ7iW6U+v8/2CjZIXLJhGjZdDnmoKtLKI iSf05W7Y3w3bkVmZs81qAxIANbYfkWugVFd+SbrJpHvBTCFQWrTLUiXWNGC7/infhje/DKRoflt 18ys9SfVJRB52YN43x++mI35tuEBbIeKL6fsXqRnWJCrJ/XwDMHJAGp2roQn8VLj44ol77Nvrwd QfvgX0ED0HL1shy+8SM/Npsqh75C23ak6l6oPTnH/Coa9kWWfcUYnqEvEMbEO37qtB4kVBfJC/c 9RPAXsCTIfLwhn X-Google-Smtp-Source: AGHT+IGhn2BhSHWFDoozkG8rL01GLeqFkYg2AyJwTWU+9+XF/fbe0VNyrElgCTmDYeBHx6jzMQbcKw== X-Received: by 2002:a05:600c:4e4e:b0:456:1bca:7faf with SMTP id 5b1f17b1804b1-45868cf76e4mr72058865e9.16.1753365394813; Thu, 24 Jul 2025 06:56:34 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:34 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 14/29] mm/page_alloc: Annotate static information into Kmemdump Date: Thu, 24 Jul 2025 16:54:57 +0300 Message-ID: <20250724135512.518487-15-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - node_states Information on these variables is stored into dedicated kmemdump section. Signed-off-by: Eugen Hristev --- mm/page_alloc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index fa09154a799c..5f0015e27a30 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include "internal.h" #include "shuffle.h" @@ -207,6 +208,7 @@ nodemask_t node_states[NR_NODE_STATES] __read_mostly = =3D { #endif /* NUMA */ }; EXPORT_SYMBOL(node_states); +KMEMDUMP_VAR_CORE(node_states, sizeof(node_states)); =20 gfp_t gfp_allowed_mask __read_mostly =3D GFP_BOOT_MASK; =20 --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2320D2E6D12 for ; Thu, 24 Jul 2025 13:56:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365400; cv=none; b=U8g0GupQ7yXOSuxlCIxdhEYdO8rPqddcfzegC64Bx9ygzF3b/KU3JS8/aNCzCsBtnnE6h2EPy9ENuKc0s0TNz0bPX/XmSdx5esm3yohy7pltHno00k3zx9ny1nZsJgVvan8gPay7LqHmNCsWOYr6jBmIJcPQonHMXfN7m/w/qKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365400; c=relaxed/simple; bh=IV84GkIv57xHF9DSEvVSmOlbKrWfdF7K1awiWUW2oPw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FYa0v+rHGolMQrS3yxsob5WCu2Fj9DxyV911osqfdhIv1O1YdJ6QKjVsPfnHSI4nnVya/xKvUdp9k5oKarmA6bzmufsjncFE5BgSf4ATMVBenUmqpy9oUcLbMVzNqmvTaygG2NPLZvov6Mp94y+F0/C8FPNkg+xobIdadXmdQHU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=s/jVAsrS; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="s/jVAsrS" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-455ecacfc32so4578115e9.3 for ; Thu, 24 Jul 2025 06:56:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365396; x=1753970196; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qf/VqrIHQh0utzrTdiqqaO7yt4rF9Ojfq/Zu+7lemII=; b=s/jVAsrSDhWtyo9ZcV5kEKKw/dVAaBJ/nYU0zR+1TTbAwT6C90R6q4o2Fs7FTNl7EC JBz/zNnGUfo0C6rjn6bbYNcbu0h17l1DCsyIswwpqRE/Z5YJCnvklYzvHRVr7lDcjmK/ GDb7UtK5YfwNF6dr2d7lJriWdesbG+04Mp1FaNrZo5ptMuWFm+WWlilSdR9E9Y9TXk5L Z24L7aBFpqgoH9WNId2cx3yqQWpySBhKUZFcsPEZpgj6KtjqgWBiLwpTykACJL2KYoW1 w0EaD37ra0WKDf2vQ68AkDd3tApNxU7ohBQA3Kg9ZgN3ECcv988LGUYKzeUHIywN8eb/ fBIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365396; x=1753970196; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qf/VqrIHQh0utzrTdiqqaO7yt4rF9Ojfq/Zu+7lemII=; b=pJkUGkafyBJU7DEEVpWna+1YXJgr+vXbKPaJSt5ua1rfZ04unVpaqXPHaaviNveHF9 KbVkca3kg6l3obiH/BUHgG0BgNOrRbVYabwlszBElWj8v8FIg7VG0H2MjAEw1XsZL9/N +yWRN1Nmym0lNEgqaXmwrUlggZWv7uWnTlXPHEZmZsezMk/y+Zb8xJkU3TMurun1/P0M 0sqpK437scJESTmV4KQprjni57sVFBplhbIuIeV973JHpatzBiqEd8Y8v/FtPlnBve+t a5/YaYWRbBZ5BNkMO9qN6u6Gt9C/kJfEnmDIGW6lR0fPnDFFt7Ze4oYp15iAbCBbczuh x9bA== X-Gm-Message-State: AOJu0YzXmJUvJ5VABp/ehXEN3QP1aMXzic+t5wECayLdMNqyANcoRZzB NqveEDpV/OTBf8TuQ4AL/y2/yKA0GiEW9YdGrybw6VWl8QUHN6jGC3IitvstPMp/NXI31Ot/5sI p3jQaZOw= X-Gm-Gg: ASbGncvjqj5zRvW2xSnar/r2d5yZyjqa9odnZnYUnT3A2J5NWEVdGXgOeO3cYTUxvcz hZw94jRu01cnE0AF6AH/xTRb9QdVSdkzzvWLMmvXIRNVqbYJf5OF8PCyb8oaJyuT9rx2tGfScsI ymhxK/wf44CtHtBYnTN9tl0sfTDzorvgb8hsaWpv77WPfw7CAgOWmh+rmqq9TF+zU2d23RlfBeF LUfdayZhm+FEQYfH8O+eKrTP2AyfYJHlRcvRQO55aV7fVeyPzRz8fdFmTm4KMg+Swj78tpNuwmc vqjpqpIXBDzhkvelUzVpjNagR4v5+2hhrJsE48fSM2tScLNJHoBplbS6WeDrfW2pF+P0wDGGhWg bEXZrq85jiJAmFrJ6mWlcejfKFu60jRwhABJ3s8FRyceQLcmCQ/sLQPngues7MSIQOpO48CrLSh YXArqlr/4iJ5mw X-Google-Smtp-Source: AGHT+IFzdwFCiaRsVqkw+Vzf0TWhLQA78AFXGtgtYDTFYK39RF9ZemaLlLUrmcl7qJaLyA5hKTyeLQ== X-Received: by 2002:a05:600c:3b28:b0:456:24aa:958e with SMTP id 5b1f17b1804b1-4586a8cc2famr61338095e9.0.1753365395873; Thu, 24 Jul 2025 06:56:35 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:35 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 15/29] mm/init-mm: Annotate static information into Kmemdump Date: Thu, 24 Jul 2025 16:54:58 +0300 Message-ID: <20250724135512.518487-16-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - init_mm - init_mm.pgd Information on these variables is stored into dedicated kmemdump section. Signed-off-by: Eugen Hristev --- mm/init-mm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/init-mm.c b/mm/init-mm.c index 4600e7605cab..2dbbaf640cf4 100644 --- a/mm/init-mm.c +++ b/mm/init-mm.c @@ -7,6 +7,7 @@ #include #include #include +#include =20 #include #include @@ -48,6 +49,9 @@ struct mm_struct init_mm =3D { INIT_MM_CONTEXT(init_mm) }; =20 +KMEMDUMP_VAR_CORE(init_mm, sizeof(init_mm)); +KMEMDUMP_VAR_CORE_NAMED(init_mm_pgd, init_mm.pgd, sizeof(*init_mm.pgd)); + void setup_initial_init_mm(void *start_code, void *end_code, void *end_data, void *brk) { --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31D7C2E4986 for ; Thu, 24 Jul 2025 13:56:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365402; cv=none; b=pKJnaelH+Wh6ZnRsHf4VC38txyaXpptk15iKmvcNEGfychld23Bl0cL5Ckur01g7YzLdaBMArU9YsU79dZ2RTYlVw3ygu0Ikl0eF8EOc1nSFLKgDJaAAP95lthUXiUMF132DIHx3tkraN2T6qvLN+xGDyfC0ImyA4KSUuvvredM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365402; c=relaxed/simple; bh=kDQ1UVsh8/N1GCc/zzfiOopIyL3CRcZ04ezY899nhXc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UooL7S3JFaWwqgKmWAqgiOzRrRGzuTejm0Tj3Zs63GZWfV2VK+5V5fNXsx6yCeFZqJ7Oe/Abqr8hwOLd9ZOYrC520Obk7ccrzte5QdKL5zK7d7kfaV0xMLeQDzn04Bwag/Wu0NfKkdubtborh/rbjhhJHArxOEUWCmpg8KuXWws= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=mtHD+ISg; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mtHD+ISg" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-45618ddd62fso10931375e9.3 for ; Thu, 24 Jul 2025 06:56:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365397; x=1753970197; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fX4Svte8gqoaTLJ1gLDVO4a7qJdtBtTgEqouOAtsRZg=; b=mtHD+ISgSM+SUfi253ZtmszbOMyw9ORPp7cADqLUVvtUQSh+F2uKGW/HoI+6/G8h+b sgquvAhnD90ntjDcj493uMRFktkg0EB3wJdjEsJffTHNTqZvaBbR4T6UlnV63KAgJu50 m8mhqe8AUSug1EtN8ewwaTIHIaTaMF1/2/ELIKaNg7AZaxcfN+A1nTo23afrhhqnk0mc yzsgOXEQE7HAgnyWUvWTbiCJPteSDFEDgILZsOtDaEweLOzn4WmfwXgGka8te1qf8YjK qRU+D/j+Wfz273ZqaD6mk4O8BQRoVRpM4s3MPjVrrTna5m6Vj38zKVqQHrOwG1Uq1xQr d6UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365397; x=1753970197; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fX4Svte8gqoaTLJ1gLDVO4a7qJdtBtTgEqouOAtsRZg=; b=fqvxfy570gEfhOeGgFYQztkCMxKxQu80GEW3p9QGrd8WtjN4pNAHHMbiQdLE5RIfCA lIDVfnROhXUzJOjNfWr7qEWHbQO4se+f2ssEkM22dTS6icetqlIYIhlJo5p50aTrJI4v Ns5pFfXNBucHl0aqxd0UFhaMlFBYw//ywOAd0CREQqanKGymVaUu0eequQfCm3NIIwIu f9O2Xfqchq7tVIUx10TsXMJDACNhr6IUO79NaDyYYdwUiFZDobk9IpCphPW16mWw1Qr9 eTjBQ9aX9F92uSyXNskZ9NsS5LYVzayEsK78ifwKhUrcKYT1/9rYjdKJJvelmqkZz5Lw kj/A== X-Gm-Message-State: AOJu0YxWb5z2x1j9YAM661odW1bEas5WCpF7+NNyMk54+niAgYEoTYOR zLdJOoLAye9MGkjzTe0Tg8+CRT6rCqOZFnJ2JaTOsvz0r/NN9qX0IILxnLuPtIQTG4p3wlpTdxZ +nY/MWd4= X-Gm-Gg: ASbGncsrTU92zU3vsPy9xzqza7/bNHxiRZZLQhSdWBrXyTdBpwC7BA6hBmfIj0dFPXW sETYSU7QWjpx1IeJwj0c3a3Tl5TFWdFQgC+o928Ty7CmOGOw0FYqi9f3CTktGBzJtmPjzIeQm+e P3cV0mCU3XeC6oNfy6XJFI1enkq9bFc3rH2OqH7ir1fZV+fEpKQ4Zo3eegi5GqJj/qllDvwDKSI 22qmLPB09FyM6+VJU8vSBcBEe8tuEI4L2mPYAYHbwIhkVpA2NwgTUvpLn4pKxVQdcFnOouP8e7q Y/gVyeMEyEBI2VU8FVEJe+NMGXI+/EjORz8/faucPcgj/0OlJ4KVXiCTYQ345bztB/Ldak8d+fT gTXC+Ai9gI1yJLaqHsZUJKYhVS5r73DExke2tU0Nqf/SDOx4lUSsWhi/5xs3D3wOoMMbkw02IMi 7ZJvsx817Pk3IUED53ZPniv6U= X-Google-Smtp-Source: AGHT+IEQVvnmK8e1EDhTYEG0c9433X/scuppejD17sDlP6XiymAvLgXWbUNkWttS4mn1l7PUSu9quQ== X-Received: by 2002:a05:600c:6090:b0:456:18ca:68fd with SMTP id 5b1f17b1804b1-4587118251dmr22564675e9.10.1753365396747; Thu, 24 Jul 2025 06:56:36 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:36 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 16/29] mm/show_mem: Annotate static information into Kmemdump Date: Thu, 24 Jul 2025 16:54:59 +0300 Message-ID: <20250724135512.518487-17-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - _totalram_pages Information on these variables is stored into dedicated kmemdump section. Signed-off-by: Eugen Hristev --- mm/show_mem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/show_mem.c b/mm/show_mem.c index 41999e94a56d..93a5dc041ae1 100644 --- a/mm/show_mem.c +++ b/mm/show_mem.c @@ -14,12 +14,14 @@ #include #include #include +#include =20 #include "internal.h" #include "swap.h" =20 atomic_long_t _totalram_pages __read_mostly; EXPORT_SYMBOL(_totalram_pages); +KMEMDUMP_VAR_CORE(_totalram_pages, sizeof(_totalram_pages)); unsigned long totalreserve_pages __read_mostly; unsigned long totalcma_pages __read_mostly; =20 --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 141CE2E7F05 for ; Thu, 24 Jul 2025 13:56:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365404; cv=none; b=OcffIHrj9Y8pDmX1MWHy+JjtaZWWeUqXZw7hW0lLkEJbV1Q9awFIURHMAltK+QBriTKJPolv2xmxfAHlRUtwMGg+XlEu599NdPEX5HtHW3Gnz8Wh2vG2DSVdr22zlMULsaDUwy8urpvYRUfmq3JLvHOxt+vC8DP8UQEP3y3AFas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365404; c=relaxed/simple; bh=j52yzR7Gpkc2C7QzVnAL6OhmqWFXWx3JwzJVokNsTms=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=umAvOhIe9lAPtD9HMDLTCDjmFZNjyXurAe/igNSy7u1F8lFrV/i0gUNG90DZjq6YcF5qInMYXslLuPonul9HQniXok9v+kbpbo04bf+I6qakxR2NS3DEA6AGkMI6LQJjiI2R/pRXZwTuS5cjaea+5yV1O896pc57qXL57I1zDss= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=q+n07aCt; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="q+n07aCt" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-45611a6a706so4974115e9.1 for ; Thu, 24 Jul 2025 06:56:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365398; x=1753970198; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=phPxbutaSa2cHj8lQiAqRNXIpOiUr1sfgJg1sLmhr6Q=; b=q+n07aCtzLI5b5OprZDAIq8uAz3mWb20L+1xonnsPcouJj98jigrLf3qnMfoFVGfjI OeM+S05Brccvs8IcQCcBzyyTuTZArzaZr8h9ZMfyRrLigg0kpO725gQN5XC2ZzbVUM7L y0SjDNgVhz1kD/1GqaIOIxzY9rvg50jLnvwQKhgCp4qLn+r9PwtjQG5brJ+1iI2y9KoD kezpmDXrZh+N2x4Ohl6XzyCKFMsfeS0oratUTsc7VHeirpSYKt0fwdUtrXfb5e2FHUE3 cs7nx92cEbIVH0knZ4w6CwYkO9geZwstvRoJzP/BrqrH7YGor0OWRBqmLrF6Bzl6P2Wc fJuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365398; x=1753970198; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=phPxbutaSa2cHj8lQiAqRNXIpOiUr1sfgJg1sLmhr6Q=; b=mpy/ssjPd/kURJprkK0zfulJRo+SnJRCYzgxFeCzB+30IyPixCaUYoVI1XDst9sQoJ 68E6h4i+SpnK0b+a1Pzqeg7UbE/7S5TuX9Ge1rjKnBO7sOCvaQJOWGALD94qU3lVgY3c 9+Ldx8D09FM+2UpdhIr6LDZA0hnJkJ3ZeGMUZngF6H5HTsKzTC339PvteNvHvPyuyvQ5 GTrSESj4MdPhA+SzYPVUH5utZRCi66+QDlhR0Uk7JhF2YVgieuotsoxkHGnfaSkHku3s AFnraFtChM4ZLq9shmh2T5+9sQERtUy/pZz+mNUECTYQrNFpTJVCYMM8onPXocYfkm5n tTuA== X-Gm-Message-State: AOJu0YwirhC+faQwrvai+bvBtmwguEDptIi3+odEX5ivN1HbQiIUvmq4 HTatbrYA/rwkuCh8/Avo9Q11J12w2RFV0aIi5bxldvD11dqUxziCEisnjdc2jvtlX2pZZz6sw76 n/FCFDeg= X-Gm-Gg: ASbGncvXZKec92sKRcoova2dmasElcamFFs0re140ZBxJzQeRoD6aLPhazxQ0UJQMkK TDQgL0N/GJICB1Chx4tlcvlFbGIeT5AC+vvk0KBOJ3SlHg8d2KRpsBaSZrfbfG6zwfDLMdt0gJY O01BQ8UVEbxGcqUn9D84juEmR6nGPxhuwaeSuvGxJHyZD76td3Z5rEGC0BP/BwJcDUcjt/8AoC6 yznjW2gUBeWPxvQ+MeGStCSY2IdQuY2MiL3Fb0fcDfcwBCuFxdLcdSxh7WjCd18FXh0ZDmS6+pD r8d1FkyjNeyXDfkVUzgF5fgbBLNZy6E1tBujaVenrz/KaaJrXx3gelAPDHKR76osQV9+9OSzbyu VhX5oa0tDnVZKqGyif3zCUi8BAK8DcaDkCE00LDN8Jdeuy5c01bqEijFERYdDFlERONLywTagR7 1gz9JJgXxKwTQx X-Google-Smtp-Source: AGHT+IEzG7rA7SjcU5/IexjXqSf6MXBAUKpIcrbkFM4DkAzOo8wQtcA8euIhs0yEfuaDr3L1GJYTKw== X-Received: by 2002:a05:600d:d:b0:456:207e:fd83 with SMTP id 5b1f17b1804b1-45869ea827amr55222245e9.4.1753365397698; Thu, 24 Jul 2025 06:56:37 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:37 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 17/29] mm/swapfile: Annotate static information into Kmemdump Date: Thu, 24 Jul 2025 16:55:00 +0300 Message-ID: <20250724135512.518487-18-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - nr_swapfiles Information on these variables is stored into dedicated kmemdump section. Signed-off-by: Eugen Hristev --- mm/swapfile.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/swapfile.c b/mm/swapfile.c index b4f3cc712580..ac5a2307a278 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -42,6 +42,7 @@ #include #include #include +#include =20 #include #include @@ -64,6 +65,7 @@ static inline void unlock_cluster(struct swap_cluster_inf= o *ci); =20 static DEFINE_SPINLOCK(swap_lock); static unsigned int nr_swapfiles; +KMEMDUMP_VAR_CORE(nr_swapfiles, sizeof(nr_swapfiles)); atomic_long_t nr_swap_pages; /* * Some modules use swappable objects and may try to swap them out under --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 822D12E54B2 for ; Thu, 24 Jul 2025 13:56:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365404; cv=none; b=DiFoZzvhBv8DqDTYXpwYv0amQFxdSFl7jrkVCu5JCNSPxwGMba19uTbV1SzXJ2n9wkiwHkvUPmaDgaTpr/pq8W3HmY5/2wIPrETvu4xAxx9IcdwacT6ZrBLM5pOH/13j/4JQTXQS1amSY/GNiTtKmK/n1FwasopP2QPF5r55L7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365404; c=relaxed/simple; bh=17QGeEGZ9coLnHYcyt7u8QDI4NZW28xAVJJwsgh3bn8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RLypHw5EIQb79gUJLVf/Ycx6bSahrA/23ftfci400rAUcd+5Ewg6Wlbb9XDrkIGnAqB6NvEAnFhtW03bSyQF7TRfrGfVdmI37jbT3AcawIE9NXGYD11XNU5FJRau/NW2zKS310gxhJoO6fWLcdMnxxa1ROKOU3f3WYdT48Y2CAI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=C6mxlAnj; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="C6mxlAnj" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-455b00339c8so6846105e9.3 for ; Thu, 24 Jul 2025 06:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365399; x=1753970199; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lJKFOh1t0BpMtsqdCvtkoNZefWX67AppBNjz3MRLfF4=; b=C6mxlAnjxxjv8X3k7Jnlv4sZr9Pj4TpM/k4nKrykg4D0lOJYUyc523/PaxPNtpEJL/ TXdsZL+OlLgXOkacE0AtbuEMn4kpSzX+yHu9F2eDDir2xZ8YNwP7wPzFLOjiUvx0Xj9m LKLhOoAcHEXYVrjUsjP7Ga5v4BeuXxRYovBExttSURq+FqlMGJFitUcqGrI98yXatdGd SRAbA2++JzajT/CvO7GQWsAcy3obbNBjvf7AtoDaX7Ig/8krnLnaOT34aaaG16Lpv+dC GM52ktZzXM7zphMDsSTG9mUdN9y3OtIjMOOtcyA5x4tQcjZuMA8VQJ2wR3zQ+pgNFloA +AVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365399; x=1753970199; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lJKFOh1t0BpMtsqdCvtkoNZefWX67AppBNjz3MRLfF4=; b=ishhORMhgp3UOx6b483wfDV0QW9Db87FxHQ7/I9IOMEa1lll7WQn3EsfbtF4Y0ucXi 6enD4+PRg2MP5IqP+Bj+nCTMelSFmcPQeQSWm6M4sFPVfrc5pr2JqnBveqSBlKuBQP0K XL3bl6HGFjiUAwsts5rWHlNLENKbkrpayeZ9LHMOO5H47otAyLVci5iQ9JktWLg5vbz0 GiE9RueBUVvY5Ty8zMnyUI+k4oUaW9tYq8jS5pVJvzyRApygpiAchy2AFtBlm87f1FYM FtRXcyyJuP6wui7KqksVXQrY7Fv0hqtNR7lzTH0IpFdKkt7+xtgBcRZXipHoWB5ILzWZ AUeg== X-Gm-Message-State: AOJu0Yzt7D9QtgmoVk6dMRz66J0z/Mt/NtoedzkJtBd9QGxCSMhHRYxk spaJE4pNYAdDyios77E/Bm5pKs9S7vUf0DrOQARXMYuw4ncDppMNZcyvyZrspjMxQqGQ7ttB7xm dT1c6alE= X-Gm-Gg: ASbGncuB0rL+ss+lrP8c2FgEs/BwXYD8fgqJwJK1vqskwByGJtEIzw9Lq68XFalXe/+ BsXFKqSZbbT9T+hSjvbUxpoyq3v6atq85fBchlppp1rDe7EQBNgJsS5Zg945bphvT9NiNHjWwqy AOY4W1KVcxBPmHlo1txx8zG9LwU2txJhNf3IU/hBEK+VhGUx1wk2BoEHhTxEyX5vRrhX7l/fTxe Qei5DOjXxVTa67JPwZ1zmihfaE2aYpb0yMORb6zKjPot72S0sn+FxKvhfzk3sGtFGOGmdJWrQpX f2/or13Sqpq3NRMYIdTpXogwVU8hDIGRi5hQcIkKMwaTaWrLpx8m1Vb5wpDuiv1jaAIPaPojEtA Ar+aLI2wg10wrrGXRS8r0xhNewQwrHg1Ia/LLglQlq0PKvtRsAAP+yPMvTurrIlu8tT09ORcGOE vjEKZ7eUUcwNVV X-Google-Smtp-Source: AGHT+IFBpfszojCM9BH8+214LoTonUL/68z7rgbLH3wV7lPKq/S6zSGoTIX7zNxB5lRzwaUzCOOn2w== X-Received: by 2002:a05:600c:3ba0:b0:456:8eb:a35c with SMTP id 5b1f17b1804b1-4586ef5cdb4mr25803445e9.31.1753365398629; Thu, 24 Jul 2025 06:56:38 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:38 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 18/29] mm/percpu: Annotate static information into Kmemdump Date: Thu, 24 Jul 2025 16:55:01 +0300 Message-ID: <20250724135512.518487-19-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - __per_cpu_offset Information on these variables is stored into dedicated kmemdump section. Signed-off-by: Eugen Hristev --- mm/percpu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/percpu.c b/mm/percpu.c index d9cbaee92b60..0cfe4d7818e9 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -87,6 +87,7 @@ #include #include #include +#include =20 #include #include @@ -3342,6 +3343,8 @@ void __init setup_per_cpu_areas(void) =20 #endif /* CONFIG_SMP */ =20 +KMEMDUMP_VAR_CORE(__per_cpu_offset, sizeof(__per_cpu_offset)); + /* * pcpu_nr_pages - calculate total number of populated backing pages * --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 042D42DCF51 for ; Thu, 24 Jul 2025 13:56:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365404; cv=none; b=P3WaVBqCktLZ4IomL+iqX3w5hEfBlC7sQDOrOBAEkektOvyGyG82wdG7sKle4yCNLXvyEgJHK2q6q/T9ZnM3HJuealkXOPXTZXqpCFkXL9CfWqVtKmAtBuhpghFfekZDCJbwYcXDWYslWSr1pG86x3fZv/OdiMRVyY9z5MPz72g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365404; c=relaxed/simple; bh=+cBbT6O+Tv94TMabrjEFapPNfjw9qG0Ap1lk8pPj0JA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sJ3URfrfia2WDMLcpXPcUhhLIGdfdKBWK1/zUSmsd9mkY7XPgvEPg2xg68NRbUrNQQAkqn/M3cUbggWIELdE5NJLwS1PyddgdcPcN2hv9YNB1OoRnKdnGpD9kYDfcOUbStgV6TdpDK1lTJerGpMFzpO7o6A1RMgP8E72C2v++xI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=k8SJYDLa; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="k8SJYDLa" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4561ca74829so10973395e9.0 for ; Thu, 24 Jul 2025 06:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365399; x=1753970199; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tYTWTc09XiaelzjVtYPzYhjlFtDK3ChqlxDovLkTtoE=; b=k8SJYDLaVrQBu7nJiAugL1b+RnxDGdXK2HghIEILwuyhIuapFZ08wm2arPcsVtyAGz lRDnHc/J8Oazdnt9gudw2jEdE9opbImrUxArZNGpi7AtJuWiI9nCbFU1rljwaD/1FpSV N1F6hBSBkTmBUfLKZ6grgFt69thIZNzcmZzh/yNZ13ktqFZwrbxS2zs26JjExJqECzjX WcLGXjZAlG1Ccx/JPMdpzJjcXbXG9u6cb68AumCE5jJxPEzGleBkQV5IcyWD1MrLStBc 8kzj2RJYG6ld5yMvA0zKwyNVaEi77GRKspbDpkrtaXEuypVijf5rbr6mJAxYLAeafyQo 8z6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365399; x=1753970199; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tYTWTc09XiaelzjVtYPzYhjlFtDK3ChqlxDovLkTtoE=; b=BH7qZ8sG+dnIw/BgS9bGjveLexcYjzscoygChk6wJJH5gC97HOCd6wxOZFlfo57YO6 CjKoYR4pdoOoqqty+wzhVk5+OpwFUdvXTexYvw/s3AeqNh3olmbTUDqqPDeKmzGCeyln XnQGgF2J55dmRTModM/8spKksumBMgWwnFtdGOAe1N00iqU4BD2pWhbKSxPRrsP26iNU C4UIYYuJOG55bfqekgryil7YBSlxCPoFlPoINfV7264TUE7jgFxQKEv2AteCuSrU+JSz YWCOfLsLxZr+XXZc0bum7uDpHbGyhbb2Ev6wrugxppAz4yOW5vR0O53Oig7x4+Z18Fli UgwQ== X-Gm-Message-State: AOJu0YyvfOpHIORJuEh6tYWVOrLgyWZLD0tQBzxpW0hbLhHKbIqSIMfw B725+2Cmcvc6aruNsJadpzx/s1dFRBIhMSaic3YbnWQPjAgOY9n1gIKd4/oDJvkOOYwZhH43RCW 0dXqEfR4= X-Gm-Gg: ASbGnctYOl4+fetDMXoiRFaQ+vCe0FwY3+HHrVxkawuURvgMKPUrTJZzK4jYA9SWohf 5iTI/RD46BiddLIIeurmxwlVRAzmn6SI5//ZRGX0SrDMeel3ULb7bEVXt7vN9nPEYeEbLu2R6Ux azpQgRMx8ceYqU0wEvH1HwVF3NcQhO4algv1JvNSxqsylZVGwhZK/4nZwNlpMHGQJTKXDa7ZNVM hhriAfn8S81YqUgqt+l8MJG6IO5z/9OD9api40WDxaPt37UPoLzBPSIuopSiZUTPL/ajvPcN1rM r1oIGzqMRlMnDt3tZrnemuPZNtt0h8tpaAPRdsZimXMAAjFB38ADS090zkUWFoZMckZJCnmlNKv falnPzzluTgN56bj6WeJMbwRAV8Rxcxmhug6tM3C4aKEvYmr8FhtP5RhKRMdj1O5kq8q5bbgtj/ WOAf/c69+tvCkV X-Google-Smtp-Source: AGHT+IFkEigCZ6sJ1rjDkc3I8yrqrXhO4W8lU33Z9QEAlANeXLFiBfl+v0dIWKjOVtP26nHzmGjQhQ== X-Received: by 2002:a05:600c:1d22:b0:43c:fe5e:f03b with SMTP id 5b1f17b1804b1-45872668487mr2491595e9.30.1753365399512; Thu, 24 Jul 2025 06:56:39 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:39 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 19/29] mm/mm_init: Annotate static information into Kmemdump Date: Thu, 24 Jul 2025 16:55:02 +0300 Message-ID: <20250724135512.518487-20-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - high_memory Information on these variables is stored into dedicated kmemdump section. Signed-off-by: Eugen Hristev --- mm/mm_init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/mm_init.c b/mm/mm_init.c index 5c21b3af216b..fd577f988f79 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "internal.h" #include "slab.h" #include "shuffle.h" @@ -52,6 +53,7 @@ EXPORT_SYMBOL(mem_map); */ void *high_memory; EXPORT_SYMBOL(high_memory); +KMEMDUMP_VAR_CORE(high_memory, sizeof(high_memory)); =20 #ifdef CONFIG_DEBUG_MEMORY_INIT int __meminitdata mminit_loglevel; --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 099522E92C6 for ; Thu, 24 Jul 2025 13:56:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365407; cv=none; b=f65B8ethE77DYPOTni8Adh6jYlZ7WcQBsIw2+vTElAWP3inT2Gj5UDqvafZqTwhbXeOPlwybKbJx2nrGUTjzHrAmN8FOV6BQ5XWAuOJAIyJxK0sgd1z0X2v2Qsg3W1IadRVYeJeXPZAsfjISHq/QKalAGbUo1R50ufkP5l+6xl4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365407; c=relaxed/simple; bh=wARnIHcM6q6qiMPnn5loBslIGs8WDjRosQ7TWci8o8k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J3aIi1AMpqffhGamINYngNglmGRnhieZ0EtydVQW7Edq4Ko3v2B5aIfoxA5e0WNPIQnGy+xYThYVuC0FWE2fpEz13unIqAW1jsUfv2sF8j4cPaSTD15C9ysjW26mAW3PvOHsJVWFzPJEG0ERmlW+Ud4xNGdzr+9k0y9Br6DYKPE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=JOAY9+ss; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="JOAY9+ss" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-3a4ef2c2ef3so809559f8f.2 for ; Thu, 24 Jul 2025 06:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365400; x=1753970200; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ay6ISBVXr4RhwBg6A2t7OCdYp+NqRXGL2jP3qh5ffs0=; b=JOAY9+ssBL5AftLlTXlwCYP/JT+QP2lzmifqj13XQuxS3W5e2xCdZGZJnGOoxAJ+BH 31i11imIbD07KejKcMpa89wM3cs+YfFj29ONOHDQ7VaHrBWEbk8SU3hOpyQll2rGMs96 1WbBJO6uGitA1frzw/38lz3rF8qXBUsYBMeLOpuNlvl/9TgiJIzHAseN2dPAwJRnR7sn b2/QOtkcBzcgIa1Rr/PiTMLwP1DX5yui2tNfPlZXV3rV1jD6PM0Sk3O9pcW8OiOMaGvZ RbOvuf4JT21MCkQpb/L+SzfX8EOnFYRr9SCpz5xAtpIj9aMZHf4/6AN2HTCP+STXJ3Bb MVBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365400; x=1753970200; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ay6ISBVXr4RhwBg6A2t7OCdYp+NqRXGL2jP3qh5ffs0=; b=c+wbPArmAwUnmdkeNYTod3b/Ci4a+QkWuEQHrNGuL8EPllU0zO5zA7M5voMy9ApXE5 02cYYNPcWwESgZTRbyLEgTqxZLuuXBboWUL1atYavOC2njuWBn44Ugr3G9u3hbleUBMj o9mh4Ksqwoj0BG9BfwZnHliI4duQ4NzryA0cQiSSAw/9we9hvLkTsyuvkbtmN7u/VugU 2genxBy9yvMm5UgFmNdaL65ZafQFiyXGVo4lnkK2gOirpAwDH3ki8+yDfw+NBWRxccgI dF3fSNUBqtvODDKNnCRCP3HSpdKqLEvNbu+sddZ/JErCNeRk+Id1V8iEMdlH8cSv0UYC dxBw== X-Gm-Message-State: AOJu0YwrYV4C0SomhbPZ7PNv7/O6+Z1/SA9VYxWt3fyg9o9v6G0O3MTV IznG61UlajItgQu/n5Dzg3YlSWV0U7l+/8dmsNP4NdiZyzU9gd0DqJnI1r40NABvyUwvBSk1SFp HRUTEONA= X-Gm-Gg: ASbGnctDdjyY8YHJYU4XgSv3g5vu7gymHCnIZF5AW2HvY9S9FR4oiExWWepJi65Ro6h 5Gyi2Ak/geOL+nIPCKiQHt87WVBX9edjST0qqTtMUJgkhu9XM62e0Ml3u43oY0twBQMqYNzVmWO b1/lenfo2Cr7JBTAZd1GvgqbdT8SX56nerTEuF5/p6BTZYDxJYSSs8k9lalQ3HnDCHmntTglvKA uTmQatcEkGV7hEif5q113Taqx+YEgF4dvwVu7E4x1d5/3LS6yrnYg5U1yHrilBSPikpskgV7zZy 3DD8Ji1LSBiwFdLf2Dfv0dfwGbR7rg10RUJ7ycl7WTsMY3E+3Y6Y8A8I43I8ksdAxl15k5cBSbU 0U2krekmrMFMd2XxVH3QkaTHh+UW6e3OD+K5Ka3mv2REj8WVJ49HMWo5lsuy6/7lAwEL7JNj7mA GZzGZxZqi5wg2J X-Google-Smtp-Source: AGHT+IGCkgT/Av7S5A2E0I2QQdMK0eQR1KK2t84reKZkouB15tDDQWfO+rh0+B+shYiLiz/J/iIBUg== X-Received: by 2002:a05:6000:1882:b0:3b4:9721:2b2d with SMTP id ffacd0b85a97d-3b768c9c202mr6498976f8f.9.1753365400320; Thu, 24 Jul 2025 06:56:40 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:40 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 20/29] printk: Register information into Kmemdump Date: Thu, 24 Jul 2025 16:55:03 +0300 Message-ID: <20250724135512.518487-21-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - prb_descs - prb_infos - prb - prb_data - printk_rb_static - printk_rb_dynamic Information on these variables is stored into dedicated kmemdump section. Register dynamic information into kmemdump: - new_descs - new_infos - new_log_buf In the case when the log buffer is dynamically replaced by a runtime allocated version, call kmemdump to register the data with a replace flag to remove the old registered data. Signed-off-by: Eugen Hristev --- kernel/printk/printk.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 0efbcdda9aab..f7d60dbe5e5a 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -48,6 +48,7 @@ #include #include #include +#include =20 #include #include @@ -540,10 +541,16 @@ static u32 log_buf_len =3D __LOG_BUF_LEN; #endif _DEFINE_PRINTKRB(printk_rb_static, CONFIG_LOG_BUF_SHIFT - PRB_AVGBITS, PRB_AVGBITS, &__log_buf[0]); +KMEMDUMP_VAR_CORE_NAMED(prb_descs, _printk_rb_static_descs, sizeof(_printk= _rb_static_descs)); +KMEMDUMP_VAR_CORE_NAMED(prb_infos, _printk_rb_static_infos, sizeof(_printk= _rb_static_infos)); +KMEMDUMP_VAR_CORE_NAMED(prb_data, __log_buf, __LOG_BUF_LEN); +KMEMDUMP_VAR_CORE(printk_rb_static, sizeof(printk_rb_static)); =20 static struct printk_ringbuffer printk_rb_dynamic; +KMEMDUMP_VAR_CORE(printk_rb_dynamic, sizeof(printk_rb_dynamic)); =20 struct printk_ringbuffer *prb =3D &printk_rb_static; +KMEMDUMP_VAR_CORE(prb, sizeof(prb)); =20 /* * We cannot access per-CPU data (e.g. per-CPU flush irq_work) before @@ -1211,7 +1218,10 @@ void __init setup_log_buf(int early) goto out; } =20 - new_log_buf =3D memblock_alloc(new_log_buf_len, LOG_ALIGN); + new_log_buf =3D kmemdump_alloc_id_size_replace(KMEMDUMP_ID_COREIMAGE_prb_= data, + new_log_buf_len, + memblock_alloc, + new_log_buf_len, LOG_ALIGN); if (unlikely(!new_log_buf)) { pr_err("log_buf_len: %lu text bytes not available\n", new_log_buf_len); @@ -1219,7 +1229,10 @@ void __init setup_log_buf(int early) } =20 new_descs_size =3D new_descs_count * sizeof(struct prb_desc); - new_descs =3D memblock_alloc(new_descs_size, LOG_ALIGN); + new_descs =3D kmemdump_alloc_id_size_replace(KMEMDUMP_ID_COREIMAGE_prb_de= scs, + new_descs_size, memblock_alloc, + new_descs_size, LOG_ALIGN); + if (unlikely(!new_descs)) { pr_err("log_buf_len: %zu desc bytes not available\n", new_descs_size); @@ -1227,7 +1240,10 @@ void __init setup_log_buf(int early) } =20 new_infos_size =3D new_descs_count * sizeof(struct printk_info); - new_infos =3D memblock_alloc(new_infos_size, LOG_ALIGN); + new_infos =3D kmemdump_alloc_id_size_replace(KMEMDUMP_ID_COREIMAGE_prb_in= fos, + new_infos_size, memblock_alloc, + new_infos_size, LOG_ALIGN); + if (unlikely(!new_infos)) { pr_err("log_buf_len: %zu info bytes not available\n", new_infos_size); @@ -1284,9 +1300,11 @@ void __init setup_log_buf(int early) return; =20 err_free_descs: - memblock_free(new_descs, new_descs_size); + kmemdump_free_id(KMEMDUMP_ID_COREIMAGE_prb_descs, + memblock_free, new_descs, new_descs_size); err_free_log_buf: - memblock_free(new_log_buf, new_log_buf_len); + kmemdump_free_id(KMEMDUMP_ID_COREIMAGE_prb_data, + memblock_free, new_log_buf, new_log_buf_len); out: print_log_buf_usage_stats(); } --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15D632E92DE for ; Thu, 24 Jul 2025 13:56:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365406; cv=none; b=N5WbJqKBXuaEpwZbbagkZpYXNemY3Xalf0DyiLDOrQSFGWte43gOvDas2b6P56tTIm6SDWctRqal7tMg35QmqfSTEYMhxVvdhKIdBBRNt9on/5WD1VQoXp8XSoXjjLk/4VSM/r3m3cB7AQrC+sC5gSnSMnOXZESuW6zq1Oghyt0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365406; c=relaxed/simple; bh=wYMeidmYjvDlycPH4G07GZhntMp09MWX5qBkhRN0CfI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HROaEWvT+pnd5hwvIZO3jkcEIsE9fcKnCnTX1QVi+/aDwBgyc7TGeiGRUeb7o6Vez5kfPSnk5Czrq6mOCdfPJhNHj80mU4BAXDtOX4V3sSn+W4BTPNIn5GdbdW+wX2xTQCAPAV+xIoMwOFEGl+NERYxal4Xg0BfglITOxO7OtyE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=TJGzWX/6; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TJGzWX/6" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4563cfac19cso11043895e9.2 for ; Thu, 24 Jul 2025 06:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365401; x=1753970201; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ieqGzTCdj4VITWiplNNA/VccLe5fuArNXR2nSJt3s9g=; b=TJGzWX/6v2x3LKFOGORhb25GV3SG3O5lJhLzN12s/kz3xZzSeCM2F/DPwP25r/rfjt tHSsxbljdsMdjhPrIByOBKv+U7WX0wlixs7UQeh/CpNrBitqyYW2s4gR8dLIRyOm9RTb X5gLNzW6X1Te9HXIZwJfvz9l61YLYNyHPE5jJHkr6haAkWG8sJitt9NfyZ7VW2oAURPh 3aZKnmcEKHumzKpIpyRxJjLWney0vVSv2+GaknSiXmiCIuku4s+m1scu25JSQPYnO7qg AcwqG7YrjHPSLpIuX1y6I+spSSKnMA87XLj0W6wfJfgAlwNIYFEfR3n11iV/luMdlKDq 7xnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365401; x=1753970201; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ieqGzTCdj4VITWiplNNA/VccLe5fuArNXR2nSJt3s9g=; b=sl/aJDy8P7KeUvOfPeq39hWQOLt/SFozruiBlWCDLaxr1C94jQbt2fN44yHxO3xwWM CluyFNepP/1vDGIq4WTJVEKSt2nlWVZb/ntw0jPevlUGGP+0p/g7p1+fhMIVnZ7v4SDK oOEkI/uQVbDvvso20AsnJOuZD8LcdIlS9WDmw+SUZk5yri1TDUfS5RsCkURTgPa3F/XH BOjkToKRIIwZipsVDuviVXNcuW8mVF3AtUW3FvNrcuVQsASbsHOVZxmcbjqNqHGzG3mP 4Q0jZFwAgQ6qGuoBfI2tYkO5euaMiLJgqJ7B13FheLy5v/E6c/UiKehzIAZGUkeTt59u bgQg== X-Gm-Message-State: AOJu0YxJzVvaatD+ZvidDZg/l/Fbs29hcAmIfeMRxFHPug2aQxo8Y+mA fmhl/efIUXAzDk4iR0TmUEe4M+xX99e1VNHr9MGHy41lgQYBYFFYGNqvvUW/Ptvn82qthi7sb9D tbfvE+g8= X-Gm-Gg: ASbGnctyGNguyWhXtRia4DQCC98CRmgt1lP4riua4GFx2mRBVqYB+8jzshofVzRS+gM c1FvAZpshelNoJSkK/mQfu8ZGVv7z9iL7FGiEDUt0bs/ReTYeM5UW1npGcArNCxVDlThRgWJarl KSrxlDnyeIsUDUHGWQ0kJoMIf3HcYCwKi+WMWZGbOcEBVS5YKCvI5ryvx8X0aisPUp2wBZU6XZH I/j1MB2PEs3VIBJtELoWPm6RJtmqRJZYYt/wuwYw5h4TiExLylqk3w8PLRAGAyYPfWnlpZrbtlO c+0h/xFdFnATx/kKIuNAP4TFSYI2FInwqF0nbZrBL2op3Px82nOUmr4tPBJt2Ib0QmVgdpioB9u dd4t2ZFzYln08yadyv3iKHqqauo4il9hbSjqcH7mlTIM6xvhFiBSomqegX41ENLw/koiVqIrvp1 vFRiHu4mXp999V X-Google-Smtp-Source: AGHT+IGXEHFsoY1KVpxzOAw5TwDBINg782dVci0CvVy56NLBcwsZCPP5/3Z/QT3qLnRYduHfxvJiyA== X-Received: by 2002:a05:600c:c167:b0:456:1c44:441f with SMTP id 5b1f17b1804b1-45868d7266fmr61139855e9.31.1753365401169; Thu, 24 Jul 2025 06:56:41 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:40 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 21/29] kernel/configs: Register dynamic information into Kmemdump Date: Thu, 24 Jul 2025 16:55:04 +0300 Message-ID: <20250724135512.518487-22-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Register kernel_config_data information into kmemdump. Debugging tools look for the start and end markers, so we need to capture those as well into the region. Signed-off-by: Eugen Hristev --- kernel/configs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/configs.c b/kernel/configs.c index a28c79c5f713..ec94b695f234 100644 --- a/kernel/configs.c +++ b/kernel/configs.c @@ -15,6 +15,7 @@ #include #include #include +#include =20 /* * "IKCFG_ST" and "IKCFG_ED" are used to extract the config data from @@ -64,6 +65,11 @@ static int __init ikconfig_init(void) =20 proc_set_size(entry, &kernel_config_data_end - &kernel_config_data); =20 + /* Register 8 bytes before and after, to catch the marker too */ + kmemdump_register_id(KMEMDUMP_ID_COREIMAGE_CONFIG, + (void *)&kernel_config_data - 8, + &kernel_config_data_end - &kernel_config_data + 16); + return 0; } =20 --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8D542E975D for ; Thu, 24 Jul 2025 13:56:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365408; cv=none; b=fMX6hMINdO9Shz8dK+0URzFxYoKKR+AqL9OZ5D7uGdbT7ewykigr57Lw1e7TFBUFbhbIAg3HyKkJWM6SXm6dGEagPKJKxp0V30PvSe55J8wxUT5YQNV6mx+t85V1BHOtPL5w9823tPg7pfI5efvfvZ3zmQIRlG0moig2X/+4tUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365408; c=relaxed/simple; bh=5jI4DslkjyJiQZE2KZ1KI70K82ssb8psrTPB6JrU6fo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RtwB0MstExqvdn/B9o/PhW46a9uFtioQyxe3eGaf+Et4A2pcK0Wdm/wjhyl2JkJi2BaW7qlsz1u/lBQCRzVRIeSAb9dWBYkzeL1RHvtNzCgzW8MCIPSVChecyG0QPiCciPe53YqpadPr9lRzOvdywSTEofuJNXp3xM/HOdAF9uM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=iVQlTHGJ; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iVQlTHGJ" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-45617887276so6900605e9.2 for ; Thu, 24 Jul 2025 06:56:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365402; x=1753970202; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dx+zx3hCg8Qz6JMSxLg+rjsObdnsN3uv3uvSypyoc0Q=; b=iVQlTHGJ4xtQ7RNKSFLjRG0xpbvSMhSWzygQvQWNrpIweobCi7oEbrHSeBlt+DniE4 4xhPpdciMiwjDaxlqgi/WQNTk02AB0hzNo5/qgY7M7d0ovROZDKA5vOdLDwrKyMJpBpL rbxBWa1ZGy/4Syc7iYRijahPPiJrPpMfo5SloRBdOdPRV4tsZC+eXB2eKg4yrK6ayet/ u8/5SDt6TKYe9IUDX7wtVjISOMDsBnM0RRcwIsmuYEXo4c1Ho9vDY06487FUd6ol9XWm y0hG4uwNd8ulghEu4SHFN/pLexUeHGf+c+3veUu3YpR90dqYiRMHJ7QKyu3WUxLKFYq4 YNtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365402; x=1753970202; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dx+zx3hCg8Qz6JMSxLg+rjsObdnsN3uv3uvSypyoc0Q=; b=TalMLjgE9gdJbOqL/45PX1etXuXipcwMXsZj3FdpnGsAgNxYLfciWjgjEuzF+VLj5j bjuPsIqEfLRRRnowjDcsazyyqhX7nGIVMOTKLyIPFN+ADSMqCZW0/EjibNc9EW/bmiT/ NAU2BGF9Rf6DTNYV1NZ00UKWL3z9ozJPtJVC+R1yXqXMKBRKyr6m1fzJDiVu2xoVEazu tSgm5dOx8jMWhpxB9Cd6fHkhOMSkB3fbdNTWTvi+xvKxOATesC8tQMLTLWQAPXvqa5rM qmegBFEbzDCFF0EQd6IXzhpfPdCBLq+OepxiOk3ORILEUhsP0eQB3zfhzVlSfgXFxjDu uTqQ== X-Gm-Message-State: AOJu0YyKPjnVLl0Q/8e/n3wP6uoOYKWz0eqMMBjbFqfmst98jwLLhg2C ZDR/Tm9LnnknKisVpiW3DIPSJvdbXUU17+KCB4KvqzlpdBJd4wUE82mbx4WAvzt/2qff4fINdzJ VyP6bWAA= X-Gm-Gg: ASbGncuJAZKmjsds0gN3zNPXHgRrOLM6goKdFHTKV+47zO11ON7OYqDSRJUAR/1Qz5U qotQgCoMtS4CI9LSNfhjWjdJaKzocyEkNax7/vcK902fjGpMypQ8MW5N6FHQEnRsnGHipb5Kxtx 1sH2Je4AXjvh76rGq0i8FQXH5ZUQDfrs7q6li1aKBh0hnuEfVpzXQYW6boqsFAVLoxs22vOBfGM QIAMQsb40UBM3ZA4GJiEasBUdMO2uVFbBuqB3yqllPaa6cQ5gpi/lVW8En7yivthgutB2f6r2nS EhlxW0069F8+Bl1XZlCtZxS8gZv+AoDnpIAHtIgO6tBSZIeN5hXNSiFwvHZddRNhD6LuHvE6N/+ cawlz7kECcFVGsXXflsDaqA+O8BGX2czMfdQKfAS9Z5ZUSHEh38f6GCBUsUCzpQ4e8Q4nbTievs JRd/wzFi4b/dHq X-Google-Smtp-Source: AGHT+IGliARSjFjzMbqI3XaGwe/LefU8e+9kx8i0i+1k/+nyeMB8SAYvSTjLiytSObV6pAe7PVl9aw== X-Received: by 2002:a05:600c:3583:b0:456:161c:3d77 with SMTP id 5b1f17b1804b1-45868cff2b8mr75404365e9.16.1753365402037; Thu, 24 Jul 2025 06:56:42 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:41 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 22/29] mm/numa: Register information into Kmemdump Date: Thu, 24 Jul 2025 16:55:05 +0300 Message-ID: <20250724135512.518487-23-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - node_data Information on these variables is stored into dedicated kmemdump section. Register dynamic information into kmemdump: - dynamic node data for each node This information is being allocated for each node, as physical address, so call kmemdump_phys_alloc_size that will allocate an unique kmemdump uid, and register the virtual address. Signed-off-by: Eugen Hristev --- mm/numa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/numa.c b/mm/numa.c index 7d5e06fe5bd4..88cada571171 100644 --- a/mm/numa.c +++ b/mm/numa.c @@ -4,9 +4,11 @@ #include #include #include +#include =20 struct pglist_data *node_data[MAX_NUMNODES]; EXPORT_SYMBOL(node_data); +KMEMDUMP_VAR_CORE(node_data, MAX_NUMNODES * sizeof(struct pglist_data)); =20 /* Allocate NODE_DATA for a node on the local memory */ void __init alloc_node_data(int nid) @@ -16,7 +18,8 @@ void __init alloc_node_data(int nid) int tnid; =20 /* Allocate node data. Try node-local memory and then any node. */ - nd_pa =3D memblock_phys_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid); + nd_pa =3D kmemdump_phys_alloc_size(nd_size, memblock_phys_alloc_try_nid, + nd_size, SMP_CACHE_BYTES, nid); if (!nd_pa) panic("Cannot allocate %zu bytes for node %d data\n", nd_size, nid); --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 146D82E0B6E for ; Thu, 24 Jul 2025 13:56:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365409; cv=none; b=glg9lJdFkLO3rNeLe5NLZNNd2n7lRpGV6dWQdbgSW+oQzSxnfU52lKAS+hTUIhTzXTXqzmlF/bbXcirm5TNwsDb5Go/2zUK0UoCcpcEovY1WWDATd0VzZJFKiso4zjFWohhLg9uqh2USHQUiosMyVbqo+UsJdsu9trxtsyCUl0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365409; c=relaxed/simple; bh=4mzNhzQY8HFx0bk+CHpi6+2DgmZYfQ8vHH6EB20MlrE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XRAiuEYRWOhK9bSQ/j+yOzPQOf4YeGs8lcnrDxGiDiSUOc/XKWiXilxw8qfUqkszSbfoSYD7A1MEyGUUQyjhDf+wCHcWJzBPw6XW8QM9N3vMl31niGw8sRRedYDiQAgc2JpXbyyVgzNCPRlVxO1GH/tengWC49vqnVUN3DYuaOQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=iClEbVMJ; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iClEbVMJ" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-3a588da60dfso649681f8f.1 for ; Thu, 24 Jul 2025 06:56:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365403; x=1753970203; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h5mN880WCISqsqqypOE0OCrYzPzbEuiPZ0HVDAJk/kA=; b=iClEbVMJGbk/PyxXaSMMcxMAAqWn6IMjOCGbXGY4SbpO6tWlrOvED9WZH1STFKee6Y hHtDKSjj9AXb/itAOMfu+NlNgcBkRokxFC5lEdIpCJJ+u0F3wh8ftd0RFHgtT2YaraSq ketGNDB0x/WxBU3SwLV8Obj3mnpIWnW4qIcuRREvISdg4EGUpwQhA4rQRanVEWxhschX QLhS77NmD3AasXN5Yqd1WPeHDUyi4MJVAtLajTy+fiY3NdBPLN5juxw4sHLap8dmWM+E K4f+4lYqgXd1aplpdLav6VbqVnXZ3qrRTthuhfvreR8lU17u+Vsgb2/2AhqcfcZPWSjc BIdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365403; x=1753970203; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h5mN880WCISqsqqypOE0OCrYzPzbEuiPZ0HVDAJk/kA=; b=SL+vn0LQyoH31fP+gmaSAsinnZQ9CIq4N58iN1izieMTWuT3/R6Pl0qslHgUZC0k+u dg0I4Zm8e2j4DzNHzg8HcdLw2TS7mvi1MOIt2hRkiKvfgLkg3shezy87HRpgOrZf/IMd ColppNKFF2WwAEg6qSfzlm4pJMWvjUjL5UZd8BdZlt1AXFg+3tZbLPNoZtnOVZITvTaS PCWMiAe2fjjKOxniHHXRFlb0jz8SXRWqV90K7AjXqtDsjtOeLfiLhYq3/YW1EBmJ26O1 tvJSUdaDSNhMtsZWBtt/YTXchRD7QLK26zeUO/d42N4mXA45+JyHjt43XPPD3khGoaL9 lRMw== X-Gm-Message-State: AOJu0YzaRJc8O3HmD5UwFysffL7E76AiTcBwgp/8aGPBN14uhLFrM5sA Pmx+wakCg9qLUvvhUUznBMrQigAajRJkqkzUXclke7Ly0W4WtjmvDD/AORPkw13oRNp6xrgojEo tUBQAJXU= X-Gm-Gg: ASbGnct67KvZQycR1ksmUQFTZg77dy9X2IzUmQRACmEifAgahzfF/AB4Ruwm8g7+eyg Yk+g135TWstCAoWlvLatWvxaeB2ncBV6Ije6r7FxZkden3ttGei/ZYvpl/Q35AFI5VTWhOBvJrG 2zvjpjt4UNAoH2O1pUqp6c8jRt0qOB1d4OgUkOLHU6vqKcCI79NdxgH1+2XAIka+/gFGTOgSosI iY5fand0u5PYfLQsKlf6RSssLsVs6c6bgkXKqyx+i7oiIn4UYRkzEmc/KCjEkDxy69DpmJ70jAU XZPxGR+v1g82TTLxu0q8zs1YT1umJaHgdtxFsymka08BvsykXJuPG1by8cTFTOIgFdW/f3nxUOf UH0ntLo6vqdGAH9D9L3abcXxccSuOpnD1zerv18xe+VGUmb7oJVBrySg2tTeyI54tY48vJ01WA8 +vAch0i0H1cmuZbBuVQk1zF90= X-Google-Smtp-Source: AGHT+IF4egT06XIAWuc0TJnVdNpe1wQ7sn3xvEGeH8Rc0pzDJnMJjBpN4GYnZW+sz3u5f7Eq0JGLQw== X-Received: by 2002:a05:6000:3103:b0:3b5:dc05:79b with SMTP id ffacd0b85a97d-3b768cb0f15mr6041122f8f.14.1753365402888; Thu, 24 Jul 2025 06:56:42 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:42 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 23/29] mm/sparse: Register information into Kmemdump Date: Thu, 24 Jul 2025 16:55:06 +0300 Message-ID: <20250724135512.518487-24-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - mem_section Information on these variables is stored into dedicated kmemdump section. Register dynamic information into kmemdump: - section - mem_section_usage This information is being allocated for each node, so call kmemdump_alloc_size that will allocate an unique kmemdump uid, and register the address. Signed-off-by: Eugen Hristev --- mm/sparse.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index 3c012cf83cc2..04b1b679a2ad 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "internal.h" #include =20 @@ -30,6 +31,7 @@ struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS= _PER_ROOT] ____cacheline_internodealigned_in_smp; #endif EXPORT_SYMBOL(mem_section); +KMEMDUMP_VAR_CORE(mem_section, sizeof(mem_section)); =20 #ifdef NODE_NOT_IN_PAGE_FLAGS /* @@ -67,10 +69,11 @@ static noinline struct mem_section __ref *sparse_index_= alloc(int nid) sizeof(struct mem_section); =20 if (slab_is_available()) { - section =3D kzalloc_node(array_size, GFP_KERNEL, nid); + section =3D kmemdump_alloc_size(array_size, kzalloc_node, + array_size, GFP_KERNEL, nid); } else { - section =3D memblock_alloc_node(array_size, SMP_CACHE_BYTES, - nid); + section =3D kmemdump_alloc_size(array_size, memblock_alloc_node, + array_size, SMP_CACHE_BYTES, nid); if (!section) panic("%s: Failed to allocate %lu bytes nid=3D%d\n", __func__, array_size, nid); @@ -252,7 +255,9 @@ static void __init memblocks_present(void) =20 size =3D sizeof(struct mem_section *) * NR_SECTION_ROOTS; align =3D 1 << (INTERNODE_CACHE_SHIFT); - mem_section =3D memblock_alloc_or_panic(size, align); + mem_section =3D kmemdump_alloc_id_size(KMEMDUMP_ID_COREIMAGE_MEMSECT, + size, memblock_alloc_or_panic, + size, align); } #endif =20 @@ -338,7 +343,8 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_= data *pgdat, limit =3D goal + (1UL << PA_SECTION_SHIFT); nid =3D early_pfn_to_nid(goal >> PAGE_SHIFT); again: - usage =3D memblock_alloc_try_nid(size, SMP_CACHE_BYTES, goal, limit, nid); + usage =3D kmemdump_alloc_size(size, memblock_alloc_try_nid, size, + SMP_CACHE_BYTES, goal, limit, nid); if (!usage && limit) { limit =3D MEMBLOCK_ALLOC_ACCESSIBLE; goto again; --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 131802DBF45 for ; Thu, 24 Jul 2025 13:56:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365408; cv=none; b=qtd7nWHL4QsNIQLkCXAY+pBtb3uQYB3fsS0Wkj6ffbLFbIWN0GToOQlWVFH8zc/+uxc/IF3gVkc5yUfiKOFk/9LoDRpNEy0ZjsJb0DugA19q5aMZQ4kdWKn4ZZJB127a6kc7/lPIS6bwOQoyKh8jUVFreLWJ2UUKL3ikLtEXilQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365408; c=relaxed/simple; bh=X7sQWVi2ES5AdRRit9jippI6XjHYlOeEQQ68I6dFb/U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uaM4FgMHC/3KOfOf/sCEELA6s+guZfG8RFGqU6e5hp8AOhV77161LX1dwu/NAkIDmMcnPe9wwRejw51XUBRH5OT1LlwTjO7TM20daAmON4wAycGRoFq1B9jwlcpdOPxInaZXHwr3mehv6yohq66YVAOdLv14u7xlwNmBxeDaG+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=hDK8xxre; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hDK8xxre" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4537edf2c3cso10996505e9.3 for ; Thu, 24 Jul 2025 06:56:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365404; x=1753970204; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=io4h5WAIvfQT3VZkI4AOHF3Wp3PwROfn1AQPtlUH1DA=; b=hDK8xxreujp3pWqlOMBgHmmfxII1+ZylRyCnatQz8Hk0KNv42+sXlYYp46lcSWd523 4LuB40mwAABhQX7sjVmSidiHpqHylox331Mjz4+Lchqvwum1GNawBGl4vQ57S7M+BsH+ vZkkP2Mv1RO4CpOAvit+S8EBWTHEIOFr3SehSdTDrky7xm0ndHSqS4Cov+H+OZSN1Q92 o77CgsrPAOIQ51h59pGKu40MHnFCuMgl6JMJhv6JcB6E3QJZqv1yx31SbUUXPSj0Nv+s NwxZaXNRDj4Xckeql1Mrll1FKb64A8a/27wwvKfM9If0OvfszU/UF6rmMUUqGVbUJG/9 acsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365404; x=1753970204; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=io4h5WAIvfQT3VZkI4AOHF3Wp3PwROfn1AQPtlUH1DA=; b=V/f99wUe3vCQFUaf4S69M6PDpWHcFCOGxuw4Fb5lQASIP0RKLLOruS+h8ToI+EB9t5 T0Y+63KM9i0tLsECEMLQS66UC9bBmfpkCXP3LRPEi4y0pBaiO0H7HKs0eQ3Y5hd/R6w/ ssfANN5ciF5Ca46XLEOQgXOd7C6LWkeOT2Pd6G4VUqpxHDOwXLl6Pt/ZzF+kTPd3sWth PtU+N5cNU18UrcucQGwuyebSYH/6uv4Ga3UF+8poSvxtnNFI8jHrYY8Ll8H99to5mrR5 AISGf2RlHAnvZgZQJ535no2eKGNhiz/Hu2Dag5KKvp7Q8jzXCNJLoqSg51ZIVrqLqlaN Lxwg== X-Gm-Message-State: AOJu0YyhazwtDA2KNbHdx92Cqi3qfrH0LqPMJIkkLLBp/Tqn1mOlrxFR uEWoyl0JLogErnK8QxR8fjpmDJa8Cjonf+UUh+YFBF6kWohQKsfbGDIPn1NG3/10kz7ZrHXeTG6 TF+e27N4= X-Gm-Gg: ASbGncvSusG45SQz6/qtCss9HUQC6/R1i8GDeI30MLMOrLOi0vRudmstiLITK4eW7AB OpWAmxlwTi/OCDwxscIuhci3mygcSK8lwrB/k/3Qolv6PGbM2+wYsKDhxYtdIXUvNfEvKXEc8yD 4pFh7eHFDwnWu6lXs6XbI99t/t5vunor2SkOLKrRvKSu3oZiYD/YkproC1ZOzSXM75lmf7JCiBM 1oI0/dVokoqXsijqPjA+62hGwkQqCOLlGsC4UWtisCATgF60rK8PL7kXrvOyMxoV4rbPtu5P0ds g84zDedPU1HWZGIktEH8G1VihyKHVPFLJoNvq41uYn7LB/3BFWFDgYo2sGki8ZPzL1GieEz9PfX u//blMTQR7wN0PRluPqQySpUzWrU8Sw4JzRUL2B0VU7hjdUxCfvh/5UDOBoBYNMt0xNo3rFOPxE FJOmmjGVDiiqmk X-Google-Smtp-Source: AGHT+IGKgu4NRvfPslcwd+sSrmwQP//isSIOnofkVKYWLLSsjM6dUJOy4a8soeLJ5d7o54vF2kp7ew== X-Received: by 2002:a05:600c:1c22:b0:442:f97f:8174 with SMTP id 5b1f17b1804b1-45868d31a2bmr69596125e9.18.1753365403699; Thu, 24 Jul 2025 06:56:43 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:43 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 24/29] kernel/vmcore_info: Register dynamic information into Kmemdump Date: Thu, 24 Jul 2025 16:55:07 +0300 Message-ID: <20250724135512.518487-25-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Register vmcoreinfo information into kmemdump. Because the size of the info is computed after all entries are being added, there is no point in registering the whole page, rather, call the kmemdump registration once everything is in place with the right size. A second reason is that the vmcoreinfo is added as a region inside the ELF coreimage note, there is no point in having blank space at the end. Signed-off-by: Eugen Hristev --- kernel/vmcore_info.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/vmcore_info.c b/kernel/vmcore_info.c index e066d31d08f8..d808c5e67f35 100644 --- a/kernel/vmcore_info.c +++ b/kernel/vmcore_info.c @@ -14,6 +14,7 @@ #include #include #include +#include =20 #include #include @@ -227,6 +228,8 @@ static int __init crash_save_vmcoreinfo_init(void) arch_crash_save_vmcoreinfo(); update_vmcoreinfo_note(); =20 + kmemdump_register_id(KMEMDUMP_ID_COREIMAGE_VMCOREINFO, + (void *)vmcoreinfo_data, vmcoreinfo_size); return 0; } =20 --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13B8F2EA730 for ; Thu, 24 Jul 2025 13:56:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365409; cv=none; b=XlruGDjcoLgSjKpjW82ZeuW0JeHzZu5TXc0Lkv8d4xhApIRk5Ty3QL+0Nkf4D4LWC8iwr37DrfdvCELLcx4rLjYNQveFOmBKaX59BWmKbM6YZZHUeE1a04rEjlLpTamqgIu76rXKa3iLuoLmppEzcFuJ2kIjHinzec6LbxosLaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365409; c=relaxed/simple; bh=DC8BX+UCsCDL0s+QjMq45E4j2zLW64ooBSHspomP5gs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AQw3BgCDT4dSHd9XFpDhssa1KE1o4fSoV2LydbUHfuzmNyJpPJKgWL/X5z/n4NiE8ZrRabg6GLCkP+y0nC7lwdcVvh+Yc7lZb+09TvZJl0w45qR9xp+eXNBbDfsTvFICP6TwFiozWAvnDWKpFXSuxdJ0jrEgEcbyXGozCSFZDec= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=bpN1qSTE; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="bpN1qSTE" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3a4f72cba73so1287801f8f.1 for ; Thu, 24 Jul 2025 06:56:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365405; x=1753970205; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IAPeYZVy8llrcCGwu3MIGe2nhyxNrtHRlXTr72itWZc=; b=bpN1qSTE5qttk/lJ/GnHbd0ERBi37+C3fAMBhgPXYw+BVR/WyOg0llV5z/0JJ7K2sm bDTGWXiQz/1Y6EShBsHND4rx8+2J9ALqjcHQvZA9S8raNMW9NIGuUxAR45E8oD5KIj3k MMeACj8mR3w8DdB1YvvhdJf0G1TcovVBN41fR8+CdmgJDlu7U4BinEBWL2j6PfzZmR1R WhGUVRXll9Qk0QS+28daFSbHOaE3DdEp/1s9q5S2tmvIzjk+efVkVWvH7AQ7oukiDmiM t3AyKk1j4j7YI6a84OnDQdFVn+XSH2YYYTVUJfV2hAAjoDwVPKh8P+A5rJcLcChPYEtp Z8LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365405; x=1753970205; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IAPeYZVy8llrcCGwu3MIGe2nhyxNrtHRlXTr72itWZc=; b=M7afl3m5kpSvJ/BsCrJ9qRBN9vU+T4MxkKf+xy8c9iXvxkpT3D9RlwsOmu1a+EeXh/ iLHWOZ51cpTITW7Hp3Ilo7d4ZTUNzytPbAzXNES4AmqXu5KB49gXBlro0wIuU228si9A HL4ivpcFhQci1jUoykUEgAkyfHSG49fJlcYOxhZiBN8cJ/DOArL1hihe1GdMzT5Fl6sV 35YKKhVYS6RXOPj/ZjhiX7bBcVSgPcJxeMlZgQ3cNE8t4BUEeqTyW3d/uubAHtOQ6vIZ 3hYs14V6xOK+7NOIA8NLBidTDbjOydPEfuMlYXgrkVwNsqB8jMz33OlO2BvGQfQOLpHv B2SA== X-Gm-Message-State: AOJu0Yybqa7RbJuBP7BQ0HWVcKpD/+RJVuAA8a62umdXa7tXAtjzbXUD kFA5nAiMreBTHcxHsSaaAQtIfFMYbeE1mBWUHEG0Q2abvbNppctcJxsBpgPeL1ChQ8siyxAiNnu 55P9lTQU= X-Gm-Gg: ASbGncsWq9Hr/DbYx9PmQRGJT/lNCJQjG9AbZ7F7YjlabUQvuE4qHzUm5Zp4nUr/sbL nXrCwJt8TlzpWVDwC5FSNALWxOdxjghpBbcmcjwPjecDxNZXIRq29XITOqVDGx6oFmka2kbABHP 37XJnbv6xatd9FdcP/sSz4ghHl7IDhb6525trZfVd2nqwkL5P/3NvBqSwrhlP10eN0eBkH3iHyY BD/ZOzelp6HTtpOixIjyUAPs9d++3b0/hCfoen1W5xuGDK5OjgqRmCDrsi0hamh1Uu2aHr1NlbA BBRMSHwfotpjGlnGTCYHYhJQ0IX3Ji0E54l3J99JyAVnW2yVn+3e1ENL5vftPzCewjrSGYIYX9p nRMYihTqpFEkBACxzZExgzmPQ0CYpGiDnzg5wVkSFTuimvU9vUvBvRTW0ekP5Wb583uuWDbmM/k A6n2PQJdRqQ2d1 X-Google-Smtp-Source: AGHT+IE/tOxCaZJgBIx1z77DRVJHCm2c/RVz26viacIOb6VPqsOvedK5J5brFqoj/rS9r4t912qyvQ== X-Received: by 2002:a05:6000:2482:b0:3a4:e1f5:41f4 with SMTP id ffacd0b85a97d-3b771356cacmr1929316f8f.17.1753365404772; Thu, 24 Jul 2025 06:56:44 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:44 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 25/29] kmemdump: Add additional symbols to the coreimage Date: Thu, 24 Jul 2025 16:55:08 +0300 Message-ID: <20250724135512.518487-26-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add additional symbols which are required by specific platforms firmware for dumping an image. Signed-off-by: Eugen Hristev --- include/linux/kmemdump.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/kmemdump.h b/include/linux/kmemdump.h index 7933915c2c78..94493297d643 100644 --- a/include/linux/kmemdump.h +++ b/include/linux/kmemdump.h @@ -35,6 +35,22 @@ enum kmemdump_uid { KMEMDUMP_ID_COREIMAGE_high_memory, KMEMDUMP_ID_COREIMAGE_init_mm, KMEMDUMP_ID_COREIMAGE_init_mm_pgd, + KMEMDUMP_ID_COREIMAGE__sinittext, + KMEMDUMP_ID_COREIMAGE__einittext, + KMEMDUMP_ID_COREIMAGE__end, + KMEMDUMP_ID_COREIMAGE__text, + KMEMDUMP_ID_COREIMAGE__stext, + KMEMDUMP_ID_COREIMAGE__etext, + KMEMDUMP_ID_COREIMAGE_kallsyms_num_syms, + KMEMDUMP_ID_COREIMAGE_kallsyms_relative_base, + KMEMDUMP_ID_COREIMAGE_kallsyms_offsets, + KMEMDUMP_ID_COREIMAGE_kallsyms_names, + KMEMDUMP_ID_COREIMAGE_kallsyms_token_table, + KMEMDUMP_ID_COREIMAGE_kallsyms_token_index, + KMEMDUMP_ID_COREIMAGE_kallsyms_markers, + KMEMDUMP_ID_COREIMAGE_kallsyms_seqs_of_names, + KMEMDUMP_ID_COREIMAGE_swapper_pg_dir, + KMEMDUMP_ID_COREIMAGE_init_uts_ns_name, KMEMDUMP_ID_USER_START, KMEMDUMP_ID_USER_END, KMEMDUMP_ID_NO_ID, --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 142502EACEA for ; Thu, 24 Jul 2025 13:56:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365411; cv=none; b=NaIGsyXfVEzTZUkl7CvGs4mcQYqZqupgsj+PEl5UyFnbZkfCb1Rlb4f+W8QYJG/sc5dlsTF07PBpUgqWlbV9nt8u2LXodW+kY83KxitN8kMchG3hCnorMGdGZkjgT/hFEmbiL9IsUkmxCB/l3XlHvoEbXUsaOsTKji8VUCHJlDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365411; c=relaxed/simple; bh=wEuXEElSEoeDjBLwM+2PEoqxG10Mf5YuozE9z8W97nQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c2I5aUU4ohHaUaKbtGwCmZ24GzEa+nQzdPXd0CW7WLwb2IKceMye04RhC2UfZwvA1ZcsXW28EoBkUOQ6oJJAci1ZSqdm7TkHBnG745oqtpSKCXm+ZId0zNqsF0KGyxQLPJyA4XPIxTpOCfdagSk2WNb3LYFjxhlQNbKph6cjn0c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=N0iRzo/H; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="N0iRzo/H" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-451d7b50815so6724125e9.2 for ; Thu, 24 Jul 2025 06:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365406; x=1753970206; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mrjIGy29vhQmG8TWG3X2445EHE3hkTtQk53xAku5ZzY=; b=N0iRzo/HSw4GpGt17bXx6b6/O6ZuRBfug9PwLPcIbNX++v94NlSmli3aFPaEPK7H5r iaY+TKWGEB5SfGBTAh7kaxb3R4rulLXH1c/u705kGj2fk5OEnziJZSORD+5Su9Df9h77 SLXNpM5LJtstYeKvG/AH0aSMHepM9tbTUo5eL/B4hyAAksFCeDY9CAq9DFQlQEHRxTmV frlisfgdDdcs9lsDMmzS2iHl0vq2a6XGezRMSPMqVjbHSEIx3xFWhpPwCvrtRI10jRXY fC4BJZt4VUx3H60OGMoh0qoSCptGcgPQlwoEEPuFQKolRFeRV/gh7d0hfkHSSyOK/4y6 sl+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365406; x=1753970206; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mrjIGy29vhQmG8TWG3X2445EHE3hkTtQk53xAku5ZzY=; b=u0d6hkknKTk3YvtdWRexBP/QZzCWWUfqQSTTmlgF9+I+Hu7BD3ApT32/W5cTjqiQxe PvscV465aktxNSYDOidhh5uxd9qzwPIbieDh8G3Q3kRoSQNcudT2+UO9rFiC3kGWUyXn /xjI/AK4CNQtIKSoFpnCtGAnGoG7vRuHCFoymhdnhLp5OcF7toRap3gPprNMZBwJYKij lfKlZOXfgfY/w4JMx5vb+7CSqDLKlwSjSTWO2yGNFd2Ggr009vJEF6iyscWqwogLczfq xV86+tecWYnrbyAhmTjcs5kNQG+lVdtXeHsJXwxL3AR2MVmRurp5wbcfx/gOtM4D3rSW 5/AQ== X-Gm-Message-State: AOJu0YyoGS00u+2HrYx2eWZ79RXt1N19Oh1866He/Y4ClsE+fk/a+bno Xvlc709W0S3yyPm2ateMXSMD9h2J7PdMvvAVrgO0ozQ/IG6186n2K5ryPa5dPFgvWGUAykMwSws wgH87mI4= X-Gm-Gg: ASbGncsYWlifiiAk8yv7iCExzASzOZg5oQb7djenwxBdUt6XcRhIK202BhPcA3wNy6l NE8z9YlE4VQZXtakZn/JvpDf0RUVzbKFsSS1um7mIcQG8V0yWUnB2Hh+rqWN5NdDWx98fSTK5JG i2Pmi2oM/YswDNGqBWJDNEY0QzM/qTdceI8dyPGBkbSrquHm3gRZun5j+mGu/exibo68Ev0ggSg mANReAx7g+CJ3G3TT6yoAwJo6WxCBrRPxVKaN81kVRwx5kimMeiRrhWUt1b1uuFHfNzDOmTxGrW 6G/scAagH4+01TvmmRFw8Hll5Vwjmt8RRNO6bH42TNDbDuG6KN+mEptUzVjKU3PPKCFMNQC9jQ3 6vPM5Kiml6TbHqZyI+It0s+Dq8xPFWTPTP6bdZWVWpRL5CYQGiuW+0u9gdTHUnlAYI3+jVm2wXE SZDN0o7SjG+gEv X-Google-Smtp-Source: AGHT+IEVcqWnuyhtVrHKBupbieg0QvSQq5CXC89YW4ucbe/Xkxqrak9r8AlJ1/jdx+SIbeQvU+walA== X-Received: by 2002:a05:600c:8b70:b0:456:2b4d:d752 with SMTP id 5b1f17b1804b1-45868d2c4cfmr54619365e9.20.1753365405757; Thu, 24 Jul 2025 06:56:45 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:45 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 26/29] init/version: Annotate init uts name separately into Kmemdump Date: Thu, 24 Jul 2025 16:55:09 +0300 Message-ID: <20250724135512.518487-27-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Some specific firmware is looking for the init uts name region. In consequence this has to be registered as a dedicated region into kmemdump. Signed-off-by: Eugen Hristev --- init/version.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/init/version.c b/init/version.c index f5910c027948..364e7768da68 100644 --- a/init/version.c +++ b/init/version.c @@ -53,6 +53,8 @@ const char linux_banner[] __weak; #include "version-timestamp.c" =20 KMEMDUMP_VAR_CORE(init_uts_ns, sizeof(init_uts_ns)); +KMEMDUMP_VAR_CORE_NAMED(init_uts_ns_name, init_uts_ns.name, + sizeof(init_uts_ns.name)); KMEMDUMP_VAR_CORE(linux_banner, sizeof(linux_banner)); =20 EXPORT_SYMBOL_GPL(init_uts_ns); --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9EC772EAD1D for ; Thu, 24 Jul 2025 13:56:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365412; cv=none; b=Yb4g6lRttRJEesuRGxRD+r2XdVNf0XtYJuJX5AELezTYHz5vlTLck79KFJl6QhlF9HJP5b8FWf/CEKer0a8DAfZLkXjtoVORGeHaKAv9LWlr+yosYFyVw+BtfVFFZlOnKwI960MIh61wBHulpWTDUuYWOcGibjtm1yp9qcqmTS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365412; c=relaxed/simple; bh=yDgqovov3P+BgQJIgQIcPJeeBOVhAaLQJOWmJvGhnm0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YXg+fAdZYPzvCjwAWnckgbCXwa2vYTW4v7epOoUg/J8llCDAMLlzRZnDTlroZPO7NSiuYzbTnvt1LIOTCjqGzBMtfr0rX3cRJkNXPCpxoVHK0S8/cyjxpz4UehkmXGayrUtRIgzme1QDs3adow6j8xtCZkD9xocG0eKg4IKw5Gk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=jwFZiSQV; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jwFZiSQV" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-45555e3317aso5296945e9.3 for ; Thu, 24 Jul 2025 06:56:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365407; x=1753970207; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=la6fP9HkJphfM0jMf+9F231C5ZYtMe+0kHUA15eBYp8=; b=jwFZiSQVJYWsamCDFeiyWQiJ3l/lmU7kS3tELReNf7RPsOKXGDXYGlWUMofbznWnLw 8ZnZ1porHZcgssDi+CbL/Nm4MVmuNi2l0vKRD7VTDAoimUJoblalg2o+NqLFQgq6YvSJ phfuCAjdAtTiLT/9XNloAnkBqNCM0xkC6j+phLm04TSGt8Fq+yFcCh3Uy5EFmcCdnOR6 cPIKZdFJos5wrXSPtaaeGbXhStNFIWhGew6+hUqzuDMNoMCgOyv7hMD+aIFhRM1QbNaw T0mAS/mSYMrXQf/WBLp34BXnb39XN4U3ImwgOQAqkZ2UQWp5Exo2pQmuK5X9xRzfG5Jt WZbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365407; x=1753970207; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=la6fP9HkJphfM0jMf+9F231C5ZYtMe+0kHUA15eBYp8=; b=XvopozCl9cfid5AvoyRMtypgPhgLP46q35r0rlYjKxeYV8pWe7C3o3hxgXGLeWKrSW 64LGUY7JTA7FauYagTJWMNZttPvHZevtD3jGvBh9u7oexXNlyedaeYpt8vr98YsFiO39 dTTK+xUGZ6PiZTiWCtOkthe4gOzNe9WaINdOnrQAV26lIISp3sFKfK/rMRaU1ivYYa1T i5jiAH9C/e44icN4aso0liD6Xen1J/+MtZyGiGKvsqmjAqEtnnh9BpnairGgFwuMDFLv Hh0DI4/xouVhG/p5B+LJWUpDFy3PhKT51N5PasMwq55PioxpYh1EYj7ADctXlh45aNAY jvvA== X-Gm-Message-State: AOJu0Yyc3fb62MIhLgEdi9TDrqZCjIj+X5g+sM9Y9zHislvmrj3wiBdT i/J4JXYPAuXJubao3uA6cfx8oS3V740cJLYLE+0uCznbC2cTPCFzRjNbIrsCXgwzzwbWkeosA5W 1X/BKFYo= X-Gm-Gg: ASbGncvQphVbDbBaj4MsQkHgdwmMLdJJ88KAVtX0OReuK+5oqr+Aui11E8Yg+vEy8g7 eFrulJzzEd99TwtAjwGBL/q0V8aZDAAJtmc++aZKW96tHnY+FwjCFdJmNFnt6Se8P/AJQYbW1d0 q8WqnL+6D8LkqTFFzXrZcvD3tpiqSzbhCiy4wMXORtdbt46o5taB7kM5xnQfSBMOXlf1ILZo9qx dWA2YaIyNahelBR0xnUg4HRwgg/xNmwzzEqRMg3nVQJPB6KJtNPGZvQY0789xYnnwN+2yPcqenE WVkmfgT+e8Ckxeo1483iCZyQJeUGJf/5P+/5vLu02V3wUhKHXR6w7q5OcY1dvUat2HRmriWFc2x AxVfubS/WG8oMTz6/7ZGqnKxNWpQeHZAO2hkIE+/Gb95GvPPjIajcqY05p2JHJPtebhsZg0g2j5 jp04AkKNJGAkWZ X-Google-Smtp-Source: AGHT+IHN52iDsRUI3MC45fB2NHZ78a+PI04sVz+MJmf9Pj70BNaVdCA6rPCjq4NJ6xqIYAMwjrcKOA== X-Received: by 2002:a05:600c:4693:b0:456:19be:5e8 with SMTP id 5b1f17b1804b1-45868cff3ddmr60788825e9.20.1753365406597; Thu, 24 Jul 2025 06:56:46 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:46 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 27/29] kallsyms: Annotate static information into Kmemdump Date: Thu, 24 Jul 2025 16:55:10 +0300 Message-ID: <20250724135512.518487-28-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate vital static information into kmemdump: - kallsysms_num_syms - kallsyms_relative_base - kallsysms_offsets - kallsysms_names - kallsyms_token_table - kallsyms_token_index - kallsyms_markers - kallsyms_seqs_of_names Information on these variables is stored into dedicated kmemdump section. Signed-off-by: Eugen Hristev --- kernel/kallsyms.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 1e7635864124..442dc13d00cf 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -31,9 +31,19 @@ #include #include #include +#include =20 #include "kallsyms_internal.h" =20 +KMEMDUMP_VAR_CORE(kallsyms_num_syms, sizeof(kallsyms_num_syms)); +KMEMDUMP_VAR_CORE(kallsyms_relative_base, sizeof(kallsyms_relative_base)); +KMEMDUMP_VAR_CORE(kallsyms_offsets, sizeof(&kallsyms_offsets)); +KMEMDUMP_VAR_CORE(kallsyms_names, sizeof(&kallsyms_names)); +KMEMDUMP_VAR_CORE(kallsyms_token_table, sizeof(&kallsyms_token_table)); +KMEMDUMP_VAR_CORE(kallsyms_token_index, sizeof(&kallsyms_token_index)); +KMEMDUMP_VAR_CORE(kallsyms_markers, sizeof(&kallsyms_markers)); +KMEMDUMP_VAR_CORE(kallsyms_seqs_of_names, sizeof(&kallsyms_seqs_of_names)); + /* * Expand a compressed symbol data into the resulting uncompressed string, * if uncompressed string is too long (>=3D maxlen), it will be truncated, --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 145DB2EBB8C for ; Thu, 24 Jul 2025 13:56:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365412; cv=none; b=R6hz+Drd+m976zBAv8rrx/OPZjvkOk8Uwaf8Eq/vQMy5AkUJ7KTNDGE4n1aVb7WKNLrBqe3/Rbtz5qcCX5riO838mHE/ght2fEA1A0Tqwg+c/bmFsKAKAJH9f2pvITXTmM6klTcUm+07o1sq7C9f7mCS/Y2CxGLfHIlTr+8AnKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365412; c=relaxed/simple; bh=SQxu0R+MOijEBbbV34mwRJA/GN24qy3N7mFo2kprDqM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kCpfrfe2i6F+1PsM8nHYWSddz+dQnlYzbsYT/wHpLSB53ldGhenJDVuKdwY4cgPtKJs3OXyoBdwnNuWLMwv6VS0QrpVK1VOffI+418CDz4v5w6D1Nw1IF4CayjwMhJ72sHt/drUExK2OPyAXOaVGnGy60U61mvRLCkWnlNAOKpQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=V+yP+DjN; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="V+yP+DjN" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4538bc52a8dso7185145e9.2 for ; Thu, 24 Jul 2025 06:56:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365407; x=1753970207; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GVVaZTfA71hNG0BSuf2xrM/AfoVAw+w3Csdp+8nmO5Q=; b=V+yP+DjNiFBdmZX0+X+1GT/0jSDVJQdpQWqF0ppRaNQzc49toUn7rWNbIPLNzBTV3v wNWkiexWDjY63ikTVsoU/ILyqacQjZ8QacKphScsC4/f5U/YePpcxYSjHSY+u+V5+Ltx sskxvykF7Bu6ijU8AFPBb6/AO6OoNgxwzH9F4MeY4v26sSuSak4sPl62uaKzjx8DkVRd jLbvBD4ef/mS8ygVvLqsdORg8bSZCWfz5Gmfn7oatkWV7HvTa84xItdTnRbb2envSyQ9 LHRe94Xf+/ggX86LXMsDhr6R4dQIHDZ2xL7nhc31q42I1RLqBZCiOXI8TCGbKrwR9TTW 712A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365407; x=1753970207; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GVVaZTfA71hNG0BSuf2xrM/AfoVAw+w3Csdp+8nmO5Q=; b=u3+9sxmrCAxv8cOp1WNAWtkYpSktMjISz+mwWOxpE++/dKOolUfc2nsRT2GmiA4KPe LoXoh6+TS6dqZ4XylBqlvKYlLnMBwPN+WJrDQjAIDPU2kRUAlrgcN3txx6r/iJ8V0wQc 4AtMDtwW19JPa9LiZSubTHcUM303HIDHgnlCQqLMBYYGVW2fJikV48xxQwEEIDxcT+ce k/qU31S87830krJtSK8s357EJCdILqOakDDEhd37zXnexL8l6FuXCA0Bs+ejFbsKmkUc /9WlQfT1fi5qWG4SDybu4qVJYFaBd00pcMvE8EkcGN9j35ykzvqcpulV7qJe/0zcJQNQ okkQ== X-Gm-Message-State: AOJu0YwxrpAE83uG+r9dRf6CT/9UnannKmm1SxI/6Q46vwL4HPB0MHwH Vq18KL9ivj3Tl7Ca3GethrFsgesRaOt5PtvA3tkykXa/3kbROaIBf4hxNTWnfw2ikUSEv60yQpz DI3OzTkc= X-Gm-Gg: ASbGncvRyLzu+G2fkAdAZrFd1TZolAugduFhvXIFdl5qSsAf+H11M8mCJqTHQAueUhb Bv2YI4AA3Ef3vZvo+zB0bmdaNkXsL5pI8dRGKBkUevr4skZNoeO6nIpIAFGuTugtkJUv+cem6q0 6Of6V2jc+wEE9H5X/aJuLlXdn11UT4tG/PWMaquw0E2nucW+ARPIgQpvp+RaMHZ2w6zI4ZB22Hf QMUiFWc40XsC+1C7fpya/aoDE8ZDr2vAuox8UkITDDZLaBx5AYwmTbnG7+S2ixbY8n169MyWrrA KExiR7t55E4ZOGQrFkk1f+CGk3zyOCQ7mHFus7NK6u9cL3HRrOSgDXNr8zql49t48WKL6vw7nrU Uo3z4FIj18psojQ+6AfI/X/JdA97qIcr3mLOq35eemP1oH6HMH7k83PzjHTVyhRUZTuBEr3b31A kkXiMilmGmfCfm X-Google-Smtp-Source: AGHT+IEY/sSxRS3Okztem0YstmxIRhVbZi0Ba2eKMOhhVazzTllUuYgXqZyOH8eoFni3mxJ7gmSmCg== X-Received: by 2002:a05:600c:630f:b0:456:2bac:8f8 with SMTP id 5b1f17b1804b1-45868d485b0mr79331075e9.16.1753365407522; Thu, 24 Jul 2025 06:56:47 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:47 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 28/29] mm/init-mm: Annotate additional information into Kmemdump Date: Thu, 24 Jul 2025 16:55:11 +0300 Message-ID: <20250724135512.518487-29-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Annotate additional static information into kmemdump: - _sinittext - _einittext - _end - _text - _stext - _etext - swapper_pg_dir Information on these variables is stored into dedicated kmemdump section. Signed-off-by: Eugen Hristev --- mm/init-mm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/init-mm.c b/mm/init-mm.c index 2dbbaf640cf4..01ff91f35b23 100644 --- a/mm/init-mm.c +++ b/mm/init-mm.c @@ -20,6 +20,13 @@ =20 const struct vm_operations_struct vma_dummy_vm_ops; =20 +KMEMDUMP_VAR_CORE(_sinittext, sizeof(void *)); +KMEMDUMP_VAR_CORE(_einittext, sizeof(void *)); +KMEMDUMP_VAR_CORE(_end, sizeof(void *)); +KMEMDUMP_VAR_CORE(_text, sizeof(void *)); +KMEMDUMP_VAR_CORE(_stext, sizeof(void *)); +KMEMDUMP_VAR_CORE(_etext, sizeof(void *)); + /* * For dynamically allocated mm_structs, there is a dynamically sized cpum= ask * at the end of the structure, the size of which depends on the maximum C= PU @@ -51,6 +58,7 @@ struct mm_struct init_mm =3D { =20 KMEMDUMP_VAR_CORE(init_mm, sizeof(init_mm)); KMEMDUMP_VAR_CORE_NAMED(init_mm_pgd, init_mm.pgd, sizeof(*init_mm.pgd)); +KMEMDUMP_VAR_CORE(swapper_pg_dir, sizeof(&swapper_pg_dir)); =20 void setup_initial_init_mm(void *start_code, void *end_code, void *end_data, void *brk) --=20 2.43.0 From nobody Mon Oct 6 04:56:07 2025 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26FAE2E1724 for ; Thu, 24 Jul 2025 13:56:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365414; cv=none; b=BVLvCrrTOhvcwscuGU//XoUfzm7LmzclWPS/uVeJEfRmOIkjVMnSDUp27jCSH3FfmdWbj9RBKiotFlBp1SduLqW8rf/8Unp7sCRQjCe47XNlFZpkacjDIe58lI+I0iV4CEJB3okqGTNdTgmvCP2S8fqQ2prCqjvAXYv831+Ypdc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753365414; c=relaxed/simple; bh=keWPLEbOGxgCPEXPzl+/Ir+USGzWWcNwNQoM7IMi2yk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c5oQym/Z/JYMuILGR1mKe5prBrC/XhXhg6Ubfx75cI8TThKnOK9YGbsd1P4PJFDB5vFwXIP6Z3yECpvMOFF8Pcprk4rDB4nR3XrW6unPMftCTh6joMgreUBJUDaTBbHOcOrZcCM2Gei2IDUb0oj4qsBZsDh+uKD9l3yvG8mkKaQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=e6dr/QgN; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="e6dr/QgN" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4560d176f97so11424585e9.0 for ; Thu, 24 Jul 2025 06:56:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753365408; x=1753970208; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fWG6liyAx+OC/k6NlOqOAiqfCofkENyDgSwiIXNmCrk=; b=e6dr/QgNr2/LiA/z5ZoesLi78GwxWAlcgipg2Gi7GykPmzr/RgRti8WrGZNALk0OG1 XFKUs6qIgnFdAfS43LAFX9FmNil7rIwksRGw2DlUmFbcMjkCV5vipxYfgG3HILqNg8uW kf0aHTF5voffRZygX77uTeEq0VngNqiUWJ27vMAAGamxz1BLNYV752+G6zjQdNrb05MP r/UTXRHCo3WD6gX4pnlxApLucnafTk8FkpSjAz9iSB7Ev1d91U+QNnaRksykLuOPi+ZP Hqp9tn/5tverlmHKP+0brN79cSmre1oS+DJ1QJyKW+YSbpskZU5MOqPX88te3d3W57Vi TIAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753365408; x=1753970208; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fWG6liyAx+OC/k6NlOqOAiqfCofkENyDgSwiIXNmCrk=; b=ZcKQaqQdV3jDfd7q25qLbVzZN9JrG9/Tyamlb9vITHrunB0tiCZXnuKSUL+K1INxRE KDYcyt1sOJsM0FgxvImrZmJO+7AaNy7Hy/zddUa3ovJPQrZBxTaypelQQ4D3sZmQAzHE 3S4BphHlwtDzXvYSjlIVHZQu8hB8iVkxBDg+BKoxgmC3L4dcWrSA5xnYd3udFu+FqOAw CNg+4QS1prD4pBS+Bu82dbLSoFV7AYe5FuY4lCNyNEvt6OZtSuLEXhmfoSjyzmch601B Oxf9v5yNuW8DHpr3ECgXGY5UvJudz99XnGMw6zaO0iuwKW4Cmh2iLNN9sCzJZM4gwHow dQDQ== X-Gm-Message-State: AOJu0YzJm/eaQOrtBgH6gACucQDXwkMjgHSwXlEhZ7Ktlo65q11eTmQS Mup1QSjvS2yJdU5I7rF4ncQKIXSBSZSQHT8YpgN9cSyQuGmkyQkruSHi4J26UFN5J4SlTp64uDF vnRTnpnk= X-Gm-Gg: ASbGncvWYluAWfbstTjbNnn64l6pHhQCqsMFqZnoSHTFJrdFHxA6JkAyrGaa+AcFW9C HUENg6xtWPi6uqxQG5b5/ZzFFhYTNlB1onJBEmHTmU2SYg59onvr3crjV6bsik8dBsCLmCldMz1 ppoxfvNZqee8POEzhOjrOt7PT7bxuKLqXKfTk9D2NolTj3oj4p2pNw6rO7VBFrPv/Ub6IfIA8jY zT4xhMgq2Oy0XOQdGgvIxJ39oQpIR8MsCtPS98gLOCLrJjbc5NDSP+BMs5o3QoNs1YPYAe+A0Qv k+qqDeMDfLfCfNEg4q9iksL5N1Tdvw1GzjKSGm8yPMj1urKPQufNW0JSNYF9goa94RE3uZVtvsw MlcR8WKw9ekv5Ri5PWm1O6/3YDdHgtTzQ1iSDf8D+Cahs9wlaNLL7cGGDEWaD9ZR7Z1TwiPafuy ENA1pmGu5k2QnJ X-Google-Smtp-Source: AGHT+IGPJc7unar/DDQTk3kiLLtY/cjrcVJ4F2sYy/xaKu3cmlZTqIIza2uFiyGLrfIi1KWSYZcG+g== X-Received: by 2002:a05:600c:1554:b0:456:1c4a:82b2 with SMTP id 5b1f17b1804b1-4586d84cfb5mr49962935e9.10.1753365408340; Thu, 24 Jul 2025 06:56:48 -0700 (PDT) Received: from eugen-station.. (cpc148880-bexl9-2-0-cust354.2-3.cable.virginm.net. [82.11.253.99]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4587054e37dsm20889375e9.14.2025.07.24.06.56.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jul 2025 06:56:48 -0700 (PDT) From: Eugen Hristev To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, andersson@kernel.org, pmladek@suse.com Cc: linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, eugen.hristev@linaro.org, corbet@lwn.net, mojha@qti.qualcomm.com, rostedt@goodmis.org, jonechou@google.com, tudor.ambarus@linaro.org Subject: [RFC][PATCH v2 29/29] kmemdump: Add Kinfo backend driver Date: Thu, 24 Jul 2025 16:55:12 +0300 Message-ID: <20250724135512.518487-30-eugen.hristev@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250724135512.518487-1-eugen.hristev@linaro.org> References: <20250724135512.518487-1-eugen.hristev@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add Kinfo backend driver. This backend driver will select only regions of interest for the firmware, and it copy those into a shared memory area that is supplied via OF. The firmware is only interested in addresses for some symbols. The list format is kinfo-compatible, with devices like Google Pixel phone. Based on original work from Jone Chou Signed-off-by: Eugen Hristev --- As stated in the cover letter I did not test this on a device as I do not have one. Testing is appreciated and feedback welcome ! This kinfo backend is how we envision it to look like, while preserving compatibility with existing devices and firmware. Yes I also know the compatible is not documented. But if we want to have this driver in the kernel, I can easily add one MAINTAINERS | 5 + drivers/debug/Kconfig | 13 ++ drivers/debug/Makefile | 1 + drivers/debug/kinfo.c | 304 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 323 insertions(+) create mode 100644 drivers/debug/kinfo.c diff --git a/MAINTAINERS b/MAINTAINERS index 68797717175c..bc605480d6e8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13625,6 +13625,11 @@ F: drivers/debug/kmemdump.c F: drivers/debug/kmemdump_coreimage.c F: include/linux/kmemdump.h =20 +KMEMDUMP KINFO BACKEND DRIVER +M: Eugen Hristev +S: Maintained +F: drivers/debug/kinfo.c + KMEMDUMP QCOM MINIDUMP BACKEND DRIVER M: Eugen Hristev S: Maintained diff --git a/drivers/debug/Kconfig b/drivers/debug/Kconfig index d34ceaf99bd8..1a44990c2824 100644 --- a/drivers/debug/Kconfig +++ b/drivers/debug/Kconfig @@ -39,4 +39,17 @@ config KMEMDUMP_QCOM_MINIDUMP_BACKEND into the minidump table of contents. Further on, the firmware will be able to read the table of contents and extract the memory regions on case-by-case basis. + +config KMEMDUMP_KINFO_BACKEND + tristate "Shared memory KInfo compatible backend" + depends on KMEMDUMP + help + Say y here to enable the Shared memory KInfo compatible backend + driver. + With this backend, the registered regions are copied to a shared + memory zone at register time. + The shared memory zone is supplied via OF. + This backend will select only regions that are of interest, + and keep only addresses. The format of the list is Kinfo compatible. + endmenu diff --git a/drivers/debug/Makefile b/drivers/debug/Makefile index 7f70b84049cb..861f2e2c4fe2 100644 --- a/drivers/debug/Makefile +++ b/drivers/debug/Makefile @@ -3,3 +3,4 @@ obj-$(CONFIG_KMEMDUMP) +=3D kmemdump.o obj-$(CONFIG_KMEMDUMP_COREIMAGE) +=3D kmemdump_coreimage.o obj-$(CONFIG_KMEMDUMP_QCOM_MINIDUMP_BACKEND) +=3D qcom_minidump.o +obj-$(CONFIG_KMEMDUMP_KINFO_BACKEND) +=3D kinfo.o diff --git a/drivers/debug/kinfo.c b/drivers/debug/kinfo.c new file mode 100644 index 000000000000..bdf50254fa92 --- /dev/null +++ b/drivers/debug/kinfo.c @@ -0,0 +1,304 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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; + u32 all_info_size; + struct kmemdump_backend kinfo_be; +}; + +static struct debug_kinfo *kinfo; + +#define be_to_kinfo(be) container_of(be, struct debug_kinfo, kinfo_be) + +static void update_kernel_all_info(struct kernel_all_info *all_info) +{ + int index; + struct kernel_info *info; + u32 *checksum_info; + + all_info->magic_number =3D DEBUG_KINFO_MAGIC; + all_info->combined_checksum =3D 0; + + info =3D &all_info->info; + checksum_info =3D (u32 *)info; + for (index =3D 0; index < sizeof(*info) / sizeof(u32); index++) + all_info->combined_checksum ^=3D checksum_info[index]; +} + +static int build_info_set(const char *str, const struct kernel_param *kp) +{ + struct kernel_all_info *all_info =3D kinfo->all_info_addr; + size_t build_info_size; + + if (kinfo->all_info_addr =3D=3D 0 || kinfo->all_info_size =3D=3D 0) + return -ENAVAIL; + + all_info =3D (struct kernel_all_info *)kinfo->all_info_addr; + build_info_size =3D sizeof(all_info->info.build_info); + + memcpy(&all_info->info.build_info, str, min(build_info_size - 1, + strlen(str))); + update_kernel_all_info(all_info); + + if (strlen(str) > build_info_size) { + pr_warn("%s: Build info buffer (len: %zd) can't hold entire string '%s'\= n", + __func__, build_info_size, str); + return -ENOMEM; + } + + return 0; +} + +static const struct kernel_param_ops build_info_op =3D { + .set =3D 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 de= bug kinfo."); + +/** + * register_kinfo_region() - Register a new kinfo region + * @be: pointer to backend + * @id: unique id to identify the region + * @vaddr: virtual memory address of the region start + * @size: size of the region + * + * Return: On success, it returns 0 and negative error value on failure. + */ +static int register_kinfo_region(const struct kmemdump_backend *be, + enum kmemdump_uid id, void *vaddr, size_t size) +{ + struct debug_kinfo *kinfo =3D be_to_kinfo(be); + struct kernel_all_info *all_info =3D kinfo->all_info_addr; + struct kernel_info *info =3D &all_info->info; + + switch (id) { + case KMEMDUMP_ID_COREIMAGE__sinittext: + info->_sinittext_pa =3D (u64)__pa(vaddr); + break; + case KMEMDUMP_ID_COREIMAGE__einittext: + info->_einittext_pa =3D (u64)__pa(vaddr); + break; + case KMEMDUMP_ID_COREIMAGE__end: + info->_end_pa =3D (u64)__pa(vaddr); + break; + case KMEMDUMP_ID_COREIMAGE__text: + info->_text_pa =3D (u64)__pa(vaddr); + break; + case KMEMDUMP_ID_COREIMAGE__stext: + info->_stext_pa =3D (u64)__pa(vaddr); + break; + case KMEMDUMP_ID_COREIMAGE__etext: + info->_etext_pa =3D (u64)__pa(vaddr); + break; + case KMEMDUMP_ID_COREIMAGE_kallsyms_num_syms: + info->num_syms =3D *(__u32 *)vaddr; + break; + case KMEMDUMP_ID_COREIMAGE_kallsyms_relative_base: + info->_relative_pa =3D (u64)__pa(vaddr); + break; + case KMEMDUMP_ID_COREIMAGE_kallsyms_offsets: + info->_offsets_pa =3D (u64)__pa(vaddr); + break; + case KMEMDUMP_ID_COREIMAGE_kallsyms_names: + info->_names_pa =3D (u64)__pa(vaddr); + break; + case KMEMDUMP_ID_COREIMAGE_kallsyms_token_table: + info->_token_table_pa =3D (u64)__pa(vaddr); + break; + case KMEMDUMP_ID_COREIMAGE_kallsyms_token_index: + info->_token_index_pa =3D (u64)__pa(vaddr); + break; + case KMEMDUMP_ID_COREIMAGE_kallsyms_markers: + info->_markers_pa =3D (u64)__pa(vaddr); + break; + case KMEMDUMP_ID_COREIMAGE_kallsyms_seqs_of_names: + info->_seqs_of_names_pa =3D (u64)__pa(vaddr); + break; + case KMEMDUMP_ID_COREIMAGE_swapper_pg_dir: + info->swapper_pg_dir_pa =3D (u64)__pa(vaddr); + break; + case KMEMDUMP_ID_COREIMAGE_init_uts_ns_name: + strscpy(info->last_uts_release, vaddr, __NEW_UTS_LEN); + break; + default: + }; + + update_kernel_all_info(all_info); + return 0; +} + +/** + * unregister_md_region() - Unregister a previously registered kinfo region + * @id: unique id to identify the region + * + * Return: On success, it returns 0 and negative error value on failure. + */ +static int unregister_kinfo_region(const struct kmemdump_backend *be, + enum kmemdump_uid id) +{ + return 0; +} + +static int debug_kinfo_probe(struct platform_device *pdev) +{ + struct device_node *mem_region; + struct reserved_mem *rmem; + struct kernel_info *info; + struct kernel_all_info *all_info; + + mem_region =3D of_parse_phandle(pdev->dev.of_node, "memory-region", 0); + if (!mem_region) { + dev_warn(&pdev->dev, "no such memory-region\n"); + return -ENODEV; + } + + rmem =3D of_reserved_mem_lookup(mem_region); + if (!rmem) { + dev_warn(&pdev->dev, "no such reserved mem of node name %s\n", + pdev->dev.of_node->name); + return -ENODEV; + } + + /* Need to wait for reserved memory to be mapped */ + if (!rmem->priv) + return -EPROBE_DEFER; + + if (!rmem->base || !rmem->size) { + dev_warn(&pdev->dev, "unexpected reserved memory\n"); + return -EINVAL; + } + + if (rmem->size < sizeof(struct kernel_all_info)) { + dev_warn(&pdev->dev, "unexpected reserved memory size\n"); + return -EINVAL; + } + + kinfo =3D kzalloc(sizeof(*kinfo), GFP_KERNEL); + if (!kinfo) + return -ENOMEM; + + kinfo->dev =3D &pdev->dev; + + strscpy(kinfo->kinfo_be.name, "debug_kinfo"); + kinfo->kinfo_be.register_region =3D register_kinfo_region; + kinfo->kinfo_be.unregister_region =3D unregister_kinfo_region; + kinfo->all_info_addr =3D rmem->priv; + kinfo->all_info_size =3D rmem->size; + + all_info =3D kinfo->all_info_addr; + + memset(all_info, 0, sizeof(struct kernel_all_info)); + info =3D &all_info->info; + info->enabled_all =3D IS_ENABLED(CONFIG_KALLSYMS_ALL); + info->enabled_absolute_percpu =3D IS_ENABLED(CONFIG_KALLSYMS_ABSOLUTE_PER= CPU); + info->enabled_cfi_clang =3D IS_ENABLED(CONFIG_CFI_CLANG); + info->name_len =3D KSYM_NAME_LEN; + info->bit_per_long =3D BITS_PER_LONG; + info->module_name_len =3D MODULE_NAME_LEN; + info->symbol_len =3D KSYM_SYMBOL_LEN; + info->thread_size =3D THREAD_SIZE; + info->enabled_modules_tree_lookup =3D IS_ENABLED(CONFIG_MODULES_TREE_LOOK= UP); + info->mod_mem_offset =3D offsetof(struct module, mem); + info->mod_kallsyms_offset =3D offsetof(struct module, kallsyms); + + return kmemdump_register_backend(&kinfo->kinfo_be); +} + +static void debug_kinfo_remove(struct platform_device *pdev) +{ + kfree(kinfo); + kmemdump_unregister_backend(&kinfo->kinfo_be); +} + +static const struct of_device_id debug_kinfo_of_match[] =3D { + { .compatible =3D "google,debug-kinfo" }, + {}, +}; +MODULE_DEVICE_TABLE(of, debug_kinfo_of_match); + +static struct platform_driver debug_kinfo_driver =3D { + .probe =3D debug_kinfo_probe, + .remove =3D debug_kinfo_remove, + .driver =3D { + .name =3D "debug-kinfo", + .of_match_table =3D of_match_ptr(debug_kinfo_of_match), + }, +}; +module_platform_driver(debug_kinfo_driver); + +MODULE_AUTHOR("Eugen Hristev "); +MODULE_AUTHOR("Jone Chou "); +MODULE_DESCRIPTION("Debug Kinfo Driver"); +MODULE_LICENSE("GPL"); --=20 2.43.0