diff mbox series

[PULL,3/9] meson: Disallow 64-bit on 32-bit Xen emulation

Message ID 20250208205725.568631-4-richard.henderson@linaro.org (mailing list archive)
State New
Headers show
Series [PULL,1/9] meson: Drop tcg as a module | expand

Commit Message

Richard Henderson Feb. 8, 2025, 8:57 p.m. UTC
Require a 64-bit host binary to spawn a 64-bit guest.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 meson.build | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Philippe Mathieu-Daudé Feb. 18, 2025, 11:20 a.m. UTC | #1
Hi,

Adding Xen community.

On 8/2/25 21:57, Richard Henderson wrote:
> Require a 64-bit host binary to spawn a 64-bit guest.
> 
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   meson.build | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index 1af8aeb194..911955cfa8 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -304,9 +304,14 @@ else
>   endif
>   accelerator_targets = { 'CONFIG_KVM': kvm_targets }
>   
> -if cpu in ['x86', 'x86_64']
> +if cpu == 'x86'
> +  xen_targets = ['i386-softmmu']
> +elif cpu == 'x86_64'
>     xen_targets = ['i386-softmmu', 'x86_64-softmmu']
> -elif cpu in ['arm', 'aarch64']
> +elif cpu == 'arm'
> +  # i386 emulator provides xenpv machine type for multiple architectures
> +  xen_targets = ['i386-softmmu']

Is actually someone *testing* this config? I'm having hard time building
it, so am very suspicious about how it runs, and start to wonder if I'm
not just wasting my time (as could be our CI).

> +elif cpu == 'aarch64'
>     # i386 emulator provides xenpv machine type for multiple architectures
>     xen_targets = ['i386-softmmu', 'x86_64-softmmu', 'aarch64-softmmu']
>   else

Regards,

Phil.
Philippe Mathieu-Daudé Feb. 18, 2025, 1:19 p.m. UTC | #2
On 18/2/25 12:20, Philippe Mathieu-Daudé wrote:
> Hi,
> 
> Adding Xen community.
> 
> On 8/2/25 21:57, Richard Henderson wrote:
>> Require a 64-bit host binary to spawn a 64-bit guest.
>>
>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>   meson.build | 9 +++++++--
>>   1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/meson.build b/meson.build
>> index 1af8aeb194..911955cfa8 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -304,9 +304,14 @@ else
>>   endif
>>   accelerator_targets = { 'CONFIG_KVM': kvm_targets }
>> -if cpu in ['x86', 'x86_64']
>> +if cpu == 'x86'
>> +  xen_targets = ['i386-softmmu']
>> +elif cpu == 'x86_64'
>>     xen_targets = ['i386-softmmu', 'x86_64-softmmu']
>> -elif cpu in ['arm', 'aarch64']
>> +elif cpu == 'arm'
>> +  # i386 emulator provides xenpv machine type for multiple architectures
>> +  xen_targets = ['i386-softmmu']
> 
> Is actually someone *testing* this config? I'm having hard time building
> it, so am very suspicious about how it runs, and start to wonder if I'm
> not just wasting my time (as could be our CI).

This config is not tested and not functional. I'll post a patch
removing it.

> 
>> +elif cpu == 'aarch64'
>>     # i386 emulator provides xenpv machine type for multiple 
>> architectures
>>     xen_targets = ['i386-softmmu', 'x86_64-softmmu', 'aarch64-softmmu']
>>   else
> 
> Regards,
> 
> Phil.
>
Philippe Mathieu-Daudé Feb. 18, 2025, 1:20 p.m. UTC | #3
On 18/2/25 14:19, Philippe Mathieu-Daudé wrote:
> On 18/2/25 12:20, Philippe Mathieu-Daudé wrote:
>> Hi,
>>
>> Adding Xen community.
>>
>> On 8/2/25 21:57, Richard Henderson wrote:
>>> Require a 64-bit host binary to spawn a 64-bit guest.
>>>
>>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>>> ---
>>>   meson.build | 9 +++++++--
>>>   1 file changed, 7 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/meson.build b/meson.build
>>> index 1af8aeb194..911955cfa8 100644
>>> --- a/meson.build
>>> +++ b/meson.build
>>> @@ -304,9 +304,14 @@ else
>>>   endif
>>>   accelerator_targets = { 'CONFIG_KVM': kvm_targets }
>>> -if cpu in ['x86', 'x86_64']
>>> +if cpu == 'x86'
>>> +  xen_targets = ['i386-softmmu']
>>> +elif cpu == 'x86_64'
>>>     xen_targets = ['i386-softmmu', 'x86_64-softmmu']
>>> -elif cpu in ['arm', 'aarch64']
>>> +elif cpu == 'arm'
>>> +  # i386 emulator provides xenpv machine type for multiple 
>>> architectures
>>> +  xen_targets = ['i386-softmmu']
>>
>> Is actually someone *testing* this config? I'm having hard time building
>> it, so am very suspicious about how it runs, and start to wonder if I'm
>> not just wasting my time (as could be our CI).
> 
> This config is not tested and not functional. I'll post a patch
> removing it.

