Hafnium S-EL2 arch timer reproducer
Hi Alex,
For starters freshest hafnium's doc is found at https://hafnium.readthedocs.io/en/latest/
A good reproducer is Linaro's OP-TEE build system:
1/ Get clang toolchain,
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.8/clang+llvm-18.1.8-x86_64-linux-gnu-ubuntu-18.04.tar.xz
(uncompress and untar)
PATH=<...>/clang+llvm-18.1.8-x86_64-linux-gnu-ubuntu-18.04/bin:$PATH
2/ Then,
mkdir workspace; cd workspace
repo init -u https://github.com/OP-TEE/manifest.git -m qemu_v8.xml repo sync -j4 --no-clone-bundle
cd build
make toolchains
make -j8 SPMC_AT_EL=2 run
You'll get TF-A/hafnium (v2.11) , OP-TEE then linux booting.
3/ Once you get this ready, checkout TF-A/Hafnium v2.12-rc0 tag.
4/ You will need this in build directory:
qemu_v8.mk +1 -1
@@ -145,7 +145,7 @@ include toolchain.mk # ARM Trusted Firmware ################################################################################ TF_A_EXPORTS ?= \ - CROSS_COMPILE="$(CCACHE)$(AARCH64_CROSS_COMPILE)" + CC="$(CCACHE)$(AARCH64_CROSS_COMPILE)gcc" TF_A_DEBUG ?= $(DEBUG) ifeq ($(TF_A_DEBUG),0)
5/ I suggest to clear trusted-firmware-a/build and hafnium/out from earlier build. Then rebuild from build dir:
make -j8 SPMC_AT_EL=2 run
With this, you'll get hafnium panicking early at boot (on accessing CNTHPS_CTL_EL2). Hopefully with your changes it should go farther.
However I cannot tell what happens after this as we did not pass this point.
On OP-TEE build setup issues, Jens Wiklander ([email protected]) should be able to help.
Regards,
Olivier.
________________________________
From: Armelle Laine <[email protected]>
Sent: 20 November 2024 19:36
To: Alex Bennée <[email protected]>; Andrei Homescu (xWF) <[email protected]>; Arve Hjønnevåg <[email protected]>
Cc: Olivier Deprez <[email protected]>
Subject: Re: Hafnium S-EL2 arch timer reproducer
+Andrei Homescu (xWF)<mailto:[email protected]> +Arve Hjønnevåg<mailto:[email protected]>
On Wed, Nov 20, 2024 at 2:54 AM Alex Bennée <[email protected]<mailto:[email protected]>> wrote:
Hi Olivier,
Armelle mentioned you had come across a SEL2 failure when booting Hafnium on QEMU. Looking at the code it seems some bits were missed when FEAT_SEL2 was implemented but we think it should be pretty easy to fix them. What would be really useful is a reproducer I could use to test and make sure everything works.
I did try following:
https://hafnium.googlesource.com/hafnium/+/HEAD/docs/GettingStarted.md?pli=1#Running-on-QEMU
But it fell over with a linker error:
🕙17:14:21 alex@draig:hafnium on master
➜ make PROECT=qemu_aarch64
ninja: Entering directory `out/reference'
[1/42] ACTION //third_party/linux:linux__defconfig(//project/reference:rpi4_vm_clang)
FAILED: rpi4_vm_clang/obj/third_party/linux/.config
python3 ../../build/make.py --directory /home/alex/src/virt/hafnium/third_party/linux/ CC=/home/alex/src/virt/hafnium/prebuilts/linux-x64/clang/bin/clang LD=/home/alex/src/virt/hafnium/prebuilts/linux-x64/gcc/bin/aarch64-linux-android-ld AR=/home/alex/src/virt/hafnium/prebuilts/linux-x64/gcc/bin/aarch64-linux-android-ar NM=/home/alex/src/virt/hafnium/prebuilts/linux-x64/clang/bin/llvm-nm OBJCOPY=/home/alex/src/virt/hafnium/prebuilts/linux-x64/gcc/bin/aarch64-linux-android-objcopy OBJDUMP=/home/alex/src/virt/hafnium/prebuilts/linux-x64/clang/bin/llvm-objdump STRIP=/home/alex/src/virt/hafnium/prebuilts/linux-x64/clang/bin/llvm-strip GCC_TOOLCHAIN_DIR=/home/alex/src/virt/hafnium/prebuilts/linux-x64/gcc/bin ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- O=/home/alex/src/virt/hafnium/out/reference/rpi4_vm_clang/obj/third_party/linux -j24 defconfig modules_prepare make[1]: Entering directory '/home/alex/src/virt/hafnium/third_party/linux'
make[2]: Entering directory '/home/alex/src/virt/hafnium/out/reference/rpi4_vm_clang/obj/third_party/linux'
GEN Makefile
*** Default configuration is based on 'defconfig'
#
# No change to .config
#
GEN Makefile
HOSTLD scripts/dtc/dtc
/usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x20): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make[4]: *** [scripts/Makefile.host:116: scripts/dtc/dtc] Error 1
make[3]: *** [/home/alex/src/virt/hafnium/third_party/linux/Makefile:1263: scripts_dtc] Error 2
make[2]: *** [/home/alex/src/virt/hafnium/third_party/linux/Makefile:326: __build_one_by_one] Error 2
make[2]: Leaving directory '/home/alex/src/virt/hafnium/out/reference/rpi4_vm_clang/obj/third_party/linux'
make[1]: *** [Makefile:179: sub-make] Error 2
make[1]: Leaving directory '/home/alex/src/virt/hafnium/third_party/linux'
[2/42] ACTION //third_party/linux:linux__defconfig(//project/reference:aem_v8a_fvp_vm_clang)
FAILED: aem_v8a_fvp_vm_clang/obj/third_party/linux/.config
python3 ../../build/make.py --directory /home/alex/src/virt/hafnium/third_party/linux/ CC=/home/alex/src/virt/hafnium/prebuilts/linux-x64/clang/bin/clang LD=/home/alex/src/virt/hafnium/prebuilts/linux-x64/gcc/bin/aarch64-linux-android-ld AR=/home/alex/src/virt/hafnium/prebuilts/linux-x64/gcc/bin/aarch64-linux-android-ar NM=/home/alex/src/virt/hafnium/prebuilts/linux-x64/clang/bin/llvm-nm OBJCOPY=/home/alex/src/virt/hafnium/prebuilts/linux-x64/gcc/bin/aarch64-linux-android-objcopy OBJDUMP=/home/alex/src/virt/hafnium/prebuilts/linux-x64/clang/bin/llvm-objdump STRIP=/home/alex/src/virt/hafnium/prebuilts/linux-x64/clang/bin/llvm-strip GCC_TOOLCHAIN_DIR=/home/alex/src/virt/hafnium/prebuilts/linux-x64/gcc/bin ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- O=/home/alex/src/virt/hafnium/out/reference/aem_v8a_fvp_vm_clang/obj/third_party/linux -j24 defconfig modules_prepare make[1]: Entering directory '/home/alex/src/virt/hafnium/third_party/linux'
make[2]: Entering directory '/home/alex/src/virt/hafnium/out/reference/aem_v8a_fvp_vm_clang/obj/third_party/linux'
GEN Makefile
*** Default configuration is based on 'defconfig'
#
# No change to .config
#
GEN Makefile
HOSTLD scripts/dtc/dtc
/usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x20): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make[4]: *** [scripts/Makefile.host:116: scripts/dtc/dtc] Error 1
make[3]: *** [/home/alex/src/virt/hafnium/third_party/linux/Makefile:1263: scripts_dtc] Error 2
make[2]: *** [/home/alex/src/virt/hafnium/third_party/linux/Makefile:326: __build_one_by_one] Error 2
make[2]: Leaving directory '/home/alex/src/virt/hafnium/out/reference/aem_v8a_fvp_vm_clang/obj/third_party/linux'
make[1]: *** [Makefile:179: sub-make] Error 2
make[1]: Leaving directory '/home/alex/src/virt/hafnium/third_party/linux'
[3/42] ACTION //third_party/linux:linux__defconfig(//project/reference:qemu_aarch64_vm_clang)
FAILED: qemu_aarch64_vm_clang/obj/third_party/linux/.config
python3 ../../build/make.py --directory /home/alex/src/virt/hafnium/third_party/linux/ CC=/home/alex/src/virt/hafnium/prebuilts/linux-x64/clang/bin/clang LD=/home/alex/src/virt/hafnium/prebuilts/linux-x64/gcc/bin/aarch64-linux-android-ld AR=/home/alex/src/virt/hafnium/prebuilts/linux-x64/gcc/bin/aarch64-linux-android-ar NM=/home/alex/src/virt/hafnium/prebuilts/linux-x64/clang/bin/llvm-nm OBJCOPY=/home/alex/src/virt/hafnium/prebuilts/linux-x64/gcc/bin/aarch64-linux-android-objcopy OBJDUMP=/home/alex/src/virt/hafnium/prebuilts/linux-x64/clang/bin/llvm-objdump STRIP=/home/alex/src/virt/hafnium/prebuilts/linux-x64/clang/bin/llvm-strip GCC_TOOLCHAIN_DIR=/home/alex/src/virt/hafnium/prebuilts/linux-x64/gcc/bin ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- O=/home/alex/src/virt/hafnium/out/reference/qemu_aarch64_vm_clang/obj/third_party/linux -j24 defconfig modules_prepare make[1]: Entering directory '/home/alex/src/virt/hafnium/third_party/linux'
make[2]: Entering directory '/home/alex/src/virt/hafnium/out/reference/qemu_aarch64_vm_clang/obj/third_party/linux'
GEN Makefile
*** Default configuration is based on 'defconfig'
#
# No change to .config
#
GEN Makefile
HOSTLD scripts/dtc/dtc
/usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x20): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make[4]: *** [scripts/Makefile.host:116: scripts/dtc/dtc] Error 1
make[3]: *** [/home/alex/src/virt/hafnium/third_party/linux/Makefile:1263: scripts_dtc] Error 2
make[2]: *** [/home/alex/src/virt/hafnium/third_party/linux/Makefile:326: __build_one_by_one] Error 2
make[2]: Leaving directory '/home/alex/src/virt/hafnium/out/reference/qemu_aarch64_vm_clang/obj/third_party/linux'
make[1]: *** [Makefile:179: sub-make] Error 2
make[1]: Leaving directory '/home/alex/src/virt/hafnium/third_party/linux'
ninja: build stopped: subcommand failed.
make: *** [Makefile:61: all] Error 1
Although Armelle mentioned they are seeing the failure in their Hafnium Trusty setup and you might be have a simpler reproduction with just Hafnium and a simple Secure Partition. If you can provide the blobs with the QEMU command line and what success should look like I'll see what I can do.
I know Arm can't work on QEMU but if you are able to test patches let me know and I'll CC you on them. Otherwise depending on the complexity I'll tag them for qemu-stable as well as the next release.
Thanks,
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.