From nobody Fri Apr 17 06:15:34 2026 Received: from lithops.sigma-star.at (mailout.nod.at [116.203.167.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F9261A00F0 for ; Mon, 23 Feb 2026 13:36:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.167.152 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771853809; cv=none; b=Mm/Sx3zzTkNKDxNSgu7D3Eu38SrIDF2/ACTV/Lq0Jbk1WYlL50HVZfFN6mK6CNxFjSenyOnSz1chzr/UkSh/f8ZGDHBL364okIUF/TWY/qff79ZREWhak+tymzcoCsMp3DVMGFsZ6bcmvBqA9kgZZQMEpC2PN19+3UkEb1+hW0k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771853809; c=relaxed/simple; bh=Le/YXgTZhodb8v9OooUJc3nwD3WU4+QduDenIC11roo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=dmQD66bD3NF8zoAFhXQyILQFDgn8m2uXhku3yLqGGiU9+MKGkl8W1nJ9A+iUaLjBbxuVQiLpo5ujm288cdqfS0hx3L3BuEUAa8pV2+BWsMzhkWOrrBQlSO2OQarYuq//lJTC6FrkfHnMZRsStE+XK12f07wXAuxsNHSRiuTX3nc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nod.at; spf=fail smtp.mailfrom=nod.at; arc=none smtp.client-ip=116.203.167.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nod.at Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nod.at Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 54403298580; Mon, 23 Feb 2026 14:36:38 +0100 (CET) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id wSNSrTTsjtd2; Mon, 23 Feb 2026 14:36:38 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id DF6FF298599; Mon, 23 Feb 2026 14:36:37 +0100 (CET) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id LMWZrnoTgbX3; Mon, 23 Feb 2026 14:36:37 +0100 (CET) Received: from nailgun.corp.sigma-star.at (unknown [82.150.214.1]) by lithops.sigma-star.at (Postfix) with ESMTPSA id 66BEB298580; Mon, 23 Feb 2026 14:36:37 +0100 (CET) From: Richard Weinberger To: linux-kernel@vger.kernel.org Cc: bhe@redhat.com, sourabhjain@linux.ibm.com, akpm@linux-foundation.org, senozhatsky@chromium.org, john.ogness@linutronix.de, rostedt@goodmis.org, pmladek@suse.com, gregkh@linuxfoundation.org, upstream+linux@sigma-star.at, Richard Weinberger Subject: [PATCH] ksysfs: Expose hardware name Date: Mon, 23 Feb 2026 14:34:48 +0100 Message-ID: <20260223133448.411343-1-richard@nod.at> X-Mailer: git-send-email 2.51.0 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" Userspace tools often require a short, descriptive name of the hardware platform. Currently, this information is fragmented: Device Tree-based platforms typically use /proc/device-tree/model, while x86 platforms combine multiple values from /sys/class/dmi/id/. There is no uniform, platform-agnostic way to retrieve this string. The kernel already maintains dump_stack_arch_desc_str[], which contains the model name or DMI values used for the "Hardware name:" field in stack traces. Expose dump_stack_arch_desc_str[] at /sys/kernel/hardware_name to provide userspace with a consistent interface for identifying the underlying hardware. Signed-off-by: Richard Weinberger --- .../ABI/testing/sysfs-kernel-hardware_name | 8 ++++++++ include/linux/printk.h | 1 + kernel/ksysfs.c | 13 +++++++++++++ lib/dump_stack.c | 2 +- 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-kernel-hardware_name diff --git a/Documentation/ABI/testing/sysfs-kernel-hardware_name b/Documen= tation/ABI/testing/sysfs-kernel-hardware_name new file mode 100644 index 000000000000..21d130da1932 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-kernel-hardware_name @@ -0,0 +1,8 @@ +What: /sys/kernel/hardware_name +Date: Feb 2026 +KernelVersion: 7.1 +Contact: Richard Weinberger +Description: + The hardware name as shown in stack traces. + + Access: Read diff --git a/include/linux/printk.h b/include/linux/printk.h index 63d516c873b4..b8929495e35e 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -13,6 +13,7 @@ struct console; =20 extern const char linux_banner[]; extern const char linux_proc_banner[]; +extern char dump_stack_arch_desc_str[128]; =20 extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() i= s in progress */ =20 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index a9e6354d9e25..af7265754183 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c @@ -176,6 +176,16 @@ static ssize_t rcu_normal_store(struct kobject *kobj, KERNEL_ATTR_RW(rcu_normal); #endif /* #ifndef CONFIG_TINY_RCU */ =20 +#ifdef CONFIG_PRINTK +/* hardware name */ +static ssize_t hardware_name_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%s\n", dump_stack_arch_desc_str); +} +KERNEL_ATTR_RO(hardware_name); +#endif + /* * Make /sys/kernel/notes give the raw contents of our kernel .notes secti= on. */ @@ -205,6 +215,9 @@ static struct attribute * kernel_attrs[] =3D { #ifndef CONFIG_TINY_RCU &rcu_expedited_attr.attr, &rcu_normal_attr.attr, +#endif +#ifdef CONFIG_PRINTK + &hardware_name_attr.attr, #endif NULL }; diff --git a/lib/dump_stack.c b/lib/dump_stack.c index f0c78b5b5324..bce41e603cff 100644 --- a/lib/dump_stack.c +++ b/lib/dump_stack.c @@ -15,7 +15,7 @@ #include #include =20 -static char dump_stack_arch_desc_str[128]; +char dump_stack_arch_desc_str[128]; =20 /** * dump_stack_set_arch_desc - set arch-specific str to show with task dumps --=20 2.51.0