Skip to contentSkip to conversation

xen: Bump the minimum version of GCC supported to 4.9 (5.1 on arm64)

PATCH Superseded Julien Grall 5 participants 14 messages Mar 6, 2021 – Mar 11, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: Bump the minimum version of GCC supported to 4.9 (5.1 on arm64)

From: Julien Grall <[email protected]>

Compilers older than 4.8 have known codegen issues which can lead to silent miscompilation:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145

Furthermore, pre-4.9 GCC have known bugs (including things like internal compiler errors on Arm) which would require workaround (I haven't checked if we have any in Xen).

The minimum version of GCC to build the hypervisor is now raised to 4.9.

In addition to that, on arm64, GCC version >= 4.9 and < 5.1 have been shown to emit memory references beyond the stack pointer, resulting in memory corruption if an interrupt is taken after the stack pointer has been adjusted but before the reference has been executed.

Therefore, the minimum for arm64 is raised to 5.1.

---

I don't have a strong opinion on the minimum version for GCC on x86. So this is following Andrew's suggestion and the minimum from Linux.

This patch is candidate to 4.15 and backport.

This is only a build change and will be low-risk for anyone using newer compiler (5.1+ for arm64 and 4.9 for everyone else). Xen will stop building for anyone using older compiler. But it is better than fighting with codegen issues.

---
 README                     |  9 ++++++---
 xen/include/xen/compiler.h | 13 +++++++++++++
 2 files changed, 19 insertions(+), 3 deletions(-)
README +6 -3
index 8c99c30986c1..5c32c03f2ea1 100644
@@ -38,12 +38,15 @@ provided by your OS distributor:
     * GNU Make v3.80 or later
     * C compiler and linker:
       - For x86:
-        - GCC 4.1.2_20070115 or later
+        - GCC 4.9 or later
         - GNU Binutils 2.16.91.0.5 or later
         or
         - Clang/LLVM 3.5 or later
-      - For ARM:
-        - GCC 4.8 or later
+      - For ARM 32-bit:
+        - GCC 4.9 or later
+        - GNU Binutils 2.24 or later
+      - For ARM 64-bit:
+        - GCC 5.1 or later
         - GNU Binutils 2.24 or later
     * Development install of zlib (e.g., zlib-dev)
     * Development install of Python 2.6 or later (e.g., python-dev)
xen/include/xen/compiler.h +13 -0
index 0ec0b4698ea7..46779660cc8f 100644
@@ -5,6 +5,19 @@
 #error Sorry, your compiler is too old/not recognized.
 #endif
 
+#if CONFIG_CC_IS_GCC
+# if CONFIG_GCC_VERSION < 40900
+/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 */
+#  error Sorry, your version of GCC is too old - please use 4.9 or newer.
+# elif defined(CONFIG_ARM_64) && CONFIG_GCC_VERSION < 50100
+/*
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
+ * https://lore.kernel.org/r/[email protected]
+ */
+#  error Sorry, your version of GCC is too old - please use 5.1 or newer.
+# endif
+#endif
+
 #define barrier()     __asm__ __volatile__("": : :"memory")
 
 #define likely(x)     __builtin_expect(!!(x),1)
Signature · 1 line
2.17.1
#1 lore raw
Quoted 5 lines · Julien Grall

From: Julien Grall <[email protected]>

Compilers older than 4.8 have known codegen issues which can lead to silent miscompilation:

Quoted 7 lines

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145

Furthermore, pre-4.9 GCC have known bugs (including things like internal compiler errors on Arm) which would require workaround (I haven't checked if we have any in Xen).

The minimum version of GCC to build the hypervisor is now raised to 4.9.

The README entry doesn't differentiate between tools and hypervisor GCC version, can the bug above also manifest in toolstack code?

I don't think it makes much sense to have diverging requirements for tools vs hypervisor builds, but if the bug(s) can also manifest in toolstack code we might want to add a GCC version check to tools/configure.ac.

Thanks, Roger.

#2 lore raw

Hi Roger,

Quoted 8 lines · Roger Pau Monné
Quoted 7 lines · Julien Grall

From: Julien Grall <[email protected]>

Compilers older than 4.8 have known codegen issues which can lead to silent miscompilation:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145

Quoted 8 lines
Quoted 5 lines

Furthermore, pre-4.9 GCC have known bugs (including things like internal compiler errors on Arm) which would require workaround (I haven't checked if we have any in Xen).

The minimum version of GCC to build the hypervisor is now raised to 4.9.

The README entry doesn't differentiate between tools and hypervisor GCC version, can the bug above also manifest in toolstack code?

I guess it can manifest in the firmware (e.g. hvmloader, rombios). It looks rather unlikely in the userspace tools as we seem to barely use volatile.

For the Arm64 bug [1], I think it can also show up when receiving a signal.

Quoted 5 lines

I don't think it makes much sense to have diverging requirements for tools vs hypervisor builds, but if the bug(s) can also manifest in toolstack code we might want to add a GCC version check to tools/configure.ac.

Agree. I can add check in ./configure for the toolstack.

Cheers,

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293

Signature · 1 line
Julien Grall
#3 lore raw
In reply to Julien Grall
Quoted 11 lines · Julien Grall

From: Julien Grall <[email protected]>

Compilers older than 4.8 have known codegen issues which can lead to silent miscompilation:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145

Furthermore, pre-4.9 GCC have known bugs (including things like internal compiler errors on Arm) which would require workaround (I haven't checked if we have any in Xen).

Quoted 8 lines

The minimum version of GCC to build the hypervisor is now raised to 4.9.

In addition to that, on arm64, GCC version >= 4.9 and < 5.1 have been shown to emit memory references beyond the stack pointer, resulting in memory corruption if an interrupt is taken after the stack pointer has been adjusted but before the reference has been executed.

Therefore, the minimum for arm64 is raised to 5.1.

I'm sure newer compiler versions also have bugs. Therefore I'm not convinced using this as the primary reason for a bump is enough. Plus what if critical to us bugs get found in, say, 5.x? Are we going to bump to 6.x then (and so on, until we allow only the most recent major version to be used)?

Additionally - partly related to your own reply regarding the CI failures - imo there needs to be an analysis of what older distros will no longer build (at all or by default). We've been discussing to bump minimum tool chain versions for a long time. At least as far as I'm concerned, I didn't take on this job precisely because the code changes needed are relatively simple, but justification can (and apparently will) be rather complicated.

Fundamentally, whatever kind of criteria we use to justify the bump now ought to be usable down the road by people justifying further bumps.

Also - what about clang? Linux requires 10.0.1 as a minimum.

Quoted 6 lines

---

I don't have a strong opinion on the minimum version for GCC on x86. So this is following Andrew's suggestion and the minimum from Linux.

This patch is candidate to 4.15 and backport.

I think such a change needs to be proposed much earlier in a release cycle.

README provided by your OS distributor: · line 42

Quoted 9 lines
README +1 -1
@@ -38,12 +38,15 @@ provided by your OS distributor:
     * GNU Make v3.80 or later
     * C compiler and linker:
       - For x86:
-        - GCC 4.1.2_20070115 or later
+        - GCC 4.9 or later
         - GNU Binutils 2.16.91.0.5 or later

I don't think it makes much sense to keep the binutils version this low, the more that I don't think we can really build (correctly) with this old a version anymore. Whatever the gcc version chosen, I think we want to pick a binutils version from about the same time frame.

xen/include/xen/compiler.h line 10

Quoted 9 lines
xen/include/xen/compiler.h +3 -0
@@ -5,6 +5,19 @@
 #error Sorry, your compiler is too old/not recognized.
 #endif
 
+#if CONFIG_CC_IS_GCC
+# if CONFIG_GCC_VERSION < 40900
+/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 */

As per the bug report, the issue was determined to not be present in e.g. 4.3. Hence while such a bug may influence our choice of minimum version, I don't think it can reasonably be named here as the apparent only reason for the choice. Personally I don't think any justification should be put here.

xen/include/xen/compiler.h line 17

Quoted 7 lines
xen/include/xen/compiler.h +7 -0
+#  error Sorry, your version of GCC is too old - please use 4.9 or newer.
+# elif defined(CONFIG_ARM_64) && CONFIG_GCC_VERSION < 50100
+/*
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
+ * https://lore.kernel.org/r/[email protected]
+ */
+#  error Sorry, your version of GCC is too old - please use 5.1 or newer.

From the bug entry the fix looks to have been backported to 4.9, or at least some (important?) branches thereof.

xen/include/xen/compiler.h line 19

Quoted 2 lines
xen/include/xen/compiler.h +2 -0
+# endif
+#endif

Instead of a completely new conditional, I think this wants to be combined with the existing one (the tail of which is visible in context above).

Jan

#4 lore raw
Quoted 14 lines · Jan Beulich
Quoted 13 lines · Julien Grall

From: Julien Grall <[email protected]>

Compilers older than 4.8 have known codegen issues which can lead to silent miscompilation:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145

Furthermore, pre-4.9 GCC have known bugs (including things like internal compiler errors on Arm) which would require workaround (I haven't checked if we have any in Xen).

The minimum version of GCC to build the hypervisor is now raised to 4.9.

Quoted 8 lines
Quoted 6 lines

In addition to that, on arm64, GCC version >= 4.9 and < 5.1 have been shown to emit memory references beyond the stack pointer, resulting in memory corruption if an interrupt is taken after the stack pointer has been adjusted but before the reference has been executed.

Therefore, the minimum for arm64 is raised to 5.1.

I'm sure newer compiler versions also have bugs.

I don't doubt that...

Quoted 2 lines

Therefore I'm not
convinced using this as the primary reason for a bump is enough.

You also have to take into account the severity of the bug and possible workaround. The bug in 5.1 is severe *and* has no easy (to avoid saying possible) workaround.

Quoted 3 lines

Plus what if critical to us bugs get found in, say, 5.x? Are we going to bump to 6.x then (and so on, until we allow only the most recent major version to be used)?

In the current situation we are claiming that all GCC versions from ~2014 are supported.

However, in reality, there are an high number of chance that some of the version will not build Xen or worse miscompile it.

The former kind of bug is not a big deal because the user will notice it directly. However, the latter is highly critical because 1) They may only happen sporadically 2) compiler related bug is difficult to root cause.

So I think a smaller set of version is going to be better for the users and for us long term.

Quoted 4 lines

Additionally - partly related to your own reply regarding the CI failures - imo there needs to be an analysis of what older distros will no longer build (at all or by default).

Per the CI, this would be Ubuntu Trusty (and older), Centos 7 (and older)

Do you have any other in mind?

Quoted 9 lines

We've been discussing
to bump minimum tool chain versions for a long time. At least as far as I'm concerned, I didn't take on this job precisely because the code changes needed are relatively simple, but justification can (and apparently will) be rather complicated.

Fundamentally, whatever kind of criteria we use to justify the bump now ought to be usable down the road by people justifying further bumps.

I see you mentioned about distros. Can you outline other criteria you have in mind?

Quoted 2 lines

Also - what about clang? Linux requires 10.0.1 as a minimum.

I don't know and I would rather focus on GCC first so we figure out a set of criterias...

Quoted 10 lines
Quoted 7 lines

---

I don't have a strong opinion on the minimum version for GCC on x86. So this is following Andrew's suggestion and the minimum from Linux.

This patch is candidate to 4.15 and backport.

I think such a change needs to be proposed much earlier in a release cycle.

Possibly... At the same time, we don't want to release 4.15 and continue to say Xen on Arm64 can build fine with 4.9 and 5.0.

Quoted 16 lines

README provided by your OS distributor: · line 42

Quoted 10 lines
README +1 -1
@@ -38,12 +38,15 @@ provided by your OS distributor:
      * GNU Make v3.80 or later
      * C compiler and linker:
        - For x86:
-        - GCC 4.1.2_20070115 or later
+        - GCC 4.9 or later
          - GNU Binutils 2.16.91.0.5 or later

I don't think it makes much sense to keep the binutils version this low, the more that I don't think we can really build (correctly) with this old a version anymore. Whatever the gcc version chosen, I think we want to pick a binutils version from about the same time frame.

Ok. Let's first agree on a GCC version and then we can decide on a binutils version.

Quoted 7 lines
Quoted 7 lines
xen/include/xen/compiler.h +0 -0
@@ -5,6 +5,19 @@
  #error Sorry, your compiler is too old/not recognized.
  #endif
 
Quoted 9 lines

xen/include/xen/compiler.h line 10

Quoted 3 lines
xen/include/xen/compiler.h +3 -0
+#if CONFIG_CC_IS_GCC
+# if CONFIG_GCC_VERSION < 40900
+/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 */

As per the bug report, the issue was determined to not be present in e.g. 4.3. Hence while such a bug may influence our choice of minimum version, I don't think it can reasonably be named here as the apparent only reason for the choice. Personally I don't think any justification should be put here.

Ok.

Quoted 11 lines

xen/include/xen/compiler.h line 17

Quoted 8 lines
xen/include/xen/compiler.h +7 -0
+#  error Sorry, your version of GCC is too old - please use 4.9 or newer.
+# elif defined(CONFIG_ARM_64) && CONFIG_GCC_VERSION < 50100
+/*
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
+ * https://lore.kernel.org/r/[email protected]
+ */
+#  error Sorry, your version of GCC is too old - please use 5.1 or newer.

From the bug entry the fix looks to have been backported to 4.9,
or at least some (important?) branches thereof.

It is not clear what's you are trying to point out. Mind clarifying?

Quoted 7 lines

xen/include/xen/compiler.h line 19

Quoted 3 lines
xen/include/xen/compiler.h +2 -0
+# endif
+#endif

Instead of a completely new conditional, I think this wants to be combined with the existing one (the tail of which is visible in context above).

OK.

Cheers,

Signature · 1 line
Julien Grall
#5 lore raw
Quoted 39 lines · Julien Grall
Quoted 14 lines · Jan Beulich
Quoted 13 lines · Julien Grall

From: Julien Grall <[email protected]>

Compilers older than 4.8 have known codegen issues which can lead to silent miscompilation:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145

Furthermore, pre-4.9 GCC have known bugs (including things like internal compiler errors on Arm) which would require workaround (I haven't checked if we have any in Xen).

The minimum version of GCC to build the hypervisor is now raised to 4.9.

Quoted 8 lines
Quoted 6 lines

In addition to that, on arm64, GCC version >= 4.9 and < 5.1 have been shown to emit memory references beyond the stack pointer, resulting in memory corruption if an interrupt is taken after the stack pointer has been adjusted but before the reference has been executed.

Therefore, the minimum for arm64 is raised to 5.1.

I'm sure newer compiler versions also have bugs.

I don't doubt that...

Quoted 2 lines

Therefore I'm not
convinced using this as the primary reason for a bump is enough.

You also have to take into account the severity of the bug and possible workaround. The bug in 5.1 is severe *and* has no easy (to avoid saying possible) workaround.

Quoted 3 lines

Plus what if critical to us bugs get found in, say, 5.x? Are we going to bump to 6.x then (and so on, until we allow only the most recent major version to be used)?

In the current situation we are claiming that all GCC versions from ~2014 are supported.

Quoted 6 lines

However, in reality, there are an high number of chance that some of the version will not build Xen or worse miscompile it.

The former kind of bug is not a big deal because the user will notice it directly. However, the latter is highly critical because 1) They may only happen sporadically 2) compiler related bug is difficult to root cause.

Since I realize it may not have been clear from my initial reply:
What you want to do for Arm64 is largely up to you. I agree that the bug in question is really bad.

I understand it was Andrew who asked you to cover x86 at the same time, so perhaps it should be more him than you to justify the choice. Yet you've submitted the patch, so (I'm sorry) there you go ...

Quoted 7 lines
Quoted 3 lines

Additionally - partly related to your own reply regarding the CI failures - imo there needs to be an analysis of what older distros will no longer build (at all or by default).

Per the CI, this would be Ubuntu Trusty (and older), Centos 7 (and older)

Do you have any other in mind?

Our SLE12 (latest service pack is SP5 and still has a while to go to at least reach LTSS state) comes with gcc 4.8 as the default compiler.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

---

I don't have a strong opinion on the minimum version for GCC on x86. So this is following Andrew's suggestion and the minimum from Linux.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

This patch is candidate to 4.15 and backport.

I think such a change needs to be proposed much earlier in a release cycle.

Possibly... At the same time, we don't want to release 4.15 and continue to say Xen on Arm64 can build fine with 4.9 and 5.0.

4.9 could be excluded if need be. 4.8 is fine? Also I don't think there's much point thinking about 5.0 - that's where their version numbering scheme changed and the first released version is 5.1.

Quoted 30 lines
Quoted 6 lines
Quoted 6 lines
xen/include/xen/compiler.h +0 -0
@@ -5,6 +5,19 @@
  #error Sorry, your compiler is too old/not recognized.
  #endif
 
Quoted 9 lines

xen/include/xen/compiler.h line 10

Quoted 3 lines
xen/include/xen/compiler.h +3 -0
+#if CONFIG_CC_IS_GCC
+# if CONFIG_GCC_VERSION < 40900
+/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 */

As per the bug report, the issue was determined to not be present in e.g. 4.3. Hence while such a bug may influence our choice of minimum version, I don't think it can reasonably be named here as the apparent only reason for the choice. Personally I don't think any justification should be put here.

Ok.

Quoted 11 lines

xen/include/xen/compiler.h line 17

Quoted 8 lines
xen/include/xen/compiler.h +7 -0
+#  error Sorry, your version of GCC is too old - please use 4.9 or newer.
+# elif defined(CONFIG_ARM_64) && CONFIG_GCC_VERSION < 50100
+/*
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
+ * https://lore.kernel.org/r/[email protected]
+ */
+#  error Sorry, your version of GCC is too old - please use 5.1 or newer.

From the bug entry the fix looks to have been backported to 4.9,
or at least some (important?) branches thereof.

Quoted 1 line

It is not clear what's you are trying to point out. Mind clarifying?

Some 4.9 compilers (perhaps widely used ones) may not have the bad issue, which puts under question their ruling out when the main reason for doing so is that bug.

Jan

#6 lore raw

Hi Jan,

Quoted 43 lines · Jan Beulich
Quoted 42 lines · Julien Grall
Quoted 14 lines · Jan Beulich
Quoted 13 lines · Julien Grall

From: Julien Grall <[email protected]>

Compilers older than 4.8 have known codegen issues which can lead to silent miscompilation:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145

Furthermore, pre-4.9 GCC have known bugs (including things like internal compiler errors on Arm) which would require workaround (I haven't checked if we have any in Xen).

The minimum version of GCC to build the hypervisor is now raised to 4.9.

Quoted 8 lines
Quoted 6 lines

In addition to that, on arm64, GCC version >= 4.9 and < 5.1 have been shown to emit memory references beyond the stack pointer, resulting in memory corruption if an interrupt is taken after the stack pointer has been adjusted but before the reference has been executed.

Therefore, the minimum for arm64 is raised to 5.1.

I'm sure newer compiler versions also have bugs.

I don't doubt that...

Quoted 2 lines

Therefore I'm not
convinced using this as the primary reason for a bump is enough.

You also have to take into account the severity of the bug and possible workaround. The bug in 5.1 is severe *and* has no easy (to avoid saying possible) workaround.

Quoted 3 lines

Plus what if critical to us bugs get found in, say, 5.x? Are we going to bump to 6.x then (and so on, until we allow only the most recent major version to be used)?

In the current situation we are claiming that all GCC versions from ~2014 are supported.

However, in reality, there are an high number of chance that some of the version will not build Xen or worse miscompile it.

Quoted 7 lines
Quoted 3 lines

The former kind of bug is not a big deal because the user will notice it directly. However, the latter is highly critical because 1) They may only happen sporadically 2) compiler related bug is difficult to root cause.

