Browse Source

Merge branch '2021-07-28-assorted-fixes'

- Assorted bugfixes
Tom Rini 2 years ago
parent
commit
15f7e0dc01

+ 1 - 1
Makefile

@@ -1735,7 +1735,7 @@ u-boot-keep-syms-lto_c := $(patsubst %.o,%.c,$(u-boot-keep-syms-lto))
 
 
 quiet_cmd_keep_syms_lto = KSL     $@
 quiet_cmd_keep_syms_lto = KSL     $@
       cmd_keep_syms_lto = \
       cmd_keep_syms_lto = \
-	NM=$(NM) $(srctree)/scripts/gen_ll_addressable_symbols.sh $^ >$@
+	$(srctree)/scripts/gen_ll_addressable_symbols.sh $(NM) $^ > $@
 
 
 quiet_cmd_keep_syms_lto_cc = KSLCC   $@
 quiet_cmd_keep_syms_lto_cc = KSLCC   $@
       cmd_keep_syms_lto_cc = \
       cmd_keep_syms_lto_cc = \

+ 10 - 0
arch/arm/cpu/armv8/cache_v8.c

@@ -719,6 +719,11 @@ int icache_status(void)
 	return (get_sctlr() & CR_I) != 0;
 	return (get_sctlr() & CR_I) != 0;
 }
 }
 
 
+int mmu_status(void)
+{
+	return (get_sctlr() & CR_M) != 0;
+}
+
 void invalidate_icache_all(void)
 void invalidate_icache_all(void)
 {
 {
 	__asm_invalidate_icache_all();
 	__asm_invalidate_icache_all();
@@ -740,6 +745,11 @@ int icache_status(void)
 	return 0;
 	return 0;
 }
 }
 
 
+int mmu_status(void)
+{
+	return 0;
+}
+
 void invalidate_icache_all(void)
 void invalidate_icache_all(void)
 {
 {
 }
 }

+ 15 - 10
arch/arm/include/asm/io.h

@@ -338,6 +338,7 @@ extern void __readwrite_bug(const char *fn);
 
 
 /* Optimized copy functions to read from/write to IO sapce */
 /* Optimized copy functions to read from/write to IO sapce */
 #ifdef CONFIG_ARM64
 #ifdef CONFIG_ARM64
+#include <cpu_func.h>
 /*
 /*
  * Copy data from IO memory space to "real" memory space.
  * Copy data from IO memory space to "real" memory space.
  */
  */
@@ -351,11 +352,13 @@ void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
 		count--;
 		count--;
 	}
 	}
 
 
-	while (count >= 8) {
-		*(u64 *)to = __raw_readq(from);
-		from += 8;
-		to += 8;
-		count -= 8;
+	if (mmu_status()) {
+		while (count >= 8) {
+			*(u64 *)to = __raw_readq(from);
+			from += 8;
+			to += 8;
+			count -= 8;
+		}
 	}
 	}
 
 
 	while (count) {
 	while (count) {
@@ -379,11 +382,13 @@ void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
 		count--;
 		count--;
 	}
 	}
 
 
-	while (count >= 8) {
-		__raw_writeq(*(u64 *)from, to);
-		from += 8;
-		to += 8;
-		count -= 8;
+	if (mmu_status()) {
+		while (count >= 8) {
+			__raw_writeq(*(u64 *)from, to);
+			from += 8;
+			to += 8;
+			count -= 8;
+		}
 	}
 	}
 
 
 	while (count) {
 	while (count) {

+ 1 - 1
arch/arm/mach-mediatek/mt8183/init.c

@@ -48,7 +48,7 @@ int mtk_soc_early_init(void)
 	return 0;
 	return 0;
 }
 }
 
 
-void reset_cpu(ulong addr)
+void reset_cpu(void)
 {
 {
 	psci_system_reset();
 	psci_system_reset();
 }
 }

+ 1 - 1
board/congatec/cgtqmx8/cgtqmx8.c