(thus no need to follow the deprecation policy).

> 
>>
>>> +elif cpu == 'aarch64'
>>>     # i386 emulator provides xenpv machine type for multiple 
>>> architectures
>>>     xen_targets = ['i386-softmmu', 'x86_64-softmmu', 'aarch64-softmmu']
>>>   else
>>
>> Regards,
>>
>> Phil.
>>
>
Andrew Cooper Feb. 18, 2025, 2:10 p.m. UTC | #4
On 18/02/2025 11:20 am, Philippe Mathieu-Daudé wrote:
> Hi,
>
> Adding Xen community.
>
> On 8/2/25 21:57, Richard Henderson wrote:
>> Require a 64-bit host binary to spawn a 64-bit guest.
>>
>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>   meson.build | 9 +++++++--
>>   1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/meson.build b/meson.build
>> index 1af8aeb194..911955cfa8 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -304,9 +304,14 @@ else
>>   endif
>>   accelerator_targets = { 'CONFIG_KVM': kvm_targets }
>>   -if cpu in ['x86', 'x86_64']
>> +if cpu == 'x86'
>> +  xen_targets = ['i386-softmmu']
>> +elif cpu == 'x86_64'
>>     xen_targets = ['i386-softmmu', 'x86_64-softmmu']
>> -elif cpu in ['arm', 'aarch64']
>> +elif cpu == 'arm'
>> +  # i386 emulator provides xenpv machine type for multiple
>> architectures
>> +  xen_targets = ['i386-softmmu']
>
> Is actually someone *testing* this config? I'm having hard time building
> it, so am very suspicious about how it runs, and start to wonder if I'm
> not just wasting my time (as could be our CI).

