Skip to contentSkip to conversation

deprecation: don't enable TCG plugins by default on 32 bit hosts

RFC PATCH In review Alex Bennée 3 participants 3 messages Sep 5, 2024

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 deprecation: don't enable TCG plugins by default on 32 bit hosts

The existing plugins already liberally use host pointer stuffing for passing user data which will fail when doing 64 bit guests on 32 bit hosts. We should discourage this by officially deprecating support and adding another nail to the 32 bit host coffin.

---
 docs/about/deprecated.rst | 11 +++++++++++
 configure                 | 11 ++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)
docs/about/deprecated.rst +11 -0
index 88f0f03786..8a4e249717 100644
@@ -184,6 +184,17 @@ be an effective use of its limited resources, and thus intends to discontinue
 it. Since all recent x86 hardware from the past >10 years is capable of the
 64-bit x86 extensions, a corresponding 64-bit OS should be used instead.
 
+TCG Plugin support not enabled by default on 32-bit hosts (since 9.2)
+'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+While it is still possible to enable TCG plugin support for 32-bit
+hosts there are a number of potential pitfalls when instrumenting
+64-bit guests. The plugin APIs typically pass most addresses as
+uint64_t but practices like encoding that address in a host pointer
+for passing as user-data will loose data. As most software analysis
+benefits from having plenty of host memory it seems reasonable to
+encourage users to use 64 bit builds of QEMU for analysis work
+whatever targets they are instrumenting.
 
 System emulator CPUs
 --------------------
configure +10 -1
index d08b71f14b..8acb311527 100755
@@ -424,6 +424,7 @@ fi
 # Note that this case should only have supported host CPUs, not guests.
 # Please keep it sorted and synchronized with meson.build's host_arch.
 host_arch=
+host_bits=64
 linux_arch=
 case "$cpu" in
   aarch64)
@@ -434,12 +435,14 @@ case "$cpu" in
   armv*b|armv*l|arm)
     cpu=arm
     host_arch=arm
+    host_bits=32
     linux_arch=arm
     ;;
 
   i386|i486|i586|i686)
     cpu="i386"
     host_arch=i386
+    host_bits=32
     linux_arch=x86
     CPU_CFLAGS="-m32"
     ;;
@@ -458,11 +461,13 @@ case "$cpu" in
   mips*)
     cpu=mips
     host_arch=mips
+    host_bits=32
     linux_arch=mips
     ;;
 
   ppc)
     host_arch=ppc
+    host_bits=32
     linux_arch=powerpc
     CPU_CFLAGS="-m32"
     ;;
@@ -480,11 +485,13 @@ case "$cpu" in
 
   riscv32 | riscv64)
     host_arch=riscv
+    host_bits=32
     linux_arch=riscv
     ;;
 
   s390)
     linux_arch=s390
+    host_bits=32
     CPU_CFLAGS="-m31"
     ;;
   s390x)
@@ -495,6 +502,7 @@ case "$cpu" in
 
   sparc|sun4[cdmuv])
     cpu=sparc
+    host_bits=32
     CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
     ;;
   sparc64)
@@ -505,6 +513,7 @@ case "$cpu" in
   x32)
     cpu="x86_64"
     host_arch=x86_64
+    host_bits=32
     linux_arch=x86
     CPU_CFLAGS="-mx32"
     ;;
@@ -1028,7 +1037,7 @@ if test "$static" = "yes" ; then
   fi
   plugins="no"
 fi
-if test "$plugins" != "no"; then
+if test "$plugins" != "no" && test host_bits = 64; then
   plugins=yes
   subdirs="$subdirs contrib/plugins"
 fi
Signature · 1 line
2.39.2
#1 lore raw
Quoted 18 lines · Alex Bennée

The existing plugins already liberally use host pointer stuffing for passing user data which will fail when doing 64 bit guests on 32 bit hosts. We should discourage this by officially deprecating support and adding another nail to the 32 bit host coffin.

---
 docs/about/deprecated.rst | 11 +++++++++++
 configure                 | 11 ++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)
docs/about/deprecated.rst +0 -0
index 88f0f03786..8a4e249717 100644
@@ -184,6 +184,17 @@ be an effective use of its limited resources, and thus intends to discontinue
 it. Since all recent x86 hardware from the past >10 years is capable of the

docs/about/deprecated.rst be an effective use of its limited resources, and thus intends to discontinue · line 194

Quoted 10 lines
docs/about/deprecated.rst +8 -0
 64-bit x86 extensions, a corresponding 64-bit OS should be used instead.
 
+TCG Plugin support not enabled by default on 32-bit hosts (since 9.2)
+'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+While it is still possible to enable TCG plugin support for 32-bit
+hosts there are a number of potential pitfalls when instrumenting
+64-bit guests. The plugin APIs typically pass most addresses as
+uint64_t but practices like encoding that address in a host pointer
+for passing as user-data will loose data. As most software analysis

"lose"

Quoted 22 lines
docs/about/deprecated.rst +3 -0
+benefits from having plenty of host memory it seems reasonable to
+encourage users to use 64 bit builds of QEMU for analysis work
+whatever targets they are instrumenting.
 
 
configure +2 -0
index d08b71f14b..8acb311527 100755
@@ -424,6 +424,7 @@ fi
 # Note that this case should only have supported host CPUs, not guests.
 # Please keep it sorted and synchronized with meson.build's host_arch.
 host_arch=
+host_bits=64
 linux_arch=
 case "$cpu" in
   aarch64)
@@ -434,12 +435,14 @@ case "$cpu" in
   armv*b|armv*l|arm)
     cpu=arm
     host_arch=arm
+    host_bits=32

configure case "$cpu" in · line 448

Quoted 10 lines
configure +1 -0
     linux_arch=arm
     ;;
 
   i386|i486|i586|i686)
     cpu="i386"
     host_arch=i386
+    host_bits=32
     linux_arch=x86
     CPU_CFLAGS="-m32"
     ;;

This is pretty awkward. We should only put stuff into this "switch per CPU architecture" where we absolutely cannot automatically determine it. Host bitness can be automatically determined (see what the compiler has set __SIZEOF_POINTER__ to), so we should do that.

thanks
-- PMM

#2 lore raw
In reply to Alex Bennée
Quoted 13 lines · Alex Bennée

The existing plugins already liberally use host pointer stuffing for passing user data which will fail when doing 64 bit guests on 32 bit hosts. We should discourage this by officially deprecating support and adding another nail to the 32 bit host coffin.

---
  docs/about/deprecated.rst | 11 +++++++++++
  configure                 | 11 ++++++++++-
  2 files changed, 21 insertions(+), 1 deletion(-)

configure case "$cpu" in · line 486

Quoted 2 lines
configure +0 -0
@@ -480,11 +485,13 @@ case "$cpu" in
 
    riscv32 | riscv64)

We need to split the riscv64 case.

Quoted 4 lines
configure +1 -0
      host_arch=riscv
+    host_bits=32
      linux_arch=riscv
      ;;