[U-Boot] [PATCH 0/4] ARM: Extend qemu_arm to support ARM64

Hi,
This series extends qemu_arm to have support for ARM64 as well. Adding test.py support for it gets us the first test.py job for an ARM64 board on Travis-CI.
Before the last patch can be merged,
https://github.com/swarren/uboot-test-hooks/pull/15
needs to be applied in the uboot-test-hooks repo.
Tuomas Tynkkynen (4): ARM: qemu-arm: Add support for AArch64 ARM: Document AArch64 version of qemu-arm Travis-CI: Download ARM64 version of GRUB as well Travis-CI: Add job for running test.py on qemu_arm64
.travis.yml | 8 +++++ arch/arm/Kconfig | 2 -- arch/arm/mach-qemu/Kconfig | 11 +++++++ board/emulation/qemu-arm/MAINTAINERS | 1 + board/emulation/qemu-arm/qemu-arm.c | 35 ++++++++++++++++++++++ .../{qemu_arm_defconfig => qemu_arm64_defconfig} | 1 + configs/qemu_arm_defconfig | 1 + doc/README.qemu-arm | 23 ++++++++++---- 8 files changed, 75 insertions(+), 7 deletions(-) copy configs/{qemu_arm_defconfig => qemu_arm64_defconfig} (94%)

This adds support for '-machine virt' on AArch64. This is rather simple: we just add TARGET_QEMU_ARM_xxBIT to select a few different Kconfig symbols, provide the ARMv8 memory map from the board file and add a new defconfig based on the 32-bit defconfig.
Signed-off-by: Tuomas Tynkkynen tuomas.tynkkynen@iki.fi --- arch/arm/Kconfig | 2 -- arch/arm/mach-qemu/Kconfig | 11 +++++++ board/emulation/qemu-arm/MAINTAINERS | 1 + board/emulation/qemu-arm/qemu-arm.c | 35 ++++++++++++++++++++++ .../{qemu_arm_defconfig => qemu_arm64_defconfig} | 1 + configs/qemu_arm_defconfig | 1 + 6 files changed, 49 insertions(+), 2 deletions(-) copy configs/{qemu_arm_defconfig => qemu_arm64_defconfig} (94%)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index f2c35e32c6..ee27f07285 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -642,8 +642,6 @@ config ARCH_MX5
config ARCH_QEMU bool "QEMU Virtual Platform" - select CPU_V7 - select ARCH_SUPPORT_PSCI select DM select DM_SERIAL select OF_CONTROL diff --git a/arch/arm/mach-qemu/Kconfig b/arch/arm/mach-qemu/Kconfig index 3500b56cb0..133163aecf 100644 --- a/arch/arm/mach-qemu/Kconfig +++ b/arch/arm/mach-qemu/Kconfig @@ -10,3 +10,14 @@ config SYS_CONFIG_NAME default "qemu-arm"
endif + +config TARGET_QEMU_ARM_32BIT + bool "Support qemu_arm" + depends on ARCH_QEMU + select CPU_V7 + select ARCH_SUPPORT_PSCI + +config TARGET_QEMU_ARM_64BIT + bool "Support qemu_arm64" + depends on ARCH_QEMU + select ARM64 diff --git a/board/emulation/qemu-arm/MAINTAINERS b/board/emulation/qemu-arm/MAINTAINERS index a803061ff4..e757ffc64f 100644 --- a/board/emulation/qemu-arm/MAINTAINERS +++ b/board/emulation/qemu-arm/MAINTAINERS @@ -4,3 +4,4 @@ S: Maintained F: board/emulation/qemu-arm/ F: include/configs/qemu-arm.h F: configs/qemu_arm_defconfig +F: configs/qemu_arm64_defconfig diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c index e29ba4630f..1bc7edcfb7 100644 --- a/board/emulation/qemu-arm/qemu-arm.c +++ b/board/emulation/qemu-arm/qemu-arm.c @@ -6,6 +6,41 @@ #include <common.h> #include <fdtdec.h>
+#ifdef CONFIG_ARM64 +#include <asm/armv8/mmu.h> + +static struct mm_region qemu_arm64_mem_map[] = { + { + /* Flash */ + .virt = 0x00000000UL, + .phys = 0x00000000UL, + .size = 0x08000000UL, + .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | + PTE_BLOCK_INNER_SHARE + }, { + /* Peripherals */ + .virt = 0x08000000UL, + .phys = 0x08000000UL, + .size = 0x38000000, + .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | + PTE_BLOCK_NON_SHARE | + PTE_BLOCK_PXN | PTE_BLOCK_UXN + }, { + /* RAM */ + .virt = 0x40000000UL, + .phys = 0x40000000UL, + .size = 0xc0000000UL, + .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | + PTE_BLOCK_INNER_SHARE + }, { + /* List terminator */ + 0, + } +}; + +struct mm_region *mem_map = qemu_arm64_mem_map; +#endif + int board_init(void) { return 0; diff --git a/configs/qemu_arm_defconfig b/configs/qemu_arm64_defconfig similarity index 94% copy from configs/qemu_arm_defconfig copy to configs/qemu_arm64_defconfig index 3cd4d45433..4309bd25eb 100644 --- a/configs/qemu_arm_defconfig +++ b/configs/qemu_arm64_defconfig @@ -1,6 +1,7 @@ CONFIG_ARM=y CONFIG_ARM_SMCCC=y CONFIG_ARCH_QEMU=y +CONFIG_TARGET_QEMU_ARM_64BIT=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y # CONFIG_DISPLAY_CPUINFO is not set diff --git a/configs/qemu_arm_defconfig b/configs/qemu_arm_defconfig index 3cd4d45433..db61b12869 100644 --- a/configs/qemu_arm_defconfig +++ b/configs/qemu_arm_defconfig @@ -1,6 +1,7 @@ CONFIG_ARM=y CONFIG_ARM_SMCCC=y CONFIG_ARCH_QEMU=y +CONFIG_TARGET_QEMU_ARM_32BIT=y CONFIG_AHCI=y CONFIG_DISTRO_DEFAULTS=y # CONFIG_DISPLAY_CPUINFO is not set

