diff options
Diffstat (limited to 'drivers/firmware/efi/libstub/arm-stub.c')
-rw-r--r-- | drivers/firmware/efi/libstub/arm-stub.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c index 3397902e4040..4deb3e7faa0e 100644 --- a/drivers/firmware/efi/libstub/arm-stub.c +++ b/drivers/firmware/efi/libstub/arm-stub.c | |||
@@ -18,6 +18,8 @@ | |||
18 | 18 | ||
19 | #include "efistub.h" | 19 | #include "efistub.h" |
20 | 20 | ||
21 | bool __nokaslr; | ||
22 | |||
21 | static int efi_secureboot_enabled(efi_system_table_t *sys_table_arg) | 23 | static int efi_secureboot_enabled(efi_system_table_t *sys_table_arg) |
22 | { | 24 | { |
23 | static efi_guid_t const var_guid = EFI_GLOBAL_VARIABLE_GUID; | 25 | static efi_guid_t const var_guid = EFI_GLOBAL_VARIABLE_GUID; |
@@ -207,14 +209,6 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table, | |||
207 | pr_efi_err(sys_table, "Failed to find DRAM base\n"); | 209 | pr_efi_err(sys_table, "Failed to find DRAM base\n"); |
208 | goto fail; | 210 | goto fail; |
209 | } | 211 | } |
210 | status = handle_kernel_image(sys_table, image_addr, &image_size, | ||
211 | &reserve_addr, | ||
212 | &reserve_size, | ||
213 | dram_base, image); | ||
214 | if (status != EFI_SUCCESS) { | ||
215 | pr_efi_err(sys_table, "Failed to relocate kernel\n"); | ||
216 | goto fail; | ||
217 | } | ||
218 | 212 | ||
219 | /* | 213 | /* |
220 | * Get the command line from EFI, using the LOADED_IMAGE | 214 | * Get the command line from EFI, using the LOADED_IMAGE |
@@ -224,7 +218,28 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table, | |||
224 | cmdline_ptr = efi_convert_cmdline(sys_table, image, &cmdline_size); | 218 | cmdline_ptr = efi_convert_cmdline(sys_table, image, &cmdline_size); |
225 | if (!cmdline_ptr) { | 219 | if (!cmdline_ptr) { |
226 | pr_efi_err(sys_table, "getting command line via LOADED_IMAGE_PROTOCOL\n"); | 220 | pr_efi_err(sys_table, "getting command line via LOADED_IMAGE_PROTOCOL\n"); |
227 | goto fail_free_image; | 221 | goto fail; |
222 | } | ||
223 | |||
224 | /* check whether 'nokaslr' was passed on the command line */ | ||
225 | if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) { | ||
226 | static const u8 default_cmdline[] = CONFIG_CMDLINE; | ||
227 | const u8 *str, *cmdline = cmdline_ptr; | ||
228 | |||
229 | if (IS_ENABLED(CONFIG_CMDLINE_FORCE)) | ||
230 | cmdline = default_cmdline; | ||
231 | str = strstr(cmdline, "nokaslr"); | ||
232 | if (str == cmdline || (str > cmdline && *(str - 1) == ' ')) | ||
233 | __nokaslr = true; | ||
234 | } | ||
235 | |||
236 | status = handle_kernel_image(sys_table, image_addr, &image_size, | ||
237 | &reserve_addr, | ||
238 | &reserve_size, | ||
239 | dram_base, image); | ||
240 | if (status != EFI_SUCCESS) { | ||
241 | pr_efi_err(sys_table, "Failed to relocate kernel\n"); | ||
242 | goto fail_free_cmdline; | ||
228 | } | 243 | } |
229 | 244 | ||
230 | status = efi_parse_options(cmdline_ptr); | 245 | status = efi_parse_options(cmdline_ptr); |
@@ -244,7 +259,7 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table, | |||
244 | 259 | ||
245 | if (status != EFI_SUCCESS) { | 260 | if (status != EFI_SUCCESS) { |
246 | pr_efi_err(sys_table, "Failed to load device tree!\n"); | 261 | pr_efi_err(sys_table, "Failed to load device tree!\n"); |
247 | goto fail_free_cmdline; | 262 | goto fail_free_image; |
248 | } | 263 | } |
249 | } | 264 | } |
250 | 265 | ||
@@ -286,12 +301,11 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table, | |||
286 | efi_free(sys_table, initrd_size, initrd_addr); | 301 | efi_free(sys_table, initrd_size, initrd_addr); |
287 | efi_free(sys_table, fdt_size, fdt_addr); | 302 | efi_free(sys_table, fdt_size, fdt_addr); |
288 | 303 | ||
289 | fail_free_cmdline: | ||
290 | efi_free(sys_table, cmdline_size, (unsigned long)cmdline_ptr); | ||
291 | |||
292 | fail_free_image: | 304 | fail_free_image: |
293 | efi_free(sys_table, image_size, *image_addr); | 305 | efi_free(sys_table, image_size, *image_addr); |
294 | efi_free(sys_table, reserve_size, reserve_addr); | 306 | efi_free(sys_table, reserve_size, reserve_addr); |
307 | fail_free_cmdline: | ||
308 | efi_free(sys_table, cmdline_size, (unsigned long)cmdline_ptr); | ||
295 | fail: | 309 | fail: |
296 | return EFI_ERROR; | 310 | return EFI_ERROR; |
297 | } | 311 | } |