mbox series

[00/13] Fix 32-bit build for plugins

Message ID 20241217010707.2557258-1-pierrick.bouvier@linaro.org
Headers show
Series Fix 32-bit build for plugins | expand

Message

Pierrick Bouvier Dec. 17, 2024, 1:06 a.m. UTC
Since 9.2.0 release, we are building contrib plugins using the QEMU build system
(before, it was external makefiles). When building for 32-bit host platform,
some warnings are triggered and build fail.

Thus, at the time, the decision was to not fix those plugins, and
disable by default plugins for 32-bit host platforms (see cf2a78cb).

This series fix plugins to have the same behaviour on 32-bit and 64-bit
platform, and reenable plugins for 32-bit platforms.

There are two portability issues:
- we use hash tables, and use data as key directly. As key has a pointer size,
  it limits its size for 32-bit platform.
  The fix is to use pointer as a key, and point to allocated 64-bit data. The
  change is pretty straightforward for concerned plugins, and does not imply a
  memory overhead, as hash table entry is already heap allocated usually.
- we use plugins callback data to pass a pc. This does not work on 32-bit
  platform, as we are limited to a pointer size.
  To avoid doing memory allocations, we simply we simply use
  inline operations and a scoreboard to achieve the same result.

Tested (for every plugin modified) on i686 and x86_64.
The behaviour before and after this series was checked as well, and there is no
difference, apart from bug fixing (some pc were clipped at 32-bit values, even
on the 64-bit platform).

Pierrick Bouvier (13):
  plugins: change signature of qemu_plugin_insn_haddr
  plugins: bump API version
  tests/tcg/plugins/insn: remove unused callback parameter
  contrib/plugins/howvec: ensure we don't regress if this plugin is
    extended
  tests/tcg/plugins/syscall: fix 32-bit build
  tests/tcg/plugins/mem: fix 32-bit build
  contrib/plugins/stoptrigger: fix 32-bit build
  contrib/plugins/cache: fix 32-bit build
  contrib/plugins/hotblocks: fix 32-bit build
  contrib/plugins/cflow: fix 32-bit build
  contrib/plugins/hwprofile: fix 32-bit build
  contrib/plugins/hotpages: fix 32-bit build
  configure: reenable plugins by default for 32-bit hosts

 configure                     | 21 +--------------
 include/qemu/qemu-plugin.h    |  8 ++++--
 plugins/plugin.h              |  2 +-
 contrib/plugins/cache.c       | 18 +++++--------
 contrib/plugins/cflow.c       | 17 ++++++++-----
 contrib/plugins/hotblocks.c   |  8 +++---
 contrib/plugins/hotpages.c    |  6 ++---
 contrib/plugins/howvec.c      |  7 ++---
 contrib/plugins/hwprofile.c   | 27 ++++++++++++--------
 contrib/plugins/stoptrigger.c | 48 ++++++++++++++++++++---------------
 plugins/api.c                 | 12 ++++-----
 tests/tcg/plugins/insn.c      |  4 +--
 tests/tcg/plugins/mem.c       |  6 ++---
 tests/tcg/plugins/syscall.c   |  6 ++---
 14 files changed, 93 insertions(+), 97 deletions(-)