mbox series

[v2,00/11] Fix 32-bit build for plugins

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

Message

Pierrick Bouvier Dec. 17, 2024, 10:38 p.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).

v2:
- do not modify qemu_plugin_insn_haddr signature
- fix cache plugin to use a correct hash/equal function

Pierrick Bouvier (11):
  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 +--------------
 contrib/plugins/cache.c       | 18 +++++--------
 contrib/plugins/cflow.c       | 17 ++++++++-----
 contrib/plugins/hotblocks.c   | 29 +++++++++++++++++----
 contrib/plugins/hotpages.c    |  6 ++---
 contrib/plugins/howvec.c      |  7 ++---
 contrib/plugins/hwprofile.c   | 27 ++++++++++++--------
 contrib/plugins/stoptrigger.c | 48 ++++++++++++++++++++---------------
 tests/tcg/plugins/insn.c      |  4 +--
 tests/tcg/plugins/mem.c       |  6 ++---
 tests/tcg/plugins/syscall.c   |  6 ++---
 11 files changed, 99 insertions(+), 90 deletions(-)

Comments

Pierrick Bouvier Dec. 17, 2024, 10:43 p.m. UTC | #1
On 12/17/24 14:38, Pierrick Bouvier wrote:
> 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).
> 
> v2:
> - do not modify qemu_plugin_insn_haddr signature
> - fix cache plugin to use a correct hash/equal function
> 
> Pierrick Bouvier (11):
>    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 +--------------
>   contrib/plugins/cache.c       | 18 +++++--------
>   contrib/plugins/cflow.c       | 17 ++++++++-----
>   contrib/plugins/hotblocks.c   | 29 +++++++++++++++++----
>   contrib/plugins/hotpages.c    |  6 ++---
>   contrib/plugins/howvec.c      |  7 ++---
>   contrib/plugins/hwprofile.c   | 27 ++++++++++++--------
>   contrib/plugins/stoptrigger.c | 48 ++++++++++++++++++++---------------
>   tests/tcg/plugins/insn.c      |  4 +--
>   tests/tcg/plugins/mem.c       |  6 ++---
>   tests/tcg/plugins/syscall.c   |  6 ++---
>   11 files changed, 99 insertions(+), 90 deletions(-)
> 

Forgot to include reviewed-by from v1, please ignore and look at v3 instead.

Thanks,
Pierrick