It was intentional.  I believe it was Stefano (CC'd) who introduced it.

Xen uses qemu-system-i386 everywhere because qemu-system-x86_64 doesn't
make compatible VMs.  I'm not sure why; I suspect it's bugs in the Xen
machine types, but I don't know QEMU well enough to be sure.

Another thing that (at least, was) tied to qemu-system-i386 was using
Qemu as a XenBlk <-> QCOW adapter, at which point it wasn't even really
a system emulator, just a paravirtual disk implementation.

This is, AIUI, what ARM wants with the xenpv machine.  If there's a
better way to do this, please do say.


Looking through Xen's CI, I can't see any of the ARM builds building
QEMU at all.  I think it's quite possible it's not tested any more.

~Andrew
Philippe Mathieu-Daudé Feb. 18, 2025, 3:25 p.m. UTC | #5
+Vikram

On 18/2/25 15:10, Andrew Cooper wrote:
> On 18/02/2025 11:20 am, Philippe Mathieu-Daudé wrote:
>> Hi,
>>
>> Adding Xen community.
>>
>> On 8/2/25 21:57, Richard Henderson wrote:
>>> Require a 64-bit host binary to spawn a 64-bit guest.
>>>
>>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>>> ---
>>>    meson.build | 9 +++++++--
>>>    1 file changed, 7 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/meson.build b/meson.build
>>> index 1af8aeb194..911955cfa8 100644
>>> --- a/meson.build
>>> +++ b/meson.build
>>> @@ -304,9 +304,14 @@ else
>>>    endif
>>>    accelerator_targets = { 'CONFIG_KVM': kvm_targets }
>>>    -if cpu in ['x86', 'x86_64']
>>> +if cpu == 'x86'
>>> +  xen_targets = ['i386-softmmu']
>>> +elif cpu == 'x86_64'
>>>      xen_targets = ['i386-softmmu', 'x86_64-softmmu']
>>> -elif cpu in ['arm', 'aarch64']
>>> +elif cpu == 'arm'
>>> +  # i386 emulator provides xenpv machine type for multiple
>>> architectures
>>> +  xen_targets = ['i386-softmmu']
>>
>> Is actually someone *testing* this config? I'm having hard time building
>> it, so am very suspicious about how it runs, and start to wonder if I'm
>> not just wasting my time (as could be our CI).
> 
> It was intentional.  I believe it was Stefano (CC'd) who introduced it.

In the introduction commit, "ARM targets" is used, so apparently both
32/64bit were picked deliberately:

---
commit aaea616d54317b8a0154adf52303a51da2d8d56f
Author: Vikram Garhwal <vikram.garhwal@amd.com>
Date:   Wed Jun 14 17:03:38 2023 -0700

     meson.build: enable xenpv machine build for ARM

     Add CONFIG_XEN for aarch64 device to support build for ARM targets.

     Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
     Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
     Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

diff --git a/meson.build b/meson.build
index 481865bfa97..cfa98e9e25f 100644
--- a/meson.build
+++ b/meson.build
@@ -136,7 +136,7 @@ endif
  if cpu in ['x86', 'x86_64', 'arm', 'aarch64']
    # i386 emulator provides xenpv machine type for multiple architectures
    accelerator_targets += {
-    'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu'],
+    'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu', 'aarch64-softmmu'],
    }
  endif
  if cpu in ['x86', 'x86_64']
---

> Xen uses qemu-system-i386 everywhere because qemu-system-x86_64 doesn't
> make compatible VMs.  I'm not sure why; I suspect it's bugs in the Xen
> machine types, but I don't know QEMU well enough to be sure.
> 
> Another thing that (at least, was) tied to qemu-system-i386 was using
> Qemu as a XenBlk <-> QCOW adapter, at which point it wasn't even really
> a system emulator, just a paravirtual disk implementation.
> 
> This is, AIUI, what ARM wants with the xenpv machine.  If there's a
> better way to do this, please do say.

No, I concur.

> Looking through Xen's CI, I can't see any of the ARM builds building
> QEMU at all.  I think it's quite possible it's not tested any more.

We only cross-build, see our cross-arm64-xen-only job:
https://gitlab.com/qemu-project/qemu/-/jobs/9165958873

Note, if it is not clear, the problem I have is to test Xen on
32-bit ARM hosts; I don't have any problem with 64-bit ones.

Regards,

Phil.
Philippe Mathieu-Daudé Feb. 18, 2025, 3:41 p.m. UTC | #6
On 18/2/25 16:25, Philippe Mathieu-Daudé wrote:
> +Vikram
> 
> On 18/2/25 15:10, Andrew Cooper wrote:
>> On 18/02/2025 11:20 am, Philippe Mathieu-Daudé wrote:
>>> Hi,
>>>
>>> Adding Xen community.
>>>
>>> On 8/2/25 21:57, Richard Henderson wrote:
>>>> Require a 64-bit host binary to spawn a 64-bit guest.
>>>>
>>>> Reviewed-by: Thomas Huth <thuth@redhat.com>
>>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>>>> ---
>>>>    meson.build | 9 +++++++--
>>>>    1 file changed, 7 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/meson.build b/meson.build
>>>> index 1af8aeb194..911955cfa8 100644
>>>> --- a/meson.build
>>>> +++ b/meson.build
>>>> @@ -304,9 +304,14 @@ else
>>>>    endif
>>>>    accelerator_targets = { 'CONFIG_KVM': kvm_targets }
>>>>    -if cpu in ['x86', 'x86_64']
>>>> +if cpu == 'x86'
>>>> +  xen_targets = ['i386-softmmu']
>>>> +elif cpu == 'x86_64'
>>>>      xen_targets = ['i386-softmmu', 'x86_64-softmmu']
>>>> -elif cpu in ['arm', 'aarch64']
>>>> +elif cpu == 'arm'
>>>> +  # i386 emulator provides xenpv machine type for multiple
>>>> architectures
>>>> +  xen_targets = ['i386-softmmu']
>>>
>>> Is actually someone *testing* this config? I'm having hard time building
>>> it, so am very suspicious about how it runs, and start to wonder if I'm
>>> not just wasting my time (as could be our CI).
>>
>> It was intentional.  I believe it was Stefano (CC'd) who introduced it.
> 
> In the introduction commit, "ARM targets" is used, so apparently both
> 32/64bit were picked deliberately:
> 
> ---
> commit aaea616d54317b8a0154adf52303a51da2d8d56f
> Author: Vikram Garhwal <vikram.garhwal@amd.com>
> Date:   Wed Jun 14 17:03:38 2023 -0700
> 
>      meson.build: enable xenpv machine build for ARM
> 
>      Add CONFIG_XEN for aarch64 device to support build for ARM targets.
> 
>      Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
>      Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
>      Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> 
> diff --git a/meson.build b/meson.build
> index 481865bfa97..cfa98e9e25f 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -136,7 +136,7 @@ endif
>   if cpu in ['x86', 'x86_64', 'arm', 'aarch64']
>     # i386 emulator provides xenpv machine type for multiple architectures
>     accelerator_targets += {
> -    'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu'],
> +    'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu', 'aarch64-softmmu'],
>     }
>   endif
>   if cpu in ['x86', 'x86_64']
> ---

