Skip to content

RFC arm64/hyperv: Enable kexec reboot support

Shradha Gupta linux-arm-kernel linux-hyperv lkml sashiko-reviews 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2arm64: Add pre-shutdown hook to machine_shutdown()arch/arm64/include/asm/system_misc.h arch/arm64/kernel/process.c+15 -01 reply
2/2arm64/hyperv: Add kexec handler using machine_shutdown hookarch/arm64/hyperv/mshyperv.c+37 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/2] arm64/hyperv: Enable kexec reboot support

Kexec reboot consistently fails on ARM64 Hyper-V guests (Azure VMs). During the kexec shutdown path, VMBus channels are never cleaned up, so in the fresh kexec kernel startup hv_acpi_init() blocks because the hypervisor still holds the old kernel's VMBus session open.

This is because ARM64 lacks the VMBus teardown that x86 performs during kexec via hv_machine_shutdown(). On x86, machine_ops.shutdown is overridden to send CHANNELMSG_UNLOAD and disable SynIC before CPUs go offline. ARM64 has no equivalent mechanism.

Why existing notification mechanisms don't work:

- Reboot notifiers: Fire too early - they run inside kernel_restart_prepare(), BEFORE device_shutdown(). VMBus UNLOAD must happen AFTER device_shutdown() so that PCI drivers can clean up interrupt mappings (PCI_DELETE_INTERRUPT_MESSAGE) before UNLOAD force-closes channels. Sending UNLOAD first causes interrupt mapping leaks because the mappings aren't released on channel close.

- Device .shutdown callbacks: Too narrow - these handle per-device cleanup (e.g., individual VMBus channel teardown), but cannot perform bus-level operations like sending the global VMBus UNLOAD message or removing the SynIC CPU hotplug state via cpuhp_remove_state().

- VMBus parent device .shutdown callback: Also insufficient - cpuhp_remove_state() for SynIC teardown must run after all device shutdown completes, not during it. A parent .shutdown callback still executes within device_shutdown().

- The required window is: after device_shutdown() completes, after cpu_hotplug_enable(), but before smp_shutdown_nonboot_cpus(). That window exists inside machine_shutdown(), which currently has no hook.

The need for an ARM64 shutdown hook was previously discussed in [1] but lacked a concrete failure case at the time. We now have one.

[1] https://lore.kernel.org/linux-arm-kernel/[email protected]/

This RFC proposes fixing kexec on ARM64 Hyper-V guests with:

Patch 1: A platform hook (arm64_pre_smp_shutdown_hook) in ARM64's
machine_shutdown(), analogous to x86's machine_ops.shutdown. This runs after device_shutdown() and cpu_hotplug_enable(), allowing platform code to inject pre-shutdown logic at the right point in the kexec path.

Design choices I'd like feedback on:
- Single function pointer vs full machine_ops struct: ARM64 uses kernel-wide APIs (register_restart_handler, register_platform_power_off) for restart/poweroff rather than x86's monolithic machine_ops, so a targeted hook seemed more consistent with the ARM64 pattern.
- On ARM64, machine_shutdown() is only called from kernel_kexec(), unlike x86/powerpc where it's also called from restart/halt/poweroff.

Patch 2: Uses this hook to call hv_kexec_handler() which performs:
- vmbus_initiate_unload(): sends CHANNELMSG_UNLOAD to host
- cpuhp_remove_state(): disables SynIC (SIMP, SIEFP, SINT) on all CPUs, ensuring the kexec'd kernel starts with clean state

Tested on ARM64 Azure VMs (Ubuntu 22.04, multiple vCPU configs):
- kexec reboot succeeds, VM comes back online with SSH
- Normal reboot/poweroff unaffected
- Multiple consecutive kexec cycles pass

Looking for feedback on:
1. Is the single function pointer hook acceptable for ARM64, or would the ARM64 maintainers prefer a registration API or __weak function?
2. Should this be arm64-specific or generic kexec infrastructure?

Shradha Gupta (2):
arm64: Add pre-shutdown hook to machine_shutdown() arm64/hyperv: Add kexec handler using machine_shutdown hook

 arch/arm64/hyperv/mshyperv.c         | 37 ++++++++++++++++++++++++++++
 arch/arm64/include/asm/system_misc.h |  2 ++
 arch/arm64/kernel/process.c          | 13 ++++++++++
 3 files changed, 52 insertions(+)
Signature · 1 line
2.43.0