Since I realize it may not have been clear from my initial reply:
What you want to do for Arm64 is largely up to you. I agree that the bug in question is really bad.

Ah, thanks for the clarification.

Quoted 4 lines

I understand it was Andrew who asked you to cover x86 at the same time, so perhaps it should be more him than you to justify the choice. Yet you've submitted the patch, so (I'm sorry) there you go ...

As I initially wrote, I don't particularly mind the version for x86.

I can split the patch in two to avoid mixing the discussions.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Additionally - partly related to your own reply regarding the CI failures - imo there needs to be an analysis of what older distros will no longer build (at all or by default).

Quoted 7 lines
Quoted 3 lines

Per the CI, this would be Ubuntu Trusty (and older), Centos 7 (and older)

Do you have any other in mind?

Our SLE12 (latest service pack is SP5 and still has a while to go to at least reach LTSS state) comes with gcc 4.8 as the default compiler.

Thanks! That's good to know. Is it the old GCC Suse supports?

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

---

I don't have a strong opinion on the minimum version for GCC on x86. So this is following Andrew's suggestion and the minimum from Linux.

This patch is candidate to 4.15 and backport.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I think such a change needs to be proposed much earlier in a release cycle.

Possibly... At the same time, we don't want to release 4.15 and continue to say Xen on Arm64 can build fine with 4.9 and 5.0.

