This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

struggling with secure exit on C6748

Hi,

i am using SecureHexAIS_OMAP_L138.exe to generate a secure exit .bin file. My main() looks like

rv = SK_registerSCWP(&scw, 1); // returns &scw

scw = SK_allocSC((unsigned)&_stack, (unsigned)&_stack + MY_STACK_SIZE); // returns 0

SK_switchNonSec((void *) (unsigned) &my_main);

I noticed that when I probe the stack pointer with __cursp(), it will be at a correct location (i.e. 0x1182a720) before SK_switchNonSec and at 0xF0680 after (this is in L1D Cache). My program runs in the upper 192kB of L2-Cache, lower 64k are not touched.

1. How can I prevent that?

2. I might force the stack pointer to a valid address in my_main. I do not use a operating system, the program will never return to that point and interrupts are not yet active. Could anything go wrong?

3. In many of the examples (i.e. in sprugq9, "Example 5. setUserKey() Function"), there is code like

stackBottom = (uint32_t) &_stack;

stackEnd = stackBottom + (uint32_t) &_STACK_SIZE;

scw = SK_allocSC(stackBottom, stackEnd);

Why are two adresses added?

 

Thanks for your help,

Bernhard

  • Hi Bernhard,

    The SK_allocSC API does require the correct start and the end address of the stack you are trying to set up. Did you read the value of &_stack and &_stack+MY_STACK_SIZE before the API is called? do they match up to the start address and end address of the stack that you intended to pass to the API? 

    We do have some examples of usage of Secure kernel APIs after exiting boot in secure state but I won`t be able to share this through the forums. Please accept the friend request that I have sent on the forums and I will send it over to you in a private email.

    Regards,

    Rahul