Hmm wrong commit apparently, but the history isn't clear. See:

-- >8 --
commit 3b6b75506de44c5070639943c30a0ad5850f5d02
Author: Paolo Bonzini <pbonzini@redhat.com>
Date:   Mon Sep 17 11:59:41 2012 +0200

     configure: factor out list of supported Xen/KVM/HAX targets

     This will be useful when the functions are called, early in the 
configure
     process, to filter out targets that do not support hardware 
acceleration.

     Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

diff --git a/configure b/configure
...
+supported_xen_target() {
+    test "$xen" = "yes" || return 1
+    glob "$1" "*-softmmu" || return 1
+    case "${1%-softmmu}:$cpu" in
+        arm:arm | aarch64:aarch64 | \
+        i386:i386 | i386:x86_64 | x86_64:i386 | x86_64:x86_64)
+            return 0
+        ;;
+    esac
+    return 1
+}
+
  # default parameters
  source_path=$(dirname "$0")
  cpu=""
@@ -6178,46 +6222,22 @@ echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> 
$config_target_mak
  if [ "$HOST_VARIANT_DIR" != "" ]; then
      echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
  fi
-case "$target_name" in
-  i386|x86_64)
-    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
-      echo "CONFIG_XEN=y" >> $config_target_mak
-      if test "$xen_pci_passthrough" = yes; then
+
+if supported_xen_target $target; then
+    echo "CONFIG_XEN=y" >> $config_target_mak
+    if test "$xen_pci_passthrough" = yes; then
          echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
-      fi
      fi
-    ;;
-  *)
---

Paolo, Alex, was this intentional?

