Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

efi: Add separate 32-bit/64-bit definitions

The traditional approach of using machine-specific types such as
'unsigned long' does not allow the kernel to interact with firmware
running in a different CPU mode, e.g. 64-bit kernel with 32-bit EFI.

Add distinct EFI structure definitions for both 32-bit and 64-bit so
that we can use them in the 32-bit and 64-bit code paths.

Acked-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>

+296
+44
arch/x86/boot/compressed/eboot.h
··· 37 37 u32 pixels_per_scan_line; 38 38 } __packed; 39 39 40 + struct efi_graphics_output_protocol_mode_32 { 41 + u32 max_mode; 42 + u32 mode; 43 + u32 info; 44 + u32 size_of_info; 45 + u64 frame_buffer_base; 46 + u32 frame_buffer_size; 47 + } __packed; 48 + 49 + struct efi_graphics_output_protocol_mode_64 { 50 + u32 max_mode; 51 + u32 mode; 52 + u64 info; 53 + u64 size_of_info; 54 + u64 frame_buffer_base; 55 + u64 frame_buffer_size; 56 + } __packed; 57 + 40 58 struct efi_graphics_output_protocol_mode { 41 59 u32 max_mode; 42 60 u32 mode; ··· 64 46 unsigned long frame_buffer_size; 65 47 } __packed; 66 48 49 + struct efi_graphics_output_protocol_32 { 50 + u32 query_mode; 51 + u32 set_mode; 52 + u32 blt; 53 + u32 mode; 54 + }; 55 + 56 + struct efi_graphics_output_protocol_64 { 57 + u64 query_mode; 58 + u64 set_mode; 59 + u64 blt; 60 + u64 mode; 61 + }; 62 + 67 63 struct efi_graphics_output_protocol { 68 64 void *query_mode; 69 65 unsigned long set_mode; 70 66 unsigned long blt; 71 67 struct efi_graphics_output_protocol_mode *mode; 68 + }; 69 + 70 + struct efi_uga_draw_protocol_32 { 71 + u32 get_mode; 72 + u32 set_mode; 73 + u32 blt; 74 + }; 75 + 76 + struct efi_uga_draw_protocol_64 { 77 + u64 get_mode; 78 + u64 set_mode; 79 + u64 blt; 72 80 }; 73 81 74 82 struct efi_uga_draw_protocol {
+252
include/linux/efi.h
··· 153 153 u8 sets_to_zero; 154 154 } efi_time_cap_t; 155 155 156 + typedef struct { 157 + efi_table_hdr_t hdr; 158 + u32 raise_tpl; 159 + u32 restore_tpl; 160 + u32 allocate_pages; 161 + u32 free_pages; 162 + u32 get_memory_map; 163 + u32 allocate_pool; 164 + u32 free_pool; 165 + u32 create_event; 166 + u32 set_timer; 167 + u32 wait_for_event; 168 + u32 signal_event; 169 + u32 close_event; 170 + u32 check_event; 171 + u32 install_protocol_interface; 172 + u32 reinstall_protocol_interface; 173 + u32 uninstall_protocol_interface; 174 + u32 handle_protocol; 175 + u32 __reserved; 176 + u32 register_protocol_notify; 177 + u32 locate_handle; 178 + u32 locate_device_path; 179 + u32 install_configuration_table; 180 + u32 load_image; 181 + u32 start_image; 182 + u32 exit; 183 + u32 unload_image; 184 + u32 exit_boot_services; 185 + u32 get_next_monotonic_count; 186 + u32 stall; 187 + u32 set_watchdog_timer; 188 + u32 connect_controller; 189 + u32 disconnect_controller; 190 + u32 open_protocol; 191 + u32 close_protocol; 192 + u32 open_protocol_information; 193 + u32 protocols_per_handle; 194 + u32 locate_handle_buffer; 195 + u32 locate_protocol; 196 + u32 install_multiple_protocol_interfaces; 197 + u32 uninstall_multiple_protocol_interfaces; 198 + u32 calculate_crc32; 199 + u32 copy_mem; 200 + u32 set_mem; 201 + u32 create_event_ex; 202 + } __packed efi_boot_services_32_t; 203 + 204 + typedef struct { 205 + efi_table_hdr_t hdr; 206 + u64 raise_tpl; 207 + u64 restore_tpl; 208 + u64 allocate_pages; 209 + u64 free_pages; 210 + u64 get_memory_map; 211 + u64 allocate_pool; 212 + u64 free_pool; 213 + u64 create_event; 214 + u64 set_timer; 215 + u64 wait_for_event; 216 + u64 signal_event; 217 + u64 close_event; 218 + u64 check_event; 219 + u64 install_protocol_interface; 220 + u64 reinstall_protocol_interface; 221 + u64 uninstall_protocol_interface; 222 + u64 handle_protocol; 223 + u64 __reserved; 224 + u64 register_protocol_notify; 225 + u64 locate_handle; 226 + u64 locate_device_path; 227 + u64 install_configuration_table; 228 + u64 load_image; 229 + u64 start_image; 230 + u64 exit; 231 + u64 unload_image; 232 + u64 exit_boot_services; 233 + u64 get_next_monotonic_count; 234 + u64 stall; 235 + u64 set_watchdog_timer; 236 + u64 connect_controller; 237 + u64 disconnect_controller; 238 + u64 open_protocol; 239 + u64 close_protocol; 240 + u64 open_protocol_information; 241 + u64 protocols_per_handle; 242 + u64 locate_handle_buffer; 243 + u64 locate_protocol; 244 + u64 install_multiple_protocol_interfaces; 245 + u64 uninstall_multiple_protocol_interfaces; 246 + u64 calculate_crc32; 247 + u64 copy_mem; 248 + u64 set_mem; 249 + u64 create_event_ex; 250 + } __packed efi_boot_services_64_t; 251 + 156 252 /* 157 253 * EFI Boot Services table 158 254 */ ··· 327 231 EfiPciIoAttributeOperationMaximum 328 232 } EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION; 329 233 234 + typedef struct { 235 + u32 read; 236 + u32 write; 237 + } efi_pci_io_protocol_access_32_t; 238 + 239 + typedef struct { 240 + u64 read; 241 + u64 write; 242 + } efi_pci_io_protocol_access_64_t; 330 243 331 244 typedef struct { 332 245 void *read; 333 246 void *write; 334 247 } efi_pci_io_protocol_access_t; 248 + 249 + typedef struct { 250 + u32 poll_mem; 251 + u32 poll_io; 252 + efi_pci_io_protocol_access_32_t mem; 253 + efi_pci_io_protocol_access_32_t io; 254 + efi_pci_io_protocol_access_32_t pci; 255 + u32 copy_mem; 256 + u32 map; 257 + u32 unmap; 258 + u32 allocate_buffer; 259 + u32 free_buffer; 260 + u32 flush; 261 + u32 get_location; 262 + u32 attributes; 263 + u32 get_bar_attributes; 264 + u32 set_bar_attributes; 265 + uint64_t romsize; 266 + void *romimage; 267 + } efi_pci_io_protocol_32; 268 + 269 + typedef struct { 270 + u64 poll_mem; 271 + u64 poll_io; 272 + efi_pci_io_protocol_access_64_t mem; 273 + efi_pci_io_protocol_access_64_t io; 274 + efi_pci_io_protocol_access_64_t pci; 275 + u64 copy_mem; 276 + u64 map; 277 + u64 unmap; 278 + u64 allocate_buffer; 279 + u64 free_buffer; 280 + u64 flush; 281 + u64 get_location; 282 + u64 attributes; 283 + u64 get_bar_attributes; 284 + u64 set_bar_attributes; 285 + uint64_t romsize; 286 + void *romimage; 287 + } efi_pci_io_protocol_64; 335 288 336 289 typedef struct { 337 290 void *poll_mem; ··· 434 289 */ 435 290 #define EFI_RUNTIME_SERVICES_SIGNATURE ((u64)0x5652453544e5552ULL) 436 291 #define EFI_RUNTIME_SERVICES_REVISION 0x00010000 292 + 293 + typedef struct { 294 + efi_table_hdr_t hdr; 295 + u32 get_time; 296 + u32 set_time; 297 + u32 get_wakeup_time; 298 + u32 set_wakeup_time; 299 + u32 set_virtual_address_map; 300 + u32 convert_pointer; 301 + u32 get_variable; 302 + u32 get_next_variable; 303 + u32 set_variable; 304 + u32 get_next_high_mono_count; 305 + u32 reset_system; 306 + u32 update_capsule; 307 + u32 query_capsule_caps; 308 + u32 query_variable_info; 309 + } efi_runtime_services_32_t; 310 + 311 + typedef struct { 312 + efi_table_hdr_t hdr; 313 + u64 get_time; 314 + u64 set_time; 315 + u64 get_wakeup_time; 316 + u64 set_wakeup_time; 317 + u64 set_virtual_address_map; 318 + u64 convert_pointer; 319 + u64 get_variable; 320 + u64 get_next_variable; 321 + u64 set_variable; 322 + u64 get_next_high_mono_count; 323 + u64 reset_system; 324 + u64 update_capsule; 325 + u64 query_capsule_caps; 326 + u64 query_variable_info; 327 + } efi_runtime_services_64_t; 437 328 438 329 typedef struct { 439 330 efi_table_hdr_t hdr; ··· 666 485 667 486 typedef struct { 668 487 u32 revision; 488 + u32 parent_handle; 489 + u32 system_table; 490 + u32 device_handle; 491 + u32 file_path; 492 + u32 reserved; 493 + u32 load_options_size; 494 + u32 load_options; 495 + u32 image_base; 496 + __aligned_u64 image_size; 497 + unsigned int image_code_type; 498 + unsigned int image_data_type; 499 + unsigned long unload; 500 + } efi_loaded_image_32_t; 501 + 502 + typedef struct { 503 + u32 revision; 504 + u64 parent_handle; 505 + u64 system_table; 506 + u64 device_handle; 507 + u64 file_path; 508 + u64 reserved; 509 + u32 load_options_size; 510 + u64 load_options; 511 + u64 image_base; 512 + __aligned_u64 image_size; 513 + unsigned int image_code_type; 514 + unsigned int image_data_type; 515 + unsigned long unload; 516 + } efi_loaded_image_64_t; 517 + 518 + typedef struct { 519 + u32 revision; 669 520 void *parent_handle; 670 521 efi_system_table_t *system_table; 671 522 void *device_handle; ··· 723 510 __aligned_u64 attribute; 724 511 efi_char16_t filename[1]; 725 512 } efi_file_info_t; 513 + 514 + typedef struct { 515 + u64 revision; 516 + u32 open; 517 + u32 close; 518 + u32 delete; 519 + u32 read; 520 + u32 write; 521 + u32 get_position; 522 + u32 set_position; 523 + u32 get_info; 524 + u32 set_info; 525 + u32 flush; 526 + } efi_file_handle_32_t; 527 + 528 + typedef struct { 529 + u64 revision; 530 + u64 open; 531 + u64 close; 532 + u64 delete; 533 + u64 read; 534 + u64 write; 535 + u64 get_position; 536 + u64 set_position; 537 + u64 get_info; 538 + u64 set_info; 539 + u64 flush; 540 + } efi_file_handle_64_t; 726 541 727 542 typedef struct _efi_file_handle { 728 543 u64 revision; ··· 1050 809 bool deleting; 1051 810 }; 1052 811 812 + struct efi_simple_text_output_protocol_32 { 813 + u32 reset; 814 + u32 output_string; 815 + u32 test_string; 816 + }; 817 + 818 + struct efi_simple_text_output_protocol_64 { 819 + u64 reset; 820 + u64 output_string; 821 + u64 test_string; 822 + }; 1053 823 1054 824 struct efi_simple_text_output_protocol { 1055 825 void *reset;