From nobody Sat Mar 26 16:12:27 2022 X-Original-To: freebsd-arm@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 B0B5A1A4A2E0 for ; Sat, 26 Mar 2022 16:12:27 +0000 (UTC) (envelope-from bugzilla-noreply@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KQkWH1xN7z4SJZ for ; Sat, 26 Mar 2022 16:12:27 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 2251A24368 for ; Sat, 26 Mar 2022 16:12:27 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 22QGCR96046916 for ; Sat, 26 Mar 2022 16:12:27 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 22QGCRGt046915 for freebsd-arm@FreeBSD.org; Sat, 26 Mar 2022 16:12:27 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: freebsd-arm@FreeBSD.org Subject: [Bug 262836] [arm64] cacheline flush instruction (dc cvau) causes SIGSEGV from userland Date: Sat, 26 Mar 2022 16:12:27 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: arm X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: dch@freebsd.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-arm@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648311147; 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=9W28knl0V3Zo+bxTzZecOnbmhNBR67OnQPGTEXT5glo=; b=VlXh3HHBgEjb/LxH3Xew1+W9Hdpwf/FqaqlW5YJM6WobxdqAoFnBq7L/VIR2NXsy6LGfZa nm6JhRWCH3yHfazkkGOwT/g4RhTszqh4ci2OOkQAr4nnrDYaRB60Dbn0m9VZEeeXvD+uq3 Tlf9Ody8r6cetMcqdoteADlIttVO/rHppEKwNxyX2swUx4TDpg5sKnyR1bqz+7dFTM2hRr Jg+tU5JXj4CHobPYNFh9D5xCSSWKgqNY5AIDadgW/cMmJAq8PkzRGWkBUPEzUyckprXpKF J4qkxnoq8/LWSfxxgO8eAa8CqDP63It9NjtTiaT8O8m+YQVU8y51Cx3We+xyhg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648311147; a=rsa-sha256; cv=none; b=bXb4OhURvaNUcqOytTF0syJTRP6wEGjhHwUL3+q6AK4knFx/IzOyurl1d7Nnv12v8QknR3 9SBXrhZJYEFFKry8knHbF1PF2fsr61Qd+M6DrzOhcTm2e8XcOiua2mS12NtHouMAaB+P/l HT/Ed3jzxbQrRpaOEiRTjRVBOfRkL3dHoMVReXDxc5jqgDAzJG9j4PiH5NiyVBrz2tFXUz e1SJup9CeBiXilkEOs0QXbwlh9cdXNwRQtS7lQ6tftfxaPuelxlhBdPoZc8leivKU1Jdqs kuLudCelMwlLHk7XfFC7qlYP6fyA/ZTz4NmScuxlCPu6Lbsam65HiBRXTHpZkA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D262836 Bug ID: 262836 Summary: [arm64] cacheline flush instruction (dc cvau) causes SIGSEGV from userland Product: Base System Version: CURRENT Hardware: arm64 OS: Any Status: New Severity: Affects Some People Priority: --- Component: arm Assignee: freebsd-arm@FreeBSD.org Reporter: dch@freebsd.org Created attachment 232744 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D232744&action= =3Dedit https://git.sr.ht/~dch/src/commit/ae9221b85d18b6816276b8401734548f03b89013.= patch building OTP-25-RC2 from source yields a segfault during build. After some build finagling, we can narrow this down to `dc cvau` failing: ``` sudo lldb ./bin/aarch64-unknown-freebsd14.0/beam.debug.jit (lldb) target create "./bin/aarch64-unknown-freebsd14.0/beam.debug.jit" Current executable set to '/tmp/otp/bin/aarch64-unknown-freebsd14.0/beam.debug.jit' (aarch64). (lldb) run Process 40356 launched: '/tmp/otp/bin/aarch64-unknown-freebsd14.0/beam.debug.jit' (aarch64) Process 40356 stopped * thread #1, name =3D 'beam.debug.jit', stop reason =3D signal SIGSEGV: add= ress access protected (fault address: 0xdee00000) frame #0: 0x0000000000769f54 beam.debug.jit`__clear_cache(start=3D0x00000000dee00000, end=3D0x00000000de= e0294c) at clear_cache.c:119:7 116 const size_t dcache_line_size =3D 4 << ((ctr_el0 >> 16) & 15); 117 for (addr =3D xstart & ~(dcache_line_size - 1); addr < xend; 118 addr +=3D dcache_line_size) -> 119 __asm __volatile("dc cvau, %0" ::"r"(addr)); 120 } 121 __asm __volatile("dsb ish"); 122 (lldb) bt * thread #1, name =3D 'beam.debug.jit', stop reason =3D signal SIGSEGV: add= ress access protected (fault address: 0xdee00000) * frame #0: 0x0000000000769f54 beam.debug.jit`__clear_cache(start=3D0x00000000dee00000, end=3D0x00000000de= e0294c) at clear_cache.c:119:7 frame #1: 0x00000000003feb60 beam.debug.jit`BeamAssembler::_codegen(this=3D0x00000000d4b0e000, allocator=3D0x000000008b16c018, executable_ptr=3D, writable_ptr=3D) at beam_jit_common.cpp:128:5 frame #2: 0x00000000003ea4e8 beam.debug.jit`BeamGlobalAssembler::BeamGlobalAssembler(this=3D0x00000000d4= b0e000, allocator=3D0x000000008b16c018) at beam_asm_global.cpp:71:9 frame #3: 0x00000000004034dc beam.debug.jit`::beamasm_init() at beam_jit_main.cpp:256:15 frame #4: 0x000000000049c908 beam.debug.jit`erl_init(ncpu=3D32, proc_tab_sz=3D262144, legacy_proc_tab=3D0, port_tab_sz=3D65536, port_tab_sz_ignore_files=3D0, legacy_port_tab=3D0, sys_proc_outst_req_lim= =3D64, time_correction=3D1, time_warp_mode=3DERTS_NO_TIME_WARP_MODE, node_tab_delete_delay=3D60, db_spin_count=3DERTS_DB_SPNCNT_NORMAL) at erl_init.c:355:5 frame #5: 0x000000000049b0a8 beam.debug.jit`erl_start(argc=3D1, argv=3D0x000000008144b690) at erl_init.c:2424:5 frame #6: 0x00000000003c0828 beam.debug.jit`main(argc=3D1, argv=3D0x000000008144b690) at erl_main.c:30:5 frame #7: 0x00000000003c063c beam.debug.jit`__start(argc=3D1, argv=3D0x000000008144b690, env=3D0x000000008144b6a0, cleanup=3D) at crt1_c.c:72:7 frame #8: 0x0000236d2a2f60d8 ld-elf.so.1`.rtld_start at rtld_start.S:41 (lldb) x/8i $pc-16 0x769f44: 0xcb0903ea neg x10, x9 0x769f48: 0x8a00014a and x10, x10, x0 0x769f4c: 0xeb01015f cmp x10, x1 0x769f50: 0x540000a2 b.hs 0x769f64 ; <+76> at clear_cache.c:121:3 -> 0x769f54: 0xd50b7b2a dc cvau, x10 0x769f58: 0x8b09014a add x10, x10, x9 0x769f5c: 0xeb01015f cmp x10, x1 0x769f60: 0x54ffffa3 b.lo 0x769f54 ; <+60> at clear_cache.c:119:7 (lldb) x/8i start 0xdee00000: 0xaa1f03e2 mov x2, xzr 0xdee00004: 0xaa1903e3 mov x3, x25 0xdee00008: 0xaa1a03e4 mov x4, x26 0xdee0000c: 0xaa0403e8 mov x8, x4 0xdee00010: 0x91020269 add x9, x19, #0x80 ; =3D0x80 0xdee00014: 0xf100ed1f cmp x8, #0x3b ; =3D0x3b 0xdee00018: 0x54000240 b.eq 0xdee00060 0xdee0001c: 0x37080148 tbnz w8, #0x1, 0xdee00044 (lldb) x/8i end 0xdee0294c: 0x00000000 udf #0x0 0xdee02950: 0x00000000 udf #0x0 0xdee02954: 0x00000000 udf #0x0 0xdee02958: 0x00000000 udf #0x0 0xdee0295c: 0x00000000 udf #0x0 0xdee02960: 0x00000000 udf #0x0 0xdee02964: 0x00000000 udf #0x0 0xdee02968: 0x00000000 udf #0x0 (lldb) x/8i $x0 0xdee00000: 0xaa1f03e2 mov x2, xzr 0xdee00004: 0xaa1903e3 mov x3, x25 0xdee00008: 0xaa1a03e4 mov x4, x26 0xdee0000c: 0xaa0403e8 mov x8, x4 0xdee00010: 0x91020269 add x9, x19, #0x80 ; =3D0x80 0xdee00014: 0xf100ed1f cmp x8, #0x3b ; =3D0x3b 0xdee00018: 0x54000240 b.eq 0xdee00060 0xdee0001c: 0x37080148 tbnz w8, #0x1, 0xdee00044 (lldb) x/8i $x1 0xdee0294c: 0x00000000 udf #0x0 0xdee02950: 0x00000000 udf #0x0 0xdee02954: 0x00000000 udf #0x0 0xdee02958: 0x00000000 udf #0x0 0xdee0295c: 0x00000000 udf #0x0 0xdee02960: 0x00000000 udf #0x0 0xdee02964: 0x00000000 udf #0x0 0xdee02968: 0x00000000 udf #0x0 (lldb) x/8i $x9 error: memory read failed for 0x0 (lldb) x/8i $x10 0xdee00000: 0xaa1f03e2 mov x2, xzr 0xdee00004: 0xaa1903e3 mov x3, x25 0xdee00008: 0xaa1a03e4 mov x4, x26 0xdee0000c: 0xaa0403e8 mov x8, x4 0xdee00010: 0x91020269 add x9, x19, #0x80 ; =3D0x80 0xdee00014: 0xf100ed1f cmp x8, #0x3b ; =3D0x3b 0xdee00018: 0x54000240 b.eq 0xdee00060 0xdee0001c: 0x37080148 tbnz w8, #0x1, 0xdee00044 (lldb) ``` andrew@ produced a small patch which seems to be sufficient (attached). It would be great to have a fix for this included in 13.1-RELEASE arm64 if possible. --=20 You are receiving this mail because: You are the assignee for the bug.=