From nobody Mon Sep 02 08:50:42 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Wy2XL5RPSz5Mnnt; Mon, 02 Sep 2024 08:50:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Wy2XL3jb1z42L9; Mon, 2 Sep 2024 08:50:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725267042; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TalzPi+Y9E54oyc59D48F/9Rk1KWE7myB1BvpzhijHM=; b=U7sWgBU6tSHO/I470kfyZ2grnFa7MoSJg02QWlZaYsSSfHaL+9Z14j8MyoiLwuUHCHcxu1 zUCc3CF9lHDejKBnZV1jcjSO9J903wIRsNfn29PTh3wGHrxqO+wngYgkZd7xDnIpYc7g7G ZWXHgHBXsmqVJDOjI12+fZIkyvs+prXbiipWYpF4WNhtnue8dhPXgqult17wdl8nrF5OOD uizf9LDv+pLO8kLiNl3aIbROMgRTbkkHJw1zoJFDPp/1/1ja4wlkd+oPfEd5hs16V25cUY PHzjW66fHg7M+A/LjvIl+kXlSEi1t0Uya7UCW+j+XYm8B3ZAO6e22N8Dd4+K9w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725267042; a=rsa-sha256; cv=none; b=ez8RIbDF09JJVX7Wvqtw3mFT503cZaUP1F6kid4cjaD66p2ei51X9ic5iSYXVHs+CMFrWS HaZ+zCfBB8DflQrWhILgbXAoDSUmnmM+Yf7tkjORbzzrgCHJF0rROvlflYp9zQoXCUdUm2 gZIEJsJ3Lxt+S3FjnYQ4p6+/jMXiAmx0DbJLopd+L49i4Pa/fJYIDWg37cpvlso+As1J9y rrQ3212fGz6cLJfqH4V4Fcf9SvMGYDZ35DoNoVc6lCsu52wvW8NWHlnVzPigmvSJ31kau+ n5TBp1xAiYvR5tamdj5eRw8CzsZFdF8wcFTkk9YaTkjpib9xF+C1D6xJw1Q6eg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725267042; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TalzPi+Y9E54oyc59D48F/9Rk1KWE7myB1BvpzhijHM=; b=Zr3QOXN+IctPTbI7nV03WE9iQKODgOy0JT5rJ3atlLqWu1JrBYLAcy0ipGFCSEI0xigWmU WJ4T3vIij5VDQr2/3ZVD1/28XAnUvx4oX3Z2bmLIFUtouXAZ/pIRXPNNHRcSch/UuUfcMP VDxQJd3qD0XiGq0/jKnsxyiORbSftTVz+BigAi5tPQsEOvh40N3q5UzHr4/9DZJO6t8s2A RibYKnQfS3q6sjC/u3oRjt3hhW5qU6CBmozzScUb+48RBOBJkuTVH25aOmy1rGdA+061nf Bc1vZhS2XI6mQKQOS/iEJ3hI/WeUQerUuLn/B+u65xEAhIwdlmhNm19/1kD/ug== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Wy2XL3CmDz15YG; Mon, 2 Sep 2024 08:50:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4828ogrQ007094; Mon, 2 Sep 2024 08:50:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4828ogxM007091; Mon, 2 Sep 2024 08:50:42 GMT (envelope-from git) Date: Mon, 2 Sep 2024 08:50:42 GMT Message-Id: <202409020850.4828ogxM007091@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: d5e29c62e923 - stable/14 - linux64: Fix the build on arm64 with bti checking List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: d5e29c62e923bd8e7a7355a0d3c5e4767c869ddf Auto-Submitted: auto-generated The branch stable/14 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=d5e29c62e923bd8e7a7355a0d3c5e4767c869ddf commit d5e29c62e923bd8e7a7355a0d3c5e4767c869ddf Author: Andrew Turner AuthorDate: 2024-06-04 12:47:52 +0000 Commit: Andrew Turner CommitDate: 2024-09-02 08:48:10 +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 (cherry picked from commit bed65d85c631c3a8e60a81a15a5a745c8ef92fbe) (cherry picked from commit ec69d230933f82c7c142b053882255aa57475463) --- 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 + #include #include #include @@ -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..44cc357b4a4a --- /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 PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * 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, STRICT + * 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 .data + .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 +#include +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 05fe76ba6a51..5d0174aa8e9b 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 aarch64 -.elif ${MACHINE_CPUARCH} == "amd64" -OBJCOPY_TARGET=--output-target elf64-x86-64 --binary-architecture i386:x86-64 -.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} \