]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
x86/hyperv: Use __naked attribute to fix stackless C function
authorArd Biesheuvel <ardb@kernel.org>
Mon, 2 Mar 2026 16:45:31 +0000 (17:45 +0100)
committerWei Liu <wei.liu@kernel.org>
Wed, 11 Mar 2026 16:54:24 +0000 (16:54 +0000)
commit3fde5281b805370a6c3bd2ef462ebff70a0ea2c6
treebc02643ac010243c812b48f9f338596945e016dd
parentedd20cb693d9cb5e3d6fcecd858093dab4e2b0aa
x86/hyperv: Use __naked attribute to fix stackless C function

hv_crash_c_entry() is a C function that is entered without a stack,
and this is only allowed for functions that have the __naked attribute,
which informs the compiler that it must not emit the usual prologue and
epilogue or emit any other kind of instrumentation that relies on a
stack frame.

So split up the function, and set the __naked attribute on the initial
part that sets up the stack, GDT, IDT and other pieces that are needed
for ordinary C execution. Given that function calls are not permitted
either, use the existing long return coded in an asm() block to call the
second part of the function, which is an ordinary function that is
permitted to call other functions as usual.

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> # asm parts, not hv parts
Reviewed-by: Mukesh Rathor <mrathor@linux.microsoft.com>
Acked-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Wei Liu <wei.liu@kernel.org>
Cc: linux-hyperv@vger.kernel.org
Fixes: 94212d34618c ("x86/hyperv: Implement hypervisor RAM collection into vmcore")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Wei Liu <wei.liu@kernel.org>
arch/x86/hyperv/hv_crash.c