Closed svanschu closed 2 years ago
Hello @svanschu,
- it seems that optee is not running proberly I configured the output to maximum debug and there are only a view entrys.
When using Qemu for arm/optee, the optee_os logs are emited to qeu secondary serial part, hence no OP-TEE trace in your logs. You need to specify both -serial
ports arguments to qemu-system-aarch64
and to get the 2 consoles. I suggest you look at buildroot doc for board arm-vexpress-tz. The board run armv7/optee on Qemu but consoles info apply to armv8/optee also.
- Some sort of emulated emmc is needed for use of rpmb. I read that there is a way to emulate the emmc with the tee_Supplicant, but I couldn't find how.
It is true OP-TEE supplicant can emulate an RPMB, but that is only the Linux OS tee-supplicant, from optee_client.git. U-Boot OP-TEE supplicant does not implement RPMB emulation.
When running OP-TEE on Qemu, there is no RPMB device emulated by Qemu so we need to enable an emulation in tee-supplicant to at least test optee_os RPMB drivers during non-regression tests (optee_test xtest
) running in Linux OS, together with optee_client's tee-supplicant
.
I think Qemu developers plan to implement an RPMB emulation but I have no pointer to give you.
- simple print -e in uboot throws many errors
As stated above, this is not supported in u-boot. However, there is an RPMB emulation patch for u-boot from @apalos that may help you. Try pick this change (you don't need the added _qemu_tfa_mmdefconfig file), and this fixup. I hope these patches can help you testing UEFI secure variables using Qemu. Note these url's are not permanent links.
@etienne-lms thank you for the clarification. We can except that rpmb is not possible with qemu. Short question without opening another issue.
REE would work for OPTEE and qemu?
@etienne-lms I turned CFG_RPMB_FS=n CFG_RPMB_FS_DEV_ID=0 CFG_RPMB_WRITE_KEY=n CFG_RPMB_TESTKEY=n
off and turned CFG_REE_FS=y
on.
make -j32 CFG_ARM64_core=y \
PLATFORM=vexpress-qemu_armv8a CFG_STMM_PATH=BL32_AP_MM.fd CFG_RPMB_FS=n \
CFG_RPMB_FS_DEV_ID=0 CFG_CORE_HEAP_SIZE=524288 CFG_RPMB_WRITE_KEY=n \
CFG_CORE_HEAP_SIZE=524288 CFG_CORE_DYN_SHM=y CFG_RPMB_TESTKEY=n \
CFG_REE_FS=y CFG_CORE_ARM64_PA_BITS=48 CFG_TEE_CORE_LOG_LEVEL=4 \
CFG_TEE_TA_LOG_LEVEL=4 CFG_SCTLR_ALIGNMENT_CHECK=n \
CFG_TEE_CORE_DEBUG=y CFG_CC_OPT_LEVEL=0 CFG_DEBUG_INFO=y
In the log output I still have RPMB messages (and a panic) included. Did I forgot something?
D/TC:? 0 spm_handle_svc:857 Received FFA direct request
D/TC:? 0 spm_handle_svc:857 Received FFA direct request
D/TC:? 0 stmm_handle_storage_service:792 RPMB read
D/TC:? 0 spm_handle_svc:857 Received FFA direct request
D/TC:? 0 stmm_handle_storage_service:798 RPMB write
D/TC:? 0 spm_handle_svc:857 Received FFA direct request
D/TC:? 0 stmm_handle_storage_service:792 RPMB read
D/TC:? 0 spm_handle_svc:857 Received FFA direct request
D/TC:? 0 stmm_handle_storage_service:798 RPMB write
D/TC:? 0 spm_handle_svc:857 Received FFA direct request
D/TC:? 0 stmm_handle_storage_service:792 RPMB read
D/TC:? 0 spm_handle_svc:857 Received FFA direct request
D/TC:? 0 stmm_handle_storage_service:798 RPMB write
D/TC:0 0 abort_handler:531 [abort] abort in User mode (TA will panic)
E/TC:? 0
E/TC:? 0 User mode data-abort at address 0x0 (translation fault)
E/TC:? 0 esr 0x92000005 ttbr0 0x200000e27c000 ttbr1 0x00000000 cidr 0x0
E/TC:? 0 cpu #0 cpsr 0x60000000
E/TC:? 0 x0 0000000000000000 x1 0000000040285000
E/TC:? 0 x2 000000004000b290 x3 0000000040285000
Ok I think I give up on that.
You can use OPTEE without RPMB and only REE, but we are using EDK2 and the stmm_handle_storage_service forces to use RPMB.
The only possibility would be to add RPMB support to QEMU to get this work in a meaningful way.
Hi,
So is it possible test the stmm on a real h/w board ? Anyone know which board is used in this blog https://www.linaro.org/blog/protected-uefi-variables-with-u-boot/ ?
Hi,
So is it possible test the stmm on a real h/w board ? Anyone know which board is used in this blog https://www.linaro.org/blog/protected-uefi-variables-with-u-boot/ ?
as @etienne-lms mentioned running this on QEMU is not possible, because there's no RPMB device emulation.
I had a horribly hacked u-boot version here [0] which we used during devel. However, this provides an RPMB emulation via U-Boot and not QEMU. As a result, the RPMB is only usable before the kernel calls ExitBootServices. IOW you can only play around with it while U-Boot is running.
As far as supported boards, any board with OP-TEE support + an eMMC with an RPMB partition would work.
If you are looking for an easy way to start I'd suggest https://wiki.radxa.com/Rockpi4 (with an eMMC). There's a precompiled firmware available here [1]
[0] https://git.linaro.org/people/ilias.apalodimas/efi_optee_variables.git/ (I haven't touched this in ages, I am not sure it even compiles anymore) [1] https://gitlab.com/Linaro/trustedsubstrate/meta-ts#images
Thank you Ilias for your kind reply.
I'm also wondering wether there are any exisiting solutions for this architecture ?
Hi all, I'm new to all the secure boot stuff and I try to self educate myself. I now working on this topic several weeks and months and I tried to sort it out by reading docs, learn and debugging on my own. But unfortunately I failed at one point and I don't get it why. I would need some help to sort all and get a new input for further education. In theory and docu reading it sound pretty easy, but the practicle part was not that easy.
Problems
BL32_AP_MM.fd
to use it in the optee_os build. Beside configure u-boot for OPTEE and build it.(0x0E100000) OPTEE load address
(0x00D00000) Amount of Trust-Zone RAM for the OPTEE image
(0x0E300000) Base address of Trust-Zone RAM for the OPTEE image | | CONFIG_EFI_MM_COMM_TEE | UEFI variables storage service via OP-TEE| | CONFIG_SUPPORT_EMMC_RPMB | Support eMMC replay protected memory block (RPMB) | | CONFIG_CMD_OPTEE_RPMB | Enable read/write support on RPMB via OPTEE |
All three as described in https://optee.readthedocs.io/en/latest/building/efi_vars/stmm.html?highlight=j32#op-tee-build-instructions
After that I build the TF-A with
make CROSS_COMPILE=aarch64-linux-gnu- PLAT=qemu BL32=tee-header_v2.bin BL32_EXTRA1=tee-pager_v2.bin BL32_EXTRA2=tee-pageable_v2.bin BL33=bl33.bin BL32_RAM_LOCATION=tdram SPD=opteed all fip
optee as BL32 and u-boot.bin as BL33How to start qemu I took from this documentation https://trustedfirmware-a.readthedocs.io/en/latest/plat/qemu.html
Any help is welcome, so I can understand how all is fitting together. Thank You!