Search notes:

drivers/firmware/efi/libstub/x86-stub.c

Documentation/admin-guide/efi-stub.rst says that drivers/firmware/efi/libstub/x86-stub.c and arch/x86/boot/header.S are collectively known as the EFI boot stub, which is the code that modifies the bzImage header along with the EFI-specific entry point which the firmware loader jumps to.

efi_pe_entry

The address of efi_pe_entry is assigned to the AddressOfEntryPoint field (defined in arch/x86/boot/header.S) and will thus be the function that UEFI calls when it has loaded arch/x86/boot/bzImage (provided the kernel is started via UEFI, I believe CONFIG_EFI_STUB must be enabled).
In order to be able to add this address to bzImage, it is recorded in arch/x86/boot/zoffset.h.
If the kernel is booted in 64-bit mode on a 32-bit EFI firmware, efi_pe_entry is called from startup_64_mixed_mode.
The signature of efi_pe_entry is
efi_status_t __efiapi efi_pe_entry(
    efi_handle_t        handle,
    efi_system_table_t *sys_table_arg
)
Among others, efi_pe_entry creates a boot_params struct (because this is expected to be passed in the x86 boot code) and copies the fields of jump and above of the setup header from the «second sector» (of bzImage) to this boot_params and fills a few other values in the struct:
When the struct is set up, it calls efi_stub_entry and passes the struct to it.
In earlier releases (when exactly did it change?), efi_stub_entry was defined as SYM_FUNC_ALIAS for
In a mixed environment, efi_pe_entry is called from startup_64_mixed_mode.
Note: drivers/firmware/libstub/efi-stub-entry.c defines an efi_pe_entry function to be used for ARM, arm64, RISC-v and LoongArch.

efi_stub_entry

efi_stub_entry is the shared entry point for all different boot modes that enter via the EFI stub.
If successful, the last statement of efi_stub_entry is to call enter_kernel (passing a kernel address and the so called boot parameters) which does not return (hence, also efi_stub_entry is annotated with __noreturn`).

efi_handover_entry

efi_handover_entry is compiled if the (deprecated) CONFIG_EFI_HANDOVER_PROTOCOL is enabled.
This function calls efi_stub_entry.

Index