mbox series

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

Message ID 20241217224306.2900490-1-pierrick.bouvier@linaro.org (mailing list archive)
Headers show
Series Fix 32-bit build for plugins | expand

Message

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

v3:
- add missing Reviewed-by tags

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

Alex Bennée Jan. 9, 2025, 11:44 a.m. UTC | #1
Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:

> 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).

Queued to plugins/next, thanks.

Although I think people trying to use plugins on 32 bit platforms are
still in for a bad time.
Pierrick Bouvier Jan. 9, 2025, 8:51 p.m. UTC | #2
On 1/9/25 03:44, Alex Bennée wrote:
> Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
> 
>> 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).
> 
> Queued to plugins/next, thanks.
> 
> Although I think people trying to use plugins on 32 bit platforms are
> still in for a bad time.
> 

Thanks, at least it will keep on compiling warning free (casts might 
still hide some problems though), which is better than nothing, 
especially when we introduce new plugins.