@@ -374,7 +374,7 @@ void detail_board_ddr_info(void)
 /*
 /*
  * Board specific reset that is system reset.
  * Board specific reset that is system reset.
  */
  */
-void reset_cpu(ulong addr)
+void reset_cpu(void)
 {
 {
 	/* TODO */
 	/* TODO */
 }
 }

+ 1 - 1
board/hoperun/hihope-rzg2/hihope-rzg2.c

@@ -65,7 +65,7 @@ int board_init(void)
 	return 0;
 	return 0;
 }
 }
 
 
-void reset_cpu(ulong addr)
+void reset_cpu(void)
 {
 {
 	unsigned long midr, cputype;
 	unsigned long midr, cputype;
 
 

+ 1 - 1
board/silinux/ek874/ek874.c

@@ -24,7 +24,7 @@ int board_init(void)
 	return 0;
 	return 0;
 }
 }
 
 
-void reset_cpu(ulong addr)
+void reset_cpu(void)
 {
 {
 	writel(RST_CA53_CODE, RST_CA53RESCNT);
 	writel(RST_CA53_CODE, RST_CA53RESCNT);
 }
 }

+ 1 - 5
doc/arch/sandbox.rst

@@ -43,11 +43,7 @@ Note that standalone/API support is not available at present.
 Prerequisites
 Prerequisites
 -------------
 -------------
 
 
-Here are some packages that are worth installing if you are doing sandbox or
-tools development in U-Boot:
-
-   python3-pytest lzma lzma-alone lz4 python3 python3-virtualenv
-   libssl1.0-dev
+Install the dependencies noted in :doc:`../build/gcc`.
 
 
 
 
 Basic Operation
 Basic Operation

+ 4 - 2
doc/build/gcc.rst

@@ -26,8 +26,10 @@ Depending on the build targets further packages maybe needed
     sudo apt-get install bc bison build-essential coccinelle \
     sudo apt-get install bc bison build-essential coccinelle \
       device-tree-compiler dfu-util efitools flex gdisk liblz4-tool \
       device-tree-compiler dfu-util efitools flex gdisk liblz4-tool \
       libguestfs-tools libncurses-dev libpython3-dev libsdl2-dev libssl-dev \
       libguestfs-tools libncurses-dev libpython3-dev libsdl2-dev libssl-dev \
-      lzma-alone openssl python3 python3-coverage python3-pyelftools \
-      python3-pytest python3-sphinxcontrib.apidoc python3-sphinx-rtd-theme swig
+      lz4 lzma lzma-alone openssl python3 python3-coverage \
+      python3-pycryptodome python3-pyelftools python3-pytest \
+      python3-sphinxcontrib.apidoc python3-sphinx-rtd-theme python3-virtualenv \
+      swig
 
 
 SUSE based
 SUSE based
 ~~~~~~~~~~
 ~~~~~~~~~~

+ 2 - 2
doc/uImage.FIT/signature.txt

@@ -533,8 +533,8 @@ Generic engine key ids:
 or
 or
   "<key-name-hint>"
   "<key-name-hint>"
 
 
-As mkimage does not at this time support prompting for passwords HSM may need
-key preloading wrapper to be used when invoking mkimage.
+In order to set the pin in the HSM, an environment variable "MKIMAGE_SIGN_PIN"
+can be specified.
 
 
 The following examples use the Nitrokey Pro using pkcs11 engine. Instructions
 The following examples use the Nitrokey Pro using pkcs11 engine. Instructions
 for other devices may vary.
 for other devices may vary.

+ 11 - 2
drivers/misc/swap_case.c

@@ -302,7 +302,6 @@ static int sandbox_swap_case_write_io(struct udevice *dev, unsigned int addr,
 }
 }
 
 
 static int pci_ea_bar2_magic = PCI_EA_BAR2_MAGIC;
 static int pci_ea_bar2_magic = PCI_EA_BAR2_MAGIC;
