Skip to content

Commit 2e21426

Browse files
anchaoAlan C. Assis
authored andcommitted
qemu-armv8a/ivshmem: add ivshmem chapter
An example implementation for OpenAMP based on the Inter-VM share memory(ivshmem):: rpproxy_ivshmem: Remote slave(client) proxy process. rpserver_ivshmem: Remote master(host) server process. Please refer to the official Qemu ivshmem documentation for more information: https://www.qemu.org/docs/master/system/devices/ivshmem.html Signed-off-by: chao an <anchao.archer@bytedance.com>
1 parent f22b93b commit 2e21426

File tree

1 file changed

+103
-0
lines changed
  • Documentation/platforms/arm64/qemu/boards/qemu-armv8a

1 file changed

+103
-0
lines changed

Documentation/platforms/arm64/qemu/boards/qemu-armv8a/README.txt

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,109 @@ Getting Started
198198
-net none -chardev stdio,id=con,mux=on -serial chardev:con \
199199
-mon chardev=con,mode=readline -kernel ./nuttx
200200

201+
Inter-VM share memory Device (ivshmem)
202+
--------------------------------------
203+
204+
Inter-VM shared memory support support can be found in ``drivers/pci/pci_ivshmem.c``.
205+
206+
This implementation is for ``ivshmem-v1`` which is compatible with QEMU and
207+
ACRN hypervisor but won't work with Jailhouse hypervisor which uses ``ivshmem-v2``.
208+
209+
Please refer to the official `Qemu ivshmem documentation
210+
<https://www.qemu.org/docs/master/system/devices/ivshmem.html>`_ for more information.
211+
212+
This is an example implementation for OpenAMP based on the Inter-VM share memory(ivshmem)::
213+
214+
rpproxy_ivshmem: Remote slave(client) proxy process.
215+
rpserver_ivshmem: Remote master(host) server process.
216+
217+
Steps for Using NuttX as IVSHMEM host and guest
218+
219+
1. Build images
220+
221+
a. Build rpserver_ivshmem::
222+
223+
$ cmake -B server -DBOARD_CONFIG=qemu-armv8a:rpserver_ivshmem -GNinja
224+
$ cmake --build server
225+
226+
b. Build rpproxy_ivshmem::
227+
228+
$ cmake -B proxy -DBOARD_CONFIG=qemu-armv8a:rpproxy_ivshmem -GNinja
229+
$ cmake --build proxy
230+
231+
2. Bringup firmware via Qemu:
232+
233+
The Inter-VM Shared Memory device basic syntax is::
234+
235+
-device ivshmem-plain,id=shmem0,memdev=shmmem-shmem0,addr=0xb \
236+
-object memory-backend-file,id=shmmem-shmem0,mem-path=/dev/shm/ivshmem0,size=4194304,share=yes
237+
238+
a. Start rpserver_ivshmem::
239+
240+
$ qemu-system-aarch64 -cpu cortex-a53 -nographic -machine virt,virtualization=on,gic-version=3 -kernel server/nuttx \
241+
-device ivshmem-plain,id=shmem0,memdev=shmmem-shmem0,addr=0xb \
242+
-object memory-backend-file,id=shmmem-shmem0,mem-path=/dev/shm/ivshmem0,size=4194304,share=yes
243+
244+
b. Start rpproxy_ivshmem::
245+
246+
$ qemu-system-aarch64 -cpu cortex-a53 -nographic -machine virt,virtualization=on,gic-version=3 -kernel proxy/nuttx \
247+
-device ivshmem-plain,id=shmem0,memdev=shmmem-shmem0,addr=0xb \
248+
-object memory-backend-file,discard-data=on,id=shmmem-shmem0,mem-path=/dev/shm/ivshmem0,size=4194304,share=yes
249+
250+
c. Check the RPMSG Syslog in rpserver shell:
251+
252+
In the current configuration, the proxy syslog will be sent to the server by default.
253+
You can check whether there is proxy startup log in the server shell.
254+
255+
RpServer bring up::
256+
257+
$ qemu-system-aarch64 -cpu cortex-a53 -nographic -machine virt,virtualization=on,gic-version=3 -kernel server/nuttx \
258+
-device ivshmem-plain,id=shmem0,memdev=shmmem-shmem0,addr=0xb \
259+
-object memory-backend-file,id=shmmem-shmem0,mem-path=/dev/shm/ivshmem0,size=4194304,share=yes
260+
[ 0.000000] [ 0] [ INFO] [server] pci_register_rptun_ivshmem_driver: Register ivshmem driver, id=0, cpuname=proxy, master=1
261+
...
262+
[ 0.033200] [ 3] [ INFO] [server] ivshmem_probe: shmem addr=0x10400000 size=4194304 reg=0x10008000
263+
[ 0.033700] [ 3] [ INFO] [server] rptun_ivshmem_probe: shmem addr=0x10400000 size=4194304
264+
265+
After rpproxy bring up, check the log from rpserver::
266+
267+
NuttShell (NSH) NuttX-10.4.0
268+
server>
269+
[ 0.000000] [ 0] [ INFO] [proxy] pci_register_rptun_ivshmem_driver: Register ivshmem driver, id=0, cpuname=server, master=0
270+
...
271+
[ 0.031400] [ 3] [ INFO] [proxy] ivshmem_probe: shmem addr=0x10400000 size=4194304 reg=0x10008000
272+
[ 0.031800] [ 3] [ INFO] [proxy] rptun_ivshmem_probe: shmem addr=0x10400000 size=4194304
273+
[ 0.033100] [ 3] [ INFO] [proxy] rptun_ivshmem_probe: Start the wdog
274+
275+
d. IPC test via RPMSG socket:
276+
277+
Start rpmsg socket server::
278+
279+
server> rpsock_server stream block test
280+
server: create socket SOCK_STREAM nonblock 0
281+
server: bind cpu , name test ...
282+
server: listen ...
283+
server: try accept ...
284+
server: Connection accepted -- 4
285+
server: try accept ...
286+
287+
Switch to proxy shell and start rpmsg socket client, test start::
288+
289+
proxy> rpsock_client stream block test server
290+
client: create socket SOCK_STREAM nonblock 0
291+
client: Connecting to server,test...
292+
client: Connected
293+
client send data, cnt 0, total len 64, BUFHEAD process0007, msg0000, name:test
294+
client recv data process0007, msg0000, name:test
295+
...
296+
client recv done, total 4096000, endflags, send total 4096000
297+
client: Terminating
298+
299+
Check the log on rpserver shell::
300+
301+
server recv data normal exit
302+
server Complete ret 0, errno 0
303+
201304
Status
202305
======
203306

0 commit comments

Comments
 (0)