第一章 optee介绍(一)代码下载与编译
第二章 optee介绍(二)qemu run-only运行
本文主要记录optee qemu_v8代码的下载与编译,以及编译过程遇到的问题的解决方式
repo init -u https://github.com/OP-TEE/manifest.git -m qemu_v8.xml -b 3.19.0
repo sync
此种方式因为个人网络原因,自动下载失败,个人使用手动下载方式下载
进入:https://github.com/OP-TEE
注意:离线手动下载qemu需要从https://www.qemu.org/download/#source中下载,否则编译会报错。
cd build
make -f toolchain.mk toolchains
依赖于网络情况,若是自动下载失败,可以选择手动下载
编译使用的工具链也手动下载,工具链下载地址:
https://developer.arm.com/downloads/-/gnu-a#panel2a
使用uname -m命令确认编译环境,我使用的编译环境为x86_64
使用make -f toolchain.mk toolchains命令编译工具链
做了上述第5步的修改后,编译过程实际就是解压过程。
若是网络好,不做上面第5步对toolchains.mk文件的修改,可以直接执行此步骤命令完成工具链的下载和解压。
解压完成后目录:
参考:https://optee.readthedocs.io/en/latest/building/prerequisites.html
ubuntu22.04:
$ sudo apt install \
adb \
acpica-tools \
autoconf \
automake \
bc \
bison \
build-essential \
ccache \
cscope \
curl \
device-tree-compiler \
e2tools \
expect \
fastboot \
flex \
ftp-upload \
gdisk \
libattr1-dev \
libcap-dev \
libfdt-dev \
libftdi-dev \
libglib2.0-dev \
libgmp3-dev \
libhidapi-dev \
libmpc-dev \
libncurses5-dev \
libpixman-1-dev \
libslirp-dev \
libssl-dev \
libtool \
libusb-1.0-0-dev \
make \
mtools \
netcat \
ninja-build \
python3-cryptography \
python3-pip \
python3-pyelftools \
python3-serial \
python-is-python3 \
rsync \
unzip \
uuid-dev \
xdg-utils \
xterm \
xz-utils \
zlib1g-dev
ubuntu20.04:
$ sudo apt install \
android-tools-adb \
android-tools-fastboot \
autoconf \
automake \
bc \
bison \
build-essential \
ccache \
cscope \
curl \
device-tree-compiler \
expect \
flex \
ftp-upload \
gdisk \
iasl \
libattr1-dev \
libcap-dev \
libfdt-dev \
libftdi-dev \
libglib2.0-dev \
libgmp3-dev \
libhidapi-dev \
libmpc-dev \
libncurses5-dev \
libpixman-1-dev \
libssl-dev \
libtool \
make \
mtools \
netcat \
ninja-build \
python3-crypto \
python3-cryptography \
python3-pip \
python3-pyelftools \
python3-serial \
rsync \
unzip \
uuid-dev \
xdg-utils \
xterm \
xz-utils \
zlib1g-dev
本人使用的是ubuntu 20.04环境,除了上面的安装包配置完成外,还可能遇到如下问题
/usr/bin$ find -iname "*python*"
./python3.8
./x86_64-linux-gnu-python3-config
./x86_64-linux-gnu-python3.8-config
./python3.8-config
./python3-config
./python3
解决办法:建立软连接
sudo ln -sf /usr/bin/python3.8 /usr/bin/python
修改build/qemu_v8.mk,使用uboot替换edk2。并且调整CPU型号、SMP核数、内存
--- a/qemu_v8.mk
+++ b/qemu_v8.mk
@@ -35,7 +35,7 @@ include common.mk
DEBUG ?= 1
# Option to use U-Boot in the boot flow instead of EDK2
-UBOOT ?= n
+UBOOT ?= y
# Option to build with GICV3 enabled
GICV3 ?= y
@@ -406,9 +406,9 @@ QEMU_VIRT = true
QEMU_XEN ?= -drive if=none,file=$(XEN_EXT4),format=raw,id=hd1 \
-device virtio-blk-device,drive=hd1
else
-QEMU_CPU ?= max,sve=off
-QEMU_SMP ?= 2
-QEMU_MEM ?= 1057
+QEMU_CPU ?= cortex-a53
+QEMU_SMP ?= 1
+QEMU_MEM ?= 2048
QEMU_VIRT = false
endif
进入build目录执行如下命令进行编译:
make -f qemu_v8.mk
>>> host-autoconf 2.71 Downloading
wget --passive-ftp -nd -t 3 -O './optee/3.19/out-br/build/.autoconf-2.71.tar.xz.n3ysmY/output' 'http://ftpmirror.gnu.org/autoconf/autoconf-2.71.tar.xz'
./optee/3.19/buildroot/support/download/wget: line 43: wget: command not found
wget --passive-ftp -nd -t 3 -O './optee/3.19/out-br/build/.autoconf-2.71.tar.xz.pVxWhE/output' 'http://sources.buildroot.net/autoconf/autoconf-2.71.tar.xz'
./optee/3.19/buildroot/support/download/wget: line 43: wget: command not found
wget --passive-ftp -nd -t 3 -O './optee/3.19/out-br/build/.autoconf-2.71.tar.xz.mNHUWc/output' 'http://sources.buildroot.net/autoconf-2.71.tar.xz'
./optee/3.19/buildroot/support/download/wget: line 43: wget: command not found
make[2]: *** [package/pkg-generic.mk:190: ./optee/3.19/out-br/build/host-autoconf-2.71/.stamp_downloaded] Error 1
make[1]: *** [Makefile:23: _all] Error 2
make[1]: Leaving directory './optee/3.19/out-br'
make: *** [common.mk:346: buildroot] Error 2
注意:正常若是网络ok的话,编译过程会自动进行下载,若是自动下载失败,可采用手动下载方式处理。
>>> util-linux-libs 2.37.2 Downloading
ERROR: No hash found for util-linux-2.37.2.tar.xz
make[2]: *** [package/pkg-generic.mk:190: ./optee/3.19/out-br/build/util-linux-libs-2.37.2/.stamp_downloaded] Error 1
make[1]: *** [Makefile:23: _all] Error 2
make[1]: Leaving directory './optee/3.19/out-br'
修改support/download/check-hash进行临时规避,注释掉 exit 3
if [ ${nb_checks} -eq 0 ]; then
case " ${BR_NO_CHECK_HASH_FOR} " in
*" ${base} "*)
# File explicitly has no hash
exit 0
;;
esac
printf "ERROR: No hash found for %s\n" "${base}" >&2
# exit 3
fi
In file included from arch/arm64/kernel/signal.c:34:
arch/arm64/kernel/signal.c: In function 'setup_return':
./arch/arm64/include/asm/vdso.h:26:11: error: 'vdso_offset_sigtramp' undeclared (first use in this function)
26 | (void *)(vdso_offset_##name - VDSO_LBASE + (unsigned long)(base)); \
| ^~~~~~~~~~~~
arch/arm64/kernel/signal.c:933:14: note: in expansion of macro 'VDSO_SYMBOL'
933 | sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp);
| ^~~~~~~~~~~
./arch/arm64/include/asm/vdso.h:26:11: note: each undeclared identifier is reported only once for each function it appears in
26 | (void *)(vdso_offset_##name - VDSO_LBASE + (unsigned long)(base)); \
| ^~~~~~~~~~~~
arch/arm64/kernel/signal.c:933:14: note: in expansion of macro 'VDSO_SYMBOL'
933 | sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp);
| ^~~~~~~~~~~
make[3]: *** [scripts/Makefile.build:249: arch/arm64/kernel/signal.o] Error 1
make[2]: *** [scripts/Makefile.build:466: arch/arm64/kernel] Error 2
make[1]: *** [Makefile:1843: arch/arm64] Error 2
make[1]: Leaving directory '/home8/optee/3.19/linux'
make: *** [common.mk:404: linux-common] Error 2
检查linux/include/generated目录,发现vdso-offset.h文件中内容为空:
解决方案:
修改linux/arch/arm64/Makefile
prepare: vdso_prepare
vdso_prepare: prepare0
$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso \
include/generated/vdso-offsets.h arch/arm64/kernel/vdso/vdso.so
ifdef CONFIG_COMPAT_VDSO
$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 \
include/generated/vdso32-offsets.h arch/arm64/kernel/vdso32/vdso.so
endif
endif
将上述代码移到下述代码前面:
PHONY += vdso_install
vdso_install:
$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
$(if $(CONFIG_COMPAT_VDSO), \
$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 $@)
4. qemu编译失败
原因:使用的qemu是手动从https://github.com/qemu下载的,看报错说明是因为这个地方只能通过GIT下载
解决办法:从https://www.qemu.org/download/#source中重新下载qemu仓库
错误提示
ERROR: missing GIT submodules
This is not a GIT checkout but module content appears to
be missing. Do not use 'git archive' or GitHub download links
to acquire QEMU source archives. Non-GIT builds are only
supported with source archives linked from:
https://www.qemu.org/download/#source
Developers working with GIT can use scripts/archive-source.sh
if they need to create valid source archives.
make: *** [qemu_v8.mk:232: ./optee/3.19/build/../qemu/build/config-host.mak] Error 1
在build目录执行如下命令:
make -f qemu_v8.mk run-only
运行之后qemu console显示:
xxx:~/work/optee_code/3.19/build$ make -f qemu_v8.mk run-only
ln -sf /home/work/optee_code/3.19/build/../out-br/images/rootfs.cpio.gz /home/work/optee_code/3.19/build/../out/bin/
* QEMU is now waiting to start the execution
* Start execution with either a 'c' followed by in the QEMU console or
* attach a debugger and continue from there.
*
* To run OP-TEE tests, use the xtest command in the 'Normal World' terminal
* Enter 'xtest -h' for help.
# Option “-x” is deprecated and might be removed in a later version of gnome-terminal.
# Option “-x” is deprecated and might be removed in a later version of gnome-terminal.
# Use “-- ” to terminate the options and put the command line to execute after it.
# Use “-- ” to terminate the options and put the command line to execute after it.
cd /home/work/optee_code/3.19/build/../out/bin && /home/work/optee_code/3.19/build/../qemu/build/aarch64-softmmu/qemu-system-aarch64 \
-nographic \
-serial tcp:localhost:54320 -serial tcp:localhost:54321 \
-smp 1 \
-s -S -machine virt,secure=on,mte=off,gic-version=3,virtualization=false \
-cpu cortex-a53 \
-d unimp -semihosting-config enable=on,target=native \
-m 2048 \
-bios bl1.bin \
-initrd rootfs.cpio.gz \
-kernel Image -no-acpi \
-append 'console=ttyAMA0,38400 keep_bootcon root=/dev/vda2 ' \
\
-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0,max-bytes=1024,period=1000 -netdev user,id=vmnic -device virtio-net-device,netdev=vmnic
QEMU 7.0.0 monitor - type 'help' for more information
(qemu)
同时会启动两个console。normal world和secure world,其窗口的显示如下:
|
|
继续在qemu console中输入c然后按enter:
QEMU 7.0.0 monitor - type 'help' for more information
(qemu) c
(qemu)
secure world显示:
listening on port 54321
soc_term: accepted fd 4
soc_term: read fd EOF
soc_term: accepted fd 4
D/TC:0 add_phys_mem:635 ROUNDDOWN((0x08000000 + 0x10000), CORE_MMU_PGDIR_SIZE) type IO_SEC 0x08000000 size 0x00200000
D/TC:0 add_phys_mem:635 ROUNDDOWN((0x08000000 + 0), CORE_MMU_PGDIR_SIZE) type IO_SEC 0x08000000 size 0x00200000
D/TC:0 add_phys_mem:649 Physical mem map overlaps 0x8000000
D/TC:0 add_phys_mem:635 ROUNDDOWN(0x09040000, CORE_MMU_PGDIR_SIZE) type IO_SEC 0x09000000 size 0x00200000
D/TC:0 add_phys_mem:635 TEE_SHMEM_START type NSEC_SHM 0x42000000 size 0x00200000
D/TC:0 add_phys_mem:635 TA_RAM_START type TA_RAM 0x0e300000 size 0x00d00000
D/TC:0 add_phys_mem:635 VCORE_UNPG_RW_PA type TEE_RAM_RW 0x0e174000 size 0x0018c000
D/TC:0 add_phys_mem:635 VCORE_UNPG_RX_PA type TEE_RAM_RX 0x0e100000 size 0x00074000
D/TC:0 add_va_space:675 type RES_VASPACE size 0x00a00000
D/TC:0 add_va_space:675 type SHM_VASPACE size 0x02000000
D/TC:0 init_mem_map:1244 Mapping core at 0x58adb000 offs 0x4a9db000
D/TC:0 dump_mmap_table:800 type IDENTITY_MAP_RX va 0x0e100000..0x0e101fff pa 0x0e100000..0x0e101fff size 0x00002000 (smallpg)
D/TC:0 dump_mmap_table:800 type TEE_RAM_RX va 0x58adb000..0x58b4efff pa 0x0e100000..0x0e173fff size 0x00074000 (smallpg)
D/TC:0 dump_mmap_table:800 type TEE_RAM_RW va 0x58b4f000..0x58cdafff pa 0x0e174000..0x0e2fffff size 0x0018c000 (smallpg)
D/TC:0 dump_mmap_table:800 type TA_RAM va 0x58d00000..0x599fffff pa 0x0e300000..0x0effffff size 0x00d00000 (smallpg)
D/TC:0 dump_mmap_table:800 type SHM_VASPACE va 0x59a00000..0x5b9fffff pa 0x00000000..0x01ffffff size 0x02000000 (pgdir)
D/TC:0 dump_mmap_table:800 type RES_VASPACE va 0x5ba00000..0x5c3fffff pa 0x00000000..0x009fffff size 0x00a00000 (pgdir)
D/TC:0 dump_mmap_table:800 type IO_SEC va 0x5c400000..0x5c5fffff pa 0x08000000..0x081fffff size 0x00200000 (pgdir)
D/TC:0 dump_mmap_table:800 type IO_SEC va 0x5c600000..0x5c7fffff pa 0x09000000..0x091fffff size 0x00200000 (pgdir)
D/TC:0 dump_mmap_table:800 type NSEC_SHM va 0x5c800000..0x5c9fffff pa 0x42000000..0x421fffff size 0x00200000 (pgdir)
D/TC:0 core_mmu_xlat_table_alloc:526 xlat tables used 1 / 8
D/TC:0 core_mmu_xlat_table_alloc:526 xlat tables used 2 / 8
D/TC:0 core_mmu_xlat_table_alloc:526 xlat tables used 3 / 8
D/TC:0 core_mmu_xlat_table_alloc:526 xlat tables used 4 / 8
D/TC:0 core_mmu_xlat_table_alloc:526 xlat tables used 5 / 8
I/TC:
I/TC: Non-secure external DT found
D/TC:0 0 carve_out_phys_mem:337 No need to carve out 0xe100000 size 0x200000
D/TC:0 0 carve_out_phys_mem:337 No need to carve out 0xe300000 size 0xd00000
I/TC: Embedded DTB found
D/TC:0 0 get_console_node_from_dt:72 No console directive from DTB
I/TC: OP-TEE version: Unknown_3.19 (gcc version 10.2.1 20201103 (GNU Toolchain for the A-profile Architecture 10.2-2020.11 (arm-10.16))) #1 Fri Feb 3 09:19:12 UTC 2023 aarch64
I/TC: WARNING: This OP-TEE configuration might be insecure!
I/TC: WARNING: Please check https://optee.readthedocs.io/en/latest/architecture/porting_guidelines.html
I/TC: Primary CPU initializing
D/TC:0 0 boot_init_primary_late:1334 Executing at offset 0x4a9db000 with virtual load address 0x58adb000
D/TC:0 0 call_preinitcalls:21 level 2 mobj_mapped_shm_init()
D/TC:0 0 mobj_mapped_shm_init:463 Shared memory address range: 59a00000, 5ba00000
D/TC:0 0 call_initcalls:40 level 1 register_time_source()
D/TC:0 0 call_initcalls:40 level 1 teecore_init_pub_ram()
D/TC:0 0 call_initcalls:40 level 2 probe_dt_drivers_early()
D/TC:0 0 add_node_to_probe:553 element: dt-test-consumer on node dt-test-consumer
D/TC:0 0 add_node_to_probe:553 element: dt-test-bus-b0 on node simple-bus
D/TC:0 0 add_node_to_probe:553 element: dt-test-crypt-consumer on node dt-test-crypt-consumer
D/TC:0 0 probe_driver_node:361 element: dt-test-crypt-consumer on node dt-test-crypt-consumer deferred 1 time(s)
D/TC:0 0 add_node_to_probe:553 element: dt-test-bus-b1 on node simple-bus
D/TC:0 0 probe_driver_node:355 element: simple-bus on node dt-test-bus-b0 initialized
D/TC:0 0 probe_driver_node:361 element: dt-test-consumer on node dt-test-consumer deferred 1 time(s)
D/TC:0 0 probe_driver_node:361 element: dt-test-consumer on node dt-test-consumer deferred 2 time(s)
D/TC:0 0 add_node_to_probe:553 element: dt-test-bus-b2 on node simple-bus
D/TC:0 0 probe_driver_node:355 element: simple-bus on node dt-test-bus-b1 initialized
D/TC:0 0 probe_driver_node:361 element: dt-test-crypt-consumer on node dt-test-crypt-consumer deferred 2 time(s)
D/TC:0 0 probe_driver_node:361 element: dt-test-crypt-consumer on node dt-test-crypt-consumer deferred 3 time(s)
D/TC:0 0 add_node_to_probe:553 element: dt-test-bus-b3 on node simple-bus
D/TC:0 0 probe_driver_node:355 element: simple-bus on node dt-test-bus-b2 initialized
D/TC:0 0 probe_driver_node:361 element: dt-test-consumer on node dt-test-consumer deferred 3 time(s)
D/TC:0 0 probe_driver_node:361 element: dt-test-consumer on node dt-test-consumer deferred 4 time(s)
D/TC:0 0 add_node_to_probe:553 element: dt-test-provider@0 on node dt_test_rstctrl_provider
D/TC:0 0 add_node_to_probe:553 element: dt-test-provider@0 on node dt_test_clock_provider
D/TC:0 0 probe_driver_node:355 element: simple-bus on node dt-test-bus-b3 initialized
D/TC:0 0 probe_driver_node:361 element: dt-test-crypt-consumer on node dt-test-crypt-consumer deferred 4 time(s)
D/TC:0 0 probe_driver_node:361 element: dt-test-crypt-consumer on node dt-test-crypt-consumer deferred 5 time(s)
D/TC:0 0 clk_register:104 Registered clock dt_test-clk3, freq 0
D/TC:0 0 clk_register:104 Registered clock dt_test-clk7, freq 0
D/TC:0 0 probe_driver_node:355 element: dt_test_clock_provider on node dt-test-provider@0 initialized
D/TC:0 0 probe_driver_node:355 element: dt_test_rstctrl_provider on node dt-test-provider@0 initialized
D/TC:0 0 probe_driver_node:355 element: dt-test-consumer on node dt-test-consumer initialized
D/TC:0 0 probe_driver_node:361 element: dt-test-crypt-consumer on node dt-test-crypt-consumer deferred 6 time(s)
D/TC:0 0 process_probe_list:502 Unresolved dependencies after 6 rounds, 6 deferred
D/TC:0 0 probe_dt_drivers_early:690 Deferred drivers probing
D/TC:0 0 print_probe_list:309 Probe list: 1 elements
D/TC:0 0 print_probe_list:311 |- Driver dt-test-crypt-consumer probes on node dt-test-crypt-consumer
D/TC:0 0 print_probe_list:315 `- Probe list end
D/TC:0 0 print_probe_list:321 Failed list: 0 elements
D/TC:0 0 print_probe_list:326 `- Failed list end
D/TC:0 0 call_initcalls:40 level 3 check_ta_store()
D/TC:0 0 check_ta_store:407 TA store: "early TA"
D/TC:0 0 check_ta_store:407 TA store: "Secure Storage TA"
D/TC:0 0 check_ta_store:407 TA store: "REE"
D/TC:0 0 call_initcalls:40 level 3 early_ta_init()
D/TC:0 0 early_ta_init:56 Early TA f04a0fe7-1f5d-4b9b-abf7-619b85b4ce8c size 33962 (compressed, uncompressed 55144)
D/TC:0 0 call_initcalls:40 level 3 verify_pseudo_tas_conformance()
D/TC:0 0 call_initcalls:40 level 3 tee_cryp_init()
D/TC:0 0 call_initcalls:40 level 4 tee_fs_init_key_manager()
D/TC:0 0 call_initcalls:40 level 5 init_console_itr()
D/TC:0 0 gic_it_set_cpu_mask:307 cpu_mask: writing 0xff to 0x5c400828
D/TC:0 0 gic_it_set_cpu_mask:309 cpu_mask: 0x0
D/TC:0 0 gic_it_set_prio:321 prio: writing 0x1 to 0x5c400428
D/TC:0 0 call_initcalls:40 level 5 probe_dt_drivers()
D/TC:0 0 probe_driver_node:355 element: dt-test-crypt-consumer on node dt-test-crypt-consumer initialized
D/TC:0 0 call_initcalls:40 level 6 mobj_init()
D/TC:0 0 call_initcalls:40 level 6 default_mobj_init()
D/TC:0 0 call_initcalls:40 level 7 release_probe_lists()
D/TC:0 0 call_initcalls:40 level 7 dt_test_release()
D/TC:0 0 call_finalcalls:59 level 1 release_external_dt()
I/TC: Primary CPU switching to normal world boot
D/TC:0 tee_entry_exchange_capabilities:100 Asynchronous notifications are disabled
D/TC:0 tee_entry_exchange_capabilities:109 Dynamic shared memory is enabled
D/TC:0 0 core_mmu_xlat_table_alloc:526 xlat tables used 6 / 8
D/TC:? 0 tee_ta_init_pseudo_ta_session:296 Lookup pseudo TA 7011a688-ddde-4053-a5a9-7b3c4ddf13b8
D/TC:? 0 tee_ta_init_pseudo_ta_session:309 Open device.pta
D/TC:? 0 tee_ta_init_pseudo_ta_session:326 device.pta : 7011a688-ddde-4053-a5a9-7b3c4ddf13b8
D/TC:? 0 tee_ta_close_session:510 csess 0x58b6c600 id 1
D/TC:? 0 tee_ta_close_session:529 Destroy session
D/TC:? 0 tee_ta_init_pseudo_ta_session:296 Lookup pseudo TA f04a0fe7-1f5d-4b9b-abf7-619b85b4ce8c
D/TC:? 0 ldelf_load_ldelf:96 ldelf load address 0x80006000
D/LD: ldelf:134 Loading TS f04a0fe7-1f5d-4b9b-abf7-619b85b4ce8c
D/TC:? 0 ldelf_syscall_open_bin:142 Lookup user TA ELF f04a0fe7-1f5d-4b9b-abf7-619b85b4ce8c (early TA)
D/TC:? 0 ldelf_syscall_open_bin:146 res=0
D/LD: ldelf:168 ELF (f04a0fe7-1f5d-4b9b-abf7-619b85b4ce8c) at 0x80076000
D/TC:? 0 tee_ta_init_session_with_context:605 Re-open TA 7011a688-ddde-4053-a5a9-7b3c4ddf13b8
D/TC:? 0 tee_ta_close_session:510 csess 0x58b619d0 id 2
D/TC:? 0 tee_ta_close_session:529 Destroy session
normal world显示:
listening on port 54320
soc_term: accepted fd 4
soc_term: read fd EOF
soc_term: accepted fd 4
NOTICE: Booting Trusted Firmware
NOTICE: BL1: v2.6(release):
NOTICE: BL1: Built : 17:20:59, Feb 3 2023
WARNING: Firmware Image Package header check failed.
NOTICE: BL1: Booting BL2
NOTICE: BL2: v2.6(release):
NOTICE: BL2: Built : 17:21:02, Feb 3 2023
WARNING: Firmware Image Package header check failed.
WARNING: Firmware Image Package header check failed.
WARNING: Firmware Image Package header check failed.
WARNING: Firmware Image Package header check failed.
NOTICE: BL1: Booting BL31
NOTICE: BL31: v2.6(release):
NOTICE: BL31: Built : 17:21:09, Feb 3 2023
U-Boot 2021.04 (Feb 06 2023 - 11:28:30 +0800)
DRAM: 2 GiB
Flash: 64 MiB
*** Warning - bad CRC, using default environment
In: pl011@9000000
Out: pl011@9000000
Err: pl011@9000000
Net: eth0: virtio-net#31
Hit any key to stop autoboot: 0
loaded file uImage from 40400000 to 426D2A3F, 022D2A40 bytes
loaded file rootfs.cpio.uboot from 44000000 to 447A1816, 007A1817 bytes
## Booting kernel from Legacy Image at 40400000 ...
Image Name: Linux kernel
Created: 2023-02-06 3:30:18 UTC
Image Type: AArch64 Linux Kernel Image (uncompressed)
Data Size: 36514304 Bytes = 34.8 MiB
Load Address: 40400000
Entry Point: 40400000
Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 44000000 ...
Image Name: Root file system
Created: 2023-02-06 3:30:19 UTC
Image Type: AArch64 Linux RAMDisk Image (gzip compressed)
Data Size: 8001495 Bytes = 7.6 MiB
Load Address: 44000000
Entry Point: 44000000
Verifying Checksum ... OK
## Flattened Device Tree blob at 40000000
Booting using the fdt blob at 0x40000000
Loading Kernel Image
Loading Ramdisk to be746000, end beee77d7 ... OK
Loading Device Tree to 00000000be740000, end 00000000be74528b ... OK
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[ 0.000000] Linux version 5.19.0 (aarch64-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 10.2-2020.11 (arm-10.16)) 10.2.1 20201103, GNU ld (GNU Toolchain for the A-profile Architecture 10.2-2020.11 (arm-10.16)) 2.35.1.20201028) #1 SMP PREEMPT Fri Feb 3 19:13:33 CST 2023
[ 0.000000] Machine model: linux,dummy-virt
[ 0.000000] efi: UEFI not found.
[ 0.000000] OF: fdt: Reserved memory: failed to reserve memory for node 'optee_shm@42000000': base 0x0000000042000000, size 2 MiB
[ 0.000000] NUMA: No NUMA configuration found
[ 0.000000] NUMA: Faking a node at [mem 0x0000000040000000-0x00000000bfffffff]
[ 0.000000] NUMA: NODE_DATA [mem 0xbfbf1b40-0xbfbf3fff]
[ 0.000000] Zone ranges:
[ 0.000000] DMA [mem 0x0000000040000000-0x00000000bfffffff]
[ 0.000000] DMA32 empty
[ 0.000000] Normal empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000040000000-0x00000000bfffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x00000000bfffffff]
[ 0.000000] cma: Reserved 32 MiB at 0x00000000ba600000
[ 0.000000] psci: probing for conduit method from DT.
[ 0.000000] psci: PSCIv1.1 detected in firmware.
[ 0.000000] psci: Using standard PSCI v0.2 function IDs
[ 0.000000] psci: Trusted OS migration not required
[ 0.000000] psci: SMC Calling Convention v1.2
[ 0.000000] percpu: Embedded 20 pages/cpu s44520 r8192 d29208 u81920
[ 0.000000] Detected VIPT I-cache on CPU0
[ 0.000000] CPU features: detected: GIC system register CPU interface
[ 0.000000] CPU features: kernel page table isolation forced ON by KASLR
[ 0.000000] CPU features: detected: Kernel page table isolation (KPTI)
[ 0.000000] CPU features: detected: ARM erratum 843419
[ 0.000000] CPU features: detected: ARM erratum 845719
[ 0.000000] Fallback order for Node 0: 0
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 516096
[ 0.000000] Policy zone: DMA
[ 0.000000] Kernel command line: console=ttyAMA0,115200 earlyprintk=serial,ttyAMA0,115200 root=/dev/ram
[ 0.000000] Unknown kernel command line parameters "earlyprintk=serial,ttyAMA0,115200", will be passed to user space.
[ 0.000000] Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes, linear)
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Memory: 1980192K/2097152K available (16064K kernel code, 3402K rwdata, 9040K rodata, 6976K init, 581K bss, 84192K reserved, 32768K cma-reserved)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] rcu: Preemptible hierarchical RCU implementation.
[ 0.000000] rcu: RCU event tracing is enabled.
[ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=256 to nr_cpu_ids=1.
[ 0.000000] Trampoline variant of Tasks RCU enabled.
[ 0.000000] Tracing variant of Tasks RCU enabled.
[ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[ 0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[ 0.000000] GICv3: 224 SPIs implemented
[ 0.000000] GICv3: 0 Extended SPIs implemented
[ 0.000000] Root IRQ handler: gic_handle_irq
[ 0.000000] GICv3: GICv3 features: 16 PPIs
[ 0.000000] GICv3: CPU0: found redistributor 0 region 0:0x00000000080a0000
[ 0.000000] ITS [mem 0x08080000-0x0809ffff]
[ 0.000000] ITS@0x0000000008080000: allocated 8192 Devices @40030000 (indirect, esz 8, psz 64K, shr 1)
[ 0.000000] ITS@0x0000000008080000: allocated 8192 Interrupt Collections @40040000 (flat, esz 8, psz 64K, shr 1)
[ 0.000000] GICv3: using LPI property table @0x0000000040050000
[ 0.000000] GICv3: CPU0: using allocated LPI pending table @0x0000000040060000
[ 0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[ 0.000000] arch_timer: cp15 timer(s) running at 62.50MHz (virt).
[ 0.000000] clocksource: arch_sys_counter: mask: 0x1ffffffffffffff max_cycles: 0x1cd42e208c, max_idle_ns: 881590405314 ns
[ 0.000111] sched_clock: 57 bits at 63MHz, resolution 16ns, wraps every 4398046511096ns
[ 0.011447] Console: colour dummy device 80x25
[ 0.014339] Calibrating delay loop (skipped), value calculated using timer frequency.. 125.00 BogoMIPS (lpj=250000)
[ 0.014519] pid_max: default: 32768 minimum: 301
[ 0.015613] LSM: Security Framework initializing
[ 0.019457] Mount-cache hash table entries: 4096 (order: 3, 32768 bytes, linear)
[ 0.019540] Mountpoint-cache hash table entries: 4096 (order: 3, 32768 bytes, linear)
[ 0.062465] /cpus/cpu-map: empty cluster
[ 0.073033] cblist_init_generic: Setting adjustable number of callback queues.
[ 0.073187] cblist_init_generic: Setting shift to 0 and lim to 1.
[ 0.073707] cblist_init_generic: Setting shift to 0 and lim to 1.
[ 0.075718] rcu: Hierarchical SRCU implementation.
[ 0.075777] rcu: Max phase no-delay instances is 1000.
[ 0.080076] Platform MSI: its@8080000 domain created
[ 0.080683] PCI/MSI: /intc@8000000/its@8080000 domain created
[ 0.081072] fsl-mc MSI: its@8080000 domain created
[ 0.084541] EFI services will not be available.
[ 0.086106] smp: Bringing up secondary CPUs ...
[ 0.086227] smp: Brought up 1 node, 1 CPU
[ 0.086269] SMP: Total of 1 processors activated.
[ 0.086363] CPU features: detected: 32-bit EL0 Support
[ 0.086393] CPU features: detected: 32-bit EL1 Support
[ 0.086497] CPU features: detected: CRC32 instructions
[ 0.091562] CPU: All CPU(s) started at EL1
[ 0.092144] alternatives: patching kernel code
[ 0.112766] devtmpfs: initialized
[ 0.128463] KASLR enabled
[ 0.129988] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[ 0.130197] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[ 0.135946] pinctrl core: initialized pinctrl subsystem
[ 0.150470] DMI not present or invalid.
[ 0.162134] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[ 0.176463] DMA: preallocated 256 KiB GFP_KERNEL pool for atomic allocations
[ 0.177370] DMA: preallocated 256 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[ 0.177752] DMA: preallocated 256 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[ 0.178139] audit: initializing netlink subsys (disabled)
[ 0.185620] audit: type=2000 audit(0.160:1): state=initialized audit_enabled=0 res=1
[ 0.188263] thermal_sys: Registered thermal governor 'step_wise'
[ 0.188320] thermal_sys: Registered thermal governor 'power_allocator'
[ 0.189044] cpuidle: using governor menu
[ 0.190346] hw-breakpoint: found 6 breakpoint and 4 watchpoint registers.
[ 0.190919] ASID allocator initialised with 32768 entries
[ 0.191133] HugeTLB: can optimize 4095 vmemmap pages for hugepages-1048576kB
[ 0.191215] HugeTLB: can optimize 127 vmemmap pages for hugepages-32768kB
[ 0.191241] HugeTLB: can optimize 7 vmemmap pages for hugepages-2048kB
[ 0.191275] HugeTLB: can optimize 0 vmemmap pages for hugepages-64kB
[ 0.198838] Serial: AMBA PL011 UART driver
[ 0.245084] 9000000.pl011: ttyAMA0 at MMIO 0x9000000 (irq = 13, base_baud = 0) is a PL011 rev1
[ 0.265456] printk: console [ttyAMA0] enabled
[ 0.319870] HugeTLB registered 1.00 GiB page size, pre-allocated 0 pages
[ 0.320171] HugeTLB registered 32.0 MiB page size, pre-allocated 0 pages
[ 0.320367] HugeTLB registered 2.00 MiB page size, pre-allocated 0 pages
[ 0.320566] HugeTLB registered 64.0 KiB page size, pre-allocated 0 pages
[ 0.332720] ACPI: Interpreter disabled.
[ 0.340863] iommu: Default domain type: Translated
[ 0.341213] iommu: DMA domain TLB invalidation policy: strict mode
[ 0.343885] SCSI subsystem initialized
[ 0.348918] usbcore: registered new interface driver usbfs
[ 0.349733] usbcore: registered new interface driver hub
[ 0.350736] usbcore: registered new device driver usb
[ 0.354943] pps_core: LinuxPPS API ver. 1 registered
[ 0.355178] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti .it>
[ 0.355570] PTP clock support registered
[ 0.356426] EDAC MC: Ver: 3.0.0
[ 0.361111] ARM FF-A: FFA_VERSION returned not supported
[ 0.365755] FPGA manager framework
[ 0.367382] Advanced Linux Sound Architecture Driver Initialized.
[ 0.406253] vgaarb: loaded
[ 0.410357] clocksource: Switched to clocksource arch_sys_counter
[ 0.415488] VFS: Disk quotas dquot_6.6.0
[ 0.415987] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[ 0.418538] pnp: PnP ACPI: disabled
[ 0.444975] NET: Registered PF_INET protocol family
[ 0.448134] IP idents hash table entries: 32768 (order: 6, 262144 bytes, linear)
[ 0.457267] tcp_listen_portaddr_hash hash table entries: 1024 (order: 2, 16384 bytes, linear)
[ 0.457813] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[ 0.458263] TCP established hash table entries: 16384 (order: 5, 131072 bytes, linear)
[ 0.459284] TCP bind hash table entries: 16384 (order: 6, 262144 bytes, linear)
[ 0.459953] TCP: Hash tables configured (established 16384 bind 16384)
[ 0.461751] UDP hash table entries: 1024 (order: 3, 32768 bytes, linear)
[ 0.462351] UDP-Lite hash table entries: 1024 (order: 3, 32768 bytes, linear)
[ 0.464209] NET: Registered PF_UNIX/PF_LOCAL protocol family
[ 0.467770] RPC: Registered named UNIX socket transport module.
[ 0.468050] RPC: Registered udp transport module.
[ 0.468228] RPC: Registered tcp transport module.
[ 0.468383] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.468726] PCI: CLS 0 bytes, default 64
[ 0.479870] Unpacking initramfs...
[ 0.484340] hw perfevents: enabled with armv8_pmuv3 PMU driver, 5 counters available
[ 0.485904] kvm [1]: HYP mode not available
[ 0.499548] Initialise system trusted keyrings
[ 0.506956] workingset: timestamp_bits=42 max_order=19 bucket_order=0
[ 0.553723] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 0.564649] NFS: Registering the id_resolver key type
[ 0.565395] Key type id_resolver registered
[ 0.565604] Key type id_legacy registered
[ 0.571106] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[ 0.571561] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[ 0.572952] 9p: Installing v9fs 9p2000 file system support
[ 0.650955] Key type asymmetric registered
[ 0.651270] Asymmetric key parser 'x509' registered
[ 0.651919] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 245)
[ 0.652331] io scheduler mq-deadline registered
[ 0.652569] io scheduler kyber registered
[ 0.734923] pl061_gpio 9030000.pl061: PL061 GPIO chip registered
[ 0.752778] pci-host-generic 4010000000.pcie: host bridge /pcie@10000000 ranges:
[ 0.754628] pci-host-generic 4010000000.pcie: IO 0x003eff0000..0x003effffff -> 0x0000000000
[ 0.755573] pci-host-generic 4010000000.pcie: MEM 0x0010000000..0x003efeffff -> 0x0010000000
[ 0.755902] pci-host-generic 4010000000.pcie: MEM 0x8000000000..0xffffffffff -> 0x8000000000
[ 0.756951] pci-host-generic 4010000000.pcie: Memory resource size exceeds max for 32 bits
[ 0.757913] pci-host-generic 4010000000.pcie: ECAM at [mem 0x4010000000-0x401fffffff] for [bus 00-ff]
[ 0.768101] pci-host-generic 4010000000.pcie: PCI host bridge to bus 0000:00
[ 0.768739] pci_bus 0000:00: root bus resource [bus 00-ff]
[ 0.769014] pci_bus 0000:00: root bus resource [io 0x0000-0xffff]
[ 0.769326] pci_bus 0000:00: root bus resource [mem 0x10000000-0x3efeffff]
[ 0.769572] pci_bus 0000:00: root bus resource [mem 0x8000000000-0xffffffffff]
[ 0.776042] pci 0000:00:00.0: [1b36:0008] type 00 class 0x060000
[ 0.786036] pci 0000:00:01.0: [1af4:1005] type 00 class 0x00ff00
[ 0.791327] pci 0000:00:01.0: reg 0x10: [io 0x1000-0x101f]
[ 0.799024] pci 0000:00:01.0: reg 0x20: [mem 0x10000000-0x10003fff 64bit pref]
[ 0.808603] pci 0000:00:01.0: BAR 4: assigned [mem 0x8000000000-0x8000003fff 64bit pref]
[ 0.809906] pci 0000:00:01.0: BAR 0: assigned [io 0x1000-0x101f]
[ 0.832003] EINJ: ACPI disabled.
[ 0.963433] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[ 0.981426] SuperH (H)SCI(F) driver initialized
[ 1.012890] msm_serial: driver initialized
[ 1.027506] random: crng init done
[ 1.029750] cacheinfo: Unable to detect cache hierarchy for CPU 0
[ 1.074693] loop: module loaded
[ 1.082750] megasas: 07.719.03.00-rc1
[ 1.100628] physmap-flash 4000000.flash: physmap platform flash device: [mem 0x04000000-0x07ffffff]
[ 1.107265] 4000000.flash: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
[ 1.108347] Intel/Sharp Extended Query Table at 0x0031
[ 1.109756] Using buffer write method
[ 1.360455] Freeing initrd memory: 7812K
[ 1.515226] tun: Universal TUN/TAP device driver, 1.6
[ 1.527483] thunder_xcv, ver 1.0
[ 1.527887] thunder_bgx, ver 1.0
[ 1.528168] nicpf, ver 1.0
[ 1.532632] hns3: Hisilicon Ethernet Network Driver for Hip08 Family - version
[ 1.532935] hns3: Copyright (c) 2017 Huawei Corporation.
[ 1.533671] hclge is initializing
[ 1.534003] e1000: Intel(R) PRO/1000 Network Driver
[ 1.534397] e1000: Copyright (c) 1999-2006 Intel Corporation.
[ 1.534778] e1000e: Intel(R) PRO/1000 Network Driver
[ 1.534944] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[ 1.535366] igb: Intel(R) Gigabit Ethernet Network Driver
[ 1.535530] igb: Copyright (c) 2007-2014 Intel Corporation.
[ 1.535845] igbvf: Intel(R) Gigabit Virtual Function Network Driver
[ 1.536043] igbvf: Copyright (c) 2009 - 2012 Intel Corporation.
[ 1.537361] sky2: driver version 1.30
[ 1.541365] VFIO - User Level meta-driver version: 0.3
[ 1.549751] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 1.550453] ehci-pci: EHCI PCI platform driver
[ 1.550936] ehci-platform: EHCI generic platform driver
[ 1.551541] ehci-orion: EHCI orion driver
[ 1.551976] ehci-exynos: EHCI Exynos driver
[ 1.552404] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 1.552837] ohci-pci: OHCI PCI platform driver
[ 1.553346] ohci-platform: OHCI generic platform driver
[ 1.553862] ohci-exynos: OHCI Exynos driver
[ 1.556227] usbcore: registered new interface driver usb-storage
[ 1.568654] rtc-pl031 9010000.pl031: registered as rtc0
[ 1.569609] rtc-pl031 9010000.pl031: setting system clock to 2023-02-06T08:37:11 UTC (1675672631)
[ 1.572362] i2c_dev: i2c /dev entries driver
[ 1.592007] sdhci: Secure Digital Host Controller Interface driver
[ 1.592269] sdhci: Copyright(c) Pierre Ossman
[ 1.594464] Synopsys Designware Multimedia Card Interface Driver
[ 1.597213] sdhci-pltfm: SDHCI platform and OF driver helper
[ 1.602906] ledtrig-cpu: registered to indicate activity on CPUs
[ 1.606934] SMCCC: SOC_ID: ARCH_SOC_ID not implemented, skipping ....
[ 1.610596] usbcore: registered new interface driver usbhid
[ 1.610833] usbhid: USB HID core driver
[ 1.622379] optee: probing for conduit method.
[ 1.623668] optee: revision 3.19
[ 1.627388] optee: dynamic shared memory is enabled
[ 1.644219] optee: initialized driver
[ 1.645341] Driver 'optee' was unable to register with bus_type 'arm_ffa' because the bus was not initialized.
[ 1.655605] NET: Registered PF_PACKET protocol family
[ 1.657620] 9pnet: Installing 9P2000 support
[ 1.658547] Key type dns_resolver registered
[ 1.660847] registered taskstats version 1
[ 1.661499] Loading compiled-in X.509 certificates
[ 1.713389] Key type trusted registered
[ 1.715952] Key type encrypted registered
[ 1.749594] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[ 1.758432] ALSA device list:
[ 1.758685] No soundcards found.
[ 1.763799] uart-pl011 9000000.pl011: no DMA platform data
[ 1.818646] Freeing unused kernel memory: 6976K
[ 1.819906] Run /init as init process
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Saving random seed: OK
Set permissions on /dev/tee*: OK
Create/set permissions on /data/tee: OK
Starting tee-supplicant: Using device /dev/teepriv0.
OK
Starting network: OK
Starting network (udhcpc): OK
Welcome to Buildroot, type root or test to login
buildroot login:
secure world显示无改变:
|
|
normal world:
buildroot login: root
# optee_example_hello_world
Invoking TA to increment 42
TA incremented value to 43
secure world:
D/TC:? 0 tee_ta_close_session:510 csess 0x58b619d0 id 2
D/TC:? 0 tee_ta_close_session:529 Destroy session
D/TC:? 0 tee_ta_init_pseudo_ta_session:296 Lookup pseudo TA 8aaaf200-2450-11e4-abe2-0002a5d5c51b
D/TC:? 0 ldelf_load_ldelf:96 ldelf load address 0x80006000
D/LD: ldelf:134 Loading TS 8aaaf200-2450-11e4-abe2-0002a5d5c51b
D/TC:? 0 ldelf_syscall_open_bin:142 Lookup user TA ELF 8aaaf200-2450-11e4-abe2-0002a5d5c51b (early TA)
D/TC:? 0 ldelf_syscall_open_bin:146 res=0xffff0008
D/TC:? 0 ldelf_syscall_open_bin:142 Lookup user TA ELF 8aaaf200-2450-11e4-abe2-0002a5d5c51b (Secure Storage TA)
D/TC:? 0 ldelf_syscall_open_bin:146 res=0xffff0008
D/TC:? 0 ldelf_syscall_open_bin:142 Lookup user TA ELF 8aaaf200-2450-11e4-abe2-0002a5d5c51b (REE)
D/TC:? 0 ldelf_syscall_open_bin:146 res=0
D/LD: ldelf:168 ELF (8aaaf200-2450-11e4-abe2-0002a5d5c51b) at 0x80044000
D/TA: TA_CreateEntryPoint:39 has been called
D/TA: TA_OpenSessionEntryPoint:68 has been called
I/TA: Hello World!
D/TA: inc_value:105 has been called
I/TA: Got value: 42 from NW
I/TA: Increase value to: 43
D/TC:? 0 tee_ta_close_session:510 csess 0x58b619d0 id 2
D/TC:? 0 tee_ta_close_session:529 Destroy session
I/TA: Goodbye!
D/TA: TA_DestroyEntryPoint:50 has been called
D/TC:? 0 destroy_context:307 Destroy TA ctx (0x58b61970)
本文主要介绍了optee代码的下载编译以及使用qemu运行,以及此过程中可能遇到的问题及解决方案。本文着重介绍手动下载代码方式,主要针对repo下载方式因为万络原因容易失败的情况,若是网络好,可使用repo下载会更方便。