diff options
36 files changed, 316 insertions, 147 deletions
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon index 7dae9f03c3..b3c6693a42 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon +++ b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon @@ -110,7 +110,7 @@ Example: type = "ramdisk"; arch = "arm64"; os = "linux"; - compression = "gzip"; + compression = "none"; load = <0xa0000000>; }; }; diff --git a/arch/arm/dts/tegra20-u-boot.dtsi b/arch/arm/dts/tegra20-u-boot.dtsi index 7c11972552..f64667e549 100644 --- a/arch/arm/dts/tegra20-u-boot.dtsi +++ b/arch/arm/dts/tegra20-u-boot.dtsi @@ -1,3 +1,13 @@ #include <config.h> #include "tegra-u-boot.dtsi" + + +/ { + host1x@50000000 { + u-boot,dm-pre-reloc; + dc@54200000 { + u-boot,dm-pre-reloc; + }; + }; +}; diff --git a/arch/arm/mach-bcmstb/include/mach/timer.h b/arch/arm/mach-bcmstb/include/mach/timer.h index d05b4d64fe..039dd664c2 100644 --- a/arch/arm/mach-bcmstb/include/mach/timer.h +++ b/arch/arm/mach-bcmstb/include/mach/timer.h @@ -8,6 +8,6 @@ #ifndef _BCMSTB_TIMER_H #define _BCMSTB_TIMER_H -unsigned long timer_read_counter(void); +uint64_t get_ticks(void); #endif /* _BCMSTB_TIMER_H */ diff --git a/arch/arm/mach-tegra/ap.c b/arch/arm/mach-tegra/ap.c index bf8001d9db..84c20a48ad 100644 --- a/arch/arm/mach-tegra/ap.c +++ b/arch/arm/mach-tegra/ap.c @@ -155,8 +155,13 @@ static void init_pmc_scratch(void) int i; /* SCRATCH0 is initialized by the boot ROM and shouldn't be cleared */ - for (i = 0; i < 23; i++) - writel(0, &pmc->pmc_scratch1+i); +#if defined(CONFIG_TEGRA_SUPPORT_NON_SECURE) + if (!tegra_cpu_is_non_secure()) +#endif + { + for (i = 0; i < 23; i++) + writel(0, &pmc->pmc_scratch1 + i); + } /* ODMDATA is for kernel use to determine RAM size, LP config, etc. */ odmdata = get_odmdata(); diff --git a/arch/arm/mach-tegra/gpu.c b/arch/arm/mach-tegra/gpu.c index 2e203f735b..e047f67821 100644 --- a/arch/arm/mach-tegra/gpu.c +++ b/arch/arm/mach-tegra/gpu.c @@ -9,6 +9,7 @@ #include <asm/io.h> #include <asm/arch/tegra.h> #include <asm/arch/mc.h> +#include <asm/arch-tegra/ap.h> #include <fdt_support.h> @@ -18,12 +19,17 @@ void tegra_gpu_config(void) { struct mc_ctlr *mc = (struct mc_ctlr *)NV_PA_MC_BASE; - /* Turn VPR off */ - writel(0, &mc->mc_video_protect_size_mb); - writel(TEGRA_MC_VIDEO_PROTECT_REG_WRITE_ACCESS_DISABLED, - &mc->mc_video_protect_reg_ctrl); - /* read back to ensure the write went through */ - readl(&mc->mc_video_protect_reg_ctrl); +#if defined(CONFIG_TEGRA_SUPPORT_NON_SECURE) + if (!tegra_cpu_is_non_secure()) +#endif + { + /* Turn VPR off */ + writel(0, &mc->mc_video_protect_size_mb); + writel(TEGRA_MC_VIDEO_PROTECT_REG_WRITE_ACCESS_DISABLED, + &mc->mc_video_protect_reg_ctrl); + /* read back to ensure the write went through */ + readl(&mc->mc_video_protect_reg_ctrl); + } debug("configured VPR\n"); diff --git a/arch/riscv/cpu/ax25/u-boot.lds b/arch/riscv/cpu/ax25/u-boot.lds index 3cc89746b1..c50b9642f1 100644 --- a/arch/riscv/cpu/ax25/u-boot.lds +++ b/arch/riscv/cpu/ax25/u-boot.lds @@ -82,7 +82,7 @@ SECTIONS .bss : { __bss_start = .; - *(.bss) + *(.bss*) . = ALIGN(4); __bss_end = .; } diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index 5e7077bfe7..2babcde881 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -5,9 +5,6 @@ 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 727bcc3598..6a26c27e8e 100644 --- a/arch/sandbox/cpu/u-boot.lds +++ b/arch/sandbox/cpu/u-boot.lds @@ -17,16 +17,13 @@ SECTIONS _u_boot_sandbox_getopt : { *(.u_boot_sandbox_getopt) } __u_boot_sandbox_option_end = .; - __bss_start = .; - - .__efi_runtime_start : { + .__efi_runtime_start : { *(.__efi_runtime_start) } .efi_runtime : { - *(.text.efi_runtime*) - *(.rodata.efi_runtime*) - *(.data.efi_runtime*) + *(efi_runtime_text) + *(efi_runtime_data) } .__efi_runtime_stop : { @@ -39,8 +36,8 @@ SECTIONS } .efi_runtime_rel : { - *(.rel*.efi_runtime) - *(.rel*.efi_runtime.*) + *(.relefi_runtime_text) + *(.relefi_runtime_data) } .efi_runtime_rel_stop : @@ -48,6 +45,7 @@ SECTIONS *(.__efi_runtime_rel_stop) } + __bss_start = .; } INSERT BEFORE .data; diff --git a/arch/x86/config.mk b/arch/x86/config.mk index 586e11a0dd..5b04febd68 100644 --- a/arch/x86/config.mk +++ b/arch/x86/config.mk @@ -23,13 +23,11 @@ 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 -PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden +PLATFORM_RELFLAGS += -fdata-sections -ffunction-sections -fvisibility=hidden PLATFORM_LDFLAGS += -Bsymbolic -Bsymbolic-functions PLATFORM_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64) diff --git a/arch/x86/cpu/u-boot-64.lds b/arch/x86/cpu/u-boot-64.lds index 862aa2d35e..98c7f8e9c5 100644 --- a/arch/x86/cpu/u-boot-64.lds +++ b/arch/x86/cpu/u-boot-64.lds @@ -95,7 +95,7 @@ SECTIONS .bss __rel_dyn_start (OVERLAY) : { __bss_start = .; - *(.bss) + *(.bss*) *(COM*) . = ALIGN(4); __bss_end = .; diff --git a/arch/x86/cpu/u-boot.lds b/arch/x86/cpu/u-boot.lds index a1cc19ce4c..a283c290ee 100644 --- a/arch/x86/cpu/u-boot.lds +++ b/arch/x86/cpu/u-boot.lds @@ -94,7 +94,7 @@ SECTIONS .bss __rel_dyn_start (OVERLAY) : { __bss_start = .; - *(.bss) + *(.bss*) *(COM*) . = ALIGN(4); __bss_end = .; diff --git a/arch/x86/lib/elf_ia32_efi.lds b/arch/x86/lib/elf_ia32_efi.lds index 983fabbc4d..aad61e7f81 100644 --- a/arch/x86/lib/elf_ia32_efi.lds +++ b/arch/x86/lib/elf_ia32_efi.lds @@ -46,7 +46,7 @@ SECTIONS *(.sbss) *(.scommon) *(.dynbss) - *(.bss) + *(.bss*) *(COMMON) /* U-Boot lists and device tree */ diff --git a/arch/x86/lib/elf_x86_64_efi.lds b/arch/x86/lib/elf_x86_64_efi.lds index 7cad70a2e4..b436429b33 100644 --- a/arch/x86/lib/elf_x86_64_efi.lds +++ b/arch/x86/lib/elf_x86_64_efi.lds @@ -44,7 +44,7 @@ SECTIONS *(.sbss) *(.scommon) *(.dynbss) - *(.bss) + *(.bss*) *(COMMON) *(.rel.local) diff --git a/board/amlogic/nanopi-k2/nanopi-k2.c b/board/amlogic/nanopi-k2/nanopi-k2.c index 339dbb81db..ae29dd6fa4 100644 --- a/board/amlogic/nanopi-k2/nanopi-k2.c +++ b/board/amlogic/nanopi-k2/nanopi-k2.c @@ -30,12 +30,6 @@ int misc_init_r(void) meson_gx_eth_init(PHY_INTERFACE_MODE_RGMII, 0); - /* Reset PHY on GPIOZ_14 */ - clrbits_le32(GX_GPIO_EN(3), BIT(14)); - clrbits_le32(GX_GPIO_OUT(3), BIT(14)); - mdelay(10); - setbits_le32(GX_GPIO_OUT(3), BIT(14)); - if (!eth_env_get_enetaddr("ethaddr", mac_addr)) { len = meson_sm_read_efuse(EFUSE_MAC_OFFSET, mac_addr, EFUSE_MAC_SIZE); diff --git a/board/amlogic/odroid-c2/odroid-c2.c b/board/amlogic/odroid-c2/odroid-c2.c index c47b9ce9cb..2a2755c387 100644 --- a/board/amlogic/odroid-c2/odroid-c2.c +++ b/board/amlogic/odroid-c2/odroid-c2.c @@ -30,12 +30,6 @@ int misc_init_r(void) meson_gx_eth_init(PHY_INTERFACE_MODE_RGMII, 0); - /* Reset PHY on GPIOZ_14 */ - clrbits_le32(GX_GPIO_EN(3), BIT(14)); - clrbits_le32(GX_GPIO_OUT(3), BIT(14)); - mdelay(10); - setbits_le32(GX_GPIO_OUT(3), BIT(14)); - if (!eth_env_get_enetaddr("ethaddr", mac_addr)) { len = meson_sm_read_efuse(EFUSE_MAC_OFFSET, mac_addr, EFUSE_MAC_SIZE); @@ -28,18 +28,21 @@ static const char *const type_name[] = { }; static struct attr_info { - int shift; + u64 val; const char *name; } mem_attr[] = { - { EFI_MEMORY_UC_SHIFT, "uncached" }, - { EFI_MEMORY_WC_SHIFT, "write-coalescing" }, - { EFI_MEMORY_WT_SHIFT, "write-through" }, - { EFI_MEMORY_WB_SHIFT, "write-back" }, - { EFI_MEMORY_UCE_SHIFT, "uncached & exported" }, - { EFI_MEMORY_WP_SHIFT, "write-protect" }, - { EFI_MEMORY_RP_SHIFT, "read-protect" }, - { EFI_MEMORY_XP_SHIFT, "execute-protect" }, - { EFI_MEMORY_RUNTIME_SHIFT, "needs runtime mapping" } + { EFI_MEMORY_UC, "uncached" }, + { EFI_MEMORY_WC, "write-coalescing" }, + { EFI_MEMORY_WT, "write-through" }, + { EFI_MEMORY_WB, "write-back" }, + { EFI_MEMORY_UCE, "uncached & exported" }, + { EFI_MEMORY_WP, "write-protect" }, + { EFI_MEMORY_RP, "read-protect" }, + { EFI_MEMORY_XP, "execute-protect" }, + { EFI_MEMORY_NV, "non-volatile" }, + { EFI_MEMORY_MORE_RELIABLE, "higher reliability" }, + { EFI_MEMORY_RO, "read-only" }, + { EFI_MEMORY_RUNTIME, "needs runtime mapping" } }; /* Maximum different attribute values we can track */ @@ -170,10 +173,10 @@ static void efi_print_mem_table(struct efi_entry_memmap *map, bool first; int j; - printf("%c%llx: ", attr & EFI_MEMORY_RUNTIME ? 'r' : ' ', + printf("%c%llx: ", (attr & EFI_MEMORY_RUNTIME) ? 'r' : ' ', attr & ~EFI_MEMORY_RUNTIME); for (j = 0, first = true; j < ARRAY_SIZE(mem_attr); j++) { - if (attr & (1ULL << mem_attr[j].shift)) { + if (attr & mem_attr[j].val) { if (first) first = false; else @@ -115,7 +115,10 @@ static unsigned long load_elf64_image_shdr(unsigned long addr) memcpy((void *)(uintptr_t)shdr->sh_addr, (const void *)image, shdr->sh_size); } - flush_cache((ulong)shdr->sh_addr, shdr->sh_size); + flush_cache(rounddown(shdr->sh_addr, ARCH_DMA_MINALIGN), + roundup((shdr->sh_addr + shdr->sh_size), + ARCH_DMA_MINALIGN) - + rounddown(shdr->sh_addr, ARCH_DMA_MINALIGN)); } if (ehdr->e_machine == EM_PPC64 && (ehdr->e_flags & diff --git a/common/Kconfig b/common/Kconfig index b3d9b37463..3030da4fc9 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -647,6 +647,7 @@ config HASH config AVB_VERIFY bool "Build Android Verified Boot operations" depends on LIBAVB && FASTBOOT + depends on PARTITION_UUIDS help This option enables compilation of bootloader-dependent operations, used by Android Verified Boot 2.0 library (libavb). Includes: diff --git a/common/avb_verify.c b/common/avb_verify.c index 82ddebcfc2..f8c6ae5566 100644 --- a/common/avb_verify.c +++ b/common/avb_verify.c @@ -11,7 +11,7 @@ #include <malloc.h> #include <part.h> -const unsigned char avb_root_pub[1032] = { +static const unsigned char avb_root_pub[1032] = { 0x0, 0x0, 0x10, 0x0, 0x55, 0xd9, 0x4, 0xad, 0xd8, 0x4, 0xaf, 0xe3, 0xd3, 0x84, 0x6c, 0x7e, 0xd, 0x89, 0x3d, 0xc2, 0x8c, 0xd3, 0x12, 0x55, 0xe9, 0x62, 0xc9, 0xf1, 0xf, 0x5e, @@ -176,7 +176,7 @@ static int avb_find_dm_args(char **args, char *str) if (!str) return -1; - for (i = 0; i < AVB_MAX_ARGS, args[i]; ++i) { + for (i = 0; i < AVB_MAX_ARGS && args[i]; ++i) { if (strstr(args[i], str)) return i; } @@ -348,34 +348,37 @@ static struct mmc_part *get_partition(AvbOps *ops, const char *partition) part->mmc = find_mmc_device(dev_num); if (!part->mmc) { printf("No MMC device at slot %x\n", dev_num); - return NULL; + goto err; } if (mmc_init(part->mmc)) { printf("MMC initialization failed\n"); - return NULL; + goto err; } ret = mmc_switch_part(part->mmc, part_num); if (ret) - return NULL; + goto err; mmc_blk = mmc_get_blk_desc(part->mmc); if (!mmc_blk) { printf("Error - failed to obtain block descriptor\n"); - return NULL; + goto err; } ret = part_get_info_by_name(mmc_blk, partition, &part->info); if (!ret) { printf("Can't find partition '%s'\n", partition); - return NULL; + goto err; } part->dev_num = dev_num; part->mmc_blk = mmc_blk; return part; +err: + free(part); + return NULL; } static AvbIOResult mmc_byte_io(AvbOps *ops, @@ -399,6 +402,9 @@ static AvbIOResult mmc_byte_io(AvbOps *ops, if (!part) return AVB_IO_RESULT_ERROR_NO_SUCH_PARTITION; + if (!part->info.blksz) + return AVB_IO_RESULT_ERROR_IO; + start_offset = calc_offset(part, offset); while (num_bytes) { start_sector = start_offset / part->info.blksz; @@ -763,7 +769,7 @@ void avb_ops_free(AvbOps *ops) { struct AvbOpsData *ops_data; - if (ops) + if (!ops) return; ops_data = ops->user_data; diff --git a/common/malloc_simple.c b/common/malloc_simple.c index c14f8b59c1..871b5444bd 100644 --- a/common/malloc_simple.c +++ b/common/malloc_simple.c @@ -57,7 +57,8 @@ void *calloc(size_t nmemb, size_t elem_size) void *ptr; ptr = malloc(size); - memset(ptr, '\0', size); + if (ptr) + memset(ptr, '\0', size); return ptr; } diff --git a/configs/display5_factory_defconfig b/configs/display5_factory_defconfig index edb37c3b2f..5962b642b2 100644 --- a/configs/display5_factory_defconfig +++ b/configs/display5_factory_defconfig @@ -15,7 +15,7 @@ CONFIG_OF_BOARD_SETUP=y CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg,MX6Q" CONFIG_BOOTDELAY=3 CONFIG_USE_BOOTCOMMAND=y -CONFIG_BOOTCOMMAND="run factory" +CONFIG_BOOTCOMMAND="echo SDP Display5 recovery" CONFIG_SUPPORT_RAW_INITRD=y CONFIG_MISC_INIT_R=y # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set @@ -168,6 +168,7 @@ static int env_ubi_load(void) U_BOOT_ENV_LOCATION(ubi) = { .location = ENVL_UBI, + ENV_NAME("UBI") .load = env_ubi_load, .save = env_save_ptr(env_ubi_save), }; diff --git a/include/configs/display5.h b/include/configs/display5.h index 514638f684..6d00699ebd 100644 --- a/include/configs/display5.h +++ b/include/configs/display5.h @@ -115,27 +115,6 @@ "name=rootfs2,size=512M,uuid=${uuid_gpt_rootfs2};" \ "name=data,size=-,uuid=${uuid_gpt_data}\0" -#define FACTORY_PROCEDURE \ - "echo '#######################';" \ - "echo '# Factory Boot #';" \ - "echo '#######################';" \ - "env default -a;" \ - "saveenv;" \ - "gpt write mmc ${mmcdev} ${partitions};" \ - "run tftp_sf_SPL;" \ - "run tftp_sf_uboot;" \ - TFTP_UPDATE_KERNEL \ - "run tftp_sf_fitImg_SWU;" \ - "run tftp_sf_initramfs_SWU;" \ - TFTP_UPDATE_ROOTFS \ - "echo '#######################';" \ - "echo '# END - OK #';" \ - "echo '#######################';" \ - "setenv bootcmd 'env default -a; saveenv; run falcon_setup; reset';" \ - "setenv boot_os 'n';" \ - "saveenv;" \ - "reset;" - #define SWUPDATE_RECOVERY_PROCEDURE \ "echo '#######################';" \ "echo '# RECOVERY SWUupdate #';" \ @@ -261,7 +240,6 @@ "bootdelay=1\0" \ "baudrate=115200\0" \ "bootcmd=" CONFIG_BOOTCOMMAND "\0" \ - "factory=" FACTORY_PROCEDURE "\0" \ "ethact=FEC\0" \ "netdev=eth0\0" \ "boot_os=y\0" \ diff --git a/include/configs/ls1088a_common.h b/include/configs/ls1088a_common.h index 2d6a5fc3d4..822fd76cc5 100644 --- a/include/configs/ls1088a_common.h +++ b/include/configs/ls1088a_common.h @@ -222,6 +222,7 @@ unsigned long long get_qixis_addr(void); #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" #define CONFIG_SPL_MAX_SIZE 0x16000 #define CONFIG_SPL_STACK (CONFIG_SYS_FSL_OCRAM_BASE + 0x9ff0) +#define CONFIG_SPL_TARGET "u-boot-with-spl.bin" #define CONFIG_SPL_TEXT_BASE 0x1800a000 #define CONFIG_SYS_SPL_MALLOC_SIZE 0x00100000 diff --git a/include/configs/ls2080a_common.h b/include/configs/ls2080a_common.h index e756844c6a..713e1d1d09 100644 --- a/include/configs/ls2080a_common.h +++ b/include/configs/ls2080a_common.h @@ -204,6 +204,7 @@ unsigned long long get_qixis_addr(void); #define CONFIG_SPL_BSS_MAX_SIZE 0x00100000 #define CONFIG_SPL_MAX_SIZE 0x16000 #define CONFIG_SPL_STACK (CONFIG_SYS_FSL_OCRAM_BASE + 0x9ff0) +#define CONFIG_SPL_TARGET "u-boot-with-spl.bin" #define CONFIG_SPL_TEXT_BASE 0x1800a000 #ifdef CONFIG_NAND_BOOT diff --git a/include/dt-bindings/pinctrl/am33xx.h b/include/dt-bindings/pinctrl/am33xx.h index 2fbc804e1a..226f77246a 100644 --- a/include/dt-bindings/pinctrl/am33xx.h +++ b/include/dt-bindings/pinctrl/am33xx.h @@ -13,7 +13,8 @@ #define PULL_DISABLE (1 << 3) #define INPUT_EN (1 << 5) -#define SLEWCTRL_FAST (1 << 6) +#define SLEWCTRL_SLOW (1 << 6) +#define SLEWCTRL_FAST 0 /* update macro depending on INPUT_EN and PULL_ENA */ #undef PIN_OUTPUT diff --git a/include/efi.h b/include/efi.h index 41530a7537..7e7c1cafc2 100644 --- a/include/efi.h +++ b/include/efi.h @@ -170,20 +170,20 @@ enum efi_mem_type { }; /* Attribute values */ -enum { - EFI_MEMORY_UC_SHIFT = 0, /* uncached */ - EFI_MEMORY_WC_SHIFT = 1, /* write-coalescing */ - EFI_MEMORY_WT_SHIFT = 2, /* write-through */ - EFI_MEMORY_WB_SHIFT = 3, /* write-back */ - EFI_MEMORY_UCE_SHIFT = 4, /* uncached, exported */ - EFI_MEMORY_WP_SHIFT = 12, /* write-protect */ - EFI_MEMORY_RP_SHIFT = 13, /* read-protect */ - EFI_MEMORY_XP_SHIFT = 14, /* execute-protect */ - EFI_MEMORY_RUNTIME_SHIFT = 63, /* range requires runtime mapping */ - - EFI_MEMORY_RUNTIME = 1ULL << EFI_MEMORY_RUNTIME_SHIFT, - EFI_MEM_DESC_VERSION = 1, -}; +#define EFI_MEMORY_UC ((u64)0x0000000000000001ULL) /* uncached */ +#define EFI_MEMORY_WC ((u64)0x0000000000000002ULL) /* write-coalescing */ +#define EFI_MEMORY_WT ((u64)0x0000000000000004ULL) /* write-through */ +#define EFI_MEMORY_WB ((u64)0x0000000000000008ULL) /* write-back */ +#define EFI_MEMORY_UCE ((u64)0x0000000000000010ULL) /* uncached, exported */ +#define EFI_MEMORY_WP ((u64)0x0000000000001000ULL) /* write-protect */ +#define EFI_MEMORY_RP ((u64)0x0000000000002000ULL) /* read-protect */ +#define EFI_MEMORY_XP ((u64)0x0000000000004000ULL) /* execute-protect */ +#define EFI_MEMORY_NV ((u64)0x0000000000008000ULL) /* non-volatile */ +#define EFI_MEMORY_MORE_RELIABLE \ + ((u64)0x0000000000010000ULL) /* higher reliability */ +#define EFI_MEMORY_RO ((u64)0x0000000000020000ULL) /* read-only */ +#define EFI_MEMORY_RUNTIME ((u64)0x8000000000000000ULL) /* range requires runtime mapping */ +#define EFI_MEM_DESC_VERSION 1 #define EFI_PAGE_SHIFT 12 #define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT) diff --git a/include/efi_loader.h b/include/efi_loader.h index 57ca550272..f162adfff7 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -417,6 +417,9 @@ static inline int guidcmp(const efi_guid_t *g1, const efi_guid_t *g2) #define __efi_runtime_data __attribute__ ((section (".data.efi_runtime"))) #define __efi_runtime __attribute__ ((section (".text.efi_runtime"))) +/* Update CRC32 in table header */ +void __efi_runtime efi_update_table_header_crc32(struct efi_table_hdr *table); + /* Call this with mmio_ptr as the _pointer_ to a pointer to an MMIO region * to make it available at runtime */ efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len); diff --git a/lib/crc32.c b/lib/crc32.c index 7f545fde4a..71e27df78e 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -12,6 +12,7 @@ #include <arpa/inet.h> #else #include <common.h> +#include <efi_loader.h> #endif #include <compiler.h> #include <u-boot/crc.h> @@ -21,16 +22,18 @@ #endif #include "u-boot/zlib.h" -#define local static -#define ZEXPORT /* empty */ +#ifdef USE_HOSTCC +#define __efi_runtime +#define __efi_runtime_data +#endif #define tole(x) cpu_to_le32(x) #ifdef CONFIG_DYNAMIC_CRC_TABLE -local int crc_table_empty = 1; -local uint32_t crc_table[256]; -local void make_crc_table OF((void)); +static int __efi_runtime_data crc_table_empty = 1; +static uint32_t __efi_runtime_data crc_table[256]; +static void __efi_runtime make_crc_table OF((void)); /* Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: @@ -56,7 +59,7 @@ local void make_crc_table OF((void)); the information needed to generate CRC's on data a byte at a time for all combinations of CRC register values and incoming bytes. */ -local void make_crc_table() +static void __efi_runtime make_crc_table(void) { uint32_t c; int n, k; @@ -83,7 +86,7 @@ local void make_crc_table() * Table of CRC-32's of all single-byte values (made by make_crc_table) */ -local const uint32_t crc_table[256] = { +static const uint32_t __efi_runtime_data crc_table[256] = { tole(0x00000000L), tole(0x77073096L), tole(0xee0e612cL), tole(0x990951baL), tole(0x076dc419L), tole(0x706af48fL), tole(0xe963a535L), tole(0x9e6495a3L), tole(0x0edb8832L), tole(0x79dcb8a4L), tole(0xe0d5e91eL), tole(0x97d2d988L), @@ -176,7 +179,7 @@ const uint32_t * ZEXPORT get_crc_table() /* No ones complement version. JFFS2 (and other things ?) * don't use ones compliment in their CRC calculations. */ -uint32_t ZEXPORT crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len) +uint32_t __efi_runtime crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len) { const uint32_t *tab = crc_table; const uint32_t *b =(const uint32_t *)buf; @@ -218,7 +221,7 @@ uint32_t ZEXPORT crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len) } #undef DO_CRC -uint32_t ZEXPORT crc32 (uint32_t crc, const Bytef *p, uInt len) +uint32_t __efi_runtime crc32(uint32_t crc, const Bytef *p, uInt len) { return crc32_no_comp(crc ^ 0xffffffffL, p, len) ^ 0xffffffffL; } @@ -227,9 +230,8 @@ uint32_t ZEXPORT crc32 (uint32_t crc, const Bytef *p, uInt len) * Calculate the crc32 checksum triggering the watchdog every 'chunk_sz' bytes * of input. */ -uint32_t ZEXPORT crc32_wd (uint32_t crc, - const unsigned char *buf, - uInt len, uInt chunk_sz) +uint32_t crc32_wd(uint32_t crc, const unsigned char *buf, uInt len, + uInt chunk_sz) { #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG) const unsigned char *end, *curr; diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index b9e54f551a..3935e4f1ce 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -154,18 +154,6 @@ const char *__efi_nesting_dec(void) } /** - * 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 * @check_tpl: check the TPL level @@ -627,7 +615,8 @@ efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl, return EFI_INVALID_PARAMETER; } - if (is_valid_tpl(notify_tpl) != EFI_SUCCESS) + if ((type & (EVT_NOTIFY_WAIT | EVT_NOTIFY_SIGNAL)) && + (is_valid_tpl(notify_tpl) != EFI_SUCCESS)) return EFI_INVALID_PARAMETER; evt = calloc(1, sizeof(struct efi_event)); diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 3fd0d2fd51..b487288785 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -105,14 +105,6 @@ static int term_read_reply(int *n, int num, char end_char) return 0; } -static efi_status_t EFIAPI efi_cout_reset( - struct efi_simple_text_output_protocol *this, - char extended_verification) -{ - EFI_ENTRY("%p, %d", this, extended_verification); - return EFI_EXIT(EFI_UNSUPPORTED); -} - static efi_status_t EFIAPI efi_cout_output_string( struct efi_simple_text_output_protocol *this, const efi_string_t string) @@ -341,6 +333,20 @@ static efi_status_t EFIAPI efi_cout_clear_screen( return EFI_EXIT(EFI_SUCCESS); } +static efi_status_t EFIAPI efi_cout_reset( + struct efi_simple_text_output_protocol *this, + char extended_verification) +{ + EFI_ENTRY("%p, %d", this, extended_verification); + + /* Clear screen */ + EFI_CALL(efi_cout_clear_screen(this)); + /* Set default colors */ + printf(ESC "[0;37;40m"); + + return EFI_EXIT(EFI_SUCCESS); +} + static efi_status_t EFIAPI efi_cout_set_cursor_position( struct efi_simple_text_output_protocol *this, unsigned long column, unsigned long row) diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 967c3f733e..e2b40aa85b 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -178,14 +178,13 @@ uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, switch (memory_type) { case EFI_RUNTIME_SERVICES_CODE: case EFI_RUNTIME_SERVICES_DATA: - newlist->desc.attribute = (1 << EFI_MEMORY_WB_SHIFT) | - (1ULL << EFI_MEMORY_RUNTIME_SHIFT); + newlist->desc.attribute = EFI_MEMORY_WB | EFI_MEMORY_RUNTIME; break; case EFI_MMAP_IO: - newlist->desc.attribute = 1ULL << EFI_MEMORY_RUNTIME_SHIFT; + newlist->desc.attribute = EFI_MEMORY_RUNTIME; break; default: - newlist->desc.attribute = 1 << EFI_MEMORY_WB_SHIFT; + newlist->desc.attribute = EFI_MEMORY_WB; break; } @@ -305,7 +304,7 @@ efi_status_t efi_allocate_pages(int type, int memory_type, switch (type) { case EFI_ALLOCATE_ANY_PAGES: /* Any page */ - addr = efi_find_free_memory(len, -1ULL); + addr = efi_find_free_memory(len, gd->start_addr_sp); if (!addr) { r = EFI_NOT_FOUND; break; @@ -457,11 +456,13 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, efi_uintn_t map_size = 0; int map_entries = 0; struct list_head *lhandle; - efi_uintn_t provided_map_size = *memory_map_size; + efi_uintn_t provided_map_size; if (!memory_map_size) return EFI_INVALID_PARAMETER; + provided_map_size = *memory_map_size; + list_for_each(lhandle, &efi_mem) map_entries++; diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 06958f23fa..27136cbedd 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -84,6 +84,32 @@ struct elf_rela { * handle a good number of runtime callbacks */ +/** + * efi_update_table_header_crc32() - Update crc32 in table header + * + * @table: EFI table + */ +void __efi_runtime efi_update_table_header_crc32(struct efi_table_hdr *table) +{ + table->crc32 = 0; + table->crc32 = crc32(0, (const unsigned char *)table, + table->headersize); +} + +/** + * efi_reset_system_boottime() - reset system at boottime + * + * This function implements the ResetSystem() runtime service before + * SetVirtualAddressMap() is called. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * @reset_type: type of reset to perform + * @reset_status: status code for the reset + * @data_size: size of reset_data + * @reset_data: information about the reset + */ static void EFIAPI efi_reset_system_boottime( enum efi_reset_type reset_type, efi_status_t reset_status, @@ -118,15 +144,17 @@ static void EFIAPI efi_reset_system_boottime( } /** - * efi_get_time_boottime - get current time + * efi_get_time_boottime() - get current time at boottime + * + * This function implements the GetTime runtime service before + * SetVirtualAddressMap() is called. * - * This function implements the GetTime runtime service. * See the Unified Extensible Firmware Interface (UEFI) specification * for details. * * @time: pointer to structure to receive current time * @capabilities: pointer to structure to receive RTC properties - * Return Value: status code + * Returns: status code */ static efi_status_t EFIAPI efi_get_time_boottime( struct efi_time *time, @@ -179,8 +207,22 @@ out: #endif } -/* Boards may override the helpers below to implement RTS functionality */ +/** + * efi_reset_system() - reset system + * + * This function implements the ResetSystem() runtime service after + * SetVirtualAddressMap() is called. It only executes an endless loop. + * Boards may override the helpers below to implement reset functionality. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * @reset_type: type of reset to perform + * @reset_status: status code for the reset + * @data_size: size of reset_data + * @reset_data: information about the reset + */ void __weak __efi_runtime EFIAPI efi_reset_system( enum efi_reset_type reset_type, efi_status_t reset_status, @@ -190,11 +232,30 @@ void __weak __efi_runtime EFIAPI efi_reset_system( while (1) { } } +/** + * efi_reset_system_init() - initialize the reset driver + * + * Boards may override this function to initialize the reset driver. + */ efi_status_t __weak efi_reset_system_init(void) { return EFI_SUCCESS; } +/** + * efi_get_time() - get current time + * + * This function implements the GetTime runtime service after + * SetVirtualAddressMap() is called. As the U-Boot driver are not available + * anymore only an error code is returned. + * + * See the Unified Extensible Firmware Interface (UEFI) specification + * for details. + * + * @time: pointer to structure to receive current time + * @capabilities: pointer to structure to receive RTC properties + * Returns: status code + */ efi_status_t __weak __efi_runtime EFIAPI efi_get_time( struct efi_time *time, struct efi_time_cap *capabilities) @@ -273,6 +334,9 @@ static void efi_runtime_detach(ulong offset) debug("%s: Setting %p to %lx\n", __func__, p, newaddr); *p = newaddr; } + + /* Update crc32 */ + efi_update_table_header_crc32(&efi_runtime_services.hdr); } /* Relocate EFI runtime to uboot_reloc_base = offset */ @@ -338,6 +402,20 @@ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map) invalidate_icache_all(); } +/** + * efi_set_virtual_address_map() - change from physical to virtual mapping + * + * This function implements the SetVirtualAddressMap() runtime service. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * @memory_map_size: size of the virtual map + * @descriptor_size: size of an entry in the map + * @descriptor_version: version of the map entries + * @virtmap: virtual address mapping information + * Return: status code + */ static efi_status_t EFIAPI efi_set_virtual_address_map( unsigned long memory_map_size, unsigned long descriptor_size, @@ -360,6 +438,7 @@ static efi_status_t EFIAPI efi_set_virtual_address_map( efi_physical_addr_t map_start = map->physical_start; efi_physical_addr_t map_len = map->num_pages << EFI_PAGE_SHIFT; efi_physical_addr_t map_end = map_start + map_len; + u64 off = map->virtual_start - map_start; /* Adjust all mmio pointers in this region */ list_for_each(lhandle, &efi_runtime_mmio) { @@ -370,11 +449,17 @@ static efi_status_t EFIAPI efi_set_virtual_address_map( link); if ((map_start <= lmmio->paddr) && (map_end >= lmmio->paddr)) { - u64 off = map->virtual_start - map_start; uintptr_t new_addr = lmmio->paddr + off; *lmmio->ptr = (void *)new_addr; } } + if ((map_start <= (uintptr_t)systab.tables) && + (map_end >= (uintptr_t)systab.tables)) { + char *ptr = (char *)systab.tables; + + ptr += off; + systab.tables = (struct efi_configuration_table *)ptr; + } } /* Move the actual runtime code over */ @@ -397,6 +482,16 @@ static efi_status_t EFIAPI efi_set_virtual_address_map( return EFI_EXIT(EFI_INVALID_PARAMETER); } +/** + * efi_add_runtime_mmio() - add memory-mapped IO region + * + * This function adds a memory-mapped IO region to the memory map to make it + * available at runtime. + * + * @mmio_ptr: address of the memory-mapped IO region + * @len: size of thememory-mapped IO region + * Returns: status code + */ efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len) { struct efi_runtime_mmio_list *newmmio; @@ -439,21 +534,61 @@ efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len) * address map calls. */ +/** + * efi_unimplemented() - replacement function, returns EFI_UNSUPPORTED + * + * This function is used after SetVirtualAddressMap() is called as replacement + * for services that are not available anymore due to constraints of the U-Boot + * implementation. + * + * Return: EFI_UNSUPPORTED + */ static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void) { return EFI_UNSUPPORTED; } +/** + * efi_device_error() - replacement function, returns EFI_DEVICE_ERROR + * + * This function is used after SetVirtualAddressMap() is called as replacement + * for services that are not available anymore due to constraints of the U-Boot + * implementation. + * + * Return: EFI_DEVICE_ERROR + */ static efi_status_t __efi_runtime EFIAPI efi_device_error(void) { return EFI_DEVICE_ERROR; } +/** + * efi_invalid_parameter() - replacement function, returns EFI_INVALID_PARAMETER + * + * This function is used after SetVirtualAddressMap() is called as replacement + * for services that are not available anymore due to constraints of the U-Boot + * implementation. + * + * Return: EFI_INVALID_PARAMETER + */ static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void) { return EFI_INVALID_PARAMETER; } +/** + * efi_update_capsule() - process information from operating system + * + * This function implements the UpdateCapsule() runtime service. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * @capsule_header_array: pointer to array of virtual pointers + * @capsule_count: number of pointers in capsule_header_array + * @scatter_gather_list: pointer to arry of physical pointers + * Returns: status code + */ efi_status_t __efi_runtime EFIAPI efi_update_capsule( struct efi_capsule_header **capsule_header_array, efi_uintn_t capsule_count, @@ -462,6 +597,20 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule( return EFI_UNSUPPORTED; } +/** + * efi_query_capsule_caps() - check if capsule is supported + * + * This function implements the QueryCapsuleCapabilities() runtime service. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * @capsule_header_array: pointer to array of virtual pointers + * @capsule_count: number of pointers in capsule_header_array + * @capsule_size: maximum capsule size + * @reset_type: type of reset needed for capsule update + * Returns: status code + */ efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps( struct efi_capsule_header **capsule_header_array, efi_uintn_t capsule_count, @@ -471,6 +620,24 @@ efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps( return EFI_UNSUPPORTED; } +/** + * efi_query_variable_info() - get information about EFI variables + * + * This function implements the QueryVariableInfo() runtime service. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * @attributes: bitmask to select variables to be + * queried + * @maximum_variable_storage_size: maximum size of storage area for the + * selected variable types + * @remaining_variable_storage_size: remaining size of storage are for the + * selected variable types + * @maximum_variable_size: maximum size of a variable of the + * selected type + * Returns: status code + */ efi_status_t __efi_runtime EFIAPI efi_query_variable_info( u32 attributes, u64 *maximum_variable_storage_size, diff --git a/lib/efi_selftest/efi_selftest_block_device.c b/lib/efi_selftest/efi_selftest_block_device.c index b82e405030..1cd13042e9 100644 --- a/lib/efi_selftest/efi_selftest_block_device.c +++ b/lib/efi_selftest/efi_selftest_block_device.c @@ -415,7 +415,7 @@ static int execute(void) #ifdef CONFIG_FAT_WRITE /* Write file */ - ret = root->open(root, &file, (s16 *)L"u-boot.txt", + ret = root->open(root, &file, (s16 *)L"u-boot.txt", EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0); if (ret != EFI_SUCCESS) { efi_st_error("Failed to open file\n"); diff --git a/lib/libavb/avb_cmdline.c b/lib/libavb/avb_cmdline.c index 91a6615c74..d246699272 100644 --- a/lib/libavb/avb_cmdline.c +++ b/lib/libavb/avb_cmdline.c @@ -331,6 +331,9 @@ AvbSlotVerifyResult avb_append_options( verity_mode = "logging"; dm_verity_mode = "ignore_corruption"; break; + default: + ret = AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_ARGUMENT; + goto out; } new_ret = avb_replace( slot_data->cmdline, "$(ANDROID_VERITY_MODE)", dm_verity_mode); diff --git a/test/dm/test-main.c b/test/dm/test-main.c index 4def795c79..5d79ce641d 100644 --- a/test/dm/test-main.c +++ b/test/dm/test-main.c @@ -94,7 +94,7 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test, ut_assertok(dm_extended_scan_fdt(gd->fdt_blob, false)); /* - * Silence the console and rely on console reocrding to get + * Silence the console and rely on console recording to get * our output. */ console_record_reset(); |