[RFC PATCH v2 0/9] Add an interVM memory sharing device

i.kotrasinsk@partner.samsung.com posted 9 patches 4 years, 3 months ago
Test docker-quick@centos7 passed
Test FreeBSD passed
Test docker-mingw@fedora failed
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1580895185-24341-1-git-send-email-i.kotrasinsk@partner.samsung.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, Thomas Huth <thuth@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Michael S. Tsirkin" <mst@redhat.com>, Richard Henderson <rth@twiddle.net>, Igor Mammedov <imammedo@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Laurent Vivier <lvivier@redhat.com>
There is a newer version of this series
Kconfig.host                            |   3 +
MAINTAINERS                             |  13 +
Makefile                                |   1 +
backends/hostmem-memfd.c                |   2 +-
configure                               |   8 +
docs/specs/memexpose-spec.txt           | 168 +++++++++
exec.c                                  |  10 +-
hw/arm/virt.c                           | 110 +++++-
hw/core/numa.c                          |   4 +-
hw/mem/Kconfig                          |   3 +
hw/misc/Makefile.objs                   |   1 +
hw/misc/ivshmem.c                       |   3 +-
hw/misc/memexpose/Makefile.objs         |   4 +
hw/misc/memexpose/memexpose-core.c      | 630 ++++++++++++++++++++++++++++++++
hw/misc/memexpose/memexpose-core.h      | 109 ++++++
hw/misc/memexpose/memexpose-memregion.c | 142 +++++++
hw/misc/memexpose/memexpose-memregion.h |  41 +++
hw/misc/memexpose/memexpose-msg.c       | 261 +++++++++++++
hw/misc/memexpose/memexpose-msg.h       | 161 ++++++++
hw/misc/memexpose/memexpose-pci.c       | 218 +++++++++++
include/exec/memory.h                   |  21 ++
include/exec/ram_addr.h                 |   2 +-
include/hw/arm/virt.h                   |   5 +
include/qemu/mmap-alloc.h               |   1 +
memory.c                                |  82 ++++-
tests/qtest/Makefile.include            |   2 +
tests/qtest/memexpose-test.c            | 364 ++++++++++++++++++
util/mmap-alloc.c                       |   7 +-
util/oslib-posix.c                      |   2 +-
29 files changed, 2362 insertions(+), 16 deletions(-)
create mode 100644 docs/specs/memexpose-spec.txt
create mode 100644 hw/misc/memexpose/Makefile.objs
create mode 100644 hw/misc/memexpose/memexpose-core.c
create mode 100644 hw/misc/memexpose/memexpose-core.h
create mode 100644 hw/misc/memexpose/memexpose-memregion.c
create mode 100644 hw/misc/memexpose/memexpose-memregion.h
create mode 100644 hw/misc/memexpose/memexpose-msg.c
create mode 100644 hw/misc/memexpose/memexpose-msg.h
create mode 100644 hw/misc/memexpose/memexpose-pci.c
create mode 100644 tests/qtest/memexpose-test.c
[RFC PATCH v2 0/9] Add an interVM memory sharing device
Posted by i.kotrasinsk@partner.samsung.com 4 years, 3 months ago
From: Igor Kotrasinski <i.kotrasinsk@partner.samsung.com>

This patchset adds a "memory exposing" device that allows two QEMU
instances to share arbitrary memory regions. Unlike ivshmem, it does not
create a new region of memory that's shared between VMs, but instead
allows one VM to access any memory region of the other VM we choose to
share.

The motivation for this device is a sort of ARM Trustzone "emulation",
where a rich system running on one machine (e.g. x86_64 linux) is able
to perform SMCs to a trusted system running on another (e.g. OpTEE on
ARM). With a device that allows sharing arbitrary memory between VMs,
this can be achieved with minimal changes to the trusted system and its
linux driver while allowing the rich system to run on a speedier x86
emulator. I prepared additional patches for linux, OpTEE OS and OpTEE
build system as a PoC that such emulation works and passes OpTEE tests;
I'm not sure what would be the best way to share them.

This patchset is my first foray into QEMU source code and I'm certain
it's not yet ready to be merged in. I'm not sure whether memory sharing
code has any race conditions or breaks rules of working with memory
regions, or if having VMs communicate synchronously via chardevs is the
right way to do it. I do believe the basic idea for sharing memory
regions is sound and that it could be useful for inter-VM communication.

Changes in v2:
- Fixed patchew errors.
- Rebased on master.

