Closed wangxiang-github closed 11 months ago
Perhaps the secondary cores crash in OP-TEE before they are able to report something. You could try printing a single character on the UART with a few assembly instructions just after the entry address to see how far you get.
Hi jenswi-linaro, thanks for your interest in this issue, I tried to print a single character in the optee_os, but nothing printed. there is my changes:
Actually, I've thought about this, secondary boot maybe be crashed somewhere, but I designed a test to verify sencondary boot process, I added an SMC call to the ATF and simulated a scene that kernel launch the SMP call:
extern uintptr_t std_svc_smc_handler(uint32_t smc_fid, u_register_t x1, u_register_t x2, u_register_t x3, u_register_t x4, void *cookie, void *handle, u_register_t flags);
struct optee_res_arm_smccc {
unsigned long a0;
unsigned long a1;
unsigned long a2;
unsigned long a3;
};
void cpu_on_secondary_prehandle(void)
{
struct optee_res_arm_smccc handle;
NOTICE("secondary bootup init\n");
std_svc_smc_handler(0xc4000003, 0x1, 0x50091dc, 0x0, 0x0, NULL, &handle, 1);
mdelay(100);
std_svc_smc_handler(0xc4000003, 0x2, 0x50091dc, 0x0, 0x0, NULL, &handle, 1);
//mdelay(100);
//std_svc_smc_handler(0xc4000003, 0x3, 0x50091dc, 0x0, 0x0, NULL, &handle, 1);
}
Function cpu_on_secondary_prehandle
is called from bl31_main
at the end of the line, then, during ATF initialization, I get the secondary boot log.
NOTICE: opteed_smc_handler:enter, is_caller_non_secure(flags=0x0)=0x0
NOTICE: opteed_smc_handler:smc_fid = 0xbe000000
NOTICE: opteed_smc_handler:x1=0x3e0018ac,x2=0x3e09c860,x3=0x8000000000,x4=0x3e0ceba0
NOTICE: TEESMC_OPTEED_RETURN_ENTRY_DONE
NOTICE: opteed_smc_handler: x1=0x3e0018ac
NOTICE: optee_vector_table(0x3e0018ac) is not NULL
NOTICE: optee_entrypoint_test:ctx->state=1[0-OFF,1-ON]
NOTICE: opteed_init_optee_ep_state: arg0=0x0, arg1=0x0, arg2=0x0, spsr=0x3c5, pc=0x3e0018b4
NOTICE: optee_entrypoint_test:linear_id=0, optee_on_entrypoint.pc=0x3e0018b4, spsr=0x3c5
NOTICE: first enter optee os finished!
NOTICE: bl31_prepare_next_image_entry: image_type = 1[0-SECURE, 1-NON_SECURE]
NOTICE: bl31_plat_get_next_image_ep_info: type=1.[0-SECURE, 1-NON_SECURE]
NOTICE: type=0x1, version=0x1, size=0x58, attr=0x1, pc=0x200000, spsr=0x3c9
INFO: BL31: Preparing for EL3 exit to normal world
INFO: Entry point address = 0x200000
INFO: SPSR = 0x3c9
NOTICE: secondary bootup init
NOTICE: std_svc_smc_handler: smc_fid=0xc4000003,x1=0x1,x2=0x50091dc,x3=0x0,x4=0x0,flags=1
NOTICE: psci_smc_handler:AARCH64
NOTICE: psci_cpu_on: enter
NOTICE: cpu is exist
NOTICE: pc=0x50091dc, spsr=0x3c5
NOTICE: psci_cpu_on_start: target_cpu=0x1
NOTICE: socfpga_pwr_domain_on: mpidr: 0x1
NOTICE: rc = 0
NOTICE: CurrentEl=0x3, MODE_EL=3
NOTICE: sctlr_el=0xc5183a
NOTICE: psci_warmboot_entrypoint start
NOTICE: psci_cpu_on_finish:cpu_idx=1
NOTICE: opteed_cpu_on_finish_handler: linear_id=1, optee_ctx->state=0[0-OFF,1-ON]
NOTICE: opteed_init_optee_ep_state: arg0=0x0, arg1=0x0, arg2=0x0, spsr=0x3c5, pc=0x3e0018b4
NOTICE: opteed_cpu_on_finish_handler: entry=0x3e0018b4
I/TC: Secondary CPU 1 initializing
I/TC: Secondary CPU 1 switching to normal world boot
NOTICE: opteed_smc_handler:enter, is_caller_non_secure(flags=0x0)=0x0
NOTICE: opteed_smc_handler:smc_fid = 0xbe000001
NOTICE: opteed_smc_handler:x1=0x0,x2=0x3e0229f8,x3=0x8000000100,x4=0x3e0c9e40
NOTICE: TEESMC_OPTEED_RETURN_ON_DONE
NOTICE: psci_warmboot_entrypoint end
NOTICE: std_svc_smc_handler: smc_fid=0xc4000003,x1=0x2,x2=0x50091dc,x3=0x0,x4=0x0,flags=1
NOTICE: psci_smc_handler:AARCH64
NOTICE: psci_cpu_on: enter
NOTICE: cpu is exist
NOTICE: pc=0x50091dc, spsr=0x3c5
NOTICE: psci_cpu_on_start: target_cpu=0x2
NOTICE: socfpga_pwr_domain_on: mpidr: 0x2
NOTICE: rc = 0
NOTICE: CurrentEl=0x3, MODE_EL=3
NOTICE: sctlr_el=0xc5183a
NOTICE: psci_warmboot_entrypoint start
NOTICE: psci_cpu_on_finish:cpu_idx=2
NOTICE: opteed_cpu_on_finish_handler: linear_id=2, optee_ctx->state=0[0-OFF,1-ON]
NOTICE: opteed_init_optee_ep_state: arg0=0x0, arg1=0x0, arg2=0x0, spsr=0x3c5, pc=0x3e0018b4
NOTICE: opteed_cpu_on_finish_handler: entry=0x3e0018b4
I/TC: Secondary CPU 2 initializing
I/TC: Secondary CPU 2 switching to normal world boot
NOTICE: opteed_smc_handler:enter, is_caller_non_secure(flags=0x0)=0x0
NOTICE: opteed_smc_handler:smc_fid = 0xbe000001
NOTICE: opteed_smc_handler:x1=0x0,x2=0x3e0229f8,x3=0x8000000200,x4=0x3e0ca680
NOTICE: TEESMC_OPTEED_RETURN_ON_DONE
NOTICE: psci_warmboot_entrypoint end
I can see the secondary print in the ATF initilize log:
I/TC: Secondary CPU 1 initializing
I/TC: Secondary CPU 1 switching to normal world boot
so I guess secondary boot should be fine, and SMP call will go through in this case, but it will eventually gets stuck in the Optee driver:
[ 1.139218] usbcore: registered new interface driver usb-storage
[ 1.147367] i2c /dev entries driver
[ 1.152376] optee: probing for conduit method.
NOTICE: opteed_smc_handler:enter, is_caller_non_secure(flags=0x1)=0x1
NOTICE: opteed_smc_handler:smc_fid = 0xbf00ff01
NOTICE: opteed_smc_handler:x1=0x0,x2=0x0,x3=0x0,x4=0x0
NOTICE: opteed_smc_handler: call fast_smc_entry->0x3e0018b0
Similarly, address 0x3e0018b0
is the entry point address for function vector_fast_smc_entry
, but optee can't run with this address either. It looks like optee can not work once a state transition occurs (EL0 to EL3). so I don't understand this point.
It's no surprise that you didn't get anything printed with that change, the stack pointer isn't initialized at that stage.
It looks like optee can not work once a state transition occurs (EL0 to EL3). so I don't understand this point.
It seems that the problem lies outside of OP-TEE. Perhaps the memory where OP-TEE is loaded becomes corrupted by the normal world?
Maybe so, intel's socfpga silicon didn't have bl32 address layout originally, I added it manualy, maybe it doesn't work.
OK, there's your problem. You need to find and/or configure some secure memory where OP-TEE can reside.
I am not so sure about this, However, I have a qustion, if bl32
start address is fine, then theoretically, when an SMC call occurs, OPTEE should jump to the thread_vector_table
table to get the entry point address (e.g., 0x3e0018b4
) to run the corresponding function (vector_cpu_on_entry
) , instead of getting stuck in this place, right?
Yes, I believe you've even demonstrated that above.
This issue has been marked as a stale issue because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this issue will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time.
Background
I've added a new platform Intel Stratix10 to OPTEE_OS which comes from Intel's socfpga chip. I would like to support OPTEE functionality based on this platform, ATF using Intel's official Intel platform repo(https://github.com/altera-opensource/arm-trusted-firmware/tree/socfpga_v2.7.0). I've implemented the intel platform configuration and releted files(e.g. main.c, conf.mk, platform_config.h, sub.mk) under the
core/arch/arm/plat-intel
folder. Then wait for the yocto to fininsh compiling, flash WIC file to the SD card, and boot it up with the following initialization process:The initialization process gets stuck at the end of the line, then wait 6 or 7 seconds for the intel socfpga to reset and repeat the process again. I've confirmed that the CPU boot method is PSCI:
Very strangely, the
optee.dmp
file shows the correct call address (0x3e0018b4
the last line of the initialization process), but optee doesn't run at this address:So, I don't know why optee_os doesn't response the SMCCC here, I would appreciate it if you know how to solve this problem! Best Regards!