4.9 could be excluded if need be. 4.8 is fine?

I am not entirely sure. The bug I pointed out in the commit message ([1]) seems to affect any GCC version until 4.8.

Quoted 3 lines

Also I don't think
there's much point thinking about 5.0 - that's where their version numbering scheme changed and the first released version is 5.1.

Good point. I didn't released that 5.0 never existed.

Quoted 30 lines
Quoted 30 lines
Quoted 6 lines
Quoted 6 lines
xen/include/xen/compiler.h +0 -0
@@ -5,6 +5,19 @@
   #error Sorry, your compiler is too old/not recognized.
   #endif
 
Quoted 9 lines

xen/include/xen/compiler.h line 10

Quoted 3 lines
xen/include/xen/compiler.h +3 -0
+#if CONFIG_CC_IS_GCC
+# if CONFIG_GCC_VERSION < 40900
+/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 */

As per the bug report, the issue was determined to not be present in e.g. 4.3. Hence while such a bug may influence our choice of minimum version, I don't think it can reasonably be named here as the apparent only reason for the choice. Personally I don't think any justification should be put here.

Ok.

Quoted 11 lines

xen/include/xen/compiler.h line 17

Quoted 8 lines
xen/include/xen/compiler.h +7 -0
+#  error Sorry, your version of GCC is too old - please use 4.9 or newer.
+# elif defined(CONFIG_ARM_64) && CONFIG_GCC_VERSION < 50100
+/*
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
+ * https://lore.kernel.org/r/[email protected]
+ */
+#  error Sorry, your version of GCC is too old - please use 5.1 or newer.

