[PATCH 05/50] *: Remove __i386__ tests

Richard Henderson posted 50 patches 2 days, 5 hours ago
Maintainers: "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Thomas Huth <thuth@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Riku Voipio <riku.voipio@iki.fi>, Stefan Hajnoczi <stefanha@redhat.com>, Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, "Daniel P. Berrangé" <berrange@redhat.com>, Stefano Stabellini <sstabellini@kernel.org>, Anthony PERARD <anthony@xenproject.org>, Paul Durrant <paul@xen.org>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, "Michael S. Tsirkin" <mst@redhat.com>, David Hildenbrand <david@kernel.org>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Peter Xu <peterx@redhat.com>, Li Zhijian <lizhijian@fujitsu.com>, Hyman Huang <yong.huang@smartx.com>, Peter Maydell <peter.maydell@linaro.org>, Helge Deller <deller@gmx.de>, Zhao Liu <zhao1.liu@intel.com>, Eduardo Habkost <eduardo@habkost.net>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Ilya Leoshkevich <iii@linux.ibm.com>, WANG Xuerui <git@xen0n.name>, Stefan Weil <sw@weilnetz.de>
[PATCH 05/50] *: Remove __i386__ tests
Posted by Richard Henderson 2 days, 5 hours ago
Remove instances of __i386__, except from tests and imported headers.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/qemu/atomic.h     |  4 ++--
 include/qemu/cacheflush.h |  2 +-
 include/qemu/osdep.h      |  4 +---
 include/qemu/processor.h  |  2 +-
 include/qemu/timer.h      |  9 ---------
 tcg/tci/tcg-target-mo.h   |  2 +-
 accel/kvm/kvm-all.c       |  2 +-
 disas/disas-host.c        |  6 ------
 hw/display/xenfb.c        | 10 +---------
 linux-user/syscall.c      |  9 ---------
 target/i386/cpu.c         | 10 ----------
 util/cacheflush.c         |  2 +-
 configure                 |  2 --
 13 files changed, 9 insertions(+), 55 deletions(-)

diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
index f80cba24cf..c39dc99f2f 100644
--- a/include/qemu/atomic.h
+++ b/include/qemu/atomic.h
@@ -204,7 +204,7 @@
  * the same semantics.
  */
 #if !defined(QEMU_SANITIZE_THREAD) && \
-    (defined(__i386__) || defined(__x86_64__) || defined(__s390x__))
+    (defined(__x86_64__) || defined(__s390x__))
 # define smp_mb__before_rmw() signal_barrier()
 # define smp_mb__after_rmw() signal_barrier()
 #else
@@ -218,7 +218,7 @@
  */
 
 #if !defined(QEMU_SANITIZE_THREAD) && \
-    (defined(__i386__) || defined(__x86_64__) || defined(__s390x__))
+    (defined(__x86_64__) || defined(__s390x__))
 # define qatomic_set_mb(ptr, i) \
     ({ (void)qatomic_xchg(ptr, i); smp_mb__after_rmw(); })
 #else
diff --git a/include/qemu/cacheflush.h b/include/qemu/cacheflush.h
index 76eb55d818..8c64b87814 100644
--- a/include/qemu/cacheflush.h
+++ b/include/qemu/cacheflush.h
@@ -19,7 +19,7 @@
  * mappings of the same physical page(s).
  */
 
-#if defined(__i386__) || defined(__x86_64__) || defined(__s390__)
+#if defined(__x86_64__) || defined(__s390__)
 
 static inline void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len)
 {
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 4cdeda0b9c..b384b5b506 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -637,9 +637,7 @@ bool qemu_has_ofd_lock(void);
 
 bool qemu_has_direct_io(void);
 
-#if defined(__HAIKU__) && defined(__i386__)
-#define FMT_pid "%ld"
-#elif defined(WIN64)
+#ifdef WIN64
 #define FMT_pid "%" PRId64
 #else
 #define FMT_pid "%d"
diff --git a/include/qemu/processor.h b/include/qemu/processor.h
index 9f0dcdf28f..95b3262f8b 100644
--- a/include/qemu/processor.h
+++ b/include/qemu/processor.h
@@ -7,7 +7,7 @@
 #ifndef QEMU_PROCESSOR_H
 #define QEMU_PROCESSOR_H
 
-#if defined(__i386__) || defined(__x86_64__)
+#if defined(__x86_64__)
 # define cpu_relax() asm volatile("rep; nop" ::: "memory")
 
 #elif defined(__aarch64__)
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index 8b561cd696..7c18da1652 100644
--- a/include/qemu/timer.h
+++ b/include/qemu/timer.h
@@ -866,15 +866,6 @@ static inline int64_t cpu_get_host_ticks(void)
     return retval;
 }
 