Igor Kotrasinski (9):
  memory: Add function for finding flat memory ranges
  memory: Support mmap offset for fd-backed memory regions
  memory: Hack - use shared memory when possible
  hw/misc/memexpose: Add documentation
  hw/misc/memexpose: Add core memexpose files
  hw/misc/memexpose: Add memexpose pci device
  hw/misc/memexpose: Add memexpose memory region device
  hw/misc/memexpose: Add simple tests
  hw/arm/virt: Hack in support for memexpose device

 Kconfig.host                            |   3 +
 MAINTAINERS                             |  13 +
 Makefile                                |   1 +
 backends/hostmem-memfd.c                |   2 +-
 configure                               |   8 +
 docs/specs/memexpose-spec.txt           | 168 +++++++++
 exec.c                                  |  10 +-
 hw/arm/virt.c                           | 110 +++++-
 hw/core/numa.c                          |   4 +-
 hw/mem/Kconfig                          |   3 +
 hw/misc/Makefile.objs                   |   1 +
 hw/misc/ivshmem.c                       |   3 +-
 hw/misc/memexpose/Makefile.objs         |   4 +
 hw/misc/memexpose/memexpose-core.c      | 630 ++++++++++++++++++++++++++++++++
 hw/misc/memexpose/memexpose-core.h      | 109 ++++++
 hw/misc/memexpose/memexpose-memregion.c | 142 +++++++
 hw/misc/memexpose/memexpose-memregion.h |  41 +++
 hw/misc/memexpose/memexpose-msg.c       | 261 +++++++++++++
 hw/misc/memexpose/memexpose-msg.h       | 161 ++++++++
 hw/misc/memexpose/memexpose-pci.c       | 218 +++++++++++
 include/exec/memory.h                   |  21 ++
 include/exec/ram_addr.h                 |   2 +-
 include/hw/arm/virt.h                   |   5 +
 include/qemu/mmap-alloc.h               |   1 +
 memory.c                                |  82 ++++-
 tests/qtest/Makefile.include            |   2 +
 tests/qtest/memexpose-test.c            | 364 ++++++++++++++++++
 util/mmap-alloc.c                       |   7 +-
 util/oslib-posix.c                      |   2 +-
 29 files changed, 2362 insertions(+), 16 deletions(-)
 create mode 100644 docs/specs/memexpose-spec.txt
 create mode 100644 hw/misc/memexpose/Makefile.objs
 create mode 100644 hw/misc/memexpose/memexpose-core.c
 create mode 100644 hw/misc/memexpose/memexpose-core.h
 create mode 100644 hw/misc/memexpose/memexpose-memregion.c
 create mode 100644 hw/misc/memexpose/memexpose-memregion.h
 create mode 100644 hw/misc/memexpose/memexpose-msg.c
 create mode 100644 hw/misc/memexpose/memexpose-msg.h
 create mode 100644 hw/misc/memexpose/memexpose-pci.c
 create mode 100644 tests/qtest/memexpose-test.c

-- 
2.7.4


Re: [RFC PATCH v2 0/9] Add an interVM memory sharing device
Posted by no-reply@patchew.org 4 years, 3 months ago
Patchew URL: https://patchew.org/QEMU/1580895185-24341-1-git-send-email-i.kotrasinsk@partner.samsung.com/



Hi,

This series failed the docker-mingw@fedora build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#! /bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===

  CC      x86_64-softmmu/balloon.o
  CC      x86_64-softmmu/ioport.o
/tmp/qemu-test/src/memory.c: In function 'memory_region_find_flat_range_rcu':
/tmp/qemu-test/src/memory.c:2608:31: error: missing braces around initializer [-Werror=missing-braces]
     MemoryRegionSection ret = { .mr = NULL, .size = 0 };
                               ^
                                                     { }
cc1: all warnings being treated as errors
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: memory.o] Error 1
make[1]: *** Waiting for unfinished jobs....
  CC      x86_64-softmmu/qtest.o
  CC      x86_64-softmmu/memory.o
---
  CC      x86_64-softmmu/dump/win_dump.o
  CC      x86_64-softmmu/hw/block/virtio-blk.o
/tmp/qemu-test/src/memory.c: In function 'memory_region_find_flat_range_rcu':
/tmp/qemu-test/src/memory.c:2608:31: error: missing braces around initializer [-Werror=missing-braces]
     MemoryRegionSection ret = { .mr = NULL, .size = 0 };
                               ^
                                                     { }
cc1: all warnings being treated as errors
make[1]: *** [/tmp/qemu-test/src/rules.mak:69: memory.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:495: aarch64-softmmu/all] Error 2
make: *** Waiting for unfinished jobs....
make: *** [Makefile:495: x86_64-softmmu/all] Error 2
Traceback (most recent call last):
  File "./tests/docker/docker.py", line 662, in <module>
    sys.exit(main())
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=37a93e1976764c268c3476ad7cadb058', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-1j6cmboc/src/docker-src.2020-02-05-04.46.11.1417:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=37a93e1976764c268c3476ad7cadb058
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-1j6cmboc/src'
make: *** [docker-run-test-mingw@fedora] Error 2

real    10m17.870s
user    0m8.377s


The full log is available at
http://patchew.org/logs/1580895185-24341-1-git-send-email-i.kotrasinsk@partner.samsung.com/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com