From the bug entry the fix looks to have been backported to 4.9,
or at least some (important?) branches thereof.

Quoted 5 lines
Quoted 1 line

It is not clear what's you are trying to point out. Mind clarifying?

Some 4.9 compilers (perhaps widely used ones) may not have the bad issue, which puts under question their ruling out when the main reason for doing so is that bug.

Well... We could surely try to hunt which GCC 4.9 has been fixed. But I am not convinced this is useful, we would need to have an allowlist of GCC compiler.

From my experience, the best way to know if someone care about a specific version is to bump it and see who shout. If no one shout, then you know that it wasn't important.

If someone shout, then we can decide how to re-enable support for GCC X.Y.

The fact Linux bumped to 5.1 on Arm64 give me some confidence that the move is not risky.

I know you may not be happy with my problem, so one possible mitigation is to allow a developer to override the check using Kconfig (maybe gated with UNSUPPORTED/EXPERT).

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145

Signature · 1 line
Julien Grall
#7 lore raw
Quoted 9 lines · Julien Grall
Quoted 8 lines · Jan Beulich
Quoted 7 lines · Julien Grall
Quoted 3 lines · Jan Beulich

Additionally - partly related to your own reply regarding the CI failures - imo there needs to be an analysis of what older distros will no longer build (at all or by default).

