This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARMv8-A Instruction for Getting CPU Number

Hi,

I'm using a Juno r1 board and I'm trying to get processor's related CPU ID without using any header file like function sched_getcpu from sched.h.

The reason is I want to get the CPU number for TrustZone application and there is no way to using those header files.

I know there is an instruction CPUID which could be used in x86 for this purpose, so I'm wondering is there any instruction I could use for ARMv8-A?

Thanks.

Simon

Parents
  • shengyewan,

    If OP-TEE don't provide an API to do so, then the answer is pretty simply that you don't - the MPIDR_EL1 register that contains the multi-processor CPU identifier (i.e. it's thread, core, cluster and system topology) is only accessible in privileged modes, which a Secure EL0 application won't be able to access. The only way to get that value (or a value that means something to the OS, at least) is to use an SVC call into the Trusted OS, and have it give you the response (which is what sched_getgpu() does - on Linux, it is wired into sys_getcpuid syscall or something similarly named).

    If there's no API to do so then the question you may want to ask yourself is whether your application truly requires knowledge of the current CPU, or whether it can simply let the OS fill in the information when required (the OS should already know full-well which CPU the application runs on..)?

    Ta,

    Matt

Reply
  • shengyewan,

    If OP-TEE don't provide an API to do so, then the answer is pretty simply that you don't - the MPIDR_EL1 register that contains the multi-processor CPU identifier (i.e. it's thread, core, cluster and system topology) is only accessible in privileged modes, which a Secure EL0 application won't be able to access. The only way to get that value (or a value that means something to the OS, at least) is to use an SVC call into the Trusted OS, and have it give you the response (which is what sched_getgpu() does - on Linux, it is wired into sys_getcpuid syscall or something similarly named).

    If there's no API to do so then the question you may want to ask yourself is whether your application truly requires knowledge of the current CPU, or whether it can simply let the OS fill in the information when required (the OS should already know full-well which CPU the application runs on..)?

    Ta,

    Matt

Children
No data