Index | Thread | Search

From:
Jonathan Gray <jsg@jsg.id.au>
Subject:
Re: glxgears BTI SIGILL, arm64
To:
Mark Kettenis <mark.kettenis@xs4all.nl>
Cc:
tech@openbsd.org
Date:
Wed, 3 Apr 2024 11:30:04 +1100

Download raw body.

Thread
On Thu, Mar 21, 2024 at 12:31:57AM +0100, Mark Kettenis wrote:
> 
> The proposed diff has been committed.  But we can do a little bit
> better by also enabling PAC.  The diff below brings us in line with
> the default BTI/PAC options in base clang.
> 
> I've lightly tested this myself, but some more testing on an x13s or
> an Apple laptop would be appreciated.

Still applies and builds on amd64 after the Mesa update.
ok jsg@

> 
> 
> 
> Index: lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_init.c
> ===================================================================
> RCS file: /cvs/xenocara/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_init.c,v
> retrieving revision 1.16
> diff -u -p -r1.16 lp_bld_init.c
> --- lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_init.c	18 Mar 2024 00:15:10 -0000	1.16
> +++ lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_init.c	20 Mar 2024 23:23:51 -0000
> @@ -361,7 +361,7 @@ init_gallivm_state(struct gallivm_state 
>  #endif
>  
>  #if DETECT_ARCH_AARCH64
> -   lp_set_module_branch_target_enforcement(gallivm->module);
> +   lp_set_module_branch_protection(gallivm->module);
>  #endif
>  
>     gallivm->builder = LLVMCreateBuilderInContext(gallivm->context);
> Index: lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
> ===================================================================
> RCS file: /cvs/xenocara/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp,v
> retrieving revision 1.18
> diff -u -p -r1.18 lp_bld_misc.cpp
> --- lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp	18 Mar 2024 00:15:10 -0000	1.18
> +++ lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp	20 Mar 2024 23:23:51 -0000
> @@ -621,8 +621,10 @@ lp_set_module_stack_alignment_override(L
>  }
>  
>  extern "C" void
> -lp_set_module_branch_target_enforcement(LLVMModuleRef MRef)
> +lp_set_module_branch_protection(LLVMModuleRef MRef)
>  {
> +   /* Enable standard (bti+pac-ret) branch protection */
>     llvm::Module *M = llvm::unwrap(MRef);
>     M->addModuleFlag(llvm::Module::Override, "branch-target-enforcement", 1);
> +   M->addModuleFlag(llvm::Module::Override, "sign-return-address", 1);
>  }
> Index: lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.h
> ===================================================================
> RCS file: /cvs/xenocara/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.h,v
> retrieving revision 1.11
> diff -u -p -r1.11 lp_bld_misc.h
> --- lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.h	18 Mar 2024 00:15:10 -0000	1.11
> +++ lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.h	20 Mar 2024 23:23:51 -0000
> @@ -96,7 +96,7 @@ void
>  lp_set_module_stack_alignment_override(LLVMModuleRef M, unsigned align);
>  
>  void
> -lp_set_module_branch_target_enforcement(LLVMModuleRef M);
> +lp_set_module_branch_protection(LLVMModuleRef M);
>  
>  #ifdef __cplusplus
>  }
> 
>