Per the CI, this would be Ubuntu Trusty (and older), Centos 7 (and older)

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Do you have any other in mind?

Our SLE12 (latest service pack is SP5 and still has a while to go to at least reach LTSS state) comes with gcc 4.8 as the default compiler.

Thanks! That's good to know. Is it the old GCC Suse supports?

Not sure I understand the question: The default compiler of this or any distro is of course (expected to be) supported by the vendor for the lifetime of the OS.

Quoted 32 lines
Quoted 32 lines
Quoted 31 lines
Quoted 6 lines
Quoted 6 lines
xen/include/xen/compiler.h +0 -0
@@ -5,6 +5,19 @@
   #error Sorry, your compiler is too old/not recognized.
   #endif
 
Quoted 9 lines

xen/include/xen/compiler.h line 10

Quoted 3 lines
xen/include/xen/compiler.h +3 -0
+#if CONFIG_CC_IS_GCC
+# if CONFIG_GCC_VERSION < 40900
+/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 */

As per the bug report, the issue was determined to not be present in e.g. 4.3. Hence while such a bug may influence our choice of minimum version, I don't think it can reasonably be named here as the apparent only reason for the choice. Personally I don't think any justification should be put here.

Ok.

Quoted 11 lines

xen/include/xen/compiler.h line 17

Quoted 8 lines
xen/include/xen/compiler.h +7 -0
+#  error Sorry, your version of GCC is too old - please use 4.9 or newer.
+# elif defined(CONFIG_ARM_64) && CONFIG_GCC_VERSION < 50100
+/*
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
+ * https://lore.kernel.org/r/[email protected]
+ */
+#  error Sorry, your version of GCC is too old - please use 5.1 or newer.

From the bug entry the fix looks to have been backported to 4.9,
or at least some (important?) branches thereof.

It is not clear what's you are trying to point out. Mind clarifying?

