OP-TEE / optee_os

Trusted side of the TEE
Other
1.56k stars 1.05k forks source link

Secure peripherals in stm32mp1 #3955

Closed gagachang closed 4 years ago

gagachang commented 4 years ago

Hello,

I have some questions about stm32mp1 platform, could you help me out? The board I have is STM32MP157C-DK2.

I found that there are some functions, such as stm32mp_register_secure_periph() in stm32_util.h. It seems that we can register some peripherals as a secure-world-only, right? If I want some I/O to be secure, such as USART3 on GPIO expansion connectors, how can I do this?

Also, I found that USART1 is configured to be secure by default, but I didn't find out the USART1 interface on the board.

Thank you first!

etienne-lms commented 4 years ago

Hello @gagachang,

Supported boards do not all expose pins that can be muxed the secure-able interfaces and not all peripheral interfaces are secure-able. For examples, only USART1 among the UARTs is secure-able: can be assigned (or not) to secure world, others are always non-secure. Check from the documentation the ETZPC support that shows which peripheral can be assigned to the secure world.

gagachang commented 4 years ago

Hi @etienne-lms

Thanks, I check the peripheral assignments from their website and same as you said. Can you help me to find out where USART1 is on the board? I have read the user manual, it only shows that USART2 is used by Bluetooth, USART3 is used by GPIO connector. Is USART1 used by ST-LINK/V2-1?

Thanks, this is my last question.

etienne-lms commented 4 years ago

I think DK2 does not expose pins that can carry USART1 bus.

gagachang commented 4 years ago

@etienne-lms , thanks.

Does stm32mp1 support configuring the clock in OP-TEE? I tried to use USART3 in the OP-TEE, although it is non-secure. I initialized and registered the USART3, the same as the OP-TEE's console does (UART4). But the CPU stalled when I call serial functions, such as serial_usart3->ops->getchar(serial_usart3). I think the reason is that linux shut down the clock of USART3 when the CPU switches to secure state. Am I correct?

etienne-lms commented 4 years ago

Your description makes sense. Indeed, Linux likely disables the clocks that are not used.

gagachang commented 4 years ago

@etienne-lms , thank you!