efi_get_memory_map() allocates a buffer to store the memory map that it retrieves. This buffer may need to be reused by the client after ExitBootServices() is called, at which point allocations are not longer permitted. To support this usecase, provide the allocated buffer size back to the client, and allocate some additional headroom to account for any reasonable growth in the map that is likely to happen between the call to efi_get_memory_map() and the client reusing the buffer.
Showing the changes to include/linux (1 of 5 files). Show all
Unified · Split
| @@ -118,6 +118,15 @@ typedef struct { · 117 unmodified lines | ||
| 118 | 118 | u32 imagesize; |
| 119 | 119 | } efi_capsule_header_t; |
| 120 | 120 | |
| 121 | +struct efi_boot_memmap { | |
| 122 | + efi_memory_desc_t **map; | |
| 123 | + unsigned long *map_size; | |
| 124 | + unsigned long *desc_size; | |
| 125 | + u32 *desc_ver; | |
| 126 | + unsigned long *key_ptr; | |
| 127 | + unsigned long *buff_size; | |
| 128 | +}; | |
| 129 | + | |
| 121 | 130 | /* |
| 122 | 131 | * EFI capsule flags |
| 123 | 132 | */ |
| @@ -1371,11 +1380,7 @@ char *efi_convert_cmdline(efi_system_table_t *sys_table_arg, · 1247 unmodified lines | ||
| 1371 | 1380 | efi_loaded_image_t *image, int *cmd_line_len); |
| 1372 | 1381 | |
| 1373 | 1382 | efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, |
| 1374 | − efi_memory_desc_t **map, | |
| 1375 | − unsigned long *map_size, | |
| 1376 | − unsigned long *desc_size, | |
| 1377 | − u32 *desc_ver, | |
| 1378 | − unsigned long *key_ptr); | |
| 1383 | + struct efi_boot_memmap *map); | |
| 1379 | 1384 | |
| 1380 | 1385 | efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg, |
| 1381 | 1386 | unsigned long size, unsigned long align, |