Date: Wed, 5 Jun 2024 19:52:10 +0100 From: Andrew Turner <andrew@fubar.geek.nz> To: Cy Schubert <Cy.Schubert@cschubert.com> Cc: "src-committers@freebsd.org" <src-committers@FreeBSD.org>, "dev-commits-src-all@freebsd.org" <dev-commits-src-all@FreeBSD.org>, "dev-commits-src-main@freebsd.org" <dev-commits-src-main@FreeBSD.org> Subject: Re: git: bed65d85c631 - main - linux64: Fix the build on arm64 with bti checking Message-ID: <CFE64928-3C70-411E-90A0-E79C90662070@fubar.geek.nz> In-Reply-To: <20240605153714.5161218F@slippy.cwsent.com> References: <202406050929.4559TFj0027386@gitrepo.freebsd.org> <20240605153714.5161218F@slippy.cwsent.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] > On 5 Jun 2024, at 16:37, Cy Schubert <Cy.Schubert@cschubert.com> wrote: > > In message <202406050929.4559TFj0027386@gitrepo.freebsd.org>, Andrew Turner > wri > tes: >> The branch main has been updated by andrew: >> >> URL: https://cgit.FreeBSD.org/src/commit/?id=bed65d85c631c3a8e60a81a15a5a745c >> 8ef92fbe >> >> commit bed65d85c631c3a8e60a81a15a5a745c8ef92fbe >> Author: Andrew Turner <andrew@FreeBSD.org> >> AuthorDate: 2024-06-04 12:47:52 +0000 >> Commit: Andrew Turner <andrew@FreeBSD.org> >> CommitDate: 2024-06-05 09:23:40 +0000 >> >> linux64: Fix the build on arm64 with bti checking >> >> When we enable checking for BTI on arm64 we need to include an ELF >> note in all object files linked into a module. >> >> As using objcopy from a binary to an ELF object file doesn't add the >> note switch to using .incbin from an assembly file. This allows us to >> add the needed note without affecting the included object. >> >> Reviewed by: imp, kib, emaste >> Sponsored by: Arm Ltd >> Differential Revision: https://reviews.freebsd.org/D45468 >> --- >> sys/arm64/linux/linux_support.S | 4 ++++ >> sys/compat/linux/linux_vdso_inc.S | 39 +++++++++++++++++++++++++++++++++++++ >> ++ >> sys/modules/linux64/Makefile | 17 +++-------------- >> 3 files changed, 46 insertions(+), 14 deletions(-) >> >> diff --git a/sys/arm64/linux/linux_support.S b/sys/arm64/linux/linux_support. >> S >> index 151ede7e1c19..3b16583e9d54 100644 >> --- a/sys/arm64/linux/linux_support.S >> +++ b/sys/arm64/linux/linux_support.S >> @@ -26,6 +26,8 @@ >> * SUCH DAMAGE. >> */ >> >> +#include <sys/elf_common.h> >> + >> #include <machine/asm.h> >> #include <machine/param.h> >> #include <machine/vmparam.h> >> @@ -172,3 +174,5 @@ ENTRY(futex_xorl) >> str w4, [x2] >> ret >> END(futex_xorl) >> + >> +GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL) >> diff --git a/sys/compat/linux/linux_vdso_inc.S b/sys/compat/linux/linux_vdso_ >> inc.S >> new file mode 100644 >> index 000000000000..af10907f0b60 >> --- /dev/null >> +++ b/sys/compat/linux/linux_vdso_inc.S >> @@ -0,0 +1,39 @@ >> +/*- >> + * SPDX-License-Identifier: BSD-2-Clause >> + * >> + * Copyright (C) 2020 Arm Ltd >> + * >> + * Redistribution and use in source and binary forms, with or without >> + * modification, are permitted provided that the following conditions >> + * are met: >> + * 1. Redistributions of source code must retain the above copyright >> + * notice, this list of conditions and the following disclaimer. >> + * 2. Redistributions in binary form must reproduce the above copyright >> + * notice, this list of conditions and the following disclaimer in the >> + * documentation and/or other materials provided with the distribution. >> + * >> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND >> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOS >> E >> + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE >> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIA >> L >> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS >> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) >> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC >> T >> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY >> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF >> + * SUCH DAMAGE. >> + */ >> + >> + .section .rodata >> + .globl _binary_linux_vdso_so_o_start >> +_binary_linux_vdso_so_o_start: >> + .incbin "linux_vdso.so.o" >> + .globl _binary_linux_vdso_so_o_end >> +_binary_linux_vdso_so_o_end: >> + >> +#if defined(__aarch64__) >> +#include <sys/elf_common.h> >> +#include <machine/asm.h> >> +GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL) >> +#endif >> diff --git a/sys/modules/linux64/Makefile b/sys/modules/linux64/Makefile >> index 62e3b464d39f..beed5ec59c4b 100644 >> --- a/sys/modules/linux64/Makefile >> +++ b/sys/modules/linux64/Makefile >> @@ -35,7 +35,8 @@ SRCS= linux_dummy_machdep.c \ >> bus_if.h \ >> device_if.h \ >> vnode_if.h \ >> - linux_support.S >> + linux_support.S \ >> + linux_vdso_inc.S >> .if ${MACHINE_CPUARCH} == "amd64" >> SRCS+= linux_dummy_x86.c >> .endif >> @@ -47,7 +48,6 @@ SRCS+= opt_kstack_pages.h opt_nfs.h opt_hwpmc_hooks.h >> CLEANFILES= linux_assym.h linux_genassym.o linux_locore.o \ >> genassym.o linux_vdso_gtod.o linux_vdso.so.o >> >> -OBJS= linux_vdso.so >> >> linux_assym.h: linux_genassym.o >> sh ${SYSDIR}/kern/genassym.sh linux_genassym.o > ${.TARGET} >> @@ -83,18 +83,7 @@ linux_vdso.so.o: linux_locore.o linux_vdso_gtod.o >> -T${SRCTOP}/sys/${MACHINE}/linux/linux_vdso.lds.s \ >> -o ${.TARGET} ${.ALLSRC:M*.o} >> >> -.if ${MACHINE_CPUARCH} == "aarch64" >> -OBJCOPY_TARGET=--output-target elf64-littleaarch64 --binary-architecture aar >> ch64 >> -.elif ${MACHINE_CPUARCH} == "amd64" >> -OBJCOPY_TARGET=--output-target elf64-x86-64 --binary-architecture i386:x86-6 >> 4 >> -.else >> -.error ${MACHINE_CPUARCH} not yet supported by linux64 >> -.endif >> - >> -linux_vdso.so: linux_vdso.so.o >> - ${OBJCOPY} --input-target binary ${OBJCOPY_TARGET} \ >> - linux_vdso.so.o ${.TARGET} >> - ${STRIPBIN} -N _binary_linux_vdso_so_o_size ${.TARGET} >> +linux_vdso_inc.o: linux_vdso.so.o >> >> linux_support.o: linux_support.S assym.inc linux_assym.h >> ${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \ >> > > kldload linux64.ko results in the following panic on amd64. Reverting this > revision addresses the regression. > Does the attached patch fix it? I didn’t see this when testing. Andrew [-- Attachment #2 --] From fd684f8b907077b6ee83fe510b9163edddb645d0 Mon Sep 17 00:00:00 2001 From: Andrew Turner <andrew@FreeBSD.org> Date: Wed, 5 Jun 2024 18:47:48 +0000 Subject: [PATCH] linux: Allows writing to the vdso from the kernel We need to write to the vdso in the kernel to perform fixups. Move it from .rodata to .data so these can be run. Sponsored by: Arm Ltd --- sys/compat/linux/linux_vdso_inc.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/compat/linux/linux_vdso_inc.S b/sys/compat/linux/linux_vdso_inc.S index af10907f0b60..44cc357b4a4a 100644 --- a/sys/compat/linux/linux_vdso_inc.S +++ b/sys/compat/linux/linux_vdso_inc.S @@ -25,7 +25,7 @@ * SUCH DAMAGE. */ - .section .rodata + .section .data .globl _binary_linux_vdso_so_o_start _binary_linux_vdso_so_o_start: .incbin "linux_vdso.so.o" -- 2.44.0 [-- Attachment #3 --]
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CFE64928-3C70-411E-90A0-E79C90662070>
