HSE example code on git

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

HSE example code on git

1,581件の閲覧回数
ashwini2024
Contributor II

I am currently working with the HSE APIs on the S32G3 platform and had a query regarding the use of the hse_mem_allocfunction.

From my understanding, this function is used to allocate memory space for operations, but I am concerned about its impact on memory consumption if it is called repeatedly. Could you please clarify:

  1. Is it necessary to use hse_mem_alloc every time memory is allocated for a new operation, or is there an alternative approach that avoids frequent memory allocation?
  2. How does the memory allocation mechanism of hse_mem_alloc work under the hood, and does it manage deallocation automatically, or is there a manual cleanup process required?
  3. Are there recommended practices for optimizing memory usage when working with HSE operations to avoid potential memory overhead?

Thank you in advance for your guidance!

0 件の賞賛
返信
6 返答(返信)

1,556件の閲覧回数
alejandro_e
NXP TechSupport
NXP TechSupport

Hello @ashwini2024,

Can you help me indicating where did you find that function? I have searched in the HSE M7 demo app, ARM trusted firmware, u-boot and Linux code bases and I was not able to find it.

 

Thanks in advance for the information.

0 件の賞賛
返信

1,540件の閲覧回数
ashwini2024
Contributor II
0 件の賞賛
返信

1,531件の閲覧回数
alejandro_e
NXP TechSupport
NXP TechSupport

Hello @ashwini2024,

Thanks for letting me know. About your question, to the best of my understanding, there is no way to workaround the memory allocation, this means you will need to follow the same flow as the one shown in the examples, therefore you will need to use hse_mem_alloc

Doing a surface level analysis, the logic implemented to handle memory allocation and free is similar to a liked list. However the exact details are out of my expertise. 

This function does not handle memory deallocation automatically. You will need to implement your own logic to free the memory using the function hse_mem_free. You can check the provided examples for a reference on how to use it, for instance examples/hse-encrypt/hse-encrypt.c#L172.

 

I can also recommend checking section 10.3 of the BSP40 user manual, starting at page 78:

alejandro_e_0-1736229273136.png

 

 

Let me know if this information answers your question.

0 件の賞賛
返信

1,527件の閲覧回数
ashwini2024
Contributor II

I wanted to understand if the HSE memory can get exhausted when handling multiple cryptographic operations concurrently. Are there any specific limitations or guidelines for memory usage when performing multiple HSE operations simultaneously?

0 件の賞賛
返信

1,506件の閲覧回数
alejandro_e
NXP TechSupport
NXP TechSupport

Hello @ashwini2024,

In general, like any other memory allocation it will have a limit, and if you check the funciton definition  libhse/hse-mem.c#L119 you will see there are some conditions that will cause the function to return NULL, which in general means that the memory is all used, as you can see in the examples, if the function returns NULL, the functions return error ENOMEM (Error no memory) for instance in this line hse-encrypt/hse-encrypt.c#L98. You can implement a similar mechanism to control when to stop allocating new memory.

However, by reviewing the code I am not able to conclude what is the exact limit. I will raise this question with the internal team and let you know their feedback.

 

Best regards

0 件の賞賛
返信

1,491件の閲覧回数
alejandro_e
NXP TechSupport
NXP TechSupport

Hello @ashwini2024,

I have received the following information from the internal team:

"

The function hse_mem_alloc() allocates memory from the memory space called “HSE reserved memory range”, which is defined in device tree <linux/arch/arm64/boot/dts/freescale/s32cc.dtsi> . Customer can modify the memory range according to user's requirement.

The HSE driver creates the "HSE reserved memory range” based on the device tree, The source of hse driver is <linux/drivers/uio/uio_hse.c>

For example, according to the below picture, the start address of HSE reserved memory range is 0x8400 0000 and the size is 0x100 000. So the maximum size can be allocated from  hse_mem_alloc() is 16MB.

alejandro_e_0-1736352735033.png

 

"

 

Let me know if this information fully answers your questions.

 

0 件の賞賛
返信