-static int pci_ea_bar4_magic = PCI_EA_BAR4_MAGIC;
 
 
 static int sandbox_swap_case_map_physmem(struct udevice *dev,
 static int sandbox_swap_case_map_physmem(struct udevice *dev,
 		phys_addr_t addr, unsigned long *lenp, void **ptrp)
 		phys_addr_t addr, unsigned long *lenp, void **ptrp)
@@ -332,12 +331,22 @@ static int sandbox_swap_case_map_physmem(struct udevice *dev,
 			*ptrp = &pci_ea_bar2_magic;
 			*ptrp = &pci_ea_bar2_magic;
 			*lenp = PCI_CAP_EA_SIZE_LO;
 			*lenp = PCI_CAP_EA_SIZE_LO;
 			break;
 			break;
+#ifdef CONFIG_HOST_64BIT
+		/*
+		 * This cannot be work on a 32-bit machine since *lenp is ulong
+		 * which is 32-bits, but it needs to have a 64-bit value
+		 * assigned
+		 */
 		case (phys_addr_t)((PCI_CAP_EA_BASE_HI4 << 32) |
 		case (phys_addr_t)((PCI_CAP_EA_BASE_HI4 << 32) |
-				   PCI_CAP_EA_BASE_LO4):
+				   PCI_CAP_EA_BASE_LO4): {
+			static int pci_ea_bar4_magic = PCI_EA_BAR4_MAGIC;
+
 			*ptrp = &pci_ea_bar4_magic;
 			*ptrp = &pci_ea_bar4_magic;
 			*lenp = (PCI_CAP_EA_SIZE_HI << 32) |
 			*lenp = (PCI_CAP_EA_SIZE_HI << 32) |
 				PCI_CAP_EA_SIZE_LO;
 				PCI_CAP_EA_SIZE_LO;
 			break;
 			break;
+		}
+#endif
 		default:
 		default:
 			return -ENOENT;
 			return -ENOENT;
 		}
 		}

+ 1 - 0
include/cpu_func.h

@@ -59,6 +59,7 @@ int dcache_status(void);
 void dcache_enable(void);
 void dcache_enable(void);
 void dcache_disable(void);
 void dcache_disable(void);
 void mmu_disable(void);
 void mmu_disable(void);
+int mmu_status(void);
 
 
 /* arch/$(ARCH)/lib/cache.c */
 /* arch/$(ARCH)/lib/cache.c */
 void enable_caches(void);
 void enable_caches(void);

+ 12 - 1
lib/rsa/rsa-sign.c

@@ -338,6 +338,7 @@ static int rsa_init(void)
 
 
 static int rsa_engine_init(const char *engine_id, ENGINE **pe)
 static int rsa_engine_init(const char *engine_id, ENGINE **pe)
 {
 {
+	const char *key_pass;
 	ENGINE *e;
 	ENGINE *e;
 	int ret;
 	int ret;
 
 
@@ -362,10 +363,20 @@ static int rsa_engine_init(const char *engine_id, ENGINE **pe)
 		goto err_set_rsa;
 		goto err_set_rsa;
 	}
 	}
 
 
+	key_pass = getenv("MKIMAGE_SIGN_PIN");
+	if (key_pass) {
+		if (!ENGINE_ctrl_cmd_string(e, "PIN", key_pass, 0)) {
+			fprintf(stderr, "Couldn't set PIN\n");
+			ret = -1;
+			goto err_set_pin;
+		}
+	}
+
 	*pe = e;
 	*pe = e;
 
 
 	return 0;
 	return 0;
 
 
+err_set_pin:
 err_set_rsa:
 err_set_rsa:
 	ENGINE_finish(e);
 	ENGINE_finish(e);
 err_engine_init:
 err_engine_init:
