[PATCH 0/3] linux-user: Rewrite target_shmat

Richard Henderson posted 3 patches 9 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20240223030309.458451-1-richard.henderson@linaro.org
Maintainers: Laurent Vivier <laurent@vivier.eu>
There is a newer version of this series
linux-user/loongarch64/target_syscall.h |   7 --
linux-user/mmap.c                       | 146 ++++++++++++++++++------
linux-user/strace.c                     |  23 ++++
linux-user/strace.list                  |   2 +-
4 files changed, 134 insertions(+), 44 deletions(-)
[PATCH 0/3] linux-user: Rewrite target_shmat
Posted by Richard Henderson 9 months, 1 week ago
There are multiple issues with the implementation of shmat().

(1) With reserved_va, which is the default for 32-on-64-bit, we mmap the
    entire guest address space.  Unlike mmap, shmat refuses to replace an
    existing mapping without setting SHM_REMAP.  This is the original
    subject of issue #115, though it quicky gets distracted by
    something else.

(2) With target page size > host page size, and a shm area
    that is not a multiple of the target page size, we leave
    an unmapped hole that the target expects to be mapped.
    This is the subject of 

	https://lore.kernel.org/qemu-devel/2no4imvz2zrar5kchz2l3oddqbgpj77jgwcuf7aritkn2ok763@i2mvpcihztho/

    wherein qemu itself expects a mapping to exist, and
    dies in open_self_maps_2.

So: reimplement the thing.

There are a number of target page size != host page size and
target SHMLBA != host SHMLBA corner cases that are not implementable
without softmmu and a non-linear host to target address space.
I simply bail out in these situations and return EINVAL.

Based-on: <20240222204323.268539-1-richard.henderson@linaro.org>
("[PULL 00/39] tcg and linux-user patch queue")


r~


Richard Henderson (3):
  linux-user/loongarch64: Remove TARGET_FORCE_SHMLBA
  linux-user: Add strace for shmat
  linux-user: Rewrite target_shmat

 linux-user/loongarch64/target_syscall.h |   7 --
 linux-user/mmap.c                       | 146 ++++++++++++++++++------
 linux-user/strace.c                     |  23 ++++
 linux-user/strace.list                  |   2 +-
 4 files changed, 134 insertions(+), 44 deletions(-)

-- 
2.34.1