x86/hyperv: Add trampoline asm code to transition from hypervisor
authorMukesh Rathor <mrathor@linux.microsoft.com>
Mon, 6 Oct 2025 22:42:06 +0000 (15:42 -0700)
committerWei Liu <wei.liu@kernel.org>
Sat, 15 Nov 2025 06:18:16 +0000 (06:18 +0000)
commitb0574ba75525c6b7e7448dd755d5cc09391478b1
treee9184a690f97d5e78a74e32b8ed44a4f0320defa
parente0a975ecd2e671664d208723476eeabb3baf08be
x86/hyperv: Add trampoline asm code to transition from hypervisor

Introduce a small asm stub to transition from the hypervisor to Linux
after devirtualization. Devirtualization means disabling hypervisor on
the fly, so after it is done, the code is running on physical processor
instead of virtual, and hypervisor is gone. This can be done by a
root vm only.

At a high level, during panic of either the hypervisor or the root,
the NMI handler asks hypervisor to devirtualize. As part of that,
the arguments include an entry point to return back to Linux. This asm
stub implements that entry point.

The stub is entered in protected mode, uses temporary gdt and page table
to enable long mode and get to kernel entry point which then restores full
kernel context to resume execution to kexec.

Signed-off-by: Mukesh Rathor <mrathor@linux.microsoft.com>
Signed-off-by: Wei Liu <wei.liu@kernel.org>
arch/x86/hyperv/hv_trampoline.S [new file with mode: 0644]