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

If non-secure world pass to virtual address (allocated by malloc or mmap) and ttbr value, how to find valid physical address in secure-world

First sorry my english writing level. :-)

In non-secure world using android system(linux kernel).

I use big.little core Cortex-A53, Cortex-A57

I was tested to 2case.

previous stage.

     1. Linux allocation memory using(malloc or mmap)

     2. Pass allocated memory and TTBR value to secure-world.

     3. Find mapped physical address in TTB address.

1 case.

     - Using only 1core test (linux set_sched_affinity)

     Result : Find very well 100%. (Valid physical address : 0xXXXXXXXX)

2 case.

     - No use set_sched_affinity

     Result : Some time not found (Invalid physical address : 0x0)

I think Linux no mapping page-table. but i didn't understand why 1case success.

1case testing around 1000times.

If probleam is no mapping, why didn't occured 2case situation.

I guess this probleam related page-table attribute like a shareability(inner shareable, outer shareable?) or cache? or etc.

Question.

     How to fixing this case? or I want to some advice.

thanks!

Parents
  • I'd recommend not to pass virtual addresses between the worlds. Pass only physical addresses that the secure world then has to map in. Furthermore, on the NWd sides you also have to tell the OS not so swap out or move the memory behind the virtual address while they are shared. Otherwise, the secure world may corrupt the whole memory, as it accesses different memory. So there more involved here if you want to setup shared memory than just passing a virtual address.

Reply
  • I'd recommend not to pass virtual addresses between the worlds. Pass only physical addresses that the secure world then has to map in. Furthermore, on the NWd sides you also have to tell the OS not so swap out or move the memory behind the virtual address while they are shared. Otherwise, the secure world may corrupt the whole memory, as it accesses different memory. So there more involved here if you want to setup shared memory than just passing a virtual address.

Children
  • Thanks. and more question.

    how to find physical address allocated by user space.

    I have only 3 idea.

    1. Driver mmap about kmalloc memory so get physical address using virt_to_phy function.
      1. No vmalloc vmalloc also possible swap-out (guess)
    2. User space allocation memory and driver find physical address using co-processor.
    3. Reserve some memory and communicate use this memory. some time mapping to non-sucre user space.

    do you have a any idea? Please share your idea! thanks

  • Well, all these are valid approaches for certain scenarios. It depends on the use case what to pick there.