mbox series

[RFC,v4,00/11] Native Library Calls

Message ID 20230808141739.3110740-1-fufuyqqqqqq@gmail.com
Headers show
Series Native Library Calls | expand

Message

Yeqi Fu Aug. 8, 2023, 2:17 p.m. UTC
Executing a program under QEMU's user mode subjects the entire
program, including all library calls, to translation. It's important
to understand that many of these library functions are optimized
specifically for the guest architecture. Therefore, their
translation might not yield the most efficient execution.

When the semantics of a library function are well defined, we can
capitalize on this by substituting the translated version with a call
to the native equivalent function.

To achieve tangible results, focus should be given to functions such
as memory-related ('mem*') and string-related ('str*') functions.
These subsets of functions often have the most significant effect
on overall performance, making them optimal candidates for
optimization.

Yeqi Fu (11):
  build: Implement logic for sharing cross-building config files
  build: Implement libnative library and the build machinery for
    libnative
  linux-user: Implement envlist_appendenv and add tests for envlist
  linux-user: Implement native-bypass option support
  linux-user/elfload: Add support for parsing symbols of native
    libraries.
  tcg: Add tcg opcodes and helpers for native library calls
  target/i386: Add support for native library calls
  target/mips: Add support for native library calls
  target/arm: Add support for native library calls
  tests/tcg/multiarch: Add nativecall.c test
  docs/user: Add doc for native library calls

 Makefile                                |   2 +
 accel/tcg/tcg-runtime.h                 |  22 ++++
 common-user/native/Makefile.include     |   9 ++
 common-user/native/Makefile.target      |  22 ++++
 common-user/native/libnative.c          |  67 ++++++++++++
 configs/targets/aarch64-linux-user.mak  |   1 +
 configs/targets/arm-linux-user.mak      |   1 +
 configs/targets/i386-linux-user.mak     |   1 +
 configs/targets/mips-linux-user.mak     |   1 +
 configs/targets/mips64-linux-user.mak   |   1 +
 configs/targets/x86_64-linux-user.mak   |   1 +
 configure                               |  96 ++++++++++++----
 docs/user/index.rst                     |   1 +
 docs/user/native_calls.rst              |  90 +++++++++++++++
 include/native/libnative.h              |   8 ++
 include/native/native.h                 |   9 ++
 include/qemu/envlist.h                  |  13 +++
 include/tcg/tcg-op-common.h             |  11 ++
 include/tcg/tcg.h                       |   9 ++
 linux-user/elfload.c                    |  85 +++++++++++++-
 linux-user/main.c                       |  38 +++++++
 target/arm/tcg/translate-a64.c          |  14 +++
 target/arm/tcg/translate.c              |  11 ++
 target/i386/tcg/translate.c             |  27 +++++
 target/mips/tcg/translate.c             |  21 +++-
 tcg/tcg-op.c                            | 140 ++++++++++++++++++++++++
 tests/tcg/multiarch/Makefile.target     |  17 +++
 tests/tcg/multiarch/native/nativecall.c |  98 +++++++++++++++++
 tests/unit/meson.build                  |   1 +
 tests/unit/test-envlist.c               |  94 ++++++++++++++++
 util/envlist.c                          |  71 ++++++++++--
 31 files changed, 943 insertions(+), 39 deletions(-)
 create mode 100644 common-user/native/Makefile.include
 create mode 100644 common-user/native/Makefile.target
 create mode 100644 common-user/native/libnative.c
 create mode 100644 docs/user/native_calls.rst
 create mode 100644 include/native/libnative.h
 create mode 100644 include/native/native.h
 create mode 100644 tests/tcg/multiarch/native/nativecall.c
 create mode 100644 tests/unit/test-envlist.c