Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

32bit OPTEE OS System call interface Question #1139

Closed
acy54321 opened this issue Oct 26, 2016 · 2 comments
Closed

32bit OPTEE OS System call interface Question #1139

acy54321 opened this issue Oct 26, 2016 · 2 comments

Comments

@acy54321
Copy link

Hi optee expert

I have a question about system call, because development needs so we will add new system call api for user ta.
My question is system call parameter have limit can not used uint64_t type?
Because I have some problem when use uint64_t type as system call parameter.
In arm32 compiler when use uint64_t type as parameter will use 2 registers to save data(because arm 32 register is 32bit),if can't put in register will save to stack, and I get a problem when system call api define as follows :
void f(int a,int b,int c, uint64_t d)

f(1,2,3,0x123456789);
disassembly will like :
.
strd r2,r3,[sp] will use r2 & r3 combination to 64bit data and save to stack
movs r0,#1
movs r1,#2
movs r3,#3

In lib/libutee/arch/arm/utee_syscalls_a32.S
.macro UTEE_SYSCALL name, scn, num_args
.
.
@ Tell number of arguments passed on the stack
mov r6, #(\num_args - 4)
.
.
=> because my system call only have 4 args so here r6 will 0, because This code default considered args 1~4 will all put in arm 32 register but in our case will put in stack
then in core/arch/arm/tee/arch_svc_a32.S
tee_svc_do_call
.
.
cmp r6, #0
beq .Lno_args
.
.
=> in our case will not use tee_svc_copy_from_user copy stack from user to kernel space,
here cause subsequent code use arg4 will error

I think problem will occur when system call args have uint64_t type and not enough cpu register can't use, will cause same problem(eg. ff(uint64_t a,uint64_t b,uint32_t c) c will get error because no copy stack from user space to kernel space).

Is there a limit 32bit optee system call can't use uint64_t type as System call parameter ??
If not limit, I think have to modify utee_syscalls_a32.S & arch_svc_a32.S mechanism.

@jenswi-linaro
Copy link
Contributor

As long as you follow the guidelines at

* Arguments must use the native register width, unless it's a signed
you should be OK.

@acy54321
Copy link
Author

Ok I understand thank you for answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants