Skip to contentSkip to conversation

Fix CI build on Free BSD 13

PATCH Applied Daniel P. Berrangé 4 participants 9 messages Mar 4, 2024 – Mar 5, 2024 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover Fix CI build on Free BSD 13

FreeBSD seems to have prematurely purged the 13.2 images from gcloud, despite 13.3 not being announced until tomorrow. Historically the old images were left available for quite some time, until we noticed ports failing due to missing symbols. Either way we need to update to 13.3

This exposed a clang bug so needs a workaround adding too.

Daniel P. Berrangé (2):
meson: detect broken clang 17 with -fzero-call-used-regs
gitlab: update FreeBSD Cirrus CI image to 13.3

 .gitlab-ci.d/cirrus.yml |  2 +-
 meson.build             | 17 ++++++++++++-----
 2 files changed, 13 insertions(+), 6 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 meson: detect broken clang 17 with -fzero-call-used-regs

Clang 17 will segv if given -fzero-call-used-regs and optimization is enabled. Since upstream hasn't triaged the bug, distros are increasingly shipping with broken Clang.

https://github.com/llvm/llvm-project/issues/75168
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277474

---
 meson.build | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
meson.build +12 -5
index 0ef1654e86..762798f2ee 100644
@@ -555,17 +555,24 @@ endif
 # Check further flags that make QEMU more robust against malicious parties
 
 hardening_flags = [
-    # Zero out registers used during a function call
-    # upon its return. This makes it harder to assemble
-    # ROP gadgets into something usable
-    '-fzero-call-used-regs=used-gpr',
-
     # Initialize all stack variables to zero. This makes
     # it harder to take advantage of uninitialized stack
     # data to drive exploits
     '-ftrivial-auto-var-init=zero',
 ]
 
+# Zero out registers used during a function call
+# upon its return. This makes it harder to assemble
+# ROP gadgets into something usable
+#
+# NB: CLang 17 is broken and SEGVs
+# https://github.com/llvm/llvm-project/issues/75168
+if cc.compiles('extern struct { void (*cb)(void); } s; void f(void) { s.cb(); }',
+               name: '-fzero-call-used-regs=used-gpr',
+               args: ['-O2', '-fzero-call-used-regs=used-gpr'])
+    hardening_flags += '-fzero-call-used-regs=used-gpr'
+endif
+
 qemu_common_flags += cc.get_supported_arguments(hardening_flags)
 
 add_global_arguments(qemu_common_flags, native: false, language: all_languages)
Signature · 1 line
2.43.0
#3 lore raw

PATCH 2/2 gitlab: update FreeBSD Cirrus CI image to 13.3

In reply to Daniel P. Berrangé

The 13.2 images have been deleted from gcloud

---
 .gitlab-ci.d/cirrus.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
.gitlab-ci.d/cirrus.yml +1 -1
index 64f2e25afa..b45f9de62f 100644
@@ -52,7 +52,7 @@ x64-freebsd-13-build:
     NAME: freebsd-13
     CIRRUS_VM_INSTANCE_TYPE: freebsd_instance
     CIRRUS_VM_IMAGE_SELECTOR: image_family
-    CIRRUS_VM_IMAGE_NAME: freebsd-13-2
+    CIRRUS_VM_IMAGE_NAME: freebsd-13-3
     CIRRUS_VM_CPUS: 8
     CIRRUS_VM_RAM: 8G
     UPDATE_COMMAND: pkg update; pkg upgrade -y
Signature · 1 line
2.43.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] meson: detect broken clang 17 with -fzero-call-used-regs

In reply to Daniel P. Berrangé
Quoted 26 lines · Daniel P. Berrangé

Clang 17 will segv if given -fzero-call-used-regs and optimization is enabled. Since upstream hasn't triaged the bug, distros are increasingly shipping with broken Clang.

https://github.com/llvm/llvm-project/issues/75168
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277474

---
 meson.build | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
meson.build +0 -5
index 0ef1654e86..762798f2ee 100644
@@ -555,17 +555,24 @@ endif
 # Check further flags that make QEMU more robust against malicious parties
 
 hardening_flags = [
-    # Zero out registers used during a function call
-    # upon its return. This makes it harder to assemble
-    # ROP gadgets into something usable
-    '-fzero-call-used-regs=used-gpr',
-
     # Initialize all stack variables to zero. This makes

meson.build endif · line 568

Quoted 10 lines
meson.build +5 -0
     # it harder to take advantage of uninitialized stack
     # data to drive exploits
     '-ftrivial-auto-var-init=zero',
 ]
 
+# Zero out registers used during a function call
+# upon its return. This makes it harder to assemble
+# ROP gadgets into something usable
+#
+# NB: CLang 17 is broken and SEGVs

"Clang"

meson.build endif · line 578

Quoted 10 lines
meson.build +7 -0
+# https://github.com/llvm/llvm-project/issues/75168
+if cc.compiles('extern struct { void (*cb)(void); } s; void f(void) { s.cb(); }',
+               name: '-fzero-call-used-regs=used-gpr',
+               args: ['-O2', '-fzero-call-used-regs=used-gpr'])
+    hardening_flags += '-fzero-call-used-regs=used-gpr'
+endif
+
 qemu_common_flags += cc.get_supported_arguments(hardening_flags)
 
 add_global_arguments(qemu_common_flags, native: false, language: all_languages)

The stable releases don't have the use of -fzero-call-used-regs, so we don't need to backport this.

thanks
-- PMM

Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] gitlab: update FreeBSD Cirrus CI image to 13.3

In reply to Daniel P. Berrangé
Quoted 13 lines · Daniel P. Berrangé

The 13.2 images have been deleted from gcloud

---
 .gitlab-ci.d/cirrus.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
.gitlab-ci.d/cirrus.yml +0 -0
index 64f2e25afa..b45f9de62f 100644

.gitlab-ci.d/cirrus.yml x64-freebsd-13-build:

Quoted 9 lines
.gitlab-ci.d/cirrus.yml +1 -2
@@ -52,7 +52,7 @@ x64-freebsd-13-build:
     NAME: freebsd-13
     CIRRUS_VM_INSTANCE_TYPE: freebsd_instance
     CIRRUS_VM_IMAGE_SELECTOR: image_family
-    CIRRUS_VM_IMAGE_NAME: freebsd-13-2
+    CIRRUS_VM_IMAGE_NAME: freebsd-13-3
     CIRRUS_VM_CPUS: 8
     CIRRUS_VM_RAM: 8G
     UPDATE_COMMAND: pkg update; pkg upgrade -y
--

This one should be tagged
Cc: [email protected]
I guess?

thanks
-- PMM

#5 lore raw

Re: [PATCH 2/2] gitlab: update FreeBSD Cirrus CI image to 13.3

Quoted 26 lines · Peter Maydell
Quoted 13 lines · Daniel P. Berrangé

The 13.2 images have been deleted from gcloud

---
 .gitlab-ci.d/cirrus.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
.gitlab-ci.d/cirrus.yml +0 -0
index 64f2e25afa..b45f9de62f 100644

.gitlab-ci.d/cirrus.yml x64-freebsd-13-build:

Quoted 9 lines
.gitlab-ci.d/cirrus.yml +1 -2
@@ -52,7 +52,7 @@ x64-freebsd-13-build:
     NAME: freebsd-13
     CIRRUS_VM_INSTANCE_TYPE: freebsd_instance
     CIRRUS_VM_IMAGE_SELECTOR: image_family
-    CIRRUS_VM_IMAGE_NAME: freebsd-13-2
+    CIRRUS_VM_IMAGE_NAME: freebsd-13-3
     CIRRUS_VM_CPUS: 8
     CIRRUS_VM_RAM: 8G
     UPDATE_COMMAND: pkg update; pkg upgrade -y
--
Quoted 3 lines

This one should be tagged
Cc: [email protected]
I guess?

Yes, this will be applicable to stable.

With regards,
Daniel

Signature · 3 lines
|: 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 :|
#7 lore raw
In reply to Daniel P. Berrangé
Quoted 6 lines · Daniel P. Berrangé

FreeBSD seems to have prematurely purged the 13.2 images from gcloud, despite 13.3 not being announced until tomorrow. Historically the old images were left available for quite some time, until we noticed ports failing due to missing symbols. Either way we need to update to 13.3

This exposed a clang bug so needs a workaround adding too.

Queued to testing/next, thanks.

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#8 lore raw
Quoted 11 lines · Alex Bennée
Quoted 6 lines · Daniel P. Berrangé

FreeBSD seems to have prematurely purged the 13.2 images from gcloud, despite 13.3 not being announced until tomorrow. Historically the old images were left available for quite some time, until we noticed ports failing due to missing symbols. Either way we need to update to 13.3

This exposed a clang bug so needs a workaround adding too.

Queued to testing/next, thanks.

I've applied this directly to git to fix the CI.

thanks
-- PMM