>> Xen uses qemu-system-i386 everywhere because qemu-system-x86_64 doesn't
>> make compatible VMs.  I'm not sure why; I suspect it's bugs in the Xen
>> machine types, but I don't know QEMU well enough to be sure.
>>
>> Another thing that (at least, was) tied to qemu-system-i386 was using
>> Qemu as a XenBlk <-> QCOW adapter, at which point it wasn't even really
>> a system emulator, just a paravirtual disk implementation.
>>
>> This is, AIUI, what ARM wants with the xenpv machine.  If there's a
>> better way to do this, please do say.
> 
> No, I concur.
> 
>> Looking through Xen's CI, I can't see any of the ARM builds building
>> QEMU at all.  I think it's quite possible it's not tested any more.
> 
> We only cross-build, see our cross-arm64-xen-only job:
> https://gitlab.com/qemu-project/qemu/-/jobs/9165958873
> 
> Note, if it is not clear, the problem I have is to test Xen on
> 32-bit ARM hosts; I don't have any problem with 64-bit ones.
> 
> Regards,
> 
> Phil.
Stefano Stabellini Feb. 18, 2025, 7:30 p.m. UTC | #7
On Tue, 18 Feb 2025, Andrew Cooper wrote:
> On 18/02/2025 11:20 am, Philippe Mathieu-Daudé wrote:
> > Hi,
> >
> > Adding Xen community.
> >
> > On 8/2/25 21:57, Richard Henderson wrote:
> >> Require a 64-bit host binary to spawn a 64-bit guest.
> >>
> >> Reviewed-by: Thomas Huth <thuth@redhat.com>
> >> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> >> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> >> ---
> >>   meson.build | 9 +++++++--
> >>   1 file changed, 7 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/meson.build b/meson.build
> >> index 1af8aeb194..911955cfa8 100644
> >> --- a/meson.build
> >> +++ b/meson.build
> >> @@ -304,9 +304,14 @@ else
> >>   endif
> >>   accelerator_targets = { 'CONFIG_KVM': kvm_targets }
> >>   -if cpu in ['x86', 'x86_64']
> >> +if cpu == 'x86'
> >> +  xen_targets = ['i386-softmmu']
> >> +elif cpu == 'x86_64'
> >>     xen_targets = ['i386-softmmu', 'x86_64-softmmu']
> >> -elif cpu in ['arm', 'aarch64']
> >> +elif cpu == 'arm'
> >> +  # i386 emulator provides xenpv machine type for multiple
> >> architectures
> >> +  xen_targets = ['i386-softmmu']
> >
> > Is actually someone *testing* this config? I'm having hard time building
> > it, so am very suspicious about how it runs, and start to wonder if I'm
> > not just wasting my time (as could be our CI).
> 
> It was intentional.  I believe it was Stefano (CC'd) who introduced it.
> 
> Xen uses qemu-system-i386 everywhere because qemu-system-x86_64 doesn't
> make compatible VMs.  I'm not sure why; I suspect it's bugs in the Xen
> machine types, but I don't know QEMU well enough to be sure.
> 
> Another thing that (at least, was) tied to qemu-system-i386 was using
> Qemu as a XenBlk <-> QCOW adapter, at which point it wasn't even really
> a system emulator, just a paravirtual disk implementation.
> 
> This is, AIUI, what ARM wants with the xenpv machine.  If there's a
> better way to do this, please do say.
> 
> 
> Looking through Xen's CI, I can't see any of the ARM builds building
> QEMU at all.  I think it's quite possible it's not tested any more.

Hi all,

I answered on a similar question recently:
https://marc.info/?l=qemu-devel&m=173862237031104&w=2

In short, while QEMU for x86 HVM guest is required, QEMU is not required
for x86 PVH guests, and ARM guests. The model is different and QEMU is
only providing PV backends or virtio backends if the VM is configured
that way. You can have a fully functional VM without QEMU (or other
virtio backends provider).

In this context, the original integration of QEMU for Xen on ARM was
done reusing the qemu-system-i386 target. But Edgar recently upstreamed
a much better newer machine that is cleaner, simpler and faster: XenPVH
(see hw/arm/xen-pvh.c and hw/i386/xen/xen-pvh.c). So we don't need
qemu-system-i386 on either ARM32 or ARM64 anymore.

Moreover, for ARM32 specifically, I think it would be OK to remove QEMU
support for ARM32 Xen machines in general because of the reasons I wrote
in the other email and above here.
diff mbox series

Patch

diff --git a/meson.build b/meson.build
index 1af8aeb194..911955cfa8 100644
--- a/meson.build
+++ b/meson.build
@@ -304,9 +304,14 @@  else
 endif
 accelerator_targets = { 'CONFIG_KVM': kvm_targets }
 
-if cpu in ['x86', 'x86_64']
+if cpu == 'x86'
+  xen_targets = ['i386-softmmu']
+elif cpu == 'x86_64'
   xen_targets = ['i386-softmmu', 'x86_64-softmmu']
-elif cpu in ['arm', 'aarch64']
+elif cpu == 'arm'
+  # i386 emulator provides xenpv machine type for multiple architectures
+  xen_targets = ['i386-softmmu']
+elif cpu == 'aarch64'
   # i386 emulator provides xenpv machine type for multiple architectures
   xen_targets = ['i386-softmmu', 'x86_64-softmmu', 'aarch64-softmmu']
 else