Quoted 7 lines
Quoted 3 lines

Some 4.9 compilers (perhaps widely used ones) may not have the bad issue, which puts under question their ruling out when the main reason for doing so is that bug.

Well... We could surely try to hunt which GCC 4.9 has been fixed. But I am not convinced this is useful, we would need to have an allowlist of GCC compiler.

Or probe the compiler for the bug in question.

Jan

#8 lore raw

Hi Jan,

Quoted 16 lines · Jan Beulich
Quoted 15 lines · Julien Grall
Quoted 13 lines · Jan Beulich
Quoted 8 lines · Julien Grall
Quoted 3 lines · Jan Beulich

Additionally - partly related to your own reply regarding the CI failures - imo there needs to be an analysis of what older distros will no longer build (at all or by default).

Per the CI, this would be Ubuntu Trusty (and older), Centos 7 (and older)

Do you have any other in mind?

Our SLE12 (latest service pack is SP5 and still has a while to go to at least reach LTSS state) comes with gcc 4.8 as the default compiler.

Quoted 5 lines
Quoted 1 line

Thanks! That's good to know. Is it the old GCC Suse supports?

Not sure I understand the question: The default compiler of this or any distro is of course (expected to be) supported by the vendor for the lifetime of the OS.

Sorry for the wording. I was asking whether Suse also supports compiler older than GCC 4.8.

Quoted 37 lines
Quoted 37 lines
Quoted 36 lines
Quoted 31 lines
Quoted 7 lines
Quoted 7 lines
xen/include/xen/compiler.h +0 -0
@@ -5,6 +5,19 @@
    #error Sorry, your compiler is too old/not recognized.
    #endif
 
Quoted 9 lines

xen/include/xen/compiler.h line 10

Quoted 3 lines
xen/include/xen/compiler.h +3 -0
+#if CONFIG_CC_IS_GCC
+# if CONFIG_GCC_VERSION < 40900
+/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 */

As per the bug report, the issue was determined to not be present in e.g. 4.3. Hence while such a bug may influence our choice of minimum version, I don't think it can reasonably be named here as the apparent only reason for the choice. Personally I don't think any justification should be put here.

Ok.

Quoted 11 lines

xen/include/xen/compiler.h line 17

Quoted 8 lines
xen/include/xen/compiler.h +7 -0
+#  error Sorry, your version of GCC is too old - please use 4.9 or newer.
+# elif defined(CONFIG_ARM_64) && CONFIG_GCC_VERSION < 50100
+/*
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
+ * https://lore.kernel.org/r/[email protected]
+ */
+#  error Sorry, your version of GCC is too old - please use 5.1 or newer.

From the bug entry the fix looks to have been backported to 4.9,
or at least some (important?) branches thereof.

Quoted 1 line

It is not clear what's you are trying to point out. Mind clarifying?

Some 4.9 compilers (perhaps widely used ones) may not have the bad issue, which puts under question their ruling out when the main reason for doing so is that bug.

Quoted 5 lines
Quoted 3 lines

Well... We could surely try to hunt which GCC 4.9 has been fixed. But I am not convinced this is useful, we would need to have an allowlist of GCC compiler.

Or probe the compiler for the bug in question.

I thought about it but it is not clear to me whether the reproducer would work on every GCC version and how to detect that this was miscompiled.

Do you have any suggestion?

Cheers,

Signature · 1 line
Julien Grall
#9 lore raw
Quoted 17 lines · Julien Grall
Quoted 16 lines · Jan Beulich
Quoted 15 lines · Julien Grall
Quoted 13 lines · Jan Beulich
Quoted 8 lines · Julien Grall
Quoted 3 lines · Jan Beulich

Additionally - partly related to your own reply regarding the CI failures - imo there needs to be an analysis of what older distros will no longer build (at all or by default).

Per the CI, this would be Ubuntu Trusty (and older), Centos 7 (and older)

Do you have any other in mind?

Our SLE12 (latest service pack is SP5 and still has a while to go to at least reach LTSS state) comes with gcc 4.8 as the default compiler.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Thanks! That's good to know. Is it the old GCC Suse supports?

Not sure I understand the question: The default compiler of this or any distro is of course (expected to be) supported by the vendor for the lifetime of the OS.

Sorry for the wording. I was asking whether Suse also supports compiler older than GCC 4.8.

Oh, I see. SLES11 has another year to go for LTSS to end, and it's 4.3 which is used there.

Quoted 40 lines
Quoted 40 lines
Quoted 39 lines
Quoted 30 lines
Quoted 30 lines
Quoted 6 lines
Quoted 6 lines
xen/include/xen/compiler.h +0 -0
@@ -5,6 +5,19 @@
    #error Sorry, your compiler is too old/not recognized.
    #endif
 
Quoted 9 lines

xen/include/xen/compiler.h line 10

Quoted 3 lines
xen/include/xen/compiler.h +3 -0
+#if CONFIG_CC_IS_GCC
+# if CONFIG_GCC_VERSION < 40900
+/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 */

As per the bug report, the issue was determined to not be present in e.g. 4.3. Hence while such a bug may influence our choice of minimum version, I don't think it can reasonably be named here as the apparent only reason for the choice. Personally I don't think any justification should be put here.

Ok.

