From owner-dev-commits-src-main@freebsd.org Wed Dec 23 07:59:58 2020 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0CCB94B689B; Wed, 23 Dec 2020 07:59:58 +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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4D15GP6wfbz4Txw; Wed, 23 Dec 2020 07:59:57 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 E0F051AD0D; Wed, 23 Dec 2020 07:59:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 0BN7xvR5031240; Wed, 23 Dec 2020 07:59:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 0BN7xvZZ031239; Wed, 23 Dec 2020 07:59:57 GMT (envelope-from git) Date: Wed, 23 Dec 2020 07:59:57 GMT Message-Id: <202012230759.0BN7xvZZ031239@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 659f1a6aad04 - Improve address generation in the early arm64 boot 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/main X-Git-Reftype: branch X-Git-Commit: 659f1a6aad04adf0a0d27415f7a967d231ce4cfb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "Commit messages for the main branch of the src repository." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Dec 2020 07:59:58 -0000 The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=659f1a6aad04adf0a0d27415f7a967d231ce4cfb commit 659f1a6aad04adf0a0d27415f7a967d231ce4cfb Author: Andrew Turner AuthorDate: 2020-12-23 07:24:07 +0000 Commit: Andrew Turner CommitDate: 2020-12-23 07:54:59 +0000 Improve address generation in the early arm64 boot The adr instruction allows for an address of +-1M from the instruction. If we replace these with an adrp and an add instruction we can generate an address +-4G. The adrp will get an address of the 4k page the label is within, and the add uses the :lo12: prefix to add just the low bits to this address. This will allow us to move things around with fewer issues than if we needed to keep them within the +-1MB range. Sponsored by: Innovate UK --- sys/arm64/arm64/locore.S | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S index f438865a961a..6f8d007b2efa 100644 --- a/sys/arm64/arm64/locore.S +++ b/sys/arm64/arm64/locore.S @@ -127,7 +127,8 @@ _start: bl start_mmu /* Load the new ttbr0 pagetable */ - adr x27, pagetable_l0_ttbr0 + adrp x27, pagetable_l0_ttbr0 + add x27, x27, :lo12:pagetable_l0_ttbr0 /* Jump to the virtual address space */ ldr x15, .Lvirtdone @@ -135,7 +136,8 @@ _start: virtdone: /* Set up the stack */ - adr x25, initstack_end + adrp x25, initstack_end + add x25, x25, :lo12:initstack_end mov sp, x25 sub sp, sp, #PCB_SIZE @@ -163,7 +165,8 @@ virtdone: str x1, [x0, #BP_MODULEP] str x26, [x0, #BP_KERN_L1PT] str x29, [x0, #BP_KERN_DELTA] - adr x25, initstack + adrp x25, initstack + add x25, x25, :lo12:initstack str x25, [x0, #BP_KERN_STACK] str x24, [x0, #BP_KERN_L0PT] str x27, [x0, #BP_KERN_TTBR0] @@ -206,15 +209,18 @@ ENTRY(mpentry) msr contextidr_el1, xzr /* Load the kernel page table */ - adr x24, pagetable_l0_ttbr1 + adrp x24, pagetable_l0_ttbr1 + add x24, x24, :lo12:pagetable_l0_ttbr1 /* Load the identity page table */ - adr x27, pagetable_l0_ttbr0_boostrap + adrp x27, pagetable_l0_ttbr0_boostrap + add x27, x27, :lo12:pagetable_l0_ttbr0_boostrap /* Enable the mmu */ bl start_mmu /* Load the new ttbr0 pagetable */ - adr x27, pagetable_l0_ttbr0 + adrp x27, pagetable_l0_ttbr0 + add x27, x27, :lo12:pagetable_l0_ttbr0 /* Jump to the virtual address space */ ldr x15, =mp_virtdone @@ -282,7 +288,8 @@ drop_to_el1: msr cntvoff_el2, xzr /* Hypervisor trap functions */ - adr x2, hyp_vectors + adrp x2, hyp_vectors + add x2, x2, :lo12:hyp_vectors msr vbar_el2, x2 mov x2, #(PSR_F | PSR_I | PSR_A | PSR_D | PSR_M_EL1h) @@ -345,7 +352,8 @@ hyp_vectors: */ get_virt_delta: /* Load the physical address of virt_map */ - adr x29, virt_map + adrp x29, virt_map + add x29, x29, :lo12:virt_map /* Load the virtual address of virt_map stored in virt_map */ ldr x28, [x29] /* Find PA - VA as PA' = VA' - VA + PA = VA' + (PA - VA) = VA' + x29 */ @@ -383,9 +391,11 @@ create_pagetables: mov x5, x30 /* Clean the page table */ - adr x6, pagetable + adrp x6, pagetable + add x6, x6, :lo12:pagetable mov x26, x6 - adr x27, pagetable_end + adrp x27, pagetable_end + add x27, x27, :lo12:pagetable_end 1: stp xzr, xzr, [x6], #16 stp xzr, xzr, [x6], #16 @@ -474,7 +484,8 @@ common: /* Link the DMAP tables */ ldr x8, =DMAP_MIN_ADDRESS - adr x9, pagetable_dmap; + adrp x9, pagetable_dmap + add x9, x9, :lo12:pagetable_dmap mov x10, #DMAP_TABLES bl link_l0_pagetable