From nobody Wed Jun 05 15:37:14 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 4VvWmY53rGz5NGhG; Wed, 05 Jun 2024 15:37:17 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from omta002.cacentral1.a.cloudfilter.net (omta002.cacentral1.a.cloudfilter.net [3.97.99.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VvWmY2xQFz4DSB; Wed, 5 Jun 2024 15:37:17 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Authentication-Results: mx1.freebsd.org; none Received: from shw-obgw-4004a.ext.cloudfilter.net ([10.228.9.227]) by cmsmtp with ESMTPS id ErKqsggx3drxEEshQsSXYL; Wed, 05 Jun 2024 15:37:16 +0000 Received: from spqr.komquats.com ([70.66.152.170]) by cmsmtp with ESMTPSA id EshOsKl4RWhyfEshPsnzS1; Wed, 05 Jun 2024 15:37:16 +0000 X-Auth-User: cschuber X-Authority-Analysis: v=2.4 cv=MenPuI/f c=1 sm=1 tr=0 ts=6660862c a=y8EK/9tc/U6QY+pUhnbtgQ==:117 a=y8EK/9tc/U6QY+pUhnbtgQ==:17 a=kj9zAlcOel0A:10 a=T1WGqf2p2xoA:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=EkcXrb_YAAAA:8 a=fY2H276N9kE6I-Hg-AQA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 a=LK5xJRSDVpKd5WXXoEvA:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTP id 7B48FE4; Wed, 05 Jun 2024 08:37:14 -0700 (PDT) Received: by slippy.cwsent.com (Postfix, from userid 1000) id 5161218F; Wed, 05 Jun 2024 08:37:14 -0700 (PDT) X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.8+dev Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Andrew Turner cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: bed65d85c631 - main - linux64: Fix the build on arm64 with bti checking In-reply-to: <202406050929.4559TFj0027386@gitrepo.freebsd.org> References: <202406050929.4559TFj0027386@gitrepo.freebsd.org> Comments: In-reply-to Andrew Turner message dated "Wed, 05 Jun 2024 09:29:15 +0000." 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=us-ascii Date: Wed, 05 Jun 2024 08:37:14 -0700 Message-Id: <20240605153714.5161218F@slippy.cwsent.com> X-CMAE-Envelope: MS4xfEim+Co7LYoPti2XYqU28nerNhMDY5vmlrA+NOSkFK8vfFEkTzYw89nzdrAexpLfCX3JPyl5VbsgvTk6tBt2piaMAty+EpifvqhrwajRsWqkqcPR/EVQ bKcxHyvbjo5jzqyHr+eNSEjW2xaEX2J5Kt5qDwIiAuNXnQjyfrjufgw6g1pqVbaIIw/Bq0fizbGzxTCc3nf/nHam19ZPYjTEeCtm663gUMOAJe7c6ZPlo42y Q9zJLM/jcpfv6/N/nSKUAUoXC9KfaypMHnrUfqKpK9jdW7LjYLJdONlguId3KmUqWyTKjYClwBpuZiOIiPaLr2OZkP8g2zXLblfkN4qGkJA= X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:16509, ipnet:3.96.0.0/15, country:US] X-Rspamd-Queue-Id: 4VvWmY2xQFz4DSB 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 > AuthorDate: 2024-06-04 12:47:52 +0000 > Commit: Andrew Turner > 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 > + > #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..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 > +#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 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. Fatal trap 12: page fault while in kernel mode cpuid = 2; apic id = 02 fault virtual address = 0xffffffff824cd1df fault code = supervisor write data, protection violation instruction pointer = 0x20:0xffffffff824c49d9 stack pointer = 0x28:0xfffffe008ecc8a10 frame pointer = 0x28:0xfffffe008ecc8a50 code segment = base 0x0, limit 0xfffff, type 0x1b = DPL 0, pres 1, long 1, def32 0, gran 1 processor eflags = interrupt enabled, resume, IOPL = 0 current process = 4069 (kldload) rdi: ffffffff824cd1d8 rsi: ffffffff824ce298 rdx: 000000000000000b rcx: aaaaaaaaaaaaaaab r8: 00000000000000c0 r9: fffffe00b3123bc0 rax: 0000000000000058 rbx: fffff801701a6c00 rbp: fffffe008ecc8a50 r10: fffff80006015800 r11: 0000000000000423 r12: fffff8002075c000 r13: ffffffff824cd4b0 r14: fffff8002075c000 r15: fffff800031d6a00 trap number = 12 panic: page fault cpuid = 2 time = 1717600139 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe008ecc8700 vpanic() at vpanic+0x13f/frame 0xfffffe008ecc8830 panic() at panic+0x43/frame 0xfffffe008ecc8890 trap_fatal() at trap_fatal+0x40b/frame 0xfffffe008ecc88f0 trap_pfault() at trap_pfault+0x46/frame 0xfffffe008ecc8940 calltrap() at calltrap+0x8/frame 0xfffffe008ecc8940 --- trap 0xc, rip = 0xffffffff824c49d9, rsp = 0xfffffe008ecc8a10, rbp = 0xfffffe008ecc8a50 --- elf64_linux_vdso_fixup() at elf64_linux_vdso_fixup+0x99/frame 0xfffffe008ecc8a50 linux_vdso_install() at linux_vdso_install+0x53/frame 0xfffffe008ecc8a90 linker_load_module() at linker_load_module+0xc29/frame 0xfffffe008ecc8d80 kern_kldload() at kern_kldload+0x164/frame 0xfffffe008ecc8dd0 sys_kldload() at sys_kldload+0x5c/frame 0xfffffe008ecc8e00 amd64_syscall() at amd64_syscall+0x115/frame 0xfffffe008ecc8f30 fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe008ecc8f30 --- syscall (304, FreeBSD ELF64, kldload), rip = 0x2959195a57da, rsp = 0x295917b80438, rbp = 0x295917b809b0 --- Uptime: 7m24s Dumping 608 out of 8160 MB:..3%..11%..22%..32%..43%..53%..61%..71%..82%..92% Dump complete Automatic reboot in 15 seconds - press a key on the console to abort acpi0: reset failed - timeout Rebooting... cpu_reset: Restarting BSP cpu_reset_proxy: Stopped CPU 2 -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org e^(i*pi)+1=0