|
12 | 12 | #include <asm/efi.h>
|
13 | 13 | #include <asm/setup.h>
|
14 | 14 | #include <asm/desc.h>
|
| 15 | +#include <asm/bootparam_utils.h> |
15 | 16 |
|
16 | 17 | #include "../string.h"
|
17 | 18 | #include "eboot.h"
|
@@ -571,6 +572,36 @@ static void setup_efi_pci(struct boot_params *params)
|
571 | 572 | efi_call_early(free_pool, pci_handle);
|
572 | 573 | }
|
573 | 574 |
|
| 575 | +static int get_secure_boot(void) |
| 576 | +{ |
| 577 | + u8 sb, setup; |
| 578 | + unsigned long datasize = sizeof(sb); |
| 579 | + efi_guid_t var_guid = EFI_GLOBAL_VARIABLE_GUID; |
| 580 | + efi_status_t status; |
| 581 | + |
| 582 | + status = efi_early->call((unsigned long)sys_table->runtime->get_variable, |
| 583 | + L"SecureBoot", &var_guid, NULL, &datasize, &sb); |
| 584 | + |
| 585 | + if (status != EFI_SUCCESS) |
| 586 | + return 0; |
| 587 | + |
| 588 | + if (sb == 0) |
| 589 | + return 0; |
| 590 | + |
| 591 | + |
| 592 | + status = efi_early->call((unsigned long)sys_table->runtime->get_variable, |
| 593 | + L"SetupMode", &var_guid, NULL, &datasize, |
| 594 | + &setup); |
| 595 | + |
| 596 | + if (status != EFI_SUCCESS) |
| 597 | + return 0; |
| 598 | + |
| 599 | + if (setup == 1) |
| 600 | + return 0; |
| 601 | + |
| 602 | + return 1; |
| 603 | +} |
| 604 | + |
574 | 605 | static efi_status_t
|
575 | 606 | setup_uga32(void **uga_handle, unsigned long size, u32 *width, u32 *height)
|
576 | 607 | {
|
@@ -1126,6 +1157,10 @@ struct boot_params *efi_main(struct efi_config *c,
|
1126 | 1157 | else
|
1127 | 1158 | setup_boot_services32(efi_early);
|
1128 | 1159 |
|
| 1160 | + sanitize_boot_params(boot_params); |
| 1161 | + |
| 1162 | + boot_params->secure_boot = get_secure_boot(); |
| 1163 | + |
1129 | 1164 | setup_graphics(boot_params);
|
1130 | 1165 |
|
1131 | 1166 | setup_efi_pci(boot_params);
|
|
0 commit comments