On Tue, Jan 09, 2018 at 04:34:27PM +0200, Tuomas Tynkkynen wrote:
This adds support for '-machine virt' on AArch64. This is rather simple: we just add TARGET_QEMU_ARM_xxBIT to select a few different Kconfig symbols, provide the ARMv8 memory map from the board file and add a new defconfig based on the 32-bit defconfig.
Signed-off-by: Tuomas Tynkkynen tuomas.tynkkynen@iki.fi
Reviewed-by: Tom Rini trini@konsulko.com

It's mostly obvious, except that QEMU is annoying and requires an explicit '-cpu cortex-a57' (or some other 64-bit core) to actually run in 64-bit mode.
Signed-off-by: Tuomas Tynkkynen tuomas.tynkkynen@iki.fi --- doc/README.qemu-arm | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/doc/README.qemu-arm b/doc/README.qemu-arm index 2895e3b97f..5fe8e87a5c 100644 --- a/doc/README.qemu-arm +++ b/doc/README.qemu-arm @@ -4,11 +4,12 @@ # SPDX-License-Identifier: GPL-2.0+ #
-U-Boot on QEMU's 'virt' machine on ARM -====================================== +U-Boot on QEMU's 'virt' machine on ARM & AArch64 +================================================
QEMU for ARM supports a special 'virt' machine designed for emulation and virtualization purposes. This document describes how to run U-Boot under it. +Both 32-bit ARM and AArch64 are supported.
The 'virt' platform provides the following as the basic functionality:
@@ -17,7 +18,7 @@ The 'virt' platform provides the following as the basic functionality: - A generated device tree blob placed at the start of RAM - A freely configurable amount of RAM, described by the DTB - A PL011 serial port, discoverable via the DTB - - An ARMv7 architected timer + - An ARMv7/ARMv8 architected timer - PSCI for rebooting the system - A generic ECAM-based PCI host controller, discoverable via the DTB
@@ -25,19 +26,31 @@ Additionally, a number of optional peripherals can be added to the PCI bus.
Building U-Boot --------------- -Set the CROSS_COMPILE and ARCH=arm environment variables as usual, and run: +Set the CROSS_COMPILE environment variable as usual, and run:
+- For ARM: + export ARCH=arm make qemu_arm_defconfig make
+- For AArch64: + export ARCH=arm64 + make qemu_arm64_defconfig + make + Running U-Boot -------------- The minimal QEMU command line to get U-Boot up and running is:
+- For ARM: qemu-system-arm -machine virt,highmem=off -bios u-boot.bin
+- For AArch64: + qemu-system-aarch64 -machine virt,highmem=off -cpu cortex-a57 -bios u-boot.bin + The 'highmem=off' parameter to the 'virt' machine is required for PCI to work -in U-Boot. +in U-Boot. Also, for some odd reason qemu-system-aarch64 needs to be explicitly +told to use a 64-bit CPU or it will boot in 32-bit mode.
Additional peripherals that have been tested to work in both U-Boot and Linux can be enabled with the following command line parameters:

