From: Shradha Gupta <shradhagupta@linux.microsoft.com>
To: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
Long Li <longli@microsoft.com>
Cc: Shradha Gupta <shradhagupta@linux.microsoft.com>,
linux-arm-kernel@lists.infradead.org,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
Mark Rutland <mark.rutland@arm.com>,
Marc Zyngier <maz@kernel.org>,
Michael Kelley <mikelley@microsoft.com>,
Shradha Gupta <shradhagupta@microsoft.com>
Subject: [RFC PATCH 1/2] arm64: Add pre-shutdown hook to machine_shutdown()
Date: Fri, 14 Aug 2026 02:31:50 -0700 [thread overview]
Message-ID: <20260814093154.3191311-1-shradhagupta@linux.microsoft.com> (raw)
In-Reply-To: <20260814093133.3191250-1-shradhagupta@linux.microsoft.com>
Add a function pointer hook (arm64_pre_smp_shutdown_hook) that is invoked
from machine_shutdown() before smp_shutdown_nonboot_cpus(). This allows
platform code (e.g., hypervisors) to perform cleanup that must happen
after device_shutdown() but before secondary CPUs go offline.
In the kexec path, the call sequence is:
kernel_kexec()
kernel_restart_prepare()
device_shutdown() // drivers shut down here
migrate_to_reboot_cpu()
cpu_hotplug_enable()
machine_shutdown()
arm64_pre_smp_shutdown_hook() // new: platform cleanup
smp_shutdown_nonboot_cpus() // CPUs go offline
x86 achieves this via machine_ops.shutdown; ARM64 currently has no
equivalent mechanism. Rather than introducing the full machine_ops
structure, add a targeted hook for the shutdown path.
Signed-off-by: Shradha Gupta <shradhagupta@linux.microsoft.com>
---
arch/arm64/include/asm/system_misc.h | 2 ++
arch/arm64/kernel/process.c | 13 +++++++++++++
2 files changed, 15 insertions(+)
diff --git a/arch/arm64/include/asm/system_misc.h b/arch/arm64/include/asm/system_misc.h
index d316a804eb38..7c37b9f33e96 100644
--- a/arch/arm64/include/asm/system_misc.h
+++ b/arch/arm64/include/asm/system_misc.h
@@ -28,6 +28,8 @@ void arm64_notify_die(const char *str, struct pt_regs *regs,
struct mm_struct;
extern void __show_regs(struct pt_regs *);
+extern void (*arm64_pre_smp_shutdown_hook)(void);
+
#endif /* __ASSEMBLER__ */
#endif /* __ASM_SYSTEM_MISC_H */
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 581f80e9b9b7..41c0e9840913 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -88,8 +88,21 @@ void __noreturn arch_cpu_idle_dead(void)
* avoid any code or data used by any SW CPU pin loop. The CPU hotplug
* functionality embodied in smpt_shutdown_nonboot_cpus() to achieve this.
*/
+
+/*
+ * Hook for platform code to perform cleanup after device_shutdown()
+ * but before secondary CPUs are offlined. This runs in the kexec path
+ * from kernel_kexec() after device_shutdown() and cpu_hotplug_enable()
+ * have been called, matching the point at which x86 invokes
+ * machine_ops.shutdown.
+ */
+void (*arm64_pre_smp_shutdown_hook)(void);
+
void machine_shutdown(void)
{
+ if (arm64_pre_smp_shutdown_hook)
+ arm64_pre_smp_shutdown_hook();
+
smp_shutdown_nonboot_cpus(reboot_cpu);
}
--
2.43.0
next prev parent reply other threads:[~2026-08-14 9:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 9:31 [RFC PATCH 0/2] arm64/hyperv: Enable kexec reboot support Shradha Gupta
2026-08-14 9:31 ` Shradha Gupta [this message]
2026-08-14 9:38 ` [RFC PATCH 1/2] arm64: Add pre-shutdown hook to machine_shutdown() sashiko-bot
2026-08-14 9:32 ` [RFC PATCH 2/2] arm64/hyperv: Add kexec handler using machine_shutdown hook Shradha Gupta
2026-08-14 9:49 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260814093154.3191311-1-shradhagupta@linux.microsoft.com \
--to=shradhagupta@linux.microsoft.com \
--cc=catalin.marinas@arm.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=mikelley@microsoft.com \
--cc=shradhagupta@microsoft.com \
--cc=wei.liu@kernel.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox