From nobody Mon Feb 19 16:45:05 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 4TdpL94b4kz5C99M; Mon, 19 Feb 2024 16:45:05 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TdpL92zjLz4bLd; Mon, 19 Feb 2024 16:45:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708361105; 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=urvVrChkNndZ7EMKGIy6WLj6+tpt4KLgH9zIPCkRI28=; b=Qtp4a8z8b89hqXybDxo2nU9xgtikXWd3ftxBgNM3Jj+HEmHG1/GtPTIvTCQQ+vRqB+qmJk wJyKq7L/7K8Gzl2YpPs0nfMmvDEsaxE22Bno7qiDcyE+VPHpoDeR3+x7pTFqSi+UU7LSr5 XAv1l5H4YJczjpnkoz18p95BDanT+o2m3t0o8q//YemU951GVzsVpfZ34YFIqCWl6DPDPp 131k+akizXw5koocLkeKxEViU5v5iHqfeEymiU6d1a9Nv44ijVZfuhaOlzJSlZRAmUWPWF 8FiGPr9rPP8zVj+b7FynJAc7eEL43KJtNJY9Dc6ePKfP1hVi9M4R7ZSsiDtTvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708361105; 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=urvVrChkNndZ7EMKGIy6WLj6+tpt4KLgH9zIPCkRI28=; b=Mp6uCyxc/pOaNA0zlQanzLN+5GR7Zn5nTLGkLGlYfF34xul2QhsF2p3AKiFX8AdhdvYu1D GmeMm706bS+dEm4qBA+RjbWwEIoKDxJVILyTKFYyH06KNUbUZI1Am0ZFsRUW5w0eHEJ6b2 mqGy/TNFbKpUUW2iL9A1GWZ0+8HMaNvID6FYig8+3CZcJVZKrY38C9A+NKFJuic7WwtWyv VUYFaEwm0yLXDzaUhlFfkfzUu9Ta5G+9/RB1CxYSJst1NTAwaCTGNDXrWTkPDitdeW3r7F itJByg7+oUbRYVqb+e8ItDTDE95SjFthhI/sCGgqrw+H4sS21vDT6SIKRNCQUQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708361105; a=rsa-sha256; cv=none; b=s1P7Kt5xQH0I3u97xYhcgia8d4M1gF9AVlFJZOrdFoqV77pK3rc77hB27jO8fVY4pKb5FJ AqlekCtGAuCm+XUWK8H/XXxKifLoNux/yoCscglqAV3jAMAm4FGp5WvohxWDJufNxB0qi0 dy7VMIBYHWEPraJPmP3sSBsGhWMgVwu67AgFdGZtS1fMAvozDh6zJme23c/3xtSxrBnOv7 ZIbvuJRths1XK+BEd2csxLC81vIILFeFqWr7+mn37cxpCBJwy7Lm/jToPabI4iNBoAu4u1 PXBcygKtg5VuT1OIUPsy2T/MWOiqhyFpCmZWB9DdxBnMwEGGUho6OhEp6CdaWw== 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 4TdpL924cGzjfZ; Mon, 19 Feb 2024 16:45:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41JGj5IV095215; Mon, 19 Feb 2024 16:45:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41JGj5va095212; Mon, 19 Feb 2024 16:45:05 GMT (envelope-from git) Date: Mon, 19 Feb 2024 16:45:05 GMT Message-Id: <202402191645.41JGj5va095212@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: ab63af3ab3fd - stable/13 - arm64: Use adrp + :lo12: to load globals from asm 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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/13 X-Git-Reftype: branch X-Git-Commit: ab63af3ab3fdaee5dd934fa1d5eda981c28e2a87 Auto-Submitted: auto-generated The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=ab63af3ab3fdaee5dd934fa1d5eda981c28e2a87 commit ab63af3ab3fdaee5dd934fa1d5eda981c28e2a87 Author: Andrew Turner AuthorDate: 2023-11-11 09:27:30 +0000 Commit: Andrew Turner CommitDate: 2024-02-19 12:44:31 +0000 arm64: Use adrp + :lo12: to load globals from asm When loading a global variable we can use a pseudo-instruction similar to "ldr, xn, =global" to load the address of the symbol. As this is unlikely to be supported by a mov instruction a pc-relative load is used, with the absolute address written at the end of the function so it will be loaded. This load can be partially replaced with an adrp instruction. This generates the address, aligned to a 4k boundary, using a pc-relative addition. Because the address is 4k-aligned we then update reading the global variable using a load with the offset of the load the low 12-bits of the global. Arm64 assemblers have :lo12: to support this, e.g. "ldr xn, [xn, :lo12:global]". The only remaining users of "ldr, xn, =global" that I can find are executed from the physical address space the kernel was loaded in and need an address in the kernels virtual address space. Because of this they can't use adrp. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D42565 (cherry picked from commit 7eb26be9c8080686f64fdc0a28e5ae7839bbc82d) --- sys/arm64/arm64/cpufunc_asm.S | 7 ++++--- sys/arm64/arm64/locore.S | 4 ++-- sys/arm64/arm64/support.S | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sys/arm64/arm64/cpufunc_asm.S b/sys/arm64/arm64/cpufunc_asm.S index 2b2ca6836530..8163e6c3d0d0 100644 --- a/sys/arm64/arm64/cpufunc_asm.S +++ b/sys/arm64/arm64/cpufunc_asm.S @@ -52,11 +52,12 @@ */ .macro cache_handle_range dcop = 0, ic = 0, icop = 0 .if \ic == 0 - ldr x3, =dcache_line_size /* Load the D cache line size */ + adrp x3, dcache_line_size /* Load the D cache line size */ + ldr x3, [x3, :lo12:dcache_line_size] .else - ldr x3, =idcache_line_size /* Load the I & D cache line size */ + adrp x3, idcache_line_size /* Load the I & D cache line size */ + ldr x3, [x3, :lo12:idcache_line_size] .endif - ldr x3, [x3] sub x4, x3, #1 /* Get the address mask */ and x2, x0, x4 /* Get the low bits of the address */ add x1, x1, x2 /* Add these to the size */ diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S index 58f0ad8d85aa..7d93d1de30c0 100644 --- a/sys/arm64/arm64/locore.S +++ b/sys/arm64/arm64/locore.S @@ -204,8 +204,8 @@ mp_virtdone: BTI_J /* Start using the AP boot stack */ - ldr x4, =bootstack - ldr x4, [x4] + adrp x4, bootstack + ldr x4, [x4, :lo12:bootstack] mov sp, x4 #if defined(PERTHREAD_SSP) diff --git a/sys/arm64/arm64/support.S b/sys/arm64/arm64/support.S index 805867fd5d17..a2d422c31fea 100644 --- a/sys/arm64/arm64/support.S +++ b/sys/arm64/arm64/support.S @@ -284,8 +284,8 @@ END(pagezero_simple) ENTRY(pagezero_cache) add x1, x0, #PAGE_SIZE - ldr x2, =dczva_line_size - ldr x2, [x2] + adrp x2, dczva_line_size + ldr x2, [x2, :lo12:dczva_line_size] 1: dc zva, x0