On Tue, Jan 09, 2018 at 04:34:28PM +0200, Tuomas Tynkkynen wrote:
It's mostly obvious, except that QEMU is annoying and requires an explicit '-cpu cortex-a57' (or some other 64-bit core) to actually run in 64-bit mode.
Signed-off-by: Tuomas Tynkkynen tuomas.tynkkynen@iki.fi
doc/README.qemu-arm | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/doc/README.qemu-arm b/doc/README.qemu-arm index 2895e3b97f..5fe8e87a5c 100644 --- a/doc/README.qemu-arm +++ b/doc/README.qemu-arm @@ -4,11 +4,12 @@ # SPDX-License-Identifier: GPL-2.0+ #
-U-Boot on QEMU's 'virt' machine on ARM
+U-Boot on QEMU's 'virt' machine on ARM & AArch64 +================================================
QEMU for ARM supports a special 'virt' machine designed for emulation and virtualization purposes. This document describes how to run U-Boot under it. +Both 32-bit ARM and AArch64 are supported.
The 'virt' platform provides the following as the basic functionality:
@@ -17,7 +18,7 @@ The 'virt' platform provides the following as the basic functionality: - A generated device tree blob placed at the start of RAM - A freely configurable amount of RAM, described by the DTB - A PL011 serial port, discoverable via the DTB
- An ARMv7 architected timer
- An ARMv7/ARMv8 architected timer
- PSCI for rebooting the system
- A generic ECAM-based PCI host controller, discoverable via the DTB
@@ -25,19 +26,31 @@ Additionally, a number of optional peripherals can be added to the PCI bus.
Building U-Boot
-Set the CROSS_COMPILE and ARCH=arm environment variables as usual, and run: +Set the CROSS_COMPILE environment variable as usual, and run:
+- For ARM:
- export ARCH=arm make qemu_arm_defconfig make
+- For AArch64:
- export ARCH=arm64
- make qemu_arm64_defconfig
- make
This isn't Linux, we don't need ARCH set in the env, it's part of the Kconfig choices. Thanks!

On 01/09/2018 06:22 PM, Tom Rini wrote:
On Tue, Jan 09, 2018 at 04:34:28PM +0200, Tuomas Tynkkynen wrote:
Building U-Boot
-Set the CROSS_COMPILE and ARCH=arm environment variables as usual, and run: +Set the CROSS_COMPILE environment variable as usual, and run:
+- For ARM:
- export ARCH=arm make qemu_arm_defconfig make
+- For AArch64:
- export ARCH=arm64
- make qemu_arm64_defconfig
- make
This isn't Linux, we don't need ARCH set in the env, it's part of the Kconfig choices. Thanks!
Okay, good to know. Will send a new revision with this fixed in a couple of days.
Thanks, Tuomas

For preparation of adding AArch64 test.py jobs.
Signed-off-by: Tuomas Tynkkynen tuomas.tynkkynen@iki.fi --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/.travis.yml b/.travis.yml index 00ff53cbfe..31e06bbd74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,6 +46,8 @@ install: - grub-mkimage -o ~/grub_x86.efi -O i386-efi normal echo lsefimmap lsefi lsefisystab efinet tftp minicmd - mkdir ~/grub2-arm - ( cd ~/grub2-arm; wget -O - http://download.opensuse.org/ports/armv7hl/distribution/leap/42.2/repo/oss/s... | rpm2cpio | cpio -di ) + - mkdir ~/grub2-arm64 + - ( cd ~/grub2-arm64; wget -O - http://download.opensuse.org/ports/aarch64/distribution/leap/42.2/repo/oss/s... | rpm2cpio | cpio -di )
env: global: @@ -109,6 +111,7 @@ script: - export UBOOT_TRAVIS_BUILD_DIR=`cd .. && pwd`/.bm-work/${TEST_PY_BD}; cp ~/grub_x86.efi $UBOOT_TRAVIS_BUILD_DIR/; cp ~/grub2-arm/usr/lib/grub2/arm-efi/grub.efi $UBOOT_TRAVIS_BUILD_DIR/grub_arm.efi; + cp ~/grub2-arm64/usr/lib/grub2/arm64-efi/grub.efi $UBOOT_TRAVIS_BUILD_DIR/grub_arm64.efi; if [[ "${TEST_PY_BD}" != "" ]]; then ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID} -k "${TEST_PY_TEST_SPEC:-not a_test_which_does_not_exist}"

On Tue, Jan 09, 2018 at 04:34:29PM +0200, Tuomas Tynkkynen wrote:
For preparation of adding AArch64 test.py jobs.
Signed-off-by: Tuomas Tynkkynen tuomas.tynkkynen@iki.fi
Reviewed-by: Tom Rini trini@konsulko.com

The corresponding changes in the uboot-test-hooks repo are:
https://github.com/swarren/uboot-test-hooks/pull/15
Signed-off-by: Tuomas Tynkkynen tuomas.tynkkynen@iki.fi --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/.travis.yml b/.travis.yml index 31e06bbd74..6b37ee5513 100644 --- a/.travis.yml +++ b/.travis.yml @@ -311,6 +311,11 @@ matrix: TEST_PY_TEST_SPEC="not sleep" QEMU_TARGET="arm-softmmu" BUILDMAN="^qemu_arm$" + - env: + - TEST_PY_BD="qemu_arm64" + TEST_PY_TEST_SPEC="not sleep" + QEMU_TARGET="aarch64-softmmu" + BUILDMAN="^qemu_arm64$" - env: - TEST_PY_BD="qemu_mips" TEST_PY_TEST_SPEC="not sleep"

On Tue, Jan 09, 2018 at 04:34:30PM +0200, Tuomas Tynkkynen wrote:
The corresponding changes in the uboot-test-hooks repo are:
https://github.com/swarren/uboot-test-hooks/pull/15
Signed-off-by: Tuomas Tynkkynen tuomas.tynkkynen@iki.fi
Reviewed-by: Tom Rini trini@konsulko.com
participants (2)
-
Tom Rini
-
Tuomas Tynkkynen