I found by setting -cpu max, this ID_AA64MMFR1 register value is read correctly.
With this setting, the start_kernel is entered in el2 as in the fpga test. Thanks! Chan Kim From: Chan Kim <c...@etri.re.kr> Sent: Thursday, February 17, 2022 4:18 PM To: 'qemu-discuss' <qemu-discuss@nongnu.org> Subject: ID_AA64MMFR1 VHE fields read as 0 when virtualization=true Hello all, I hope somebody could help me here.(booting linux using u-boot-spl) In linux-5.4.21 arch/arm64/kernel/head.S, there is this code in function el2_setup. #ifdef CONFIG_ARM64_VHE /* * Check for VHE being present. For the rest of the EL2 setup, * x2 being non-zero indicates that we do have VHE, and that the * kernel is intended to run at EL2. */ mrs x2, id_aa64mmfr1_el1 ubfx x2, x2, #ID_AA64MMFR1_VHE_SHIFT, #4 #else mov x2, xzr #endif By the way, linux was entered at EL2 by u-boot. and when x2 is non-zero, we do stuff for VHE (virtualization hardware extension). When I do experiment with FPGA (arm64 core, supporting up to armv8.4), the value of id_aa64mmfr1_el1 's VH (4bits) field are read as "0001" so the el2_setup function later returns with 'ret' and the program remains in el2 and enters start_kernel in el2. (I built the kernel with CONFIG_ARM64_VHE=y). But with qemu-5.1.0, this register value's VH value is read as "0000" so it goes to 'install_el2_stub' and returns with 'msr elr_el2, lr' and 'eret' so that it drops down to el1 and start_kernsl runs in el1. The command I used for qemu is : ~/prj/abdsn/ab21sim/ab21tsim/QEMU/qemu-5.1.0/build-baremetal/aarch64-softmmu /qemu-system-aarch64 -machine ab21q,gic-version=max,secure=true,virtualization=true -cpu cortex-a72 -kernel ~/U-BOOT/u-boot/spl/u-boot-spl -m 2048M -nographic -device loader,file=/home/ckim/U-BOOT/u-boot/images/Image,addr=0x80080000 -device loader,file=/home/ckim/U-BOOT/u-boot/images/ab21m.dtb,addr=0x807fd000 I thought by setting 'virtualization=true', the VH value will be read as 1 and other VH features will be enabled in qemu but it seems not. What am I missing? (I tried doing it with qemu-6.2.0 today by adding my virtual machine there. Linux boots ok with 'kernel=Image' method but when I do u-boot method, it doesn't proceed somewhere in u-boot so I couldn't check the above code. But start_kernel is in el1 as in 5.1.0) Any comment will be appreciated. Thank you! Chan Kim