From beb077a2a8201c4b215d82e58c4d1d8ec8e48b58 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Mon, 18 Jun 2018 17:23:05 +0200 Subject: efi_loader: Introduce ms abi vararg helpers Varargs differ between sysv and ms abi. On x86_64 we have to follow the ms abi though, so we also need to make sure we use x86_64 varargs helpers. This patch introduces generic efi vararg helpers that adhere to the respective EFI ABI. That way we can deal with them properly from efi loader code and properly interpret variable arguments. This fixes the InstallMultipleProtocolInterfaces tests in the efi selftests on x86_64 for me. Signed-off-by: Alexander Graf --- include/efi.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/efi.h b/include/efi.h index 0fe15e65c06..41530a7537d 100644 --- a/include/efi.h +++ b/include/efi.h @@ -29,8 +29,16 @@ */ #ifdef __x86_64__ #define EFIAPI __attribute__((ms_abi)) +#define efi_va_list __builtin_ms_va_list +#define efi_va_start __builtin_ms_va_start +#define efi_va_arg __builtin_va_arg +#define efi_va_end __builtin_ms_va_end #else #define EFIAPI asmlinkage +#define efi_va_list va_list +#define efi_va_start va_start +#define efi_va_arg va_arg +#define efi_va_end va_end #endif /* __x86_64__ */ struct efi_device_path; -- cgit v1.3.1 From dae73c4cdc862017a10d09588571e7f98de0cdd4 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Mon, 18 Jun 2018 17:23:10 +0200 Subject: elf: Move x86 reloc defines to common elf.h We need to know about x86 relocation definitions even in cases where we don't officially build against the x86 target, such as with sandbox. So let's move the x86 definitions into the common elf header, where all other architectures already have them. Signed-off-by: Alexander Graf --- arch/x86/include/asm/elf.h | 45 ----------------------------------------- arch/x86/lib/reloc_ia32_efi.c | 1 - arch/x86/lib/reloc_x86_64_efi.c | 1 - include/elf.h | 35 ++++++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 47 deletions(-) delete mode 100644 arch/x86/include/asm/elf.h (limited to 'include') diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h deleted file mode 100644 index 7ae9c7d6da3..00000000000 --- a/arch/x86/include/asm/elf.h +++ /dev/null @@ -1,45 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * Brought in from Linux 4.1, removed things not useful to U-Boot. - * The definitions perhaps came from the GNU Library which is GPL. - */ - -#ifndef _ASM_X86_ELF_H -#define _ASM_X86_ELF_H - -/* ELF register definitions */ -#define R_386_NONE 0 -#define R_386_32 1 -#define R_386_PC32 2 -#define R_386_GOT32 3 -#define R_386_PLT32 4 -#define R_386_COPY 5 -#define R_386_GLOB_DAT 6 -#define R_386_JMP_SLOT 7 -#define R_386_RELATIVE 8 -#define R_386_GOTOFF 9 -#define R_386_GOTPC 10 -#define R_386_NUM 11 - -/* x86-64 relocation types */ -#define R_X86_64_NONE 0 /* No reloc */ -#define R_X86_64_64 1 /* Direct 64 bit */ -#define R_X86_64_PC32 2 /* PC relative 32 bit signed */ -#define R_X86_64_GOT32 3 /* 32 bit GOT entry */ -#define R_X86_64_PLT32 4 /* 32 bit PLT address */ -#define R_X86_64_COPY 5 /* Copy symbol at runtime */ -#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ -#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ -#define R_X86_64_RELATIVE 8 /* Adjust by program base */ -/* 32 bit signed pc relative offset to GOT */ -#define R_X86_64_GOTPCREL 9 -#define R_X86_64_32 10 /* Direct 32 bit zero extended */ -#define R_X86_64_32S 11 /* Direct 32 bit sign extended */ -#define R_X86_64_16 12 /* Direct 16 bit zero extended */ -#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ -#define R_X86_64_8 14 /* Direct 8 bit sign extended */ -#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ - -#define R_X86_64_NUM 16 - -#endif diff --git a/arch/x86/lib/reloc_ia32_efi.c b/arch/x86/lib/reloc_ia32_efi.c index a262533c0fd..d56cd50bd93 100644 --- a/arch/x86/lib/reloc_ia32_efi.c +++ b/arch/x86/lib/reloc_ia32_efi.c @@ -10,7 +10,6 @@ #include #include #include -#include efi_status_t EFIAPI _relocate(long ldbase, Elf32_Dyn *dyn) { diff --git a/arch/x86/lib/reloc_x86_64_efi.c b/arch/x86/lib/reloc_x86_64_efi.c index 59d6f8d3d34..2694de71104 100644 --- a/arch/x86/lib/reloc_x86_64_efi.c +++ b/arch/x86/lib/reloc_x86_64_efi.c @@ -12,7 +12,6 @@ #include #include #include -#include efi_status_t EFIAPI _relocate(long ldbase, Elf64_Dyn *dyn) { diff --git a/include/elf.h b/include/elf.h index 0d3845e0632..6802428ac42 100644 --- a/include/elf.h +++ b/include/elf.h @@ -550,6 +550,41 @@ unsigned long elf_hash(const unsigned char *name); #endif /* __ASSEMBLER */ +/* ELF register definitions */ +#define R_386_NONE 0 +#define R_386_32 1 +#define R_386_PC32 2 +#define R_386_GOT32 3 +#define R_386_PLT32 4 +#define R_386_COPY 5 +#define R_386_GLOB_DAT 6 +#define R_386_JMP_SLOT 7 +#define R_386_RELATIVE 8 +#define R_386_GOTOFF 9 +#define R_386_GOTPC 10 +#define R_386_NUM 11 + +/* x86-64 relocation types */ +#define R_X86_64_NONE 0 /* No reloc */ +#define R_X86_64_64 1 /* Direct 64 bit */ +#define R_X86_64_PC32 2 /* PC relative 32 bit signed */ +#define R_X86_64_GOT32 3 /* 32 bit GOT entry */ +#define R_X86_64_PLT32 4 /* 32 bit PLT address */ +#define R_X86_64_COPY 5 /* Copy symbol at runtime */ +#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ +#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ +#define R_X86_64_RELATIVE 8 /* Adjust by program base */ +/* 32 bit signed pc relative offset to GOT */ +#define R_X86_64_GOTPCREL 9 +#define R_X86_64_32 10 /* Direct 32 bit zero extended */ +#define R_X86_64_32S 11 /* Direct 32 bit sign extended */ +#define R_X86_64_16 12 /* Direct 16 bit zero extended */ +#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ +#define R_X86_64_8 14 /* Direct 8 bit sign extended */ +#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ + +#define R_X86_64_NUM 16 + /* * XXX - PowerPC defines really don't belong in here, * but we'll put them in for simplicity. -- cgit v1.3.1 From 7e21fbca26d18327cf7cabaad08df276a06a07d8 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 12 Jun 2018 07:48:37 +0200 Subject: efi_loader: Rename sections to allow for implicit data Some times gcc may generate data that is then used within code that may be part of an efi runtime section. That data could be jump tables, constants or strings. In order to make sure we catch these, we need to ensure that gcc emits them into a section that we can relocate together with all the other efi runtime bits. This only works if the -ffunction-sections and -fdata-sections flags are passed and the efi runtime functions are in a section that starts with ".text". Up to now we had all efi runtime bits in sections that did not interfere with the normal section naming scheme, but this forces us to do so. Hence we need to move the efi_loader text/data/rodata sections before the global *(.text*) catch-all section. With this patch in place, we should hopefully have an easier time to extend the efi runtime functionality in the future. Signed-off-by: Alexander Graf [agraf: Fix x86_64 breakage] --- arch/arm/config.mk | 4 ++-- arch/arm/cpu/armv8/u-boot.lds | 24 +++++++++++++-------- arch/arm/cpu/u-boot.lds | 36 ++++++++++++++++++------------- arch/arm/mach-zynq/u-boot.lds | 36 ++++++++++++++++++------------- arch/riscv/cpu/ax25/u-boot.lds | 26 +++++++++++++--------- arch/sandbox/config.mk | 3 +++ arch/sandbox/cpu/u-boot.lds | 9 ++++---- arch/x86/config.mk | 2 ++ arch/x86/cpu/start.S | 2 +- arch/x86/cpu/start64.S | 2 +- arch/x86/cpu/u-boot-64.lds | 3 +++ arch/x86/cpu/u-boot.lds | 34 ++++++++++++++++------------- board/qualcomm/dragonboard410c/u-boot.lds | 17 +++++++++++++-- board/qualcomm/dragonboard820c/u-boot.lds | 24 +++++++++++++-------- board/ti/am335x/u-boot.lds | 36 ++++++++++++++++++------------- include/efi_loader.h | 4 ++-- 16 files changed, 162 insertions(+), 100 deletions(-) (limited to 'include') diff --git a/arch/arm/config.mk b/arch/arm/config.mk index efafc69d1b3..f25603109e0 100644 --- a/arch/arm/config.mk +++ b/arch/arm/config.mk @@ -134,11 +134,11 @@ endif ifdef CONFIG_ARM64 OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \ -j .u_boot_list -j .rela.dyn -j .got -j .got.plt \ - -j .binman_sym_table + -j .binman_sym_table -j .text_rest else OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \ -j .data -j .got -j .got.plt -j .u_boot_list -j .rel.dyn \ - -j .binman_sym_table + -j .binman_sym_table -j .text_rest endif # if a dtb section exists we always have to include it diff --git a/arch/arm/cpu/armv8/u-boot.lds b/arch/arm/cpu/armv8/u-boot.lds index eb926b3c148..53de80f745e 100644 --- a/arch/arm/cpu/armv8/u-boot.lds +++ b/arch/arm/cpu/armv8/u-boot.lds @@ -25,6 +25,19 @@ SECTIONS { *(.__image_copy_start) CPUDIR/start.o (.text*) + } + + /* This needs to come before *(.text*) */ + .efi_runtime : { + __efi_runtime_start = .; + *(.text.efi_runtime*) + *(.rodata.efi_runtime*) + *(.data.efi_runtime*) + __efi_runtime_stop = .; + } + + .text_rest : + { *(.text*) } @@ -98,17 +111,10 @@ SECTIONS . = ALIGN(8); - .efi_runtime : { - __efi_runtime_start = .; - *(efi_runtime_text) - *(efi_runtime_data) - __efi_runtime_stop = .; - } - .efi_runtime_rel : { __efi_runtime_rel_start = .; - *(.relaefi_runtime_text) - *(.relaefi_runtime_data) + *(.rel*.efi_runtime) + *(.rel*.efi_runtime.*) __efi_runtime_rel_stop = .; } diff --git a/arch/arm/cpu/u-boot.lds b/arch/arm/cpu/u-boot.lds index 4157374d21d..834dc99554c 100644 --- a/arch/arm/cpu/u-boot.lds +++ b/arch/arm/cpu/u-boot.lds @@ -43,6 +43,25 @@ SECTIONS *(.__image_copy_start) *(.vectors) CPUDIR/start.o (.text*) + } + + /* This needs to come before *(.text*) */ + .__efi_runtime_start : { + *(.__efi_runtime_start) + } + + .efi_runtime : { + *(.text.efi_runtime*) + *(.rodata.efi_runtime*) + *(.data.efi_runtime*) + } + + .__efi_runtime_stop : { + *(.__efi_runtime_stop) + } + + .text_rest : + { *(.text*) } @@ -136,27 +155,14 @@ SECTIONS . = ALIGN(4); - .__efi_runtime_start : { - *(.__efi_runtime_start) - } - - .efi_runtime : { - *(efi_runtime_text) - *(efi_runtime_data) - } - - .__efi_runtime_stop : { - *(.__efi_runtime_stop) - } - .efi_runtime_rel_start : { *(.__efi_runtime_rel_start) } .efi_runtime_rel : { - *(.relefi_runtime_text) - *(.relefi_runtime_data) + *(.rel*.efi_runtime) + *(.rel*.efi_runtime.*) } .efi_runtime_rel_stop : diff --git a/arch/arm/mach-zynq/u-boot.lds b/arch/arm/mach-zynq/u-boot.lds index ec9a0a01610..91c32e89e8f 100644 --- a/arch/arm/mach-zynq/u-boot.lds +++ b/arch/arm/mach-zynq/u-boot.lds @@ -19,6 +19,25 @@ SECTIONS *(.__image_copy_start) *(.vectors) CPUDIR/start.o (.text*) + } + + /* This needs to come before *(.text*) */ + .__efi_runtime_start : { + *(.__efi_runtime_start) + } + + .efi_runtime : { + *(.text.efi_runtime*) + *(.rodata.efi_runtime*) + *(.data.efi_runtime*) + } + + .__efi_runtime_stop : { + *(.__efi_runtime_stop) + } + + .text_rest : + { *(.text*) } @@ -41,27 +60,14 @@ SECTIONS . = ALIGN(4); - .__efi_runtime_start : { - *(.__efi_runtime_start) - } - - .efi_runtime : { - *(efi_runtime_text) - *(efi_runtime_data) - } - - .__efi_runtime_stop : { - *(.__efi_runtime_stop) - } - .efi_runtime_rel_start : { *(.__efi_runtime_rel_start) } .efi_runtime_rel : { - *(.relefi_runtime_text) - *(.relefi_runtime_data) + *(.rel*.efi_runtime) + *(.rel*.efi_runtime.*) } .efi_runtime_rel_stop : diff --git a/arch/riscv/cpu/ax25/u-boot.lds b/arch/riscv/cpu/ax25/u-boot.lds index 1589babf6c3..3cc89746b16 100644 --- a/arch/riscv/cpu/ax25/u-boot.lds +++ b/arch/riscv/cpu/ax25/u-boot.lds @@ -12,7 +12,20 @@ SECTIONS .text : { arch/riscv/cpu/ax25/start.o (.text) - *(.text) + } + + /* This needs to come before *(.text*) */ + .efi_runtime : { + __efi_runtime_start = .; + *(.text.efi_runtime*) + *(.rodata.efi_runtime*) + *(.data.efi_runtime*) + __efi_runtime_stop = .; + } + + .text_rest : + { + *(.text*) } . = ALIGN(4); @@ -39,17 +52,10 @@ SECTIONS . = ALIGN(4); - .efi_runtime : { - __efi_runtime_start = .; - *(efi_runtime_text) - *(efi_runtime_data) - __efi_runtime_stop = .; - } - .efi_runtime_rel : { __efi_runtime_rel_start = .; - *(.relaefi_runtime_text) - *(.relaefi_runtime_data) + *(.rel*.efi_runtime) + *(.rel*.efi_runtime.*) __efi_runtime_rel_stop = .; } diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index 2babcde8815..5e7077bfe75 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -5,6 +5,9 @@ PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE PLATFORM_CPPFLAGS += -DCONFIG_ARCH_MAP_SYSMEM PLATFORM_LIBS += -lrt +LDFLAGS_FINAL += --gc-sections +PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections + # Define this to avoid linking with SDL, which requires SDL libraries # This can solve 'sdl-config: Command not found' errors ifneq ($(NO_SDL),) diff --git a/arch/sandbox/cpu/u-boot.lds b/arch/sandbox/cpu/u-boot.lds index 3a6cf55eb99..727bcc35981 100644 --- a/arch/sandbox/cpu/u-boot.lds +++ b/arch/sandbox/cpu/u-boot.lds @@ -24,8 +24,9 @@ SECTIONS } .efi_runtime : { - *(efi_runtime_text) - *(efi_runtime_data) + *(.text.efi_runtime*) + *(.rodata.efi_runtime*) + *(.data.efi_runtime*) } .__efi_runtime_stop : { @@ -38,8 +39,8 @@ SECTIONS } .efi_runtime_rel : { - *(.relefi_runtime_text) - *(.relefi_runtime_data) + *(.rel*.efi_runtime) + *(.rel*.efi_runtime.*) } .efi_runtime_rel_stop : diff --git a/arch/x86/config.mk b/arch/x86/config.mk index 5f77f98e60a..586e11a0dda 100644 --- a/arch/x86/config.mk +++ b/arch/x86/config.mk @@ -23,6 +23,8 @@ endif ifeq ($(IS_32BIT),y) PLATFORM_CPPFLAGS += -march=i386 -m32 +# TODO: These break on x86_64; need to debug further +PLATFORM_RELFLAGS += -fdata-sections else PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -m64 endif diff --git a/arch/x86/cpu/start.S b/arch/x86/cpu/start.S index e4e997e3e88..e1f634ffcd5 100644 --- a/arch/x86/cpu/start.S +++ b/arch/x86/cpu/start.S @@ -17,7 +17,7 @@ #include #include -.section .text +.section .text.start .code32 .globl _start .type _start, @function diff --git a/arch/x86/cpu/start64.S b/arch/x86/cpu/start64.S index 234482b793a..a473fd166d3 100644 --- a/arch/x86/cpu/start64.S +++ b/arch/x86/cpu/start64.S @@ -8,7 +8,7 @@ #include -.section .text +.section .text.start .code64 .globl _start .type _start, @function diff --git a/arch/x86/cpu/u-boot-64.lds b/arch/x86/cpu/u-boot-64.lds index 3f38681669a..9a9d39cef29 100644 --- a/arch/x86/cpu/u-boot-64.lds +++ b/arch/x86/cpu/u-boot-64.lds @@ -17,6 +17,9 @@ SECTIONS . = CONFIG_SYS_TEXT_BASE; /* Location of bootcode in flash */ __text_start = .; + + .text.start : { *(.text.start); } + .text : { *(.text*); } . = ALIGN(4); diff --git a/arch/x86/cpu/u-boot.lds b/arch/x86/cpu/u-boot.lds index f0719368ba6..a1cc19ce4cb 100644 --- a/arch/x86/cpu/u-boot.lds +++ b/arch/x86/cpu/u-boot.lds @@ -17,6 +17,23 @@ SECTIONS . = CONFIG_SYS_TEXT_BASE; /* Location of bootcode in flash */ __text_start = .; + + .text.start : { *(.text.start); } + + .__efi_runtime_start : { + *(.__efi_runtime_start) + } + + .efi_runtime : { + *(.text.efi_runtime*) + *(.rodata.efi_runtime*) + *(.data.efi_runtime*) + } + + .__efi_runtime_stop : { + *(.__efi_runtime_stop) + } + .text : { *(.text*); } . = ALIGN(4); @@ -43,27 +60,14 @@ SECTIONS . = ALIGN(4); - .__efi_runtime_start : { - *(.__efi_runtime_start) - } - - .efi_runtime : { - *(efi_runtime_text) - *(efi_runtime_data) - } - - .__efi_runtime_stop : { - *(.__efi_runtime_stop) - } - .efi_runtime_rel_start : { *(.__efi_runtime_rel_start) } .efi_runtime_rel : { - *(.relefi_runtime_text) - *(.relefi_runtime_data) + *(.rel*.efi_runtime) + *(.rel*.efi_runtime.*) } .efi_runtime_rel_stop : diff --git a/board/qualcomm/dragonboard410c/u-boot.lds b/board/qualcomm/dragonboard410c/u-boot.lds index dc3f718b056..fc1bba8cf08 100644 --- a/board/qualcomm/dragonboard410c/u-boot.lds +++ b/board/qualcomm/dragonboard410c/u-boot.lds @@ -20,6 +20,19 @@ SECTIONS *(.__image_copy_start) board/qualcomm/dragonboard410c/head.o (.text*) CPUDIR/start.o (.text*) + } + + /* This needs to come before *(.text*) */ + .efi_runtime : { + __efi_runtime_start = .; + *(.text.efi_runtime*) + *(.rodata.efi_runtime*) + *(.data.efi_runtime*) + __efi_runtime_stop = .; + } + + .text_rest : + { *(.text*) } @@ -51,8 +64,8 @@ SECTIONS .efi_runtime_rel : { __efi_runtime_rel_start = .; - *(.relaefi_runtime_text) - *(.relaefi_runtime_data) + *(.rel*.efi_runtime) + *(.rel*.efi_runtime.*) __efi_runtime_rel_stop = .; } diff --git a/board/qualcomm/dragonboard820c/u-boot.lds b/board/qualcomm/dragonboard820c/u-boot.lds index bcf5738d387..dcf8256cec3 100644 --- a/board/qualcomm/dragonboard820c/u-boot.lds +++ b/board/qualcomm/dragonboard820c/u-boot.lds @@ -20,6 +20,19 @@ SECTIONS *(.__image_copy_start) board/qualcomm/dragonboard820c/head.o (.text*) CPUDIR/start.o (.text*) + } + + /* This needs to come before *(.text*) */ + .efi_runtime : { + __efi_runtime_start = .; + *(.text.efi_runtime*) + *(.rodata.efi_runtime*) + *(.data.efi_runtime*) + __efi_runtime_stop = .; + } + + .text_rest : + { *(.text*) } @@ -42,17 +55,10 @@ SECTIONS . = ALIGN(8); - .efi_runtime : { - __efi_runtime_start = .; - *(efi_runtime_text) - *(efi_runtime_data) - __efi_runtime_stop = .; - } - .efi_runtime_rel : { __efi_runtime_rel_start = .; - *(.relaefi_runtime_text) - *(.relaefi_runtime_data) + *(.rel*.efi_runtime) + *(.rel*.efi_runtime.*) __efi_runtime_rel_stop = .; } diff --git a/board/ti/am335x/u-boot.lds b/board/ti/am335x/u-boot.lds index a56cc8216bf..03c1d5f73b3 100644 --- a/board/ti/am335x/u-boot.lds +++ b/board/ti/am335x/u-boot.lds @@ -37,6 +37,25 @@ SECTIONS *(.vectors) CPUDIR/start.o (.text*) board/ti/am335x/built-in.o (.text*) + } + + /* This needs to come before *(.text*) */ + .__efi_runtime_start : { + *(.__efi_runtime_start) + } + + .efi_runtime : { + *(.text.efi_runtime*) + *(.rodata.efi_runtime*) + *(.data.efi_runtime*) + } + + .__efi_runtime_stop : { + *(.__efi_runtime_stop) + } + + .text_rest : + { *(.text*) } @@ -59,27 +78,14 @@ SECTIONS . = ALIGN(4); - .__efi_runtime_start : { - *(.__efi_runtime_start) - } - - .efi_runtime : { - *(efi_runtime_text) - *(efi_runtime_data) - } - - .__efi_runtime_stop : { - *(.__efi_runtime_stop) - } - .efi_runtime_rel_start : { *(.__efi_runtime_rel_start) } .efi_runtime_rel : { - *(.relefi_runtime_text) - *(.relefi_runtime_data) + *(.rel*.efi_runtime) + *(.rel*.efi_runtime.*) } .efi_runtime_rel_stop : diff --git a/include/efi_loader.h b/include/efi_loader.h index d837e7b157f..a0495db2918 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -406,8 +406,8 @@ static inline int guidcmp(const efi_guid_t *g1, const efi_guid_t *g2) * Use these to indicate that your code / data should go into the EFI runtime * section and thus still be available when the OS is running */ -#define __efi_runtime_data __attribute__ ((section ("efi_runtime_data"))) -#define __efi_runtime __attribute__ ((section ("efi_runtime_text"))) +#define __efi_runtime_data __attribute__ ((section (".data.efi_runtime"))) +#define __efi_runtime __attribute__ ((section (".text.efi_runtime"))) /* Call this with mmio_ptr as the _pointer_ to a pointer to an MMIO region * to make it available at runtime */ -- cgit v1.3.1 From 1fcb7ea28400aa69e157dc4b19c9667e96d3a033 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 2 Jul 2018 12:53:55 +0200 Subject: efi_loader: check map_key in ExitBootServices The UEFI spec requires that the memory map key is checked in ExitBootServices(). Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_loader.h | 3 +++ lib/efi_loader/efi_boottime.c | 4 ++++ lib/efi_loader/efi_memory.c | 8 +++++++- 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index a0495db2918..3cbec15c297 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -82,6 +82,9 @@ const char *__efi_nesting_dec(void); #define EFI_CACHELINE_SIZE 128 #endif +/* Key identifying current memory map */ +extern efi_uintn_t efi_memory_map_key; + extern struct efi_runtime_services efi_runtime_services; extern struct efi_system_table systab; diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 86cb9ba479a..6bd64b9df9c 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1854,6 +1854,10 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle, EFI_ENTRY("%p, %ld", image_handle, map_key); + /* Check that the caller has read the current memory map */ + if (map_key != efi_memory_map_key) + return EFI_INVALID_PARAMETER; + /* Make sure that notification functions are not called anymore */ efi_tpl = TPL_HIGH_LEVEL; diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index bad87042695..967c3f733e4 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -15,6 +15,8 @@ DECLARE_GLOBAL_DATA_PTR; +efi_uintn_t efi_memory_map_key; + struct efi_mem_list { struct list_head link; struct efi_mem_desc desc; @@ -160,9 +162,13 @@ uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, debug("%s: 0x%" PRIx64 " 0x%" PRIx64 " %d %s\n", __func__, start, pages, memory_type, overlap_only_ram ? "yes" : "no"); + if (memory_type >= EFI_MAX_MEMORY_TYPE) + return EFI_INVALID_PARAMETER; + if (!pages) return start; + ++efi_memory_map_key; newlist = calloc(1, sizeof(*newlist)); newlist->desc.type = memory_type; newlist->desc.physical_start = start; @@ -487,7 +493,7 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, } if (map_key) - *map_key = 0; + *map_key = efi_memory_map_key; return EFI_SUCCESS; } -- cgit v1.3.1 From 95147313a98c2403589c6bd9a6768c657442e16c Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 5 Jul 2018 08:17:58 +0200 Subject: efi_loader: set revision in loaded image protocol The revision number has to be set in the loaded image protocol. The problem was detected by running the SCT in Protocol/LoadedImage/BlackBoxTest/LoadedImageBBTestMain.c:890 Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_api.h | 2 ++ lib/efi_loader/efi_boottime.c | 1 + 2 files changed, 3 insertions(+) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 0c3dd3cdd49..53798d54490 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -318,6 +318,8 @@ struct efi_system_table { EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, \ 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) +#define EFI_LOADED_IMAGE_PROTOCOL_REVISION 0x1000 + struct efi_loaded_image { u32 revision; void *parent_handle; diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 6bd64b9df9c..18698566f53 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1497,6 +1497,7 @@ efi_status_t efi_setup_loaded_image( /* efi_exit() assumes that the handle points to the info */ obj->handle = info; + info->revision = EFI_LOADED_IMAGE_PROTOCOL_REVISION; info->file_path = file_path; if (device_path) { -- cgit v1.3.1 From 112f24301696d015e25090d713e2e5c73f4b8a3c Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 28 Jun 2018 12:45:27 +0200 Subject: efi_loader: specify UEFI spec revision Both in the boot and the runtime services tables we have to specify the UEFI spec revision. The same value is already used for the system table. So let's use a common constant. In the boot services table we have to provide the header signature. Signed-off-by: Heinrich Schuchardt Reviewed-by: Bin Meng Signed-off-by: Alexander Graf --- include/efi_api.h | 5 ++++- lib/efi_loader/efi_boottime.c | 4 +++- lib/efi_loader/efi_runtime.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 53798d54490..696cb26133c 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -21,6 +21,9 @@ #include #endif +/* UEFI spec version 2.7 */ +#define EFI_SPECIFICATION_VERSION (2 << 16 | 70) + /* Types and defines for EFI CreateEvent */ enum efi_timer_delay { EFI_TIMER_STOP = 0, @@ -46,6 +49,7 @@ typedef uint16_t *efi_string_t; struct efi_event; /* EFI Boot Services table */ +#define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42 struct efi_boot_services { struct efi_table_hdr hdr; efi_status_t (EFIAPI *raise_tpl)(efi_uintn_t new_tpl); @@ -186,7 +190,6 @@ enum efi_reset_type { /* EFI Runtime Services table */ #define EFI_RUNTIME_SERVICES_SIGNATURE 0x5652453544e5552ULL -#define EFI_RUNTIME_SERVICES_REVISION 0x00010000 #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000 #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000 diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 18698566f53..9a0c3235cf2 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -3058,6 +3058,8 @@ out: static const struct efi_boot_services efi_boot_services = { .hdr = { + .signature = EFI_BOOT_SERVICES_SIGNATURE, + .revision = EFI_SPECIFICATION_VERSION, .headersize = sizeof(struct efi_table_hdr), }, .raise_tpl = efi_raise_tpl, @@ -3113,7 +3115,7 @@ static uint16_t __efi_runtime_data firmware_vendor[] = L"Das U-Boot"; struct efi_system_table __efi_runtime_data systab = { .hdr = { .signature = EFI_SYSTEM_TABLE_SIGNATURE, - .revision = 2 << 16 | 70, /* 2.7 */ + .revision = EFI_SPECIFICATION_VERSION, .headersize = sizeof(struct efi_table_hdr), }, .fw_vendor = (long)firmware_vendor, diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index dd3ff8ad236..cfa60b8ff74 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -459,7 +459,7 @@ efi_status_t __efi_runtime EFIAPI efi_query_variable_info( struct efi_runtime_services __efi_runtime_data efi_runtime_services = { .hdr = { .signature = EFI_RUNTIME_SERVICES_SIGNATURE, - .revision = EFI_RUNTIME_SERVICES_REVISION, + .revision = EFI_SPECIFICATION_VERSION, .headersize = sizeof(struct efi_table_hdr), }, .get_time = &efi_get_time_boottime, -- cgit v1.3.1 From bdfb894a3efbb35e184e9afece15d44bc59db43a Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 28 Jun 2018 12:45:28 +0200 Subject: efi_loader: correct EFI_RUNTIME_SERVICES_SIGNATURE The value for EFI_RUNTIME_SERVICES_SIGNATURE does not match the UEFI spec 2.7. Reported-by: Takahiro Akashi Signed-off-by: Heinrich Schuchardt Reviewed-by: Bin Meng Signed-off-by: Alexander Graf --- include/efi_api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 696cb26133c..3a9da32b82c 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -189,7 +189,7 @@ enum efi_reset_type { }; /* EFI Runtime Services table */ -#define EFI_RUNTIME_SERVICES_SIGNATURE 0x5652453544e5552ULL +#define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552ULL #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000 #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000 -- cgit v1.3.1 From 0b386537a51d5ac6e2da022ade49424ecc50ffa1 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 28 Jun 2018 12:45:30 +0200 Subject: efi_loader: provide firmware revision Provide a firmware revision in the system table using the Makefile variables VERSION and PATCHLEVEL, e.g. 0x20180700 for v2018.07. Correct the type of the firmware vendor. It is a u16* pointer. Signed-off-by: Heinrich Schuchardt Reviewed-by: Bin Meng Signed-off-by: Alexander Graf --- include/efi_api.h | 2 +- lib/efi_loader/Makefile | 3 +++ lib/efi_loader/efi_boottime.c | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 3a9da32b82c..c98cc34908b 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -303,7 +303,7 @@ struct efi_configuration_table struct efi_system_table { struct efi_table_hdr hdr; - unsigned long fw_vendor; /* physical addr of wchar_t vendor string */ + u16 *fw_vendor; /* physical addr of wchar_t vendor string */ u32 fw_revision; efi_handle_t con_in_handle; struct efi_simple_input_interface *con_in; diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index d6402c4615f..1ffbf52a898 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -6,6 +6,9 @@ # This file only gets included with CONFIG_EFI_LOADER set, so all # object inclusion implicitly depends on it +CFLAGS_efi_boottime.o += \ + -DFW_VERSION="0x$(VERSION)" \ + -DFW_PATCHLEVEL="0x$(PATCHLEVEL)" CFLAGS_helloworld.o := $(CFLAGS_EFI) -Os -ffreestanding CFLAGS_REMOVE_helloworld.o := $(CFLAGS_NON_EFI) -Os diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index f6df6df7172..c5d45dcc954 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -3110,7 +3110,7 @@ static const struct efi_boot_services efi_boot_services = { .create_event_ex = efi_create_event_ex, }; -static uint16_t __efi_runtime_data firmware_vendor[] = L"Das U-Boot"; +static u16 __efi_runtime_data firmware_vendor[] = L"Das U-Boot"; struct efi_system_table __efi_runtime_data systab = { .hdr = { @@ -3118,7 +3118,8 @@ struct efi_system_table __efi_runtime_data systab = { .revision = EFI_SPECIFICATION_VERSION, .headersize = sizeof(struct efi_system_table), }, - .fw_vendor = (long)firmware_vendor, + .fw_vendor = firmware_vendor, + .fw_revision = FW_VERSION << 16 | FW_PATCHLEVEL << 8, .con_in = (void *)&efi_con_in, .con_out = (void *)&efi_con_out, .std_err = (void *)&efi_con_out, -- cgit v1.3.1 From 640adadf811e9c229ddec597595a00db3f5304b0 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 28 Jun 2018 12:45:31 +0200 Subject: efi_loader: calculate crc32 for EFI tables For the boot and runtime services tables and for the system table the crc32 has to be set in the header. Signed-off-by: Heinrich Schuchardt Reviewed-by: Bin Meng Signed-off-by: Alexander Graf --- cmd/bootefi.c | 5 +++++ include/efi_loader.h | 2 ++ lib/efi_loader/efi_boottime.c | 32 ++++++++++++++++++++++++++++---- 3 files changed, 35 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 4097277c9cc..e57e70fc612 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -44,6 +44,11 @@ efi_status_t efi_init_obj_list(void) if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED) return efi_obj_list_initialized; + /* Initialize system table */ + ret = efi_initialize_system_table(); + if (ret != EFI_SUCCESS) + goto out; + /* Initialize EFI driver uclass */ ret = efi_driver_init(); if (ret != EFI_SUCCESS) diff --git a/include/efi_loader.h b/include/efi_loader.h index 3cbec15c297..06f74e2716c 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -202,6 +202,8 @@ extern struct list_head efi_obj_list; /* List of all events */ extern struct list_head efi_events; +/* Called by bootefi to initialize runtime */ +efi_status_t efi_initialize_system_table(void); /* Called by bootefi to make console interface available */ int efi_console_register(void); /* Called by bootefi to make all disk storage accessible as EFI objects */ diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index c5d45dcc954..5fea8b1dbd5 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -163,6 +163,18 @@ const char *__efi_nesting_dec(void) return indent_string(--nesting_level); } +/** + * efi_update_table_header_crc32() - Update CRC32 in table header + * + * @table: EFI table + */ +static void efi_update_table_header_crc32(struct efi_table_hdr *table) +{ + table->crc32 = 0; + table->crc32 = crc32(0, (const unsigned char *)table, + table->headersize); +} + /** * efi_queue_event() - queue an EFI event * @event: event to signal @@ -1901,9 +1913,7 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle, systab.boottime = NULL; /* Recalculate CRC32 */ - systab.hdr.crc32 = 0; - systab.hdr.crc32 = crc32(0, (const unsigned char *)&systab, - sizeof(struct efi_system_table)); + efi_update_table_header_crc32(&systab.hdr); /* Give the payload some time to boot */ efi_set_watchdog(0); @@ -3056,7 +3066,7 @@ out: return EFI_EXIT(r); } -static const struct efi_boot_services efi_boot_services = { +static struct efi_boot_services efi_boot_services = { .hdr = { .signature = EFI_BOOT_SERVICES_SIGNATURE, .revision = EFI_SPECIFICATION_VERSION, @@ -3128,3 +3138,17 @@ struct efi_system_table __efi_runtime_data systab = { .nr_tables = 0, .tables = (void *)efi_conf_table, }; + +/** + * efi_initialize_system_table() - Initialize system table + * + * Return Value: status code + */ +efi_status_t efi_initialize_system_table(void) +{ + /* Set crc32 field in table headers */ + efi_update_table_header_crc32(&systab.hdr); + efi_update_table_header_crc32(&efi_runtime_services.hdr); + efi_update_table_header_crc32(&efi_boot_services.hdr); + return EFI_SUCCESS; +} -- cgit v1.3.1 From 4182a129ef735bfd6c54788affe1b649ab85b851 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 28 Jun 2018 12:45:32 +0200 Subject: efi_loader: allocate configuration table array The system table contains a link to the list of configurations tables. These include the device tree, SMBIOS table, and the ACPI table. This array is currently statically linked. With the patch it is allocated as EFI_RUNTIME_SERVICES_DATA. Due to the structure of the system table we cannot work with a linked list here. Signed-off-by: Heinrich Schuchardt Reviewed-by: Bin Meng Signed-off-by: Alexander Graf --- include/efi_loader.h | 3 +++ lib/efi_loader/efi_boottime.c | 39 +++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 20 deletions(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 06f74e2716c..051f9c45141 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -17,6 +17,9 @@ #include +/* Maximum number of configuration tables */ +#define EFI_MAX_CONFIGURATION_TABLES 16 + int __efi_entry_check(void); int __efi_exit_check(void); const char *__efi_nesting(void); diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 5fea8b1dbd5..c0354258b95 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -35,16 +35,6 @@ LIST_HEAD(efi_events); */ static bool efi_is_direct_boot = true; -/* - * EFI can pass arbitrary additional "tables" containing vendor specific - * information to the payload. One such table is the FDT table which contains - * a pointer to a flattened device tree blob. - * - * In most cases we want to pass an FDT to the payload, so reserve one slot of - * config table space for it. The pointer gets populated by do_bootefi_exec(). - */ -static struct efi_configuration_table __efi_runtime_data efi_conf_table[16]; - #ifdef CONFIG_ARM /* * The "gd" pointer lives in a register on ARM and AArch64 that we declare @@ -1402,9 +1392,9 @@ static efi_status_t EFIAPI efi_locate_handle_ext( */ static void efi_remove_configuration_table(int i) { - struct efi_configuration_table *this = &efi_conf_table[i]; - struct efi_configuration_table *next = &efi_conf_table[i + 1]; - struct efi_configuration_table *end = &efi_conf_table[systab.nr_tables]; + struct efi_configuration_table *this = &systab.tables[i]; + struct efi_configuration_table *next = &systab.tables[i + 1]; + struct efi_configuration_table *end = &systab.tables[systab.nr_tables]; memmove(this, next, (ulong)end - (ulong)next); systab.nr_tables--; @@ -1432,9 +1422,9 @@ efi_status_t efi_install_configuration_table(const efi_guid_t *guid, /* Check for guid override */ for (i = 0; i < systab.nr_tables; i++) { - if (!guidcmp(guid, &efi_conf_table[i].guid)) { + if (!guidcmp(guid, &systab.tables[i].guid)) { if (table) - efi_conf_table[i].table = table; + systab.tables[i].table = table; else efi_remove_configuration_table(i); goto out; @@ -1445,12 +1435,12 @@ efi_status_t efi_install_configuration_table(const efi_guid_t *guid, return EFI_NOT_FOUND; /* No override, check for overflow */ - if (i >= ARRAY_SIZE(efi_conf_table)) + if (i >= EFI_MAX_CONFIGURATION_TABLES) return EFI_OUT_OF_RESOURCES; /* Add a new entry */ - memcpy(&efi_conf_table[i].guid, guid, sizeof(*guid)); - efi_conf_table[i].table = table; + memcpy(&systab.tables[i].guid, guid, sizeof(*guid)); + systab.tables[i].table = table; systab.nr_tables = i + 1; out: @@ -3136,7 +3126,7 @@ struct efi_system_table __efi_runtime_data systab = { .runtime = (void *)&efi_runtime_services, .boottime = (void *)&efi_boot_services, .nr_tables = 0, - .tables = (void *)efi_conf_table, + .tables = NULL, }; /** @@ -3146,9 +3136,18 @@ struct efi_system_table __efi_runtime_data systab = { */ efi_status_t efi_initialize_system_table(void) { + efi_status_t ret; + + /* Allocate configuration table array */ + ret = efi_allocate_pool(EFI_RUNTIME_SERVICES_DATA, + EFI_MAX_CONFIGURATION_TABLES * + sizeof(struct efi_configuration_table), + (void **)&systab.tables); + /* Set crc32 field in table headers */ efi_update_table_header_crc32(&systab.hdr); efi_update_table_header_crc32(&efi_runtime_services.hdr); efi_update_table_header_crc32(&efi_boot_services.hdr); - return EFI_SUCCESS; + + return ret; } -- cgit v1.3.1 From 8aa8360eca31b3b9f34645015df0556ce0e20e6d Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 7 Jul 2018 15:36:04 +0200 Subject: efi_loader: correct signature of CalculateCrc32() Use const for the buffer. We are not changing the buffer. Use efi_uintn_t where prescribed by the UEFI spec. Prefer u32 over uint32_t. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- include/efi_api.h | 5 +++-- lib/efi_loader/efi_boottime.c | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index c98cc34908b..ebf2a3bc18c 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -165,8 +165,9 @@ struct efi_boot_services { void **handle, ...); efi_status_t (EFIAPI *uninstall_multiple_protocol_interfaces)( void *handle, ...); - efi_status_t (EFIAPI *calculate_crc32)(void *data, - unsigned long data_size, uint32_t *crc32); + efi_status_t (EFIAPI *calculate_crc32)(const void *data, + efi_uintn_t data_size, + u32 *crc32); void (EFIAPI *copy_mem)(void *destination, const void *source, size_t length); void (EFIAPI *set_mem)(void *buffer, size_t size, uint8_t value); diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index c0354258b95..820d766b410 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -2448,11 +2448,11 @@ static efi_status_t EFIAPI efi_uninstall_multiple_protocol_interfaces( * * Return: status code */ -static efi_status_t EFIAPI efi_calculate_crc32(void *data, - unsigned long data_size, - uint32_t *crc32_p) +static efi_status_t EFIAPI efi_calculate_crc32(const void *data, + efi_uintn_t data_size, + u32 *crc32_p) { - EFI_ENTRY("%p, %ld", data, data_size); + EFI_ENTRY("%p, %zu", data, data_size); *crc32_p = crc32(0, data, data_size); return EFI_EXIT(EFI_SUCCESS); } -- cgit v1.3.1 From 197005ae2a78f14e02d44096c3ecb59b921c0467 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 7 Jul 2018 23:39:13 +0200 Subject: efi_loader: remove unused efi_get_time_init() Remove unused function efi_get_time_init(). Initialization of the RTC has to be done in board bring up not in the EFI subsystem. There is no RTC device in the UEFI spec. The RTC is only accessed through the runtime services. Signed-off-by: Heinrich Schuchardt Signed-off-by: Alexander Graf --- cmd/bootefi.c | 3 --- include/efi_loader.h | 1 - lib/efi_loader/efi_runtime.c | 5 ----- 3 files changed, 9 deletions(-) (limited to 'include') diff --git a/cmd/bootefi.c b/cmd/bootefi.c index e57e70fc612..b60c151fb4a 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -90,9 +90,6 @@ efi_status_t efi_init_obj_list(void) ret = efi_reset_system_init(); if (ret != EFI_SUCCESS) goto out; - ret = efi_get_time_init(); - if (ret != EFI_SUCCESS) - goto out; out: efi_obj_list_initialized = ret; diff --git a/include/efi_loader.h b/include/efi_loader.h index 051f9c45141..57ca5502726 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -434,7 +434,6 @@ efi_status_t efi_reset_system_init(void); efi_status_t __efi_runtime EFIAPI efi_get_time( struct efi_time *time, struct efi_time_cap *capabilities); -efi_status_t efi_get_time_init(void); #ifdef CONFIG_CMD_BOOTEFI_SELFTEST /* diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 1acb06a206b..866387530a6 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -174,11 +174,6 @@ efi_status_t __weak __efi_runtime EFIAPI efi_get_time( return EFI_DEVICE_ERROR; } -efi_status_t __weak efi_get_time_init(void) -{ - return EFI_SUCCESS; -} - struct efi_runtime_detach_list_struct { void *ptr; void *patchto; -- cgit v1.3.1