Access Host(O/S)-Ram from Epiphany via DMA

Any technical questions about the Epiphany chip and Parallella HW Platform.

Moderator: aolofsson

Access Host(O/S)-Ram from Epiphany via DMA

Postby moses_rotesmeer » Tue May 23, 2017 11:16 pm

Hi all,
I would like to access an arbitrary address withing the O/S RAM (not the shared ram partition but the actual os-ram) from the Epiphany core via a DMA access.
What I've found so far, is that apparently
"The Zync maps the address used by the Epiphany (row,col) onto the address of the 32Mb shared memory"

Source: http://www.parallella.org/forums/viewto ... =23&t=1906
Does that mean it's not possible without changes of the Hardware configuration - or do I just have to somehow calculate the correct address?
If it is possible, does anybody have a minimal example how to do a DMA read from the epiphany core?

Thank you and best,
moses
moses_rotesmeer
 
Posts: 13
Joined: Fri Aug 08, 2014 9:52 pm

Re: Access Host(O/S)-Ram from Epiphany via DMA

Postby sebraa » Mon May 29, 2017 12:10 pm

The Epiphany can only access the 32 MB shared memory area directly. Officially.

However, if the Epiphany chip accesses an off-chip address and that access goes out on the correct eLink interface, then it will go directly into the physical memory of the ARM host. I once did a proof-of-concept showing that, but I wouldn't recommend going this route. Keep in mind that these kind of accesses basically bypass any security measurements, ARM caches and Linux memory management simultaneously. Getting this to work reliably definitely requires more understanding than I have. Don't do it.
sebraa
 
Posts: 495
Joined: Mon Jul 21, 2014 7:54 pm

Re: Access Host(O/S)-Ram from Epiphany via DMA

Postby moses_rotesmeer » Mon May 29, 2017 12:37 pm

Ok, thank you for your response. I understand that this Access would bypass e.g the Linux memory Protection. However, I'm actually tring to access some bss section of a program running in linux, without any awareness of this by either linux or the program and also by avoiding interference/modification of this program. I thought using a DMA Acces from the Epiphany core to the main memory might be the best solution for this requirement. Any other suggestions to achieve this are highly appreciated :-)
moses_rotesmeer
 
Posts: 13
Joined: Fri Aug 08, 2014 9:52 pm

Re: Access Host(O/S)-Ram from Epiphany via DMA

Postby polas » Mon May 29, 2017 1:44 pm

moses_rotesmeer wrote:I'm actually tring to access some bss section of a program running in linux, without any awareness of this by either linux or the program and also by avoiding interference/modification of this program


The launcher program (i.e. the one that launches the ELF on the Epiphany) or any program running on the host? One approach would be to run a thread on the host listening to specific shared memory locations, the code running on the Epiphany could write the required data & target into shared memory which is then picked up by this host thread and written elsewhere in the host main memory.

Nick
polas
 
Posts: 46
Joined: Thu Mar 05, 2015 9:41 pm

Re: Access Host(O/S)-Ram from Epiphany via DMA

Postby moses_rotesmeer » Mon May 29, 2017 2:06 pm

Any program on the host.
Btw. I only need to read from the main-memory (not to write)
Thank you for your suggestion, I considered a similar approach, however, I thought a direct access from the epiphany cores is preferred since I could safe a memcopy from main-mem to shared mem first.
From the ARM/Linux perspective the access should be as invisible/non-intrusive as possible (including as little overhead on the host system (ARM) as possible).
That's another reason why I considered the DMA as my preferred solution in this scenario.
moses_rotesmeer
 
Posts: 13
Joined: Fri Aug 08, 2014 9:52 pm

Re: Access Host(O/S)-Ram from Epiphany via DMA

Postby sebraa » Tue May 30, 2017 7:20 am

Hi,

the Epiphany can directly access Linux' physical memory by just reading and writing through pointers; there is no need to use any DMA engines. At least, this was the state when I tried it (see the attached file), I do not know if this works with the current images. I have not tested the code now.

Keep in mind that these direct accesses bypass any caches, so the Epiphany may read stale data, and writes may not be noticed by the application. Getting this to work reliable may require some evil invalidation magic. Also, the Epiphany may be able to directly access some of the ARM peripheral registers (i.e. interrupt controller and such), but the same reservations apply there.

Another thing to consider is that finding the physical memory page of a running Linux application is tricky (think of ASLR), and may change at any time (think of swapping). Also, the routing algorithm employed by the Epiphany strictly routes by addresses, and only one of the eLink interfaces is actually connected to the Zynq. This means that large areas of the address space are not reachable from the Epiphany chip at all.

Best of luck,
sebraa
Attachments
host-dma.tar
host direct access, proof-of-concept
(20 KiB) Downloaded 439 times
sebraa
 
Posts: 495
Joined: Mon Jul 21, 2014 7:54 pm

Re: Access Host(O/S)-Ram from Epiphany via DMA

Postby moses_rotesmeer » Tue May 30, 2017 8:34 am

thank you, that helps me a lot.
Ok, it's going to be tricky, but otherwise it wouldn't be fun, would it? :D
best,
moses
moses_rotesmeer
 
Posts: 13
Joined: Fri Aug 08, 2014 9:52 pm


Return to Epiphany and Parallella Q & A

Who is online

Users browsing this forum: No registered users and 2 guests

cron