-#elif defined(__i386__)
-
-static inline int64_t cpu_get_host_ticks(void)
-{
-    int64_t val;
-    asm volatile ("rdtsc" : "=A" (val));
-    return val;
-}
-
 #elif defined(__x86_64__)
 
 static inline int64_t cpu_get_host_ticks(void)
diff --git a/tcg/tci/tcg-target-mo.h b/tcg/tci/tcg-target-mo.h
index 779872e39a..b5b389dafc 100644
--- a/tcg/tci/tcg-target-mo.h
+++ b/tcg/tci/tcg-target-mo.h
@@ -8,7 +8,7 @@
 #define TCG_TARGET_MO_H
 
 /*
- * We could notice __i386__ or __s390x__ and reduce the barriers depending
+ * We could notice __x86_64__ or __s390x__ and reduce the barriers depending
  * on the host.  But if you want performance, you use the normal backend.
  * We prefer consistency across hosts on this.
  */
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index f85eb42d78..8301a512e7 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -61,7 +61,7 @@
 #include <sys/eventfd.h>
 #endif
 
-#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__)
 # define KVM_HAVE_MCE_INJECTION 1
 #endif
 
diff --git a/disas/disas-host.c b/disas/disas-host.c
index 88e7d8800c..7cf432938e 100644
--- a/disas/disas-host.c
+++ b/disas/disas-host.c
@@ -44,12 +44,6 @@ static void initialize_debug_host(CPUDebug *s)
 #endif
 #if defined(CONFIG_TCG_INTERPRETER)
     s->info.print_insn = print_insn_tci;
-#elif defined(__i386__)
-    s->info.mach = bfd_mach_i386_i386;
-    s->info.cap_arch = CS_ARCH_X86;
-    s->info.cap_mode = CS_MODE_32;
-    s->info.cap_insn_unit = 1;
-    s->info.cap_insn_split = 8;
 #elif defined(__x86_64__)
     s->info.mach = bfd_mach_x86_64;
     s->info.cap_arch = CS_ARCH_X86;
diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
index 164fd0b248..ba886a940e 100644
--- a/hw/display/xenfb.c
+++ b/hw/display/xenfb.c
@@ -459,10 +459,7 @@ static int xenfb_map_fb(struct XenFB *xenfb)
          */
         uint32_t *ptr32 = NULL;
         uint32_t *ptr64 = NULL;
-#if defined(__i386__)
-        ptr32 = (void*)page->pd;
-        ptr64 = ((void*)page->pd) + 4;
-#elif defined(__x86_64__)
+#if defined(__x86_64__)
         ptr32 = ((void*)page->pd) - 4;
         ptr64 = (void*)page->pd;
 #endif
@@ -480,11 +477,6 @@ static int xenfb_map_fb(struct XenFB *xenfb)
         /* 64bit dom0, 32bit domU */
         mode = 32;
         pd   = ((void*)page->pd) - 4;
-#elif defined(__i386__)
-    } else if (strcmp(protocol, XEN_IO_PROTO_ABI_X86_64) == 0) {
-        /* 32bit dom0, 64bit domU */
-        mode = 64;
-        pd   = ((void*)page->pd) + 4;
 #endif
     }
 
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 2060e561a2..63713f1992 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7449,15 +7449,6 @@ void syscall_init(void)
                               ~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) |
                 (size << TARGET_IOC_SIZESHIFT);
         }
-
-        /* automatic consistency check if same arch */
-#if (defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)) || \
-    (defined(__x86_64__) && defined(TARGET_X86_64))
-        if (unlikely(ie->target_cmd != ie->host_cmd)) {
-            fprintf(stderr, "ERROR: ioctl(%s): target=0x%x host=0x%x\n",
-                    ie->name, ie->target_cmd, ie->host_cmd);
-        }
-#endif
         ie++;
     }
 }
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 37803cd724..0b8cca7cec 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -2251,16 +2251,6 @@ void host_cpuid(uint32_t function, uint32_t count,
                  : "=a"(vec[0]), "=b"(vec[1]),
                    "=c"(vec[2]), "=d"(vec[3])
                  : "0"(function), "c"(count) : "cc");
-#elif defined(__i386__)
-    asm volatile("pusha \n\t"
-                 "cpuid \n\t"
-                 "mov %%eax, 0(%2) \n\t"
-                 "mov %%ebx, 4(%2) \n\t"
-                 "mov %%ecx, 8(%2) \n\t"
-                 "mov %%edx, 12(%2) \n\t"
-                 "popa"
-                 : : "a"(function), "c"(count), "S"(vec)
-                 : "memory", "cc");
 #else
     abort();
 #endif
diff --git a/util/cacheflush.c b/util/cacheflush.c
index 69c9614e2c..99221a409f 100644
--- a/util/cacheflush.c
+++ b/util/cacheflush.c
@@ -225,7 +225,7 @@ static void __attribute__((constructor)) init_cache_info(void)
  * Architecture (+ OS) specific cache flushing mechanisms.
  */
 
-#if defined(__i386__) || defined(__x86_64__) || defined(__s390__)
+#if defined(__x86_64__) || defined(__s390__)
 
 /* Caches are coherent and do not require flushing; symbol inline. */
 
diff --git a/configure b/configure
index 2016062492..00e455be57 100755
--- a/configure
+++ b/configure
@@ -377,8 +377,6 @@ fi
 if test ! -z "$cpu" ; then
   # command line argument
   :
-elif check_define __i386__ ; then
-  cpu="i386"
 elif check_define __x86_64__ ; then
   if check_define __ILP32__ ; then
     cpu="x32"
-- 
2.43.0
Re: [PATCH 05/50] *: Remove __i386__ tests
Posted by Pierrick Bouvier 1 day, 14 hours ago
On 1/7/26 9:29 PM, Richard Henderson wrote:
> Remove instances of __i386__, except from tests and imported headers.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   include/qemu/atomic.h     |  4 ++--
>   include/qemu/cacheflush.h |  2 +-
>   include/qemu/osdep.h      |  4 +---
>   include/qemu/processor.h  |  2 +-
>   include/qemu/timer.h      |  9 ---------
>   tcg/tci/tcg-target-mo.h   |  2 +-
>   accel/kvm/kvm-all.c       |  2 +-
>   disas/disas-host.c        |  6 ------
>   hw/display/xenfb.c        | 10 +---------
>   linux-user/syscall.c      |  9 ---------
>   target/i386/cpu.c         | 10 ----------
>   util/cacheflush.c         |  2 +-
>   configure                 |  2 --
>   13 files changed, 9 insertions(+), 55 deletions(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Re: [PATCH 05/50] *: Remove __i386__ tests
Posted by Thomas Huth 2 days, 1 hour ago
On 08/01/2026 06.29, Richard Henderson wrote:
> Remove instances of __i386__, except from tests and imported headers.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
...
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 2060e561a2..63713f1992 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -7449,15 +7449,6 @@ void syscall_init(void)
>                                 ~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) |
>                   (size << TARGET_IOC_SIZESHIFT);
>           }
> -
> -        /* automatic consistency check if same arch */
> -#if (defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)) || \
> -    (defined(__x86_64__) && defined(TARGET_X86_64))

This looks like we should keep the x86_64 part?

> -        if (unlikely(ie->target_cmd != ie->host_cmd)) {
> -            fprintf(stderr, "ERROR: ioctl(%s): target=0x%x host=0x%x\n",
> -                    ie->name, ie->target_cmd, ie->host_cmd);
> -        }
> -#endif
>           ie++;
>       }
>   }
...
> diff --git a/configure b/configure
> index 2016062492..00e455be57 100755
> --- a/configure
> +++ b/configure
> @@ -377,8 +377,6 @@ fi
>   if test ! -z "$cpu" ; then
>     # command line argument
>     :
> -elif check_define __i386__ ; then
> -  cpu="i386"
>   elif check_define __x86_64__ ; then
>     if check_define __ILP32__ ; then
>       cpu="x32"

Aren't there some more spots in configure that could be removed now?
e.g.:

   i386|i486|i586|i686)
     cpu="i386"
     host_arch=i386
     linux_arch=x86
     CPU_CFLAGS="-m32"
     ;;

Or is this removed in a later patch?

  Thomas
