diff options
-rw-r--r-- | arch/riscv/lib/crt0_riscv_efi.S | 39 | ||||
-rw-r--r-- | arch/riscv/lib/elf_riscv32_efi.lds | 26 | ||||
-rw-r--r-- | arch/riscv/lib/elf_riscv64_efi.lds | 26 | ||||
-rw-r--r-- | cmd/efidebug.c | 7 | ||||
-rw-r--r-- | doc/develop/driver-model/migration.rst | 2 | ||||
-rw-r--r-- | doc/develop/uefi/uefi.rst | 2 | ||||
-rw-r--r-- | include/efi_loader.h | 2 | ||||
-rw-r--r-- | lib/efi_loader/efi_firmware.c | 10 | ||||
-rw-r--r-- | lib/efi_loader/efi_helper.c | 6 | ||||
-rw-r--r-- | lib/efi_loader/efi_tcg2.c | 19 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_miniapp_exit.c | 2 |
11 files changed, 77 insertions, 64 deletions
diff --git a/arch/riscv/lib/crt0_riscv_efi.S b/arch/riscv/lib/crt0_riscv_efi.S index 793eefdd88..46b0855237 100644 --- a/arch/riscv/lib/crt0_riscv_efi.S +++ b/arch/riscv/lib/crt0_riscv_efi.S @@ -53,7 +53,7 @@ pe_header: .long IMAGE_NT_SIGNATURE /* 'PE' */ coff_header: .short PE_MACHINE /* RISC-V 64/32-bit */ - .short 2 /* nr_sections */ + .short 3 /* nr_sections */ .long 0 /* TimeDateStamp */ .long 0 /* PointerToSymbolTable */ .long 0 /* NumberOfSymbols */ @@ -144,18 +144,37 @@ section_table: .byte 0 .byte 0 .byte 0 /* end of 0 padding of section name */ - .long _edata - _start /* VirtualSize */ + .long _etext - _start /* VirtualSize */ .long _start - ImageBase /* VirtualAddress */ - .long _edata - _start /* SizeOfRawData */ + .long _etext - _start /* SizeOfRawData */ .long _start - ImageBase /* PointerToRawData */ + .long 0 /* PointerToRelocations (0 for executables) */ + .long 0 /* PointerToLineNumbers (0 for executables) */ + .short 0 /* NumberOfRelocations (0 for executables) */ + .short 0 /* NumberOfLineNumbers (0 for executables) */ + /* Characteristics (section flags) */ + .long (IMAGE_SCN_MEM_READ | \ + IMAGE_SCN_MEM_EXECUTE | \ + IMAGE_SCN_CNT_CODE) + + .ascii ".data" + .byte 0 + .byte 0 + .byte 0 /* end of 0 padding of section name */ + .long _edata - _data /* VirtualSize */ + .long _data - ImageBase /* VirtualAddress */ + .long _edata - _data /* SizeOfRawData */ + .long _data - ImageBase /* PointerToRawData */ + .long 0 /* PointerToRelocations */ + .long 0 /* PointerToLineNumbers */ + .short 0 /* NumberOfRelocations */ + .short 0 /* NumberOfLineNumbers */ + /* Characteristics (section flags) */ + .long (IMAGE_SCN_MEM_WRITE | \ + IMAGE_SCN_MEM_READ | \ + IMAGE_SCN_CNT_INITIALIZED_DATA) - .long 0 /* PointerToRelocations (0 for executables) */ - .long 0 /* PointerToLineNumbers (0 for executables) */ - .short 0 /* NumberOfRelocations (0 for executables) */ - .short 0 /* NumberOfLineNumbers (0 for executables) */ - .long 0xe0500020 /* Characteristics (section flags) */ - - .align 9 + .align 12 _start: addi sp, sp, -(SIZE_LONG * 3) SAVE_LONG(a0, 0) diff --git a/arch/riscv/lib/elf_riscv32_efi.lds b/arch/riscv/lib/elf_riscv32_efi.lds index c3e0d20d57..7b9bd7b7f1 100644 --- a/arch/riscv/lib/elf_riscv32_efi.lds +++ b/arch/riscv/lib/elf_riscv32_efi.lds @@ -1,14 +1,18 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: BSD-2-Clause */ /* * U-Boot riscv32 EFI linker script * - * SPDX-License-Identifier: BSD-2-Clause - * * Modified from arch/arm/lib/elf_aarch64_efi.lds */ OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv") OUTPUT_ARCH(riscv) + +PHDRS +{ + data PT_LOAD FLAGS(3); /* SHF_WRITE | SHF_ALLOC */ +} + ENTRY(_start) SECTIONS { @@ -20,11 +24,17 @@ SECTIONS *(.gnu.linkonce.t.*) *(.srodata) *(.rodata*) + . = ALIGN(16); + *(.dynamic); . = ALIGN(512); } + .rela.dyn : { *(.rela.dyn) } + .rela.plt : { *(.rela.plt) } + .rela.got : { *(.rela.got) } + .rela.data : { *(.rela.data) *(.rela.data*) } _etext = .; _text_size = . - _text; - .dynamic : { *(.dynamic) } + . = ALIGN(4096); .data : { _data = .; *(.sdata) @@ -49,12 +59,8 @@ SECTIONS . = ALIGN(512); _bss_end = .; _edata = .; - } - .rela.dyn : { *(.rela.dyn) } - .rela.plt : { *(.rela.plt) } - .rela.got : { *(.rela.got) } - .rela.data : { *(.rela.data) *(.rela.data*) } - _data_size = . - _etext; + } :data + _data_size = _edata - _data; . = ALIGN(4096); .dynsym : { *(.dynsym) } diff --git a/arch/riscv/lib/elf_riscv64_efi.lds b/arch/riscv/lib/elf_riscv64_efi.lds index ecb9139548..d0b4f3d1d6 100644 --- a/arch/riscv/lib/elf_riscv64_efi.lds +++ b/arch/riscv/lib/elf_riscv64_efi.lds @@ -1,14 +1,18 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: BSD-2-Clause */ /* * U-Boot riscv64 EFI linker script * - * SPDX-License-Identifier: BSD-2-Clause - * * Modified from arch/arm/lib/elf_aarch64_efi.lds */ OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv") OUTPUT_ARCH(riscv) + +PHDRS +{ + data PT_LOAD FLAGS(3); /* SHF_WRITE | SHF_ALLOC */ +} + ENTRY(_start) SECTIONS { @@ -20,11 +24,17 @@ SECTIONS *(.gnu.linkonce.t.*) *(.srodata) *(.rodata*) + . = ALIGN(16); + *(.dynamic); . = ALIGN(512); } + .rela.dyn : { *(.rela.dyn) } + .rela.plt : { *(.rela.plt) } + .rela.got : { *(.rela.got) } + .rela.data : { *(.rela.data) *(.rela.data*) } _etext = .; _text_size = . - _text; - .dynamic : { *(.dynamic) } + . = ALIGN(4096); .data : { _data = .; *(.sdata) @@ -49,12 +59,8 @@ SECTIONS . = ALIGN(512); _bss_end = .; _edata = .; - } - .rela.dyn : { *(.rela.dyn) } - .rela.plt : { *(.rela.plt) } - .rela.got : { *(.rela.got) } - .rela.data : { *(.rela.data) *(.rela.data*) } - _data_size = . - _etext; + } :data + _data_size = _edata - _data; . = ALIGN(4096); .dynsym : { *(.dynsym) } diff --git a/cmd/efidebug.c b/cmd/efidebug.c index a3a7556ea4..a587860e2a 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -173,15 +173,12 @@ EFI_ESRT_UPDATE_STATUS_NUM > (idx) ? efi_update_status_str[(idx)] : "error"\ static int do_efi_capsule_esrt(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) { - struct efi_system_resource_table *esrt = NULL; + struct efi_system_resource_table *esrt; if (argc != 1) return CMD_RET_USAGE; - for (int idx = 0; idx < systab.nr_tables; idx++) - if (!guidcmp(&efi_esrt_guid, &systab.tables[idx].guid)) - esrt = (struct efi_system_resource_table *)systab.tables[idx].table; - + esrt = efi_get_configuration_table(&efi_esrt_guid); if (!esrt) { log_info("ESRT: table not present\n"); return CMD_RET_SUCCESS; diff --git a/doc/develop/driver-model/migration.rst b/doc/develop/driver-model/migration.rst index 03fea943b2..b40a6af9d1 100644 --- a/doc/develop/driver-model/migration.rst +++ b/doc/develop/driver-model/migration.rst @@ -13,7 +13,7 @@ CONFIG_DM * Status: In progress * Deadline: 2020.01 -Starting with the 2010.01 release CONFIG_DM will be enabled for all boards. +Starting with the 2020.01 release CONFIG_DM will be enabled for all boards. This does not concern CONFIG_DM_SPL and CONFIG_DM_TPL. The conversion date for these configuration items still needs to be defined. diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst index c739242b6a..0389b269c0 100644 --- a/doc/develop/uefi/uefi.rst +++ b/doc/develop/uefi/uefi.rst @@ -193,7 +193,7 @@ on the sandbox .. code-block:: bash cd <U-Boot source directory> - pytest.py test/py/tests/test_efi_secboot/test_signed.py --bd sandbox + pytest test/py/tests/test_efi_secboot/test_signed.py --bd sandbox UEFI binaries may be signed by Microsoft using the following certificates: diff --git a/include/efi_loader.h b/include/efi_loader.h index 5c5af4f7fd..7daca0afba 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -546,6 +546,8 @@ void efi_setup_console_size(void); /* Set up load options from environment variable */ efi_status_t efi_env_set_load_options(efi_handle_t handle, const char *env_var, u16 **load_options); +/* Get EFI configuration table */ +void *efi_get_configuration_table(const efi_guid_t *guid); /* Install device tree */ efi_status_t efi_install_fdt(void *fdt); /* Execute loaded UEFI image */ diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index 9fd13297a6..ba5aba098c 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -400,18 +400,18 @@ efi_status_t efi_firmware_set_fmp_state_var(struct fmp_state *state, u8 image_in } size = num_banks * sizeof(*var_state); - var_state = calloc(1, size); + var_state = malloc(size); if (!var_state) return EFI_OUT_OF_RESOURCES; /* * GetVariable may fail, EFI_NOT_FOUND is returned if FmpState * variable has not been set yet. - * Ignore the error here since the correct FmpState variable - * is set later. */ - efi_get_variable_int(varname, image_type_id, NULL, &size, var_state, - NULL); + ret = efi_get_variable_int(varname, image_type_id, NULL, &size, + var_state, NULL); + if (ret != EFI_SUCCESS) + memset(var_state, 0, num_banks * sizeof(*var_state)); /* * Only the fw_version is set here. diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c index 11066eb505..5dd9cc876e 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -380,12 +380,12 @@ done: } /** - * get_config_table() - get configuration table + * efi_get_configuration_table() - get configuration table * * @guid: GUID of the configuration table * Return: pointer to configuration table or NULL */ -static void *get_config_table(const efi_guid_t *guid) +void *efi_get_configuration_table(const efi_guid_t *guid) { size_t i; @@ -430,7 +430,7 @@ efi_status_t efi_install_fdt(void *fdt) uintptr_t fdt_addr; /* Look for device tree that is already installed */ - if (get_config_table(&efi_guid_fdt)) + if (efi_get_configuration_table(&efi_guid_fdt)) return EFI_SUCCESS; /* Check if there is a hardware device tree */ fdt_opt = env_get("fdt_addr"); diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 85562c50a1..b5d4aa7be5 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -1129,23 +1129,6 @@ out: } /** - * find_smbios_table() - find smbios table - * - * Return: pointer to the smbios table - */ -static void *find_smbios_table(void) -{ - u32 i; - - for (i = 0; i < systab.nr_tables; i++) { - if (!guidcmp(&smbios3_guid, &systab.tables[i].guid)) - return systab.tables[i].table; - } - - return NULL; -} - -/** * tcg2_measure_gpt_table() - measure gpt table * * @dev: TPM device @@ -1387,7 +1370,7 @@ efi_status_t efi_tcg2_measure_efi_app_invocation(struct efi_loaded_image_obj *ha if (ret != EFI_SUCCESS) goto out; - entry = (struct smbios3_entry *)find_smbios_table(); + entry = efi_get_configuration_table(&smbios3_guid); if (entry) { ret = tcg2_measure_smbios(dev, entry); if (ret != EFI_SUCCESS) diff --git a/lib/efi_selftest/efi_selftest_miniapp_exit.c b/lib/efi_selftest/efi_selftest_miniapp_exit.c index 8b2e60cc71..0909a5ca74 100644 --- a/lib/efi_selftest/efi_selftest_miniapp_exit.c +++ b/lib/efi_selftest/efi_selftest_miniapp_exit.c @@ -39,7 +39,7 @@ static efi_status_t EFIAPI check_loaded_image_protocol NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (ret != EFI_SUCCESS) { cout->output_string(cout, - u"Could not open loaded image protocol"); + u"Could not open loaded image protocol\n"); return ret; } if ((void *)check_loaded_image_protocol < |