qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-9.0] meson.build: Disable -fzero-call-used-regs on OpenBSD
@ 2024-04-11 12:08 Thomas Huth
  2024-04-11 12:12 ` Thomas Huth
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Thomas Huth @ 2024-04-11 12:08 UTC (permalink / raw)
  To: qemu-devel, Brad Smith, Paolo Bonzini, Daniel P. Berrangé
  Cc: Philippe Mathieu-Daudé, Marc-André Lureau

QEMU currently does not work on OpenBSD since the -fzero-call-used-regs
option that we added to meson.build recently does not work with the
"retguard" extension from OpenBSD's Clang. Thus let's disable the
-fzero-call-used-regs here until there's a better solution available.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2278
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 Note: Given that we're close to the release, I think the host_os check
 is the best we can do ... the problem does not seem to trigger in all
 functions, only if certain registers are used by the compiler, so a
 more sophisticated check here seems to be too fragile to me right now.

 meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index c9c3217ba4..91a0aa64c6 100644
--- a/meson.build
+++ b/meson.build
@@ -562,7 +562,11 @@ hardening_flags = [
 #
 # 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(); }',
+#
+# NB2: This clashes with the "retguard" extension of OpenBSD's Clang
+# https://gitlab.com/qemu-project/qemu/-/issues/2278
+if host_os != 'openbsd' and \
+   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'
-- 
2.44.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH for-9.0] meson.build: Disable -fzero-call-used-regs on OpenBSD
  2024-04-11 12:08 [PATCH for-9.0] meson.build: Disable -fzero-call-used-regs on OpenBSD Thomas Huth
@ 2024-04-11 12:12 ` Thomas Huth
  2024-04-11 20:28   ` Brad Smith
  2024-04-11 14:56 ` Philippe Mathieu-Daudé
  2024-04-12 10:02 ` Paolo Bonzini
  2 siblings, 1 reply; 5+ messages in thread
From: Thomas Huth @ 2024-04-11 12:12 UTC (permalink / raw)
  To: qemu-devel, Brad Smith, Paolo Bonzini, Daniel P. Berrangé
  Cc: Philippe Mathieu-Daudé, Marc-André Lureau

On 11/04/2024 14.08, Thomas Huth wrote:
> QEMU currently does not work on OpenBSD since the -fzero-call-used-regs

That should be "OpenBSD 7.5" ... older versions are fine since they are 
using an older version of Clang that does not have -fzero-call-used-regs 
yet, I think.

  Thomas


> option that we added to meson.build recently does not work with the
> "retguard" extension from OpenBSD's Clang. Thus let's disable the
> -fzero-call-used-regs here until there's a better solution available.
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2278
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   Note: Given that we're close to the release, I think the host_os check
>   is the best we can do ... the problem does not seem to trigger in all
>   functions, only if certain registers are used by the compiler, so a
>   more sophisticated check here seems to be too fragile to me right now.
> 
>   meson.build | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/meson.build b/meson.build
> index c9c3217ba4..91a0aa64c6 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -562,7 +562,11 @@ hardening_flags = [
>   #
>   # 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(); }',
> +#
> +# NB2: This clashes with the "retguard" extension of OpenBSD's Clang
> +# https://gitlab.com/qemu-project/qemu/-/issues/2278
> +if host_os != 'openbsd' and \
> +   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'



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH for-9.0] meson.build: Disable -fzero-call-used-regs on OpenBSD
  2024-04-11 12:08 [PATCH for-9.0] meson.build: Disable -fzero-call-used-regs on OpenBSD Thomas Huth
  2024-04-11 12:12 ` Thomas Huth
@ 2024-04-11 14:56 ` Philippe Mathieu-Daudé
  2024-04-12 10:02 ` Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-04-11 14:56 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel, Brad Smith, Paolo Bonzini,
	Daniel P. Berrangé
  Cc: Marc-André Lureau, Richard Henderson

On 11/4/24 14:08, Thomas Huth wrote:
> QEMU currently does not work on OpenBSD since the -fzero-call-used-regs
> option that we added to meson.build recently does not work with the
> "retguard" extension from OpenBSD's Clang. Thus let's disable the
> -fzero-call-used-regs here until there's a better solution available.
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2278
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   Note: Given that we're close to the release, I think the host_os check
>   is the best we can do ... the problem does not seem to trigger in all
>   functions, only if certain registers are used by the compiler, so a
>   more sophisticated check here seems to be too fragile to me right now.
> 
>   meson.build | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/meson.build b/meson.build
> index c9c3217ba4..91a0aa64c6 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -562,7 +562,11 @@ hardening_flags = [
>   #
>   # 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(); }',
> +#
> +# NB2: This clashes with the "retguard" extension of OpenBSD's Clang
> +# https://gitlab.com/qemu-project/qemu/-/issues/2278
> +if host_os != 'openbsd' and \
> +   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'

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH for-9.0] meson.build: Disable -fzero-call-used-regs on OpenBSD
  2024-04-11 12:12 ` Thomas Huth
@ 2024-04-11 20:28   ` Brad Smith
  0 siblings, 0 replies; 5+ messages in thread
From: Brad Smith @ 2024-04-11 20:28 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel, Paolo Bonzini, Daniel P. Berrangé
  Cc: Philippe Mathieu-Daudé, Marc-André Lureau

On 4/11/2024 8:12 AM, Thomas Huth wrote:
> On 11/04/2024 14.08, Thomas Huth wrote:
>> QEMU currently does not work on OpenBSD since the -fzero-call-used-regs
>
> That should be "OpenBSD 7.5" ... older versions are fine since they 
> are using an older version of Clang that does not have 
> -fzero-call-used-regs yet, I think.

About the compiler version that is correct. Between 7.4 and 7.5 we 
upgraded from Clang 13 to 16.

-fzero-call-used-regs  was added with the 15 release.

https://github.com/llvm/llvm-project/commit/deaf22bc0e306bc44c70d2503e9364b5ed312c49

Retguard is also used to mitigate ROP exploits and is enabled by default.

https://www.openbsd.org/papers/asiabsdcon2019-rop-paper.pdf



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH for-9.0] meson.build: Disable -fzero-call-used-regs on OpenBSD
  2024-04-11 12:08 [PATCH for-9.0] meson.build: Disable -fzero-call-used-regs on OpenBSD Thomas Huth
  2024-04-11 12:12 ` Thomas Huth
  2024-04-11 14:56 ` Philippe Mathieu-Daudé
@ 2024-04-12 10:02 ` Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2024-04-12 10:02 UTC (permalink / raw)
  To: Thomas Huth
  Cc: qemu-devel, Brad Smith, Daniel P . Berrangé,
	Philippe Mathieu-Daudé, Marc-André Lureau

Queued, thanks.

Paolo



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-04-12 10:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-11 12:08 [PATCH for-9.0] meson.build: Disable -fzero-call-used-regs on OpenBSD Thomas Huth
2024-04-11 12:12 ` Thomas Huth
2024-04-11 20:28   ` Brad Smith
2024-04-11 14:56 ` Philippe Mathieu-Daudé
2024-04-12 10:02 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).