Re: [PATCH 05/50] *: Remove __i386__ tests
Posted by Richard Henderson 2 days ago
On 1/8/26 20:47, Thomas Huth wrote:
> On 08/01/2026 06.29, Richard Henderson wrote:
>> Remove instances of __i386__, except from tests and imported headers.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
> ...
>> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
>> index 2060e561a2..63713f1992 100644
>> --- a/linux-user/syscall.c
>> +++ b/linux-user/syscall.c
>> @@ -7449,15 +7449,6 @@ void syscall_init(void)
>>                                 ~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) |
>>                   (size << TARGET_IOC_SIZESHIFT);
>>           }
>> -
>> -        /* automatic consistency check if same arch */
>> -#if (defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)) || \
>> -    (defined(__x86_64__) && defined(TARGET_X86_64))
> 
> This looks like we should keep the x86_64 part?
> 
>> -        if (unlikely(ie->target_cmd != ie->host_cmd)) {
>> -            fprintf(stderr, "ERROR: ioctl(%s): target=0x%x host=0x%x\n",
>> -                    ie->name, ie->target_cmd, ie->host_cmd);
>> -        }
>> -#endif

The block doesn't look worthwhile to keep, IMO.


r~

Re: [PATCH 05/50] *: Remove __i386__ tests
Posted by Thomas Huth 2 days ago
On 08/01/2026 11.21, Richard Henderson wrote:
> On 1/8/26 20:47, Thomas Huth wrote:
>> On 08/01/2026 06.29, Richard Henderson wrote:
>>> Remove instances of __i386__, except from tests and imported headers.
>>>
>>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>>> ---
>> ...
>>> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
>>> index 2060e561a2..63713f1992 100644
>>> --- a/linux-user/syscall.c
>>> +++ b/linux-user/syscall.c
>>> @@ -7449,15 +7449,6 @@ void syscall_init(void)
>>>                                 ~(TARGET_IOC_SIZEMASK << 
>>> TARGET_IOC_SIZESHIFT)) |
>>>                   (size << TARGET_IOC_SIZESHIFT);
>>>           }
>>> -
>>> -        /* automatic consistency check if same arch */
>>> -#if (defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)) 
>>> || \
>>> -    (defined(__x86_64__) && defined(TARGET_X86_64))
>>
>> This looks like we should keep the x86_64 part?
>>
>>> -        if (unlikely(ie->target_cmd != ie->host_cmd)) {
>>> -            fprintf(stderr, "ERROR: ioctl(%s): target=0x%x host=0x%x\n",
>>> -                    ie->name, ie->target_cmd, ie->host_cmd);
>>> -        }
>>> -#endif
> 
> The block doesn't look worthwhile to keep, IMO.

Ok, fine for me. Maybe mention it in the patch description, though, since 
this was not obvious (at least not to me).

  Thomas


Re: [PATCH 05/50] *: Remove __i386__ tests
Posted by Daniel P. Berrangé 2 days, 1 hour ago
On Thu, Jan 08, 2026 at 10:47:09AM +0100, Thomas Huth wrote:
> On 08/01/2026 06.29, Richard Henderson wrote:
> > Remove instances of __i386__, except from tests and imported headers.
> > 
> > Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> > ---
> ...
> > diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> > index 2060e561a2..63713f1992 100644
> > --- a/linux-user/syscall.c
> > +++ b/linux-user/syscall.c
> > @@ -7449,15 +7449,6 @@ void syscall_init(void)
> >                                 ~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) |
> >                   (size << TARGET_IOC_SIZESHIFT);
> >           }
> > -
> > -        /* automatic consistency check if same arch */
> > -#if (defined(__i386__) && defined(TARGET_I386) && defined(TARGET_ABI32)) || \
> > -    (defined(__x86_64__) && defined(TARGET_X86_64))
> 
> This looks like we should keep the x86_64 part?
> 
> > -        if (unlikely(ie->target_cmd != ie->host_cmd)) {
> > -            fprintf(stderr, "ERROR: ioctl(%s): target=0x%x host=0x%x\n",
> > -                    ie->name, ie->target_cmd, ie->host_cmd);
> > -        }
> > -#endif
> >           ie++;
> >       }
> >   }
> ...
> > diff --git a/configure b/configure
> > index 2016062492..00e455be57 100755
> > --- a/configure
> > +++ b/configure
> > @@ -377,8 +377,6 @@ fi
> >   if test ! -z "$cpu" ; then
> >     # command line argument
> >     :
> > -elif check_define __i386__ ; then
> > -  cpu="i386"
> >   elif check_define __x86_64__ ; then
> >     if check_define __ILP32__ ; then
> >       cpu="x32"
> 
> Aren't there some more spots in configure that could be removed now?
> e.g.:
> 
>   i386|i486|i586|i686)
>     cpu="i386"
>     host_arch=i386
>     linux_arch=x86
>     CPU_CFLAGS="-m32"
>     ;;
> 
> Or is this removed in a later patch?

Patch 8 does that.


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|