1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (C) 2013 - 2017 Linaro, Ltd. 4 * Copyright (C) 2013, 2014 Red Hat, Inc. 5 */ 6 7 #include <linux/pe.h> 8 #include <linux/sizes.h> 9 10 .macro efi_signature_nop 11 #ifdef CONFIG_EFI 12 .L_head: 13 /* 14 * This ccmp instruction has no meanin 15 * its opcode forms the magic "MZ" sig 16 */ 17 ccmp x18, #0, #0xd, pl 18 #else 19 /* 20 * Bootloaders may inspect the opcode 21 * image to decide if the kernel is ca 22 * So put an ordinary NOP here, not th 23 */ 24 nop 25 #endif 26 .endm 27 28 .macro __EFI_PE_HEADER 29 #ifdef CONFIG_EFI 30 .set .Lpe_header_offset, . - .L_hea 31 .long PE_MAGIC 32 .short IMAGE_FILE_MACHINE_ARM64 33 .short .Lsection_count 34 .long 0 35 .long 0 36 .long 0 37 .short .Lsection_table - .Loptional_h 38 .short IMAGE_FILE_DEBUG_STRIPPED | \ 39 IMAGE_FILE_EXECUTABLE_IMAGE | 40 IMAGE_FILE_LINE_NUMS_STRIPPED 41 42 .Loptional_header: 43 .short PE_OPT_MAGIC_PE32PLUS 44 .byte 0x02 45 .byte 0x14 46 .long __initdata_begin - .Lefi_heade 47 .long __pecoff_data_size 48 .long 0 49 .long __efistub_efi_pe_entry - .L_he 50 .long .Lefi_header_end - .L_head 51 52 .quad 0 53 .long SEGMENT_ALIGN 54 .long PECOFF_FILE_ALIGNMENT 55 .short 0 56 .short 0 57 .short LINUX_EFISTUB_MAJOR_VERSION 58 .short LINUX_EFISTUB_MINOR_VERSION 59 .short 0 60 .short 0 61 .long 0 62 63 .long _end - .L_head 64 65 // Everything before the kernel image 66 .long .Lefi_header_end - .L_head 67 .long 0 68 .short IMAGE_SUBSYSTEM_EFI_APPLICATIO 69 .short IMAGE_DLL_CHARACTERISTICS_NX_C 70 .quad 0 71 .quad 0 72 .quad 0 73 .quad 0 74 .long 0 75 .long (.Lsection_table - .) / 8 76 77 .quad 0 78 .quad 0 79 .quad 0 80 .quad 0 81 .quad 0 82 .quad 0 83 84 #if defined(CONFIG_DEBUG_EFI) || defined(CONFI 85 .long .Lefi_debug_table - .L_head 86 .long .Lefi_debug_table_size 87 88 /* 89 * The debug table is referenced via i 90 * which is only defined for those par 91 * by a section declaration. Since thi 92 * section, the debug table must be em 93 * the .init.rodata section instead. 94 * 95 * Note that the payloads themselves a 96 * which means we can simply put those 97 */ 98 __INITRODATA 99 100 .align 2 101 .Lefi_debug_table: 102 #ifdef CONFIG_DEBUG_EFI 103 // EFI_IMAGE_DEBUG_DIRECTORY_ENTRY 104 .long 0 105 .long 0 106 .short 0 107 .short 0 108 .long IMAGE_DEBUG_TYPE_CODEVIEW 109 .long .Lefi_debug_entry_size 110 .long 0 111 .long .Lefi_debug_entry - .L_head 112 #endif 113 #ifdef CONFIG_ARM64_BTI_KERNEL 114 .long 0 115 .long 0 116 .short 0 117 .short 0 118 .long IMAGE_DEBUG_TYPE_EX_DLLCHARACT 119 .long 4 120 .long 0 121 .long .Lefi_dll_characteristics_ex - 122 #endif 123 .set .Lefi_debug_table_size, . - .L 124 .previous 125 #endif 126 127 // Section table 128 .Lsection_table: 129 .ascii ".text\0\0\0" 130 .long __initdata_begin - .Lefi_heade 131 .long .Lefi_header_end - .L_head 132 .long __initdata_begin - .Lefi_heade 133 .long .Lefi_header_end - .L_head 134 135 .long 0 136 .long 0 137 .short 0 138 .short 0 139 .long IMAGE_SCN_CNT_CODE | \ 140 IMAGE_SCN_MEM_READ | \ 141 IMAGE_SCN_MEM_EXECUTE 142 143 .ascii ".data\0\0\0" 144 .long __pecoff_data_size 145 .long __initdata_begin - .L_head 146 .long __pecoff_data_rawsize 147 .long __initdata_begin - .L_head 148 149 .long 0 150 .long 0 151 .short 0 152 .short 0 153 .long IMAGE_SCN_CNT_INITIALIZED_DATA 154 IMAGE_SCN_MEM_READ | \ 155 IMAGE_SCN_MEM_WRITE 156 157 .set .Lsection_count, (. - .Lsectio 158 159 #ifdef CONFIG_DEBUG_EFI 160 .Lefi_debug_entry: 161 // EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY 162 .ascii "NB10" 163 .long 0 164 .long 0 165 .long 0 166 167 .asciz VMLINUX_PATH 168 169 .set .Lefi_debug_entry_size, . - .L 170 #endif 171 #ifdef CONFIG_ARM64_BTI_KERNEL 172 .Lefi_dll_characteristics_ex: 173 .long IMAGE_DLLCHARACTERISTICS_EX_FO 174 #endif 175 176 .balign SEGMENT_ALIGN 177 .Lefi_header_end: 178 #else 179 .set .Lpe_header_offset, 0x0 180 #endif 181 .endm
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.