From: "Theo de Raadt" Subject: Re: devel/libffi: arm64 BTI fix To: Mark Kettenis Cc: ports@openbsd.org, tobhe@openbsd.org, sthen@openbsd.org, jasper@openbsd.org Date: Thu, 07 Mar 2024 16:29:50 -0700 Crazy. Looks good. Mark Kettenis wrote: > This one was a bit tricky as I had to adjust the offsets used in the > instructions. But with this lang/guile3 no longer generates SIGILL > when running the tests. > > ok? > > > Index: devel/libffi/Makefile > =================================================================== > RCS file: /cvs/ports/devel/libffi/Makefile,v > retrieving revision 1.49 > diff -u -p -r1.49 Makefile > --- devel/libffi/Makefile 22 Nov 2023 14:18:03 -0000 1.49 > +++ devel/libffi/Makefile 7 Mar 2024 22:06:25 -0000 > @@ -1,7 +1,7 @@ > COMMENT= Foreign Function Interface > > V= 3.4.4 > -REVISION= 0 > +REVISION= 1 > DISTNAME= libffi-$V > SHARED_LIBS += ffi 2.0 # 9.2 > CATEGORIES= devel > Index: devel/libffi/patches/patch-src_aarch64_ffi_c > =================================================================== > RCS file: /cvs/ports/devel/libffi/patches/patch-src_aarch64_ffi_c,v > retrieving revision 1.1 > diff -u -p -r1.1 patch-src_aarch64_ffi_c > --- devel/libffi/patches/patch-src_aarch64_ffi_c 22 Nov 2023 14:18:03 -0000 1.1 > +++ devel/libffi/patches/patch-src_aarch64_ffi_c 7 Mar 2024 22:06:25 -0000 > @@ -74,3 +74,15 @@ Index: src/aarch64/ffi.c > : "memory", "v16", "v17", "v18", "v19"); > } > #endif > +@@ -873,8 +885,9 @@ ffi_prep_closure_loc (ffi_closure *closure, > + # endif > + #else > + static const unsigned char trampoline[16] = { > +- 0x90, 0x00, 0x00, 0x58, /* ldr x16, tramp+16 */ > +- 0xf1, 0xff, 0xff, 0x10, /* adr x17, tramp+0 */ > ++ 0x5f, 0x24, 0x03, 0xd5, /* bti c */ > ++ 0x70, 0x00, 0x00, 0x58, /* ldr x16, tramp+16 */ > ++ 0xd1, 0xff, 0xff, 0x10, /* adr x17, tramp+0 */ > + 0x00, 0x02, 0x1f, 0xd6 /* br x16 */ > + }; > + char *tramp = closure->tramp; >