Write to specific memory address

Stefan Kalkowski stefan.kalkowski at ...1...
Mon Mar 30 08:45:46 CEST 2015


Hi Vincent,

On 03/27/2015 04:32 PM, Vincent Raes wrote:
> Hello,
> 
> Thanks for the advice, it helped a lot. I was indeed confused with the
> virtual memory since I could
> I have another question, this time involving the tz_vmm itself. In mmu.h
> there is a function which should translate a virtual address of the
> normal world to a physical address in the secure world.
> However this function only returns 0 due to the ram.h throwing an
> invalid address when he gets called on by mmu.h. Could this be because
> I'm using a different kernel in the normal world/ different board so
> that mmu.h does not translate the addresses correctly?

These small helper functions in mmu.h are used to decode register values
of the normal world that potentially contain virtual addresses to
physical ones. Thereby it is assumed the guest OS uses the short
translation table format of the ARM v7 architecture. If a given address
is not found in the page tables, or if the guest OS did not setup the
page tables yet (MMU ist still off) you will get a zero as return value.

Regards
Stefan

> 
> Best regards,
> Vincent
> 
> 2015-03-23 9:27 GMT+01:00 Stefan Kalkowski
> <stefan.kalkowski at ...1...
> <mailto:stefan.kalkowski at ...1...>>:
> 
>     Hello Vincent,
> 
>     On 03/20/2015 11:40 AM, Vincent Raes wrote:
>     > Hello,
>     >
>     > I am working with TrustZone using Genode and I am trying to pass data
>     > from the secure world to the normal world and vice versa. The problem
>     > lies with the fact that the normal world can only access a certain
>     part
>     > of the RAM memory the board has to offer so all the data I want to
>     give
>     > to the normal world has to be placed somewhere it can access. And I
>     > can't seem to figure out how to place data at a specific address using
>     > Genode.
>     >
>     > When I try to use pointers to the wanted memory location, the
>     error "No
>     > RM attachment" keeps popping up. This may very well be caused by the
>     > fact I am using a pointer to a place that does not yet has a valid
>     data
>     > object in it. I believe the correct answer has something to do
>     with the
>     > use of dataspaces but am not sure how or what kind of dataspace I need
>     > to use for random data I generate myself.
> 
>     To me it seems you first have to understand the difference between
>     virtual memory and physical memory. When using memory addresses in a
>     normal application (and even mostly in the kernel) you are dealing with
>     virtual memory addresses that are translated in hardware via the MMU to
>     physical memory addresses. If you target a memory region that does not
>     relate to a valid translation entry in the translation table of the
>     process, you will get a translation fault. That is what you see with the
>     message "No RM attachment". In Genode the RM session is used to
>     administrate the virtual memory address space of a process.
> 
>     In contrast to that: the bus system, and the memory controller are
>     dealing with physical memory addresses, and probably the TrustZone
>     component that splits the memory in normal and secure one too. If you
>     say that the normal world can access only a specific portion of RAM, you
>     speak about a physical address range.
> 
>     Your intuition was right: in Genode a portion of RAM is abstracted by a
>     dataspace. In general a RAM dataspace is just an anonymous amount of
>     RAM, where you do cannot determine its location in physical memory when
>     allocating it. In contrast to a RAM dataspace, you can also use an IOMEM
>     session to request a specific dataspace, normally used for memory-mapped
>     I/O regions of devices. When allocating an IOMEM region of course you
>     can and have to specify the actual physical location. So in your case,
>     the only possibility to deposit data at a specific RAM location for the
>     normal world is to open up an IOMEM session, and attach its dataspace to
>     the RM session of your application.
> 
>     BTW: the same was done in our TrustZone example virtual machine monitor
>     implmentation (repos/os/src/server/tz_vmm).
> 
>     Regards
>     Stefan
> 
>     >
>     > Thanks in advance for any advice.
>     >
>     > Best regards,
>     > Vincent
>     >
>     >
>     >
>     ------------------------------------------------------------------------------
>     > Dive into the World of Parallel Programming The Go Parallel
>     Website, sponsored
>     > by Intel and developed in partnership with Slashdot Media, is your
>     hub for all
>     > things parallel software development, from weekly thought
>     leadership blogs to
>     > news, videos, case studies, tutorials and more. Take a look and
>     join the
>     > conversation now. http://goparallel.sourceforge.net/
>     >
>     >
>     >
>     > _______________________________________________
>     > genode-main mailing list
>     > genode-main at lists.sourceforge.net
>     <mailto:genode-main at lists.sourceforge.net>
>     > https://lists.sourceforge.net/lists/listinfo/genode-main
>     >
> 
>     --
>     Stefan Kalkowski
>     Genode Labs
> 
>     http://www.genode-labs.com/ · http://genode.org/
> 
>     ------------------------------------------------------------------------------
>     Dive into the World of Parallel Programming The Go Parallel Website,
>     sponsored
>     by Intel and developed in partnership with Slashdot Media, is your
>     hub for all
>     things parallel software development, from weekly thought leadership
>     blogs to
>     news, videos, case studies, tutorials and more. Take a look and join the
>     conversation now. http://goparallel.sourceforge.net/
>     _______________________________________________
>     genode-main mailing list
>     genode-main at lists.sourceforge.net
>     <mailto:genode-main at lists.sourceforge.net>
>     https://lists.sourceforge.net/lists/listinfo/genode-main
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the 
> conversation now. http://goparallel.sourceforge.net/
> 
> 
> 
> _______________________________________________
> genode-main mailing list
> genode-main at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/genode-main
> 

-- 
Stefan Kalkowski
Genode Labs

http://www.genode-labs.com/ · http://genode.org/




More information about the users mailing list