@@ -21,7 +21,7 @@ KERNEL_IMAGETYPE = "Image"
EXTRA_IMAGEDEPENDS += "trusted-firmware-a"
# FVP u-boot configuration
-UBOOT_MACHINE = "vexpress_aemv8a_semi_defconfig"
+UBOOT_MACHINE = "vexpress_fvp_defconfig"
# As this is a virtual target that will not be used in the real world there is
# no need for real SSH keys.
@@ -1,5 +1,8 @@
# FVP base specific U-boot support
SRC_URI:append = " file://bootargs.cfg \
- file://0001-Revert-vexpress64-pick-DRAM-size-from-DT.patch \
+ file://0001-virtio-rng-Workaround-for-FVP-returning-zero-size-bu.patch \
+ file://0002-vexpress64-Set-the-DM_RNG-property.patch \
+ file://0003-vexpress64-Select-PSCI-RESET-by-default.patch \
+ file://0004-vexpress64-Imply-CONFIG_ARM64_CRC32-by-default.patch \
"
deleted file mode 100644
@@ -1,44 +0,0 @@
-From 4f649e0a3e0f9ed1f0d6efdff5b14cdc40d84201 Mon Sep 17 00:00:00 2001
-From: Jon Mason <jon.mason@arm.com
-Date: Thu, 2 Mar 2023 15:22:08 +0000
-Subject: [PATCH] Revert "vexpress64: pick DRAM size from DT"
-
-This reverts commit 1a1143a45457161e90ea4cd5f3b0561d924ed8fe.
-
-DRAM is determined via dtb in recent versions. Since fvp isn't
-reading and specifying a dtb, this fails and hangs u-boot. Remove this
-and go back to the way things were.
-
-Signed-off-by: Jon Mason <jon.mason@arm.com>
-Upstream-Status: Inappropriate
----
- board/armltd/vexpress64/vexpress64.c | 12 ++++++++++--
- 1 file changed, 10 insertions(+), 2 deletions(-)
-
-diff --git a/board/armltd/vexpress64/vexpress64.c b/board/armltd/vexpress64/vexpress64.c
-index af326dc6f453..e8ce88b22c5a 100644
---- a/board/armltd/vexpress64/vexpress64.c
-+++ b/board/armltd/vexpress64/vexpress64.c
-@@ -88,12 +88,20 @@ int board_init(void)
-
- int dram_init(void)
- {
-- return fdtdec_setup_mem_size_base();
-+ gd->ram_size = PHYS_SDRAM_1_SIZE;
-+ return 0;
- }
-
- int dram_init_banksize(void)
- {
-- return fdtdec_setup_memory_banksize();
-+ gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
-+ gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
-+#ifdef PHYS_SDRAM_2
-+ gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
-+ gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
-+#endif
-+
-+ return 0;
- }
-
- /* Assigned in lowlevel_init.S
new file mode 100644
@@ -0,0 +1,49 @@
+From 3ab73b453016d91b9f942a7c12173854135530a4 Mon Sep 17 00:00:00 2001
+From: Peter Hoyes <Peter.Hoyes@arm.com>
+Date: Wed, 23 Aug 2023 21:17:17 +0100
+Subject: [PATCH] virtio: rng: Workaround for FVP returning zero-size buffer
+
+The FVP virtio-rng device is observed to always 8 fewer bytes of random
+data than requested. When 8 of fewer bytes are requested, the FVP
+returns 0 bytes. This causes U-Boot to hang upon attempting to fill the
+last 8 bytes of the input buffer.
+
+The virtio spec states than entropy devices must always return at least
+1 byte of random data.
+
+To workaround this, always request exactly 16 bytes from the virtio
+device, discarding any unused data.
+
+Upstream-Status: Inappropriate [Temporary workaround]
+Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
+---
+ drivers/virtio/virtio_rng.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/virtio/virtio_rng.c b/drivers/virtio/virtio_rng.c
+index b85545c2ee5..1e4fc342406 100644
+--- a/drivers/virtio/virtio_rng.c
++++ b/drivers/virtio/virtio_rng.c
+@@ -29,7 +29,7 @@ static int virtio_rng_read(struct udevice *dev, void *data, size_t len)
+
+ while (len) {
+ sg.addr = buf;
+- sg.length = min(len, sizeof(buf));
++ sg.length = sizeof(buf);
+ sgs[0] = &sg;
+
+ ret = virtqueue_add(priv->rng_vq, sgs, 0, 1);
+@@ -44,8 +44,8 @@ static int virtio_rng_read(struct udevice *dev, void *data, size_t len)
+ if (rsize > sg.length)
+ return -EIO;
+
+- memcpy(ptr, buf, rsize);
+- len -= rsize;
++ memcpy(ptr, buf, min(len, (size_t)rsize));
++ len -= min(len, (size_t)rsize);
+ ptr += rsize;
+ }
+
+--
+2.34.1
+
new file mode 100644
@@ -0,0 +1,31 @@
+From 9a28caf05b8345cd19276cf7a840599bd9e37749 Mon Sep 17 00:00:00 2001
+From: Debbie Martin <Debbie.Martin@arm.com>
+Date: Fri, 25 Aug 2023 15:09:33 +0100
+Subject: [PATCH] vexpress64: Set the DM_RNG property
+
+Enable the DM_RNG virtio random number generator driver in
+in order to consume entropy within u-boot. This is necessary
+in the case that the kernel is not configured to enable the
+virtio rng driver itself.
+
+Upstream-Status: Pending
+Signed-off-by: Debbie Martin <Debbie.Martin@arm.com>
+---
+ board/armltd/vexpress64/Kconfig | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/board/armltd/vexpress64/Kconfig b/board/armltd/vexpress64/Kconfig
+index cf998096e4..7ae5055f59 100644
+--- a/board/armltd/vexpress64/Kconfig
++++ b/board/armltd/vexpress64/Kconfig
+@@ -21,6 +21,7 @@ config VEXPRESS64_BASE_MODEL
+ imply EFI_SET_TIME if DM_RTC
+ select LINUX_KERNEL_IMAGE_HEADER
+ select POSITION_INDEPENDENT
++ imply DM_RNG
+
+ choice
+ prompt "VExpress64 board variant"
+--
+2.25.1
+
new file mode 100644
@@ -0,0 +1,52 @@
+From 43881e2e9dd165a65791927b1455f4b6c8727f4c Mon Sep 17 00:00:00 2001
+Message-Id: <43881e2e9dd165a65791927b1455f4b6c8727f4c.1696397516.git.diego.sueiro@arm.com>
+In-Reply-To: <98035c418c3df58817ab678037599303842ee931.1696397516.git.diego.sueiro@arm.com>
+References: <98035c418c3df58817ab678037599303842ee931.1696397516.git.diego.sueiro@arm.com>
+From: Diego Sueiro <diego.sueiro@arm.com>
+Date: Wed, 4 Oct 2023 06:31:50 +0100
+Subject: [PATCH 2/2] vexpress64: Select PSCI RESET by default
+
+Set SYSRESET and SYSRESET_PSCI config for vexpress64 by
+by default. This means that the reset_cpu function in
+vexpress64.c is no longer needed because it is called in
+sysreset-uclass.c instead.
+
+Upstream-Status: Pending
+Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
+---
+ board/armltd/vexpress64/Kconfig | 2 ++
+ board/armltd/vexpress64/vexpress64.c | 5 -----
+ 2 files changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/board/armltd/vexpress64/Kconfig b/board/armltd/vexpress64/Kconfig
+index 0d161740fb..0c2e5f8759 100644
+--- a/board/armltd/vexpress64/Kconfig
++++ b/board/armltd/vexpress64/Kconfig
+@@ -31,6 +31,8 @@ config TARGET_VEXPRESS64_BASE_FVP
+ bool "Support Versatile Express ARMv8a FVP BASE model"
+ select VEXPRESS64_BASE_MODEL
+ imply OF_HAS_PRIOR_STAGE
++ select SYSRESET
++ select SYSRESET_PSCI
+
+ config TARGET_VEXPRESS64_BASER_FVP
+ bool "Support Versatile Express ARMv8r64 FVP BASE model"
+diff --git a/board/armltd/vexpress64/vexpress64.c b/board/armltd/vexpress64/vexpress64.c
+index ee65a59683..f73de56464 100644
+--- a/board/armltd/vexpress64/vexpress64.c
++++ b/board/armltd/vexpress64/vexpress64.c
+@@ -207,11 +207,6 @@ void *board_fdt_blob_setup(int *err)
+ }
+ #endif
+
+-/* Actual reset is done via PSCI. */
+-void reset_cpu(void)
+-{
+-}
+-
+ /*
+ * Board specific ethernet initialization routine.
+ */
+--
+2.39.1
+
new file mode 100644
@@ -0,0 +1,31 @@
+From 98035c418c3df58817ab678037599303842ee931 Mon Sep 17 00:00:00 2001
+Message-Id: <98035c418c3df58817ab678037599303842ee931.1696397516.git.diego.sueiro@arm.com>
+From: Diego Sueiro <diego.sueiro@arm.com>
+Date: Wed, 4 Oct 2023 06:29:12 +0100
+Subject: [PATCH 1/2] vexpress64: Imply CONFIG_ARM64_CRC32 by default
+
+Enable the Arm64 CRC-32 instruction by default for
+vexpress64. The CRC-32 instruction is a required
+feature of ARMv8.1 and newer.
+
+Upstream-Status: Pending
+Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
+---
+ board/armltd/vexpress64/Kconfig | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/board/armltd/vexpress64/Kconfig b/board/armltd/vexpress64/Kconfig
+index 7ae5055f59..0d161740fb 100644
+--- a/board/armltd/vexpress64/Kconfig
++++ b/board/armltd/vexpress64/Kconfig
+@@ -22,6 +22,7 @@ config VEXPRESS64_BASE_MODEL
+ select LINUX_KERNEL_IMAGE_HEADER
+ select POSITION_INDEPENDENT
+ imply DM_RNG
++ imply ARM64_CRC32
+
+ choice
+ prompt "VExpress64 board variant"
+--
+2.39.1
+
@@ -1,4 +1,2 @@
CONFIG_BOOTARGS="console=ttyAMA0 earlycon=pl011,0x1c090000 root=/dev/vda1 rw rootwait"
CONFIG_BOOTCOMMAND="booti $kernel_addr_r - $fdt_addr_r"
-# Our FVP support CRC instructions
-CONFIG_ARM64_CRC32=y
Configure FVP base to use vexpress_fvp_defconfig as the U-boot machine. Configure U-boot: 1. Drop the patch to pick the DRAM size from the devicetree since the FVP now specifies a devicetree. 2. Enable sysreset to reset by PSCI and patch the vexpress U-boot machine to leave the reset to PSCI in this case. 3. Enable Virtio RNG and patch the U-boot Virtio RNG driver to workaround an issue with the FVP that results in RNG calls hanging. 4. Enable the Arm64 CRC-32 instruction by default and remove the now redundant config setting. Signed-off-by: Debbie Martin <Debbie.Martin@arm.com> --- meta-arm-bsp/conf/machine/fvp-base.conf | 2 +- .../recipes-bsp/u-boot/u-boot-fvp-base.inc | 5 +- ...rt-vexpress64-pick-DRAM-size-from-DT.patch | 44 ---------------- ...round-for-FVP-returning-zero-size-bu.patch | 49 +++++++++++++++++ ...2-vexpress64-Set-the-DM_RNG-property.patch | 31 +++++++++++ ...press64-Select-PSCI-RESET-by-default.patch | 52 +++++++++++++++++++ ...-Imply-CONFIG_ARM64_CRC32-by-default.patch | 31 +++++++++++ .../u-boot/u-boot/fvp-base/bootargs.cfg | 2 - 8 files changed, 168 insertions(+), 48 deletions(-) delete mode 100644 meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-base/0001-Revert-vexpress64-pick-DRAM-size-from-DT.patch create mode 100644 meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-base/0001-virtio-rng-Workaround-for-FVP-returning-zero-size-bu.patch create mode 100644 meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-base/0002-vexpress64-Set-the-DM_RNG-property.patch create mode 100644 meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-base/0003-vexpress64-Select-PSCI-RESET-by-default.patch create mode 100644 meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-base/0004-vexpress64-Imply-CONFIG_ARM64_CRC32-by-default.patch