Quoted 11 lines

xen/include/xen/compiler.h line 17

Quoted 8 lines
xen/include/xen/compiler.h +7 -0
+#  error Sorry, your version of GCC is too old - please use 4.9 or newer.
+# elif defined(CONFIG_ARM_64) && CONFIG_GCC_VERSION < 50100
+/*
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
+ * https://lore.kernel.org/r/[email protected]
+ */
+#  error Sorry, your version of GCC is too old - please use 5.1 or newer.

From the bug entry the fix looks to have been backported to 4.9,
or at least some (important?) branches thereof.

Quoted 5 lines
Quoted 1 line

It is not clear what's you are trying to point out. Mind clarifying?

Some 4.9 compilers (perhaps widely used ones) may not have the bad issue, which puts under question their ruling out when the main reason for doing so is that bug.

Well... We could surely try to hunt which GCC 4.9 has been fixed. But I am not convinced this is useful, we would need to have an allowlist of GCC compiler.

Quoted 6 lines
Quoted 1 line

Or probe the compiler for the bug in question.

I thought about it but it is not clear to me whether the reproducer would work on every GCC version and how to detect that this was miscompiled.

Do you have any suggestion?

To have one I'd have to study the problem in quite a bit more detail. But I did say that what you do for Arm is largely up to you (and Stefano did meanwhile ack the Arm side), so I'm not sure I want to invest the time that would be needed.

Jan

#10 lore raw

Hi Jan,

Quoted 24 lines · Jan Beulich
Quoted 23 lines · Julien Grall
Quoted 21 lines · Jan Beulich
Quoted 9 lines · Julien Grall
Quoted 8 lines · Jan Beulich
Quoted 7 lines · Julien Grall
Quoted 3 lines · Jan Beulich

Additionally - partly related to your own reply regarding the CI failures - imo there needs to be an analysis of what older distros will no longer build (at all or by default).

Per the CI, this would be Ubuntu Trusty (and older), Centos 7 (and older)

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Do you have any other in mind?

Our SLE12 (latest service pack is SP5 and still has a while to go to at least reach LTSS state) comes with gcc 4.8 as the default compiler.

Thanks! That's good to know. Is it the old GCC Suse supports?

Not sure I understand the question: The default compiler of this or any distro is of course (expected to be) supported by the vendor for the lifetime of the OS.

Quoted 5 lines
Quoted 2 lines

Sorry for the wording. I was asking whether Suse also supports compiler older than GCC 4.8.

Oh, I see. SLES11 has another year to go for LTSS to end, and it's 4.3 which is used there.

Thanks for the info! Are you planning to build Xen 4.15 there too?

Quoted 46 lines
Quoted 46 lines
Quoted 37 lines
Quoted 37 lines
Quoted 36 lines
Quoted 31 lines
Quoted 7 lines
Quoted 7 lines
xen/include/xen/compiler.h +0 -0
@@ -5,6 +5,19 @@
     #error Sorry, your compiler is too old/not recognized.
     #endif
 
Quoted 9 lines

xen/include/xen/compiler.h line 10

Quoted 3 lines
xen/include/xen/compiler.h +3 -0
+#if CONFIG_CC_IS_GCC
+# if CONFIG_GCC_VERSION < 40900
+/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 */

As per the bug report, the issue was determined to not be present in e.g. 4.3. Hence while such a bug may influence our choice of minimum version, I don't think it can reasonably be named here as the apparent only reason for the choice. Personally I don't think any justification should be put here.

Ok.

Quoted 11 lines

xen/include/xen/compiler.h line 17

Quoted 8 lines
xen/include/xen/compiler.h +7 -0
+#  error Sorry, your version of GCC is too old - please use 4.9 or newer.
+# elif defined(CONFIG_ARM_64) && CONFIG_GCC_VERSION < 50100
+/*
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
+ * https://lore.kernel.org/r/[email protected]
+ */
+#  error Sorry, your version of GCC is too old - please use 5.1 or newer.

From the bug entry the fix looks to have been backported to 4.9,
or at least some (important?) branches thereof.

Quoted 1 line

It is not clear what's you are trying to point out. Mind clarifying?

Some 4.9 compilers (perhaps widely used ones) may not have the bad issue, which puts under question their ruling out when the main reason for doing so is that bug.

Quoted 5 lines
Quoted 3 lines

Well... We could surely try to hunt which GCC 4.9 has been fixed. But I am not convinced this is useful, we would need to have an allowlist of GCC compiler.

Or probe the compiler for the bug in question.

I thought about it but it is not clear to me whether the reproducer would work on every GCC version and how to detect that this was miscompiled.

Quoted 6 lines
Quoted 1 line

Do you have any suggestion?

To have one I'd have to study the problem in quite a bit more detail. But I did say that what you do for Arm is largely up to you (and Stefano did meanwhile ack the Arm side), so I'm not sure I want to invest the time that would be needed.

Well, there are still miscompilation problem on x86... So it would be good to have a way to address it.

Anyway, I will split the Arm change in a separate patch so it can go in 4.15.

Cheers,

Signature · 1 line
Julien Grall
#11 lore raw
Quoted 25 lines · Julien Grall
Quoted 24 lines · Jan Beulich
Quoted 23 lines · Julien Grall
Quoted 21 lines · Jan Beulich
Quoted 9 lines · Julien Grall
Quoted 8 lines · Jan Beulich
Quoted 7 lines · Julien Grall
Quoted 3 lines · Jan Beulich

