linaro-swg / linux

Linux kernel source tree
Other
41 stars 79 forks source link

Has this linux 4.5 with optee drivers tested on aarch64? #5

Closed sakjain92 closed 8 years ago

sakjain92 commented 8 years ago

I am facing issues on arm aarch64. For example the following code in core.c in optee driver: invoke_fn(OPTEE_SMC_CALLS_UID, 0, 0, 0, 0, 0, 0, 0, &res);

As all arguments are expected to be 64 bit, OPTEE_SMC_CALLS_UID is signed extended to 64 making the higher 32 bits are all '1'.

This is causing issues with OPTEE and it is not able to recognize the SMC function id.

Has OPTEE 2.0.0 tested on a aarch64 platform or am I doing something wrong?

I guess macros such as

define ARM_SMCCC_FAST_CALL 1

define ARM_SMCCC_STD_CALL 0

needs to be replaced by

define ARM_SMCCC_FAST_CALL 1U

define ARM_SMCCC_STD_CALL 0U

in file include/linux/arm-smccc.h or change in optee function id comparision (optee os compares this function id value with unsigned value)

After the above mentioned changed, my xtests are running on aarch64 platform

jenswi-linaro commented 8 years ago

We're testing on Aarch64 on a regular basis. You're right with the sign extension, it doesn't look good. However, the SMC Calling Convention states that register 0 is to be used as a 32-bit register so the SMC handler in ARM Trusted Firmware discards the upper 32-bits when control is passed to the SMC handler and OP-TEE will never see the upper bits.

sakjain92 commented 8 years ago

OPTEE OS is comparing this function id with unsigned function id. So I am getting issues where the OPTEE OS doesn't recognize the function id. After changing the macros in the linux library, my xtests are running fine. Otherwise linux driver of optee fails to initialize (fast call for UID comparision fails)

I believe instead of changing in OPTEE OS, the header file should be changed. Otherwise during debugging it can become very confusing if i see in x0 a value of 0xffffffffbf00ff01.

Since you are saying that your aarch64 platform is working fine, am I missing something? Does your built in linux driver on OPTEE2.0.0 gets initialized on your platform?

jenswi-linaro commented 8 years ago

Yes, our Aarch64 platforms are working fine. But I think this should be addressed, as it is confusing and also obviously doesn't work on your platform.

sakjain92 commented 8 years ago

Okay. I got it now. The problem lies in the code (type) << ARM_SMCCC_TYPE_SHIFT)

and

define ARM_SMCCC_STD_CALL 0

define ARM_SMCCC_FAST_CALL 1

define ARM_SMCCC_TYPE_SHIFT 31

as 1 << 31 is undefined in C, it might be running smoothly in your machine but causes issue in my machine. In optee os, that is why fast_call macro has been defined as 0x80000000 and not 1 << 31.

jenswi-linaro commented 8 years ago

On our platforms we're saved by ARM-TF discarding the upper 32-bits of function id.

jenswi-linaro commented 8 years ago

Fixed in https://github.com/linaro-swg/linux/pull/8

jbech-linaro commented 8 years ago

Issue has been fixed in #8 , closing the issue.