From patchwork Thu Jan 18 15:25:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Lynch via B4 Relay X-Patchwork-Id: 1888104 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=SVW7z7Cg; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TG65l1t4Wz23dx for ; Fri, 19 Jan 2024 02:26:03 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=SVW7z7Cg; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TG65k4qvRz3bwJ for ; Fri, 19 Jan 2024 02:26:02 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=SVW7z7Cg; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=145.40.73.55; helo=sin.source.kernel.org; envelope-from=devnull+nathanl.linux.ibm.com@kernel.org; receiver=lists.ozlabs.org) Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TG65Q1PtJz3bq0 for ; Fri, 19 Jan 2024 02:25:46 +1100 (AEDT) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B9C04CE1FBC; Thu, 18 Jan 2024 15:25:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 1011DC43390; Thu, 18 Jan 2024 15:25:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705591542; bh=bv8EIfucd5lBrjjXVVDPU3FSiLtb8atCLikYS+cOi0U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=SVW7z7Cg7uBzrupT3P+M0huZwscyqIFAUvkR8lMUWOI1kMhI7WutgJYTNKa60UXEl 3igECw7aCQd7Y3s8DQX7J8cYc1fkFRZ3AWN5yDVkYHsD9TcUrNh5fApx9L9yE2W8xq 1tzr6fKrAF4x42Q7G+/IPIVrc142OiEJeLuInikONOBwdJqp73peJ6celGZt2u2Htl 6C07wt2UWaOQx1GnpWXDj55qj3aEyEXdo3PtOvnH5tEIUomOwMKcmfqAbV2p4aQiFN wtKdVNAlKi8wlepYq07zK8ejC56R/odwfe/SJvrszewChOnZ9etUOByQMF/u84jF85 Lro7blXHXaomA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECCAEC47DAF; Thu, 18 Jan 2024 15:25:41 +0000 (UTC) From: Nathan Lynch via B4 Relay Date: Thu, 18 Jan 2024 09:25:12 -0600 Subject: [PATCH RFC 1/5] dump_stack: Make arch description buffer __ro_after_init MIME-Version: 1.0 Message-Id: <20240118-update-dump-stack-arch-str-v1-1-5c0f98d017b5@linux.ibm.com> References: <20240118-update-dump-stack-arch-str-v1-0-5c0f98d017b5@linux.ibm.com> In-Reply-To: <20240118-update-dump-stack-arch-str-v1-0-5c0f98d017b5@linux.ibm.com> To: "Aneesh Kumar K.V" , "Naveen N. Rao" , Brian King , Christophe Leroy , John Ogness , Michael Ellerman , Nicholas Piggin , Petr Mladek , Sergey Senozhatsky , Steven Rostedt X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705591541; l=904; i=nathanl@linux.ibm.com; s=20230817; h=from:subject:message-id; bh=uGRC5bEXAZpqbl74Y43nE5tPlwjA0DDYCHWXiMdO7oY=; b=mRB3b+vZUc4j1CZuAqps+dMLW3dhH0rtknvVIhYr75cbUsWxHXQzwL1XHsgm2Dka6lOqHqzli tuQArMMkTQ6A8GpmfpD4X7jCoFyeMG5WzBkP2vlcjAz4E3Oo1hWIy2X X-Developer-Key: i=nathanl@linux.ibm.com; a=ed25519; pk=jPDF44RvT+9DGFOH3NGoIu1xN9dF+82pjdpnKjXfoJ0= X-Endpoint-Received: by B4 Relay for nathanl@linux.ibm.com/20230817 with auth_id=78 X-Original-From: Nathan Lynch X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: nathanl@linux.ibm.com Cc: Nathan Lynch , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Nathan Lynch The static hardware description buffer is populated by arch code during boot and should not change afterwards, so mark it __ro_after_init. Signed-off-by: Nathan Lynch --- lib/dump_stack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/dump_stack.c b/lib/dump_stack.c index 83471e81501a..1057f102f6f2 100644 --- a/lib/dump_stack.c +++ b/lib/dump_stack.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -15,7 +16,7 @@ #include #include -static char dump_stack_arch_desc_str[128]; +static char dump_stack_arch_desc_str[128] __ro_after_init; /** * dump_stack_set_arch_desc - set arch-specific str to show with task dumps From patchwork Thu Jan 18 15:25:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Lynch via B4 Relay X-Patchwork-Id: 1888118 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=hMcy5SKP; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TG68Y4W3Cz23dx for ; Fri, 19 Jan 2024 02:28:29 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=hMcy5SKP; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TG68Y24KLz3cV1 for ; Fri, 19 Jan 2024 02:28:29 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=hMcy5SKP; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2604:1380:4601:e00::1; helo=ams.source.kernel.org; envelope-from=devnull+nathanl.linux.ibm.com@kernel.org; receiver=lists.ozlabs.org) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TG65Q2Tlyz3bqB for ; Fri, 19 Jan 2024 02:25:46 +1100 (AEDT) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id BC54AB818EE; Thu, 18 Jan 2024 15:25:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 1EB8AC433F1; Thu, 18 Jan 2024 15:25:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705591542; bh=w4PxFc/xAGdRj/8ioyLZhaAQGJf4tgw2WnyFI/gwxtM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=hMcy5SKPS7YCfFTJ/zALrx/WfPhrTcSjJxnjYu5dYuv2xw+sGpfl8xr9+mzDfWxZn HuOzzytvzwA1oT+oxCn4yO9VdKgrtAJxQjOXqNM3YsefYeFf6T16W57OKMJr4NyuSf t0KMPV367b6QJPHD3jj3j5fiJFRf279jB5ABJTSohRvFako3bktqRjxi/kayBafP17 xy/1bfVLBWTXhAomPYf7rmt7784n8iPUcfC+//VETDFCxjREHV7EjTTRZ54SLqsEJH pdjgvIBx+UL4ZgxfGrpr8OYcj6emxg7LD3aSKQhYQg2dE4tDcKHdo9H8wlAhZ6uCp/ u7mvqgGBg1boA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04859C47DD3; Thu, 18 Jan 2024 15:25:42 +0000 (UTC) From: Nathan Lynch via B4 Relay Date: Thu, 18 Jan 2024 09:25:13 -0600 Subject: [PATCH RFC 2/5] dump_stack: Allow update of arch description string at runtime MIME-Version: 1.0 Message-Id: <20240118-update-dump-stack-arch-str-v1-2-5c0f98d017b5@linux.ibm.com> References: <20240118-update-dump-stack-arch-str-v1-0-5c0f98d017b5@linux.ibm.com> In-Reply-To: <20240118-update-dump-stack-arch-str-v1-0-5c0f98d017b5@linux.ibm.com> To: "Aneesh Kumar K.V" , "Naveen N. Rao" , Brian King , Christophe Leroy , John Ogness , Michael Ellerman , Nicholas Piggin , Petr Mladek , Sergey Senozhatsky , Steven Rostedt X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705591541; l=5563; i=nathanl@linux.ibm.com; s=20230817; h=from:subject:message-id; bh=puwstkIXbA1WYmG0j5MptfrnsQZlAPEW8ptzDFaauAY=; b=eC8LjJAwEVJmB7aywPXDM9Fgrox4pSdU02exjnufpGg8u+eRTjMukN4/TZYFFwXn5BJq5ohdO C/iNekTxjZECl9oHRmoAfyZrnbvyLV4YTDMePIUJ7UKMcuSqHbW8e6v X-Developer-Key: i=nathanl@linux.ibm.com; a=ed25519; pk=jPDF44RvT+9DGFOH3NGoIu1xN9dF+82pjdpnKjXfoJ0= X-Endpoint-Received: by B4 Relay for nathanl@linux.ibm.com/20230817 with auth_id=78 X-Original-From: Nathan Lynch X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: nathanl@linux.ibm.com Cc: Nathan Lynch , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Nathan Lynch The IBM PowerVM platform (targeted by powerpc/pseries) exposes the physical machine model and firmware version to partitions (guests), and this information is used to populate the arch description string, e.g. IBM,8408-E8E POWER8E (raw) 0x4b0201 0xf000004 \ of:IBM,FW860.50 (SV860_146) hv:phyp pSeries The platform supports live migration of partitions between different machine models and firmware versions, so the arch description string set at boot can become inaccurate, potentially misleading anyone who's analyzing stack traces produced after a migration. Introduce a RCU-guarded pointer to the current arch description string, initializing it to the static buffer populated at boot. Add to dump_stack_print_info() a RCU read-side critical section that accesses the buffer through this pointer. The majority of architectures which don't need to update the string after boot incur only an additional indirection. As for platforms which do need that ability, they can use dump_stack_update_arch_desc(), which allocates and formats a new buffer, updates the pointer, and if appropriate frees the previous buffer. Signed-off-by: Nathan Lynch --- include/linux/printk.h | 5 +++++ lib/dump_stack.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/include/linux/printk.h b/include/linux/printk.h index 8ef499ab3c1e..6138ae019d2a 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -187,6 +187,7 @@ u32 log_buf_len_get(void); void log_buf_vmcoreinfo_setup(void); void __init setup_log_buf(int early); __printf(1, 2) void dump_stack_set_arch_desc(const char *fmt, ...); +__printf(1, 2) void dump_stack_update_arch_desc(const char *fmt, ...); void dump_stack_print_info(const char *log_lvl); void show_regs_print_info(const char *log_lvl); extern asmlinkage void dump_stack_lvl(const char *log_lvl) __cold; @@ -253,6 +254,10 @@ static inline __printf(1, 2) void dump_stack_set_arch_desc(const char *fmt, ...) { } +static inline __printf(1, 2) void dump_stack_update_arch_desc(const char *fmt, ...) +{ +} + static inline void dump_stack_print_info(const char *log_lvl) { } diff --git a/lib/dump_stack.c b/lib/dump_stack.c index 1057f102f6f2..bd497e7797ee 100644 --- a/lib/dump_stack.c +++ b/lib/dump_stack.c @@ -8,15 +8,18 @@ #include #include #include +#include #include #include #include +#include #include #include #include #include static char dump_stack_arch_desc_str[128] __ro_after_init; +static const char *dump_stack_arch_desc_ptr = dump_stack_arch_desc_str; /** * dump_stack_set_arch_desc - set arch-specific str to show with task dumps @@ -28,7 +31,7 @@ static char dump_stack_arch_desc_str[128] __ro_after_init; * arch wants to make use of such an ID string, it should initialize this * as soon as possible during boot. */ -void __init dump_stack_set_arch_desc(const char *fmt, ...) +void dump_stack_set_arch_desc(const char *fmt, ...) { va_list args; @@ -38,6 +41,45 @@ void __init dump_stack_set_arch_desc(const char *fmt, ...) va_end(args); } +/** + * dump_stack_update_arch_desc() - Update the arch description string at runtime. + * @fmt: printf-style format string + * @...: arguments for the format string + * + * A runtime counterpart of dump_stack_set_arch_desc(). Arch code + * should use this when the arch description set at boot potentially + * has become inaccurate, such as after a guest migration. + * + * Context: May sleep. + */ +void dump_stack_update_arch_desc(const char *fmt, ...) +{ + static DEFINE_SPINLOCK(arch_desc_update_lock); + const char *old; + const char *new; + va_list args; + + va_start(args, fmt); + new = kvasprintf(GFP_KERNEL, fmt, args); + va_end(args); + + if (!new) + return; + + spin_lock(&arch_desc_update_lock); + old = rcu_replace_pointer(dump_stack_arch_desc_ptr, new, + lockdep_is_held(&arch_desc_update_lock)); + spin_unlock(&arch_desc_update_lock); + + /* + * Avoid freeing the static buffer initialized during boot. + */ + if (old == dump_stack_arch_desc_str) + return; + + kfree_rcu_mightsleep(old); +} + #if IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID) #define BUILD_ID_FMT " %20phN" #define BUILD_ID_VAL vmlinux_build_id @@ -55,6 +97,8 @@ void __init dump_stack_set_arch_desc(const char *fmt, ...) */ void dump_stack_print_info(const char *log_lvl) { + const char *arch_str; + printk("%sCPU: %d PID: %d Comm: %.20s %s%s %s %.*s" BUILD_ID_FMT "\n", log_lvl, raw_smp_processor_id(), current->pid, current->comm, kexec_crash_loaded() ? "Kdump: loaded " : "", @@ -63,9 +107,11 @@ void dump_stack_print_info(const char *log_lvl) (int)strcspn(init_utsname()->version, " "), init_utsname()->version, BUILD_ID_VAL); - if (dump_stack_arch_desc_str[0] != '\0') - printk("%sHardware name: %s\n", - log_lvl, dump_stack_arch_desc_str); + rcu_read_lock(); + arch_str = rcu_dereference(dump_stack_arch_desc_ptr); + if (arch_str[0] != '\0') + printk("%sHardware name: %s\n", log_lvl, arch_str); + rcu_read_unlock(); print_worker_info(log_lvl, current); print_stop_info(log_lvl, current); From patchwork Thu Jan 18 15:25:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Lynch via B4 Relay X-Patchwork-Id: 1888117 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=Co777sOq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TG67d5XkGz23dx for ; Fri, 19 Jan 2024 02:27:41 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=Co777sOq; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TG67d36C9z3cM5 for ; Fri, 19 Jan 2024 02:27:41 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=Co777sOq; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=139.178.84.217; helo=dfw.source.kernel.org; envelope-from=devnull+nathanl.linux.ibm.com@kernel.org; receiver=lists.ozlabs.org) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TG65Q13K9z3bfS for ; Fri, 19 Jan 2024 02:25:46 +1100 (AEDT) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7A579612B8; Thu, 18 Jan 2024 15:25:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 26C18C43394; Thu, 18 Jan 2024 15:25:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705591542; bh=wxONOmmGxUyWJ69hdYeGotk0425jRRxLbiWGsew7DL0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Co777sOqdXYLbF4D/uUekrfeKydKPAYpWDwgdsbWcZrKxetnwr9Skr3xawuDApwE2 q9YFhS/xB5rtfva4cnu6WgHDTOS7jZYJxSgP4LJZgxW5t651ioZVqKSy20KVuGDYrC e2XXAn5iNNr2M55Rq9+rKsXf+tPg03YeYRwHEl/QVJ0fiCjUq7Xs5ZNsLfdFEXn3z3 nRBy0d5OHU37UlLPJAvNNdLZg1IiW3cajkdTP9mOyhpwdUO7dTRE5W3UPrym2deH7D equfvmap+1N0uOVFqSk1tMhP6ANCLEGJd0qjpFgjSGr+It6Zb0dAbLSwfGr9nQSe6V Ykgc0dU+6z0JA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F1EEC47DB3; Thu, 18 Jan 2024 15:25:42 +0000 (UTC) From: Nathan Lynch via B4 Relay Date: Thu, 18 Jan 2024 09:25:14 -0600 Subject: [PATCH RFC 3/5] powerpc/prom: Add CPU info to hardware description string later MIME-Version: 1.0 Message-Id: <20240118-update-dump-stack-arch-str-v1-3-5c0f98d017b5@linux.ibm.com> References: <20240118-update-dump-stack-arch-str-v1-0-5c0f98d017b5@linux.ibm.com> In-Reply-To: <20240118-update-dump-stack-arch-str-v1-0-5c0f98d017b5@linux.ibm.com> To: "Aneesh Kumar K.V" , "Naveen N. Rao" , Brian King , Christophe Leroy , John Ogness , Michael Ellerman , Nicholas Piggin , Petr Mladek , Sergey Senozhatsky , Steven Rostedt X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705591541; l=2684; i=nathanl@linux.ibm.com; s=20230817; h=from:subject:message-id; bh=+lv6CvMHBPkIkCIUDp5N0D4IvkHpdstqrvDIpsi8Zi8=; b=PKyW2FF7XVFeI0IyJdhUDwL62a2rUyi5fyEX8m3gJZgmgZ3WcsbUSP/o9+T10oPnzRZVM8VvP 2hrKH0MUx0OBEC+PmXWCS8VJVFn0XBFnUMsWj6hQ3D8YcH7rBl4TGF2 X-Developer-Key: i=nathanl@linux.ibm.com; a=ed25519; pk=jPDF44RvT+9DGFOH3NGoIu1xN9dF+82pjdpnKjXfoJ0= X-Endpoint-Received: by B4 Relay for nathanl@linux.ibm.com/20230817 with auth_id=78 X-Original-From: Nathan Lynch X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: nathanl@linux.ibm.com Cc: Nathan Lynch , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Nathan Lynch cur_cpu_spec->cpu_name is appended to ppc_hw_desc before cur_cpu_spec has taken on its final value. This is illustrated on pseries by comparing the CPU name as reported at boot ("POWER8E (raw)") to the contents of /proc/cpuinfo ("POWER8 (architected)"): $ dmesg | grep Hardware Hardware name: IBM,8408-E8E POWER8E (raw) 0x4b0201 0xf000004 \ of:IBM,FW860.50 (SV860_146) hv:phyp pSeries $ grep -m 1 ^cpu /proc/cpuinfo cpu : POWER8 (architected), altivec supported Some 44x models would appear to be affected as well; see identical_pvr_fixup(). This results in incorrect CPU information in stack dumps -- ppc_hw_desc is an input to dump_stack_set_arch_desc(). Delay gathering the CPU name until after all potential calls to identify_cpu(). Signed-off-by: Nathan Lynch Fixes: bd649d40e0f2 ("powerpc: Add PVR & CPU name to hardware description") --- arch/powerpc/kernel/prom.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 0b5878c3125b..c12b4434336f 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -327,6 +327,7 @@ static int __init early_init_dt_scan_cpus(unsigned long node, void *data) { const char *type = of_get_flat_dt_prop(node, "device_type", NULL); + const __be32 *cpu_version = NULL; const __be32 *prop; const __be32 *intserv; int i, nthreads; @@ -398,7 +399,7 @@ static int __init early_init_dt_scan_cpus(unsigned long node, prop = of_get_flat_dt_prop(node, "cpu-version", NULL); if (prop && (be32_to_cpup(prop) & 0xff000000) == 0x0f000000) { identify_cpu(0, be32_to_cpup(prop)); - seq_buf_printf(&ppc_hw_desc, "0x%04x ", be32_to_cpup(prop)); + cpu_version = prop; } check_cpu_feature_properties(node); @@ -409,6 +410,12 @@ static int __init early_init_dt_scan_cpus(unsigned long node, } identical_pvr_fixup(node); + + // We can now add the CPU name & PVR to the hardware description + seq_buf_printf(&ppc_hw_desc, "%s 0x%04lx ", cur_cpu_spec->cpu_name, mfspr(SPRN_PVR)); + if (cpu_version) + seq_buf_printf(&ppc_hw_desc, "0x%04x ", be32_to_cpup(cpu_version)); + init_mmu_slb_size(node); #ifdef CONFIG_PPC64 @@ -846,9 +853,6 @@ void __init early_init_devtree(void *params) dt_cpu_ftrs_scan(); - // We can now add the CPU name & PVR to the hardware description - seq_buf_printf(&ppc_hw_desc, "%s 0x%04lx ", cur_cpu_spec->cpu_name, mfspr(SPRN_PVR)); - /* Retrieve CPU related informations from the flat tree * (altivec support, boot CPU ID, ...) */ From patchwork Thu Jan 18 15:25:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Lynch via B4 Relay X-Patchwork-Id: 1888109 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=pwDvU6AG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TG66j0xtjz23dx for ; Fri, 19 Jan 2024 02:26:53 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=pwDvU6AG; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TG66h1Kv5z3cMH for ; Fri, 19 Jan 2024 02:26:52 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=pwDvU6AG; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=145.40.73.55; helo=sin.source.kernel.org; envelope-from=devnull+nathanl.linux.ibm.com@kernel.org; receiver=lists.ozlabs.org) Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TG65Q1NHmz3bnx for ; Fri, 19 Jan 2024 02:25:46 +1100 (AEDT) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 1F0E6CE1FE8; Thu, 18 Jan 2024 15:25:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 2FBECC43399; Thu, 18 Jan 2024 15:25:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705591542; bh=KMC85DRJZdm++lhsdhn7YzII9zgUNTcuLEE91FWfuxY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=pwDvU6AGkVF9wFYcfG21kt7NpsY/SxrK2Iy/JqQlL9ljLEqUd1S4U+pj+6uCewKGu GysB9boz39chxyFuf3lfTPbHXDEcEtGqqXRR2O+K5kr0C63gYHV6mh8nnahiFw9J+N xTQ4FkQL/UwZe3IwYQQprGYkozRRC7X/1KkR9Rm0l/YAQ+hIr32sUOwJsh61Zi3mla XYDb7NKgjiUK9MsjVhRU8Z5ED403xSDQYMzLNGZnbRjc+ChN1KJveP8+NV3wzsExZ9 24UWI+W0vQ7B9ZJ0y1wVuIpMujImCVfAa2+x/abl+LCtmKhX4lZ0mPh3QvdCjWM1+/ iE9PFqen9jTmA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1ABABC47DD7; Thu, 18 Jan 2024 15:25:42 +0000 (UTC) From: Nathan Lynch via B4 Relay Date: Thu, 18 Jan 2024 09:25:15 -0600 Subject: [PATCH RFC 4/5] powerpc/pseries: Prepare pseries_add_hw_description() for runtime use MIME-Version: 1.0 Message-Id: <20240118-update-dump-stack-arch-str-v1-4-5c0f98d017b5@linux.ibm.com> References: <20240118-update-dump-stack-arch-str-v1-0-5c0f98d017b5@linux.ibm.com> In-Reply-To: <20240118-update-dump-stack-arch-str-v1-0-5c0f98d017b5@linux.ibm.com> To: "Aneesh Kumar K.V" , "Naveen N. Rao" , Brian King , Christophe Leroy , John Ogness , Michael Ellerman , Nicholas Piggin , Petr Mladek , Sergey Senozhatsky , Steven Rostedt X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705591541; l=2099; i=nathanl@linux.ibm.com; s=20230817; h=from:subject:message-id; bh=CZv2kpuUutCPmlUb5oeOcKP+Rm48SwsyFZd4IK8M0MI=; b=VVNznsHiVwe7zaiA0/fbe8MyMpQpbpoQiulJKy7zUG3wlvgn6w2XdK5QLCzzLofZfATALOCz8 dlidtlO/FPgAkWxOCQuJcyLT2ARRHAF958I6ehHVXDfd352+MaTHxLt X-Developer-Key: i=nathanl@linux.ibm.com; a=ed25519; pk=jPDF44RvT+9DGFOH3NGoIu1xN9dF+82pjdpnKjXfoJ0= X-Endpoint-Received: by B4 Relay for nathanl@linux.ibm.com/20230817 with auth_id=78 X-Original-From: Nathan Lynch X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: nathanl@linux.ibm.com Cc: Nathan Lynch , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Nathan Lynch pseries_add_hw_description() will be used after boot to update the hardware description string emitted in stack dumps. Remove the __init and make it take a seq_buf * parameter instead of referencing ppc_hw_desc directly. Signed-off-by: Nathan Lynch --- arch/powerpc/platforms/pseries/setup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c index ecea85c74c43..9ae1951f8312 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c @@ -1007,7 +1007,7 @@ static void __init pSeries_cmo_feature_init(void) pr_debug(" <- fw_cmo_feature_init()\n"); } -static void __init pseries_add_hw_description(void) +static void pseries_add_hw_description(struct seq_buf *sb) { struct device_node *dn; const char *s; @@ -1015,7 +1015,7 @@ static void __init pseries_add_hw_description(void) dn = of_find_node_by_path("/openprom"); if (dn) { if (of_property_read_string(dn, "model", &s) == 0) - seq_buf_printf(&ppc_hw_desc, "of:%s ", s); + seq_buf_printf(sb, "of:%s ", s); of_node_put(dn); } @@ -1023,7 +1023,7 @@ static void __init pseries_add_hw_description(void) dn = of_find_node_by_path("/hypervisor"); if (dn) { if (of_property_read_string(dn, "compatible", &s) == 0) - seq_buf_printf(&ppc_hw_desc, "hv:%s ", s); + seq_buf_printf(sb, "hv:%s ", s); of_node_put(dn); return; @@ -1031,7 +1031,7 @@ static void __init pseries_add_hw_description(void) if (of_property_read_bool(of_root, "ibm,powervm-partition") || of_property_read_bool(of_root, "ibm,fw-net-version")) - seq_buf_printf(&ppc_hw_desc, "hv:phyp "); + seq_buf_printf(sb, "hv:phyp "); } /* @@ -1041,7 +1041,7 @@ static void __init pseries_init(void) { pr_debug(" -> pseries_init()\n"); - pseries_add_hw_description(); + pseries_add_hw_description(&ppc_hw_desc); #ifdef CONFIG_HVC_CONSOLE if (firmware_has_feature(FW_FEATURE_LPAR)) From patchwork Thu Jan 18 15:25:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Lynch via B4 Relay X-Patchwork-Id: 1888119 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=pDBdwisn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TG69T4493z23dx for ; Fri, 19 Jan 2024 02:29:17 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=pDBdwisn; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TG69T2yL8z3cZx for ; Fri, 19 Jan 2024 02:29:17 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=pDBdwisn; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=145.40.73.55; helo=sin.source.kernel.org; envelope-from=devnull+nathanl.linux.ibm.com@kernel.org; receiver=lists.ozlabs.org) Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4TG65Q556Fz3bfS for ; Fri, 19 Jan 2024 02:25:46 +1100 (AEDT) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 7A38FCE1FE9; Thu, 18 Jan 2024 15:25:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 38468C433A6; Thu, 18 Jan 2024 15:25:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705591542; bh=loaLhqGDhJWXtcsUXFBqm/6Nnc30eNcrN719EvZDEF8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=pDBdwisnWTJWdSizVqn8gGCbn7LTVoeGfXEaWx+rYB2ELXojCW/UhSdoM03OITk2N V5leDhhgvX3r5nMaAs2QQauxCFIth/tKExfEEJZ4ZmctTHaHAXVlZg8oI65z7zJuCJ by7Y7PFSrbOKb0zeZqZScClsxFW4Vf7ralolLy8rQfhhhcoJ/kQetkpVKFbmTJcHSA rv9zq96ICpHm8Qz7iGcHXGRa0xEf9DwxYjRwLsNLVT7ipcFJrqfgVcGVB/Tdu+D33m voFfx8sUvZf6mveAbYOsrKP5I2io2jVZ+yClR8IvLJHqjJ74pYY5NgHCiAmMeUFfiX zgqHewOd7+SFA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2532CC47DD6; Thu, 18 Jan 2024 15:25:42 +0000 (UTC) From: Nathan Lynch via B4 Relay Date: Thu, 18 Jan 2024 09:25:16 -0600 Subject: [PATCH RFC 5/5] powerpc/pseries: Update hardware description string after migration MIME-Version: 1.0 Message-Id: <20240118-update-dump-stack-arch-str-v1-5-5c0f98d017b5@linux.ibm.com> References: <20240118-update-dump-stack-arch-str-v1-0-5c0f98d017b5@linux.ibm.com> In-Reply-To: <20240118-update-dump-stack-arch-str-v1-0-5c0f98d017b5@linux.ibm.com> To: "Aneesh Kumar K.V" , "Naveen N. Rao" , Brian King , Christophe Leroy , John Ogness , Michael Ellerman , Nicholas Piggin , Petr Mladek , Sergey Senozhatsky , Steven Rostedt X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705591541; l=4664; i=nathanl@linux.ibm.com; s=20230817; h=from:subject:message-id; bh=yLmHE9ThZlzMbb6aloXvN4gTgnWJfDyfG66G809WhB4=; b=Q+37SjK8zZS4Tun8c+TodJT0/xdTHbgWsnBNDyyUECvL05LqqXalJJi38TeuCBXrRQu3g/dT8 C/f58x/aq0iDCDQFi4PKjSRId3cA59UKDsExSucwkOSohtWaW/rYYO6 X-Developer-Key: i=nathanl@linux.ibm.com; a=ed25519; pk=jPDF44RvT+9DGFOH3NGoIu1xN9dF+82pjdpnKjXfoJ0= X-Endpoint-Received: by B4 Relay for nathanl@linux.ibm.com/20230817 with auth_id=78 X-Original-From: Nathan Lynch X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: nathanl@linux.ibm.com Cc: Nathan Lynch , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Nathan Lynch Introduce code that rebuilds the short hardware description printed by stack traces. This sort of duplicates some code from boot (prom.c mainly), but that code populates the string as early as possible using APIs that aren't available later. So sharing all the code between the boot and runtime versions isn't feasible. To prevent "drift" between the boot and runtime versions, rebuild the description using the new runtime APIs in a late initcall and warn if it doesn't match the one built earlier. The initcall also invokes dump_stack_update_arch_desc() twice to fully exercise it before any partition migration occurs. These checks could be dropped or made configurable later. Call pseries_update_hw_description() immediately after updating the device tree when resuming from a partition migration. Signed-off-by: Nathan Lynch --- arch/powerpc/platforms/pseries/mobility.c | 5 +++ arch/powerpc/platforms/pseries/pseries.h | 1 + arch/powerpc/platforms/pseries/setup.c | 70 +++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c index 1798f0f14d58..ff573cb5aee5 100644 --- a/arch/powerpc/platforms/pseries/mobility.c +++ b/arch/powerpc/platforms/pseries/mobility.c @@ -378,6 +378,11 @@ void post_mobility_fixup(void) rc = pseries_devicetree_update(MIGRATION_SCOPE); if (rc) pr_err("device tree update failed: %d\n", rc); + /* + * Rebuild the hardware description printed in stack traces + * using the updated device tree. + */ + pseries_update_hw_description(); cacheinfo_rebuild(); diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h index bba4ad192b0f..810a64fccc7e 100644 --- a/arch/powerpc/platforms/pseries/pseries.h +++ b/arch/powerpc/platforms/pseries/pseries.h @@ -56,6 +56,7 @@ extern int dlpar_acquire_drc(u32 drc_index); extern int dlpar_release_drc(u32 drc_index); extern int dlpar_unisolate_drc(u32 drc_index); extern void post_mobility_fixup(void); +void pseries_update_hw_description(void); void queue_hotplug_event(struct pseries_hp_errorlog *hp_errlog); int handle_dlpar_errorlog(struct pseries_hp_errorlog *hp_errlog); diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c index 9ae1951f8312..72177411026e 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c @@ -1034,6 +1034,76 @@ static void pseries_add_hw_description(struct seq_buf *sb) seq_buf_printf(sb, "hv:phyp "); } +static void pseries_rebuild_hw_desc(struct seq_buf *sb) +{ + struct device_node *cpudn, *root; + const char *model; + u32 cpu_version; + + seq_buf_clear(sb); + + root = of_find_node_by_path("/"); + if (!of_property_read_string(root, "model", &model)) + seq_buf_printf(sb, "%s ", model); + of_node_put(root); + + seq_buf_printf(sb, "%s 0x%04lx ", cur_cpu_spec->cpu_name, mfspr(SPRN_PVR)); + + cpudn = of_get_next_cpu_node(NULL); + if (!of_property_read_u32(cpudn, "cpu-version", &cpu_version)) { + if ((cpu_version & 0xff000000) == 0x0f000000) + seq_buf_printf(sb, "0x%04x ", cpu_version); + } + of_node_put(cpudn); + + pseries_add_hw_description(sb); + + seq_buf_puts(sb, ppc_md.name); +} + +void pseries_update_hw_description(void) +{ + struct seq_buf sb = { // todo: use DECLARE_SEQ_BUF() once it's fixed + .buffer = (char[128]) { 0 }, + .size = sizeof(char[128]), + }; + + pseries_rebuild_hw_desc(&sb); + dump_stack_update_arch_desc("%s", seq_buf_str(&sb)); +} + +static int __init pseries_test_update_hw_desc(void) +{ + struct seq_buf sb = { // todo: use DECLARE_SEQ_BUF() once it's fixed + .buffer = (char[128]) { 0 }, + .size = sizeof(char[128]), + }; + bool mismatch; + + /* + * Ensure the rebuilt description matches the one built during + * boot. + */ + pseries_rebuild_hw_desc(&sb); + + mismatch = strcmp(seq_buf_str(&ppc_hw_desc), seq_buf_str(&sb)); + if (WARN(mismatch, "rebuilt hardware description string mismatch")) { + pr_err(" boot: '%s'\n", ppc_hw_desc.buffer); + pr_err(" runtime: '%s'\n", sb.buffer); + return -EINVAL; + } + + /* + * Invoke dump_stack_update_arch_desc() *twice* to ensure it + * exercises the free path. + */ + dump_stack_update_arch_desc("%s", sb.buffer); + dump_stack_update_arch_desc("%s", sb.buffer); + + return 0; +} +late_initcall(pseries_test_update_hw_desc); + /* * Early initialization. Relocation is on but do not reference unbolted pages */