Additionally - partly related to your own reply regarding the CI failures - imo there needs to be an analysis of what older distros will no longer build (at all or by default).

Per the CI, this would be Ubuntu Trusty (and older), Centos 7 (and older)

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Do you have any other in mind?

Our SLE12 (latest service pack is SP5 and still has a while to go to at least reach LTSS state) comes with gcc 4.8 as the default compiler.

Thanks! That's good to know. Is it the old GCC Suse supports?

Not sure I understand the question: The default compiler of this or any distro is of course (expected to be) supported by the vendor for the lifetime of the OS.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Sorry for the wording. I was asking whether Suse also supports compiler older than GCC 4.8.

Oh, I see. SLES11 has another year to go for LTSS to end, and it's 4.3 which is used there.

Thanks for the info! Are you planning to build Xen 4.15 there too?

If "you" is the company - there are no plans to provide 4.15 there. But I do build Xen myself on such systems. That's how I'm noticing compatibility issues like the one in grant table code where you don't like the workaround.

Jan

#12 lore raw
In reply to Julien Grall

Julien Grall writes ("[PATCH for-4.15] xen: Bump the minimum version of GCC supported to 4.9 (5.1 on arm64)"):

Quoted 11 lines

From: Julien Grall <[email protected]>

Compilers older than 4.8 have known codegen issues which can lead to silent miscompilation:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145

Furthermore, pre-4.9 GCC have known bugs (including things like internal compiler errors on Arm) which would require workaround (I haven't checked if we have any in Xen).

Quoted 8 lines

The minimum version of GCC to build the hypervisor is now raised to 4.9.

In addition to that, on arm64, GCC version >= 4.9 and < 5.1 have been shown to emit memory references beyond the stack pointer, resulting in memory corruption if an interrupt is taken after the stack pointer has been adjusted but before the reference has been executed.

Therefore, the minimum for arm64 is raised to 5.1.

How sad.

I don't currently have an opinion about the merits of this change. I'm hoping that the disagreement can be resolved without me having to have one :-).

Thanks,
Ian.

Acked-by on v1 1/1
#13 lore raw
In reply to Julien Grall
Quoted 13 lines · Julien Grall

From: Julien Grall <[email protected]>

Compilers older than 4.8 have known codegen issues which can lead to silent miscompilation:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145

Furthermore, pre-4.9 GCC have known bugs (including things like internal compiler errors on Arm) which would require workaround (I haven't checked if we have any in Xen).

The minimum version of GCC to build the hypervisor is now raised to 4.9.

Quoted 8 lines

In addition to that, on arm64, GCC version >= 4.9 and < 5.1 have been shown to emit memory references beyond the stack pointer, resulting in memory corruption if an interrupt is taken after the stack pointer has been adjusted but before the reference has been executed.

Therefore, the minimum for arm64 is raised to 5.1.

For the ARM part:

Quoted 63 lines

---

I don't have a strong opinion on the minimum version for GCC on x86. So this is following Andrew's suggestion and the minimum from Linux.

This patch is candidate to 4.15 and backport.

This is only a build change and will be low-risk for anyone using newer compiler (5.1+ for arm64 and 4.9 for everyone else). Xen will stop building for anyone using older compiler. But it is better than fighting with codegen issues.

---
 README                     |  9 ++++++---
 xen/include/xen/compiler.h | 13 +++++++++++++
 2 files changed, 19 insertions(+), 3 deletions(-)
README +6 -3
index 8c99c30986c1..5c32c03f2ea1 100644
@@ -38,12 +38,15 @@ provided by your OS distributor:
     * GNU Make v3.80 or later
     * C compiler and linker:
       - For x86:
-        - GCC 4.1.2_20070115 or later
+        - GCC 4.9 or later
         - GNU Binutils 2.16.91.0.5 or later
         or
         - Clang/LLVM 3.5 or later
-      - For ARM:
-        - GCC 4.8 or later
+      - For ARM 32-bit:
+        - GCC 4.9 or later
+        - GNU Binutils 2.24 or later
+      - For ARM 64-bit:
+        - GCC 5.1 or later
         - GNU Binutils 2.24 or later
     * Development install of zlib (e.g., zlib-dev)
     * Development install of Python 2.6 or later (e.g., python-dev)
xen/include/xen/compiler.h +13 -0
index 0ec0b4698ea7..46779660cc8f 100644
@@ -5,6 +5,19 @@
 #error Sorry, your compiler is too old/not recognized.
 #endif
 
+#if CONFIG_CC_IS_GCC
+# if CONFIG_GCC_VERSION < 40900
+/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 */
+#  error Sorry, your version of GCC is too old - please use 4.9 or newer.
+# elif defined(CONFIG_ARM_64) && CONFIG_GCC_VERSION < 50100
+/*
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
+ * https://lore.kernel.org/r/[email protected]
+ */
+#  error Sorry, your version of GCC is too old - please use 5.1 or newer.
+# endif
+#endif
+
 #define barrier()     __asm__ __volatile__("": : :"memory")
 
 #define likely(x)     __builtin_expect(!!(x),1)