From nobody Mon Feb 19 16:45:27 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 4TdpLb6Tkvz5C9Qv; Mon, 19 Feb 2024 16:45:27 +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 4TdpLb34B2z4cFh; Mon, 19 Feb 2024 16:45:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708361127; 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=i4KTdyqQpJVh23Ra2TwxAxZaTjjNXsYXtLTgdHUgxRs=; b=eNcfyceUlaQklfOSnI5gXXXcLMmyJKLiR5HbilmX/nvVGpzE5ErN3XsaNCw8GpO4IJSBT+ jNdVG1lJZ9icBCYo0jLW7QJBQNryVnzSXSOAT6Umk2XDoAVznSei6nunrEc2u3f4VuVJma DiQ/wjYSku+5Nh5GHTtvgkqLcBl06gA8GbXPs/QjuHlvAERCM4NmwcLWqpX9COqKT3QbMO Aj3rn7BJg61BC0zaohX91HPIAWu7jOreshgPTxKZfCHnHWVovMlMCqdzFqopcGe/ESBTUp 8y8dTr2KFff0NCx8N2rXo6iIX2sN/QQZAjqkxhBsymQPuGevv1JPPUc2EqihJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708361127; 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=i4KTdyqQpJVh23Ra2TwxAxZaTjjNXsYXtLTgdHUgxRs=; b=DIOx8+Jm1XzA1L/PUmxHfbaJW229c8ejehAfKrrWMvsWNNTO+TFmXHQj3SkxaKsg4Htxwr 7dhfQp8WiKdxBMEjz1pLwNPdxjeDucJP+wLIeVsNfCk6MXO/p+b5CdmUEfqJ+hulYrtynq RViB6Q+eCeVw/4trJG+9YgVJultItrV2nXDUuWL+MJqcVMyogIcm267ulPG1T8/I1jGAe5 ZsZbEoZVQsBuAahkED0TbRzYnwHY/x4IZFVGYXoFeo6sc8ud1I4vZrEGzP3lPRg5FFL7Qo KkE7/n0bzKhGDhfV4c+FnF5jT9zjnDw/THB5JZPhQNpRIM9PflkHSQPUccTU7Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708361127; a=rsa-sha256; cv=none; b=e1XRlDfiwdjMvqX1O1b+zCb5kzc4PnNWZFxxgEYcsIlkGI7mqv3jB9k6KmN3k0ZG7F0iVk UJoU8WvzGqwDNKuOlqX7aVMnZV9WDq/FQM1L4U2Ito/5VrdlYCJReZCc0Zh9pOGk0mynCo t7veoJnNKSqDF2t0rk24KUNWTlW9KWS6RFylzz7aGXQLwKba/yYcUVIxfShXIgZ+HsSxWL 7peZ+VSkeqULKih0J6me+corVGLWP9+X1vY95vykrrRkJKoJzb+U9rtOViKXDgTrPk4BCu 5qnnDcy4DyA07jKF7E4tIKlfDQMikcyNr8tXPD+tjFRjxDJp1dArlSXGd/jX+w== 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 4TdpLb27WnzjGv; Mon, 19 Feb 2024 16:45:27 +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 41JGjR6T096435; Mon, 19 Feb 2024 16:45:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41JGjRrS096432; Mon, 19 Feb 2024 16:45:27 GMT (envelope-from git) Date: Mon, 19 Feb 2024 16:45:27 GMT Message-Id: <202402191645.41JGjRrS096432@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: 4dd61b21f9a0 - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: 4dd61b21f9a0d2c49bb95e93a54333421070e41e Auto-Submitted: auto-generated The branch stable/14 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=4dd61b21f9a0d2c49bb95e93a54333421070e41e commit 4dd61b21f9a0d2c49bb95e93a54333421070e41e Author: Andrew Turner AuthorDate: 2023-11-11 09:27:30 +0000 Commit: Andrew Turner CommitDate: 2024-02-19 13:14:16 +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 ea5ce8e15ed2..f36ee5e75185 100644 --- a/sys/arm64/arm64/locore.S +++ b/sys/arm64/arm64/locore.S @@ -235,8 +235,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 f4b35da88638..bb93cfd521e1 100644 --- a/sys/arm64/arm64/support.S +++ b/sys/arm64/arm64/support.S @@ -376,8 +376,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