@@ -473,7 +484,7 @@ static int rsa_sign_with_key(EVP_PKEY *pkey, struct padding_algo *padding_algo,
 	#endif
 	#endif
 	EVP_MD_CTX_destroy(context);
 	EVP_MD_CTX_destroy(context);
 
 
-	debug("Got signature: %d bytes, expected %zu\n", *sig_size, size);
+	debug("Got signature: %zu bytes, expected %d\n", size, EVP_PKEY_size(pkey));
 	*sigp = sig;
 	*sigp = sig;
 	*sig_size = size;
 	*sig_size = size;
 
 

+ 1 - 1
lib/rsa/rsa-verify.c

@@ -556,7 +556,7 @@ int rsa_verify(struct image_sign_info *info,
 	 */
 	 */
 	if (info->checksum->checksum_len >
 	if (info->checksum->checksum_len >
 	    info->crypto->key_len) {
 	    info->crypto->key_len) {
-		debug("%s: invlaid checksum-algorithm %s for %s\n",
+		debug("%s: invalid checksum-algorithm %s for %s\n",
 		      __func__, info->checksum->name, info->crypto->name);
 		      __func__, info->checksum->name, info->crypto->name);
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}

+ 1 - 1
scripts/Makefile.spl

@@ -459,7 +459,7 @@ u-boot-spl-keep-syms-lto_c := \
 
 
 quiet_cmd_keep_syms_lto = KSL     $@
 quiet_cmd_keep_syms_lto = KSL     $@
       cmd_keep_syms_lto = \
       cmd_keep_syms_lto = \
-	NM=$(NM) $(srctree)/scripts/gen_ll_addressable_symbols.sh $^ >$@
+	$(srctree)/scripts/gen_ll_addressable_symbols.sh $(NM) $^ > $@
 
 
 quiet_cmd_keep_syms_lto_cc = KSLCC   $@
 quiet_cmd_keep_syms_lto_cc = KSLCC   $@
       cmd_keep_syms_lto_cc = \
       cmd_keep_syms_lto_cc = \

+ 4 - 1
scripts/gen_ll_addressable_symbols.sh

@@ -5,8 +5,11 @@
 # Generate __ADDRESSABLE(symbol) for every linker list entry symbol, so that LTO
 # Generate __ADDRESSABLE(symbol) for every linker list entry symbol, so that LTO
 # does not optimize these symbols away
 # does not optimize these symbols away
 
 
+# The expected parameter of this script is the command requested to have
+# the U-Boot symbols to parse, for example: $(NM) $(u-boot-main)
+
 set -e
 set -e
 
 
 echo '#include <common.h>'
 echo '#include <common.h>'
-$NM "$@" 2>/dev/null | grep -oe '_u_boot_list_2_[a-zA-Z0-9_]*_2_[a-zA-Z0-9_]*' | \
+$@ 2>/dev/null | grep -oe '_u_boot_list_2_[a-zA-Z0-9_]*_2_[a-zA-Z0-9_]*' | \
 	sort -u | sed -e 's/^\(.*\)/extern char \1[];\n__ADDRESSABLE(\1);/'
 	sort -u | sed -e 's/^\(.*\)/extern char \1[];\n__ADDRESSABLE(\1);/'

+ 1 - 1
test/py/tests/test_fs/test_squashfs/sqfs_common.py

@@ -146,7 +146,7 @@ def get_mksquashfs_version():
     out = subprocess.run(['mksquashfs -version'], shell=True, check=True,
     out = subprocess.run(['mksquashfs -version'], shell=True, check=True,
                          capture_output=True, text=True)
                          capture_output=True, text=True)
     # 'out' is: mksquashfs version X (yyyy/mm/dd) ...
     # 'out' is: mksquashfs version X (yyyy/mm/dd) ...
-    return float(out.stdout.split()[2])
+    return float(out.stdout.split()[2].split('-')[0])
 
 
 def check_mksquashfs_version():
 def check_mksquashfs_version():
     """ Checks if mksquashfs meets the required version. """
     """ Checks if mksquashfs meets the required version. """