Message ID | 20210502174836.838816-5-thuth@redhat.com |
---|---|
State | New |
Headers | show |
Series | pc-bios/s390-ccw: Allow building with Clang, too | expand |
On 5/2/21 7:48 PM, Thomas Huth wrote: > Clang unfortunately does not support generating code for the z900 > architecture level and starts with the z10 instead. Thus to be able > to support compiling with Clang, we have to check for the supported > compiler flags. The disadvantage is of course that the bios image > will only run with z10 guest CPUs upwards (which is what most people > use anyway), so just in case let's also emit a warning in that case. > > Signed-off-by: Thomas Huth <thuth@redhat.com> > --- > configure | 9 ++++++++- > pc-bios/s390-ccw/Makefile | 3 ++- > 2 files changed, 10 insertions(+), 2 deletions(-) Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Thomas Huth <thuth@redhat.com> writes: > Clang unfortunately does not support generating code for the z900 > architecture level and starts with the z10 instead. Thus to be able > to support compiling with Clang, we have to check for the supported > compiler flags. The disadvantage is of course that the bios image > will only run with z10 guest CPUs upwards (which is what most people > use anyway), so just in case let's also emit a warning in that case. What happens when you try to use this bios with an old CPU anyway?
On 03/05/2021 06.58, Markus Armbruster wrote: > Thomas Huth <thuth@redhat.com> writes: > >> Clang unfortunately does not support generating code for the z900 >> architecture level and starts with the z10 instead. Thus to be able >> to support compiling with Clang, we have to check for the supported >> compiler flags. The disadvantage is of course that the bios image >> will only run with z10 guest CPUs upwards (which is what most people >> use anyway), so just in case let's also emit a warning in that case. > > What happens when you try to use this bios with an old CPU anyway? Interesting question. I was expecting the guest to crash since it would be using a CPU instruction that is not supported on the old CPU model. But I just gave it a try, and there was no crash. The guest booted just fine. Either Clang only emits instructions that work with the old z900 anyway, or our emulation in QEMU is imprecise and we allow newer instructions to be executed on old models, too. Thomas
On 03.05.21 07:17, Thomas Huth wrote: > On 03/05/2021 06.58, Markus Armbruster wrote: >> Thomas Huth <thuth@redhat.com> writes: >> >>> Clang unfortunately does not support generating code for the z900 >>> architecture level and starts with the z10 instead. Thus to be able >>> to support compiling with Clang, we have to check for the supported >>> compiler flags. The disadvantage is of course that the bios image >>> will only run with z10 guest CPUs upwards (which is what most people >>> use anyway), so just in case let's also emit a warning in that case. >> >> What happens when you try to use this bios with an old CPU anyway? > > Interesting question. I was expecting the guest to crash since it would be > using a CPU instruction that is not supported on the old CPU model. But I > just gave it a try, and there was no crash. The guest booted just fine. > Either Clang only emits instructions that work with the old z900 anyway, or > our emulation in QEMU is imprecise and we allow newer instructions to be > executed on old models, too. Yes, that's currently still done. We once thought about disabling that (there was a patch from Richard), but decided against it because -- back then -- the default QEMU model was still very basic and would have essentially disabled all more recent instructions as default. We can most probably do that change soon as we have a "fairly new" default QEMU CPU model. I can glue it to my z14 change.
David Hildenbrand <david@redhat.com> writes: > On 03.05.21 07:17, Thomas Huth wrote: >> On 03/05/2021 06.58, Markus Armbruster wrote: >>> Thomas Huth <thuth@redhat.com> writes: >>> >>>> Clang unfortunately does not support generating code for the z900 >>>> architecture level and starts with the z10 instead. Thus to be able >>>> to support compiling with Clang, we have to check for the supported >>>> compiler flags. The disadvantage is of course that the bios image >>>> will only run with z10 guest CPUs upwards (which is what most people >>>> use anyway), so just in case let's also emit a warning in that case. >>> >>> What happens when you try to use this bios with an old CPU anyway? >> >> Interesting question. I was expecting the guest to crash since it would be >> using a CPU instruction that is not supported on the old CPU model. But I >> just gave it a try, and there was no crash. The guest booted just fine. >> Either Clang only emits instructions that work with the old z900 anyway, or >> our emulation in QEMU is imprecise and we allow newer instructions to be >> executed on old models, too. > > Yes, that's currently still done. We once thought about disabling that > (there was a patch from Richard), but decided against it because -- back > then -- the default QEMU model was still very basic and would have > essentially disabled all more recent instructions as default. > > We can most probably do that change soon as we have a "fairly new" > default QEMU CPU model. I can glue it to my z14 change. In case this makes the BIOS crash with old CPUs: when a guest refuses to start because the BIOS was compiled the wrong way for it, configure having told you so back then is not a nice user experience. Can we do better, with reasonable effort?
On Mon, 03 May 2021 10:23:20 +0200 Markus Armbruster <armbru@redhat.com> wrote: > David Hildenbrand <david@redhat.com> writes: > > > On 03.05.21 07:17, Thomas Huth wrote: > >> On 03/05/2021 06.58, Markus Armbruster wrote: > >>> Thomas Huth <thuth@redhat.com> writes: > >>> > >>>> Clang unfortunately does not support generating code for the z900 > >>>> architecture level and starts with the z10 instead. Thus to be able > >>>> to support compiling with Clang, we have to check for the supported > >>>> compiler flags. The disadvantage is of course that the bios image > >>>> will only run with z10 guest CPUs upwards (which is what most people > >>>> use anyway), so just in case let's also emit a warning in that case. > >>> > >>> What happens when you try to use this bios with an old CPU anyway? > >> > >> Interesting question. I was expecting the guest to crash since it would be > >> using a CPU instruction that is not supported on the old CPU model. But I > >> just gave it a try, and there was no crash. The guest booted just fine. > >> Either Clang only emits instructions that work with the old z900 anyway, or > >> our emulation in QEMU is imprecise and we allow newer instructions to be > >> executed on old models, too. > > > > Yes, that's currently still done. We once thought about disabling that > > (there was a patch from Richard), but decided against it because -- back > > then -- the default QEMU model was still very basic and would have > > essentially disabled all more recent instructions as default. > > > > We can most probably do that change soon as we have a "fairly new" > > default QEMU CPU model. I can glue it to my z14 change. > > In case this makes the BIOS crash with old CPUs: when a guest refuses to > start because the BIOS was compiled the wrong way for it, configure > having told you so back then is not a nice user experience. Can we do > better, with reasonable effort? I fear the experience will be as bad as for any guest that is using features from a newer cpu level (i.e. random crashes when the guest actually tries to use that newer instruction.) I see two options: - Just try to start and hope that it works. - Deprecate any cpu model older than z10. Anyone have a better idea? I don't particularly like any of the two.
On 03.05.21 11:14, Cornelia Huck wrote: > On Mon, 03 May 2021 10:23:20 +0200 > Markus Armbruster <armbru@redhat.com> wrote: > >> David Hildenbrand <david@redhat.com> writes: >> >>> On 03.05.21 07:17, Thomas Huth wrote: >>>> On 03/05/2021 06.58, Markus Armbruster wrote: >>>>> Thomas Huth <thuth@redhat.com> writes: >>>>> >>>>>> Clang unfortunately does not support generating code for the z900 >>>>>> architecture level and starts with the z10 instead. Thus to be able >>>>>> to support compiling with Clang, we have to check for the supported >>>>>> compiler flags. The disadvantage is of course that the bios image >>>>>> will only run with z10 guest CPUs upwards (which is what most people >>>>>> use anyway), so just in case let's also emit a warning in that case. >>>>> >>>>> What happens when you try to use this bios with an old CPU anyway? >>>> >>>> Interesting question. I was expecting the guest to crash since it would be >>>> using a CPU instruction that is not supported on the old CPU model. But I >>>> just gave it a try, and there was no crash. The guest booted just fine. >>>> Either Clang only emits instructions that work with the old z900 anyway, or >>>> our emulation in QEMU is imprecise and we allow newer instructions to be >>>> executed on old models, too. >>> >>> Yes, that's currently still done. We once thought about disabling that >>> (there was a patch from Richard), but decided against it because -- back >>> then -- the default QEMU model was still very basic and would have >>> essentially disabled all more recent instructions as default. >>> >>> We can most probably do that change soon as we have a "fairly new" >>> default QEMU CPU model. I can glue it to my z14 change. >> >> In case this makes the BIOS crash with old CPUs: when a guest refuses to >> start because the BIOS was compiled the wrong way for it, configure >> having told you so back then is not a nice user experience. Can we do >> better, with reasonable effort? > > I fear the experience will be as bad as for any guest that is using > features from a newer cpu level (i.e. random crashes when the guest > actually tries to use that newer instruction.) > > I see two options: > - Just try to start and hope that it works. > - Deprecate any cpu model older than z10. > > Anyone have a better idea? I don't particularly like any of the two. As the default CPU model with new compat machines is >= z13, I wouldn't lose sleep about this. Even with a broken bios one can still boot an external kernel+initrd for testing purposes.
On Mon, 3 May 2021 11:17:54 +0200 David Hildenbrand <david@redhat.com> wrote: > On 03.05.21 11:14, Cornelia Huck wrote: > > On Mon, 03 May 2021 10:23:20 +0200 > > Markus Armbruster <armbru@redhat.com> wrote: > > > >> David Hildenbrand <david@redhat.com> writes: > >> > >>> On 03.05.21 07:17, Thomas Huth wrote: > >>>> On 03/05/2021 06.58, Markus Armbruster wrote: > >>>>> Thomas Huth <thuth@redhat.com> writes: > >>>>> > >>>>>> Clang unfortunately does not support generating code for the z900 > >>>>>> architecture level and starts with the z10 instead. Thus to be able > >>>>>> to support compiling with Clang, we have to check for the supported > >>>>>> compiler flags. The disadvantage is of course that the bios image > >>>>>> will only run with z10 guest CPUs upwards (which is what most people > >>>>>> use anyway), so just in case let's also emit a warning in that case. > >>>>> > >>>>> What happens when you try to use this bios with an old CPU anyway? > >>>> > >>>> Interesting question. I was expecting the guest to crash since it would be > >>>> using a CPU instruction that is not supported on the old CPU model. But I > >>>> just gave it a try, and there was no crash. The guest booted just fine. > >>>> Either Clang only emits instructions that work with the old z900 anyway, or > >>>> our emulation in QEMU is imprecise and we allow newer instructions to be > >>>> executed on old models, too. > >>> > >>> Yes, that's currently still done. We once thought about disabling that > >>> (there was a patch from Richard), but decided against it because -- back > >>> then -- the default QEMU model was still very basic and would have > >>> essentially disabled all more recent instructions as default. > >>> > >>> We can most probably do that change soon as we have a "fairly new" > >>> default QEMU CPU model. I can glue it to my z14 change. > >> > >> In case this makes the BIOS crash with old CPUs: when a guest refuses to > >> start because the BIOS was compiled the wrong way for it, configure > >> having told you so back then is not a nice user experience. Can we do > >> better, with reasonable effort? > > > > I fear the experience will be as bad as for any guest that is using > > features from a newer cpu level (i.e. random crashes when the guest > > actually tries to use that newer instruction.) > > > > I see two options: > > - Just try to start and hope that it works. > > - Deprecate any cpu model older than z10. > > > > Anyone have a better idea? I don't particularly like any of the two. > > As the default CPU model with new compat machines is >= z13, I wouldn't > lose sleep about this. Even with a broken bios one can still boot an > external kernel+initrd for testing purposes. Yes, I do not see many people running into this problem. Still, I fear it will be hard to figure out what exactly the problem is, when it arises...
On 03/05/2021 11.14, Cornelia Huck wrote: > On Mon, 03 May 2021 10:23:20 +0200 > Markus Armbruster <armbru@redhat.com> wrote: > >> David Hildenbrand <david@redhat.com> writes: >> >>> On 03.05.21 07:17, Thomas Huth wrote: >>>> On 03/05/2021 06.58, Markus Armbruster wrote: >>>>> Thomas Huth <thuth@redhat.com> writes: >>>>> >>>>>> Clang unfortunately does not support generating code for the z900 >>>>>> architecture level and starts with the z10 instead. Thus to be able >>>>>> to support compiling with Clang, we have to check for the supported >>>>>> compiler flags. The disadvantage is of course that the bios image >>>>>> will only run with z10 guest CPUs upwards (which is what most people >>>>>> use anyway), so just in case let's also emit a warning in that case. >>>>> >>>>> What happens when you try to use this bios with an old CPU anyway? >>>> >>>> Interesting question. I was expecting the guest to crash since it would be >>>> using a CPU instruction that is not supported on the old CPU model. But I >>>> just gave it a try, and there was no crash. The guest booted just fine. >>>> Either Clang only emits instructions that work with the old z900 anyway, or >>>> our emulation in QEMU is imprecise and we allow newer instructions to be >>>> executed on old models, too. >>> >>> Yes, that's currently still done. We once thought about disabling that >>> (there was a patch from Richard), but decided against it because -- back >>> then -- the default QEMU model was still very basic and would have >>> essentially disabled all more recent instructions as default. >>> >>> We can most probably do that change soon as we have a "fairly new" >>> default QEMU CPU model. I can glue it to my z14 change. >> >> In case this makes the BIOS crash with old CPUs: when a guest refuses to >> start because the BIOS was compiled the wrong way for it, configure >> having told you so back then is not a nice user experience. Can we do >> better, with reasonable effort? > > I fear the experience will be as bad as for any guest that is using > features from a newer cpu level (i.e. random crashes when the guest > actually tries to use that newer instruction.) > > I see two options: > - Just try to start and hope that it works. > - Deprecate any cpu model older than z10. > > Anyone have a better idea? I don't particularly like any of the two. I think we should simply continue to build the default bios with GCC and -mz900. So the normal user (who does not explicitly use the freshly compiled binaries but the pre-built ones) will never experience any problem here. The Clang builds are (at least right now) rather only meant for us developers to check the sources from time to time with this compiler, to see whether it detects some additional issues compared to GCC. Thomas
On Mon, 3 May 2021 11:31:00 +0200 Thomas Huth <thuth@redhat.com> wrote: > On 03/05/2021 11.14, Cornelia Huck wrote: > > On Mon, 03 May 2021 10:23:20 +0200 > > Markus Armbruster <armbru@redhat.com> wrote: > > > >> David Hildenbrand <david@redhat.com> writes: > >> > >>> On 03.05.21 07:17, Thomas Huth wrote: > >>>> On 03/05/2021 06.58, Markus Armbruster wrote: > >>>>> Thomas Huth <thuth@redhat.com> writes: > >>>>> > >>>>>> Clang unfortunately does not support generating code for the z900 > >>>>>> architecture level and starts with the z10 instead. Thus to be able > >>>>>> to support compiling with Clang, we have to check for the supported > >>>>>> compiler flags. The disadvantage is of course that the bios image > >>>>>> will only run with z10 guest CPUs upwards (which is what most people > >>>>>> use anyway), so just in case let's also emit a warning in that case. > >>>>> > >>>>> What happens when you try to use this bios with an old CPU anyway? > >>>> > >>>> Interesting question. I was expecting the guest to crash since it would be > >>>> using a CPU instruction that is not supported on the old CPU model. But I > >>>> just gave it a try, and there was no crash. The guest booted just fine. > >>>> Either Clang only emits instructions that work with the old z900 anyway, or > >>>> our emulation in QEMU is imprecise and we allow newer instructions to be > >>>> executed on old models, too. > >>> > >>> Yes, that's currently still done. We once thought about disabling that > >>> (there was a patch from Richard), but decided against it because -- back > >>> then -- the default QEMU model was still very basic and would have > >>> essentially disabled all more recent instructions as default. > >>> > >>> We can most probably do that change soon as we have a "fairly new" > >>> default QEMU CPU model. I can glue it to my z14 change. > >> > >> In case this makes the BIOS crash with old CPUs: when a guest refuses to > >> start because the BIOS was compiled the wrong way for it, configure > >> having told you so back then is not a nice user experience. Can we do > >> better, with reasonable effort? > > > > I fear the experience will be as bad as for any guest that is using > > features from a newer cpu level (i.e. random crashes when the guest > > actually tries to use that newer instruction.) > > > > I see two options: > > - Just try to start and hope that it works. > > - Deprecate any cpu model older than z10. > > > > Anyone have a better idea? I don't particularly like any of the two. > > I think we should simply continue to build the default bios with GCC and > -mz900. So the normal user (who does not explicitly use the freshly compiled > binaries but the pre-built ones) will never experience any problem here. The > Clang builds are (at least right now) rather only meant for us developers to > check the sources from time to time with this compiler, to see whether it > detects some additional issues compared to GCC. OK, sounds reasonable to me.
On Sun, 2 May 2021 19:48:36 +0200 Thomas Huth <thuth@redhat.com> wrote: > Clang unfortunately does not support generating code for the z900 > architecture level and starts with the z10 instead. Thus to be able > to support compiling with Clang, we have to check for the supported > compiler flags. The disadvantage is of course that the bios image > will only run with z10 guest CPUs upwards (which is what most people > use anyway), so just in case let's also emit a warning in that case. Maybe add a note here that the pre-built image will continue to be built with gcc for the z900, so for most people nothing will change? > > Signed-off-by: Thomas Huth <thuth@redhat.com> > --- > configure | 9 ++++++++- > pc-bios/s390-ccw/Makefile | 3 ++- > 2 files changed, 10 insertions(+), 2 deletions(-) > Reviewed-by: Cornelia Huck <cohuck@redhat.com>
On 03.05.21 11:31, Thomas Huth wrote: > On 03/05/2021 11.14, Cornelia Huck wrote: >> On Mon, 03 May 2021 10:23:20 +0200 >> Markus Armbruster <armbru@redhat.com> wrote: >> >>> David Hildenbrand <david@redhat.com> writes: >>> >>>> On 03.05.21 07:17, Thomas Huth wrote: >>>>> On 03/05/2021 06.58, Markus Armbruster wrote: >>>>>> Thomas Huth <thuth@redhat.com> writes: >>>>>>> Clang unfortunately does not support generating code for the z900 >>>>>>> architecture level and starts with the z10 instead. Thus to be able >>>>>>> to support compiling with Clang, we have to check for the supported >>>>>>> compiler flags. The disadvantage is of course that the bios image >>>>>>> will only run with z10 guest CPUs upwards (which is what most people >>>>>>> use anyway), so just in case let's also emit a warning in that case. >>>>>> >>>>>> What happens when you try to use this bios with an old CPU anyway? >>>>> >>>>> Interesting question. I was expecting the guest to crash since it would be >>>>> using a CPU instruction that is not supported on the old CPU model. But I >>>>> just gave it a try, and there was no crash. The guest booted just fine. >>>>> Either Clang only emits instructions that work with the old z900 anyway, or >>>>> our emulation in QEMU is imprecise and we allow newer instructions to be >>>>> executed on old models, too. >>>> >>>> Yes, that's currently still done. We once thought about disabling that >>>> (there was a patch from Richard), but decided against it because -- back >>>> then -- the default QEMU model was still very basic and would have >>>> essentially disabled all more recent instructions as default. >>>> >>>> We can most probably do that change soon as we have a "fairly new" >>>> default QEMU CPU model. I can glue it to my z14 change. >>> >>> In case this makes the BIOS crash with old CPUs: when a guest refuses to >>> start because the BIOS was compiled the wrong way for it, configure >>> having told you so back then is not a nice user experience. Can we do >>> better, with reasonable effort? >> >> I fear the experience will be as bad as for any guest that is using >> features from a newer cpu level (i.e. random crashes when the guest >> actually tries to use that newer instruction.) >> >> I see two options: >> - Just try to start and hope that it works. >> - Deprecate any cpu model older than z10. >> >> Anyone have a better idea? I don't particularly like any of the two. > > I think we should simply continue to build the default bios with GCC and -mz900. So the normal user (who does not explicitly use the freshly compiled binaries but the pre-built ones) will never experience any problem here. The Clang builds are (at least right now) rather only meant for us developers to check the sources from time to time with this compiler, to see whether it detects some additional issues compared to GCC. Ack.
diff --git a/configure b/configure index 4f374b4889..5ebc937746 100755 --- a/configure +++ b/configure @@ -5417,9 +5417,16 @@ if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \ fi # Only build s390-ccw bios if we're on s390x and the compiler has -march=z900 +# or -march=z10 (which is the lowest architecture level that Clang supports) if test "$cpu" = "s390x" ; then write_c_skeleton - if compile_prog "-march=z900" ""; then + compile_prog "-march=z900" "" + has_z900=$? + if [ $has_z900 = 0 ] || compile_prog "-march=z10" ""; then + if [ $has_z900 != 0 ]; then + echo "WARNING: Your compiler does not support the z900!" + echo " The s390-ccw bios will only work with guest CPUs >= z10." + fi roms="$roms s390-ccw" # SLOF is required for building the s390-ccw firmware on s390x, # since it is using the libnet code from SLOF for network booting. diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile index 83fb1afb73..cee9d2c63b 100644 --- a/pc-bios/s390-ccw/Makefile +++ b/pc-bios/s390-ccw/Makefile @@ -34,7 +34,8 @@ QEMU_CFLAGS += $(call cc-option,-Werror $(QEMU_CFLAGS),-Wno-stringop-overflow) QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE QEMU_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector) -QEMU_CFLAGS += -msoft-float -march=z900 +QEMU_CFLAGS += -msoft-float +QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS),-march=z900,-march=z10) QEMU_CFLAGS += -std=gnu99 LDFLAGS += -Wl,-pie -nostdlib
Clang unfortunately does not support generating code for the z900 architecture level and starts with the z10 instead. Thus to be able to support compiling with Clang, we have to check for the supported compiler flags. The disadvantage is of course that the bios image will only run with z10 guest CPUs upwards (which is what most people use anyway), so just in case let's also emit a warning in that case. Signed-off-by: Thomas Huth <thuth@redhat.com> --- configure | 9 ++++++++- pc-bios/s390-ccw/Makefile | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-)