From nobody Wed Nov 15 18:12:19 2023 X-Original-To: dev-commits-src-main@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 4SVrq80R0Vz50Zcd; Wed, 15 Nov 2023 18:12:20 +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 4SVrq76Vhzz4N3f; Wed, 15 Nov 2023 18:12:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700071939; 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=t1yu2X5wNVsOg4ubMyjuGxBdwfboFWemU3eGgr1072c=; b=Dc758dooYVqrkwnkNtLLRfQvyX3TrcFujiGyO3Ykcq3gvmTevkWtnk881cqN2xuvVD7NSp zqOvcfgPL4g+DxA4WQKwGbDrN6ouIl2gFRLLlrVwSZqw6r+qZrf2YptqxMd9DoUHyMfZ12 dpw07gYG0tUszDZF6eVhMczqBUpaKHYXaCE2l+jUdddKantjNCQ71Gkx1h7vE3mEs6Uvmh L2jpfFL3rHjriP4pQTzGDGzK6Q3zhgvdXaGb6Lkof3C00BLfW3eHiOemx8AS86kLNmFp/p +hYFVxn/xYJa99RdANNpn6nM3Jea41bqv0kEu73o3vYp+5TuFxqtEURQDCUR0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700071939; 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=t1yu2X5wNVsOg4ubMyjuGxBdwfboFWemU3eGgr1072c=; b=YVyCrwgbliIvbME53JC4Av/Ch4usrxkeX/b86s8TXkQh33q+1ZwLcamzS/AOEJm1NNXsbn jPEeIxKtd4F4bwmC3U6Yr4qVq97pymiZ1uuq+n62o6SeeG/84dwAXcyy38D0pYvojRJjf0 IKrwxR4XYzw0VNtwD5+LsRKJCkDER/97C59dhqcZOcxdw49Wn2GURyeTEJNG6k9O7nX83k tcnff7yPxW0JqWDqHvebjtKr3ezODW3tTuJw2+3tpGs/zhiBqns57OdM0PQCoB5Dwwk+ZT pQmSFCHBnf6jOAqQplp48mzd2wVQjS1DTMaOl+swBLy1tUDZDb5tOHAEj7/Fvw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700071940; a=rsa-sha256; cv=none; b=TNKM7zhawkPVAZPGbYsYrR6frbLwbM+Jk8CPxF3Gfp46Wvkfgljf368lGMSIEIjziufifc 4gDZFYz4dXmJqOq+vSz1hAlJmCyuoXfi2j3s16mJ3H0abEyi3tfcgfO5TpcobYcgihorhe G5wyjLdZS/TM9osLhqwTBGAZ2SVb+Xna5a4JfHwXV7hpcdhCwnkrm+Gwl3O/zXc63EI2GS EskwiWF+UxqAR3srsSqEGI14HEf/+ym4lWVM+rUw4t6aGzOqMcDr0lB1n91mvN4bisCMo/ mlT+WHHsP1qee/279/f+TAiuwBEwcdkUEiUlkNMn9+ULj8/RSHPgPT8AfRVj2Q== 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 4SVrq75btszBwp; Wed, 15 Nov 2023 18:12:19 +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 3AFICJ0F077472; Wed, 15 Nov 2023 18:12:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AFICJ3T077468; Wed, 15 Nov 2023 18:12:19 GMT (envelope-from git) Date: Wed, 15 Nov 2023 18:12:19 GMT Message-Id: <202311151812.3AFICJ3T077468@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: ba31362694fe - main - arm64: Make kern_delta unneeded in the boot params List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: ba31362694fe465b88a025ac7c35ad7f378efc86 Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=ba31362694fe465b88a025ac7c35ad7f378efc86 commit ba31362694fe465b88a025ac7c35ad7f378efc86 Author: Andrew Turner AuthorDate: 2023-11-13 15:29:30 +0000 Commit: Andrew Turner CommitDate: 2023-11-15 18:05:08 +0000 arm64: Make kern_delta unneeded in the boot params Use pmap_early_vtophys to translate from a virtual to physical where we were previously using the calculated delta. This means that, while we still calculate it, we don't need to pass it to initarm or either pmap bootstrap functions. While here remove an unneeded printf that indirectly used it or was related to the previous printf. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D42567 --- sys/arm64/arm64/genassym.c | 1 - sys/arm64/arm64/locore.S | 13 ++++--------- sys/arm64/arm64/machdep.c | 2 +- sys/arm64/arm64/pmap.c | 14 ++++---------- sys/arm64/include/machdep.h | 1 - sys/arm64/include/pmap.h | 2 +- 6 files changed, 10 insertions(+), 23 deletions(-) diff --git a/sys/arm64/arm64/genassym.c b/sys/arm64/arm64/genassym.c index 0fb00d8aceba..d4970177ab71 100644 --- a/sys/arm64/arm64/genassym.c +++ b/sys/arm64/arm64/genassym.c @@ -40,7 +40,6 @@ ASSYM(BOOTPARAMS_SIZE, roundup2(sizeof(struct arm64_bootparams), STACKALIGNBYTES + 1)); ASSYM(BP_MODULEP, offsetof(struct arm64_bootparams, modulep)); -ASSYM(BP_KERN_DELTA, offsetof(struct arm64_bootparams, kern_delta)); ASSYM(BP_KERN_STACK, offsetof(struct arm64_bootparams, kern_stack)); ASSYM(BP_KERN_TTBR0, offsetof(struct arm64_bootparams, kern_ttbr0)); ASSYM(BP_BOOT_EL, offsetof(struct arm64_bootparams, boot_el)); diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S index 2d4501d4bfea..cea2f690b60f 100644 --- a/sys/arm64/arm64/locore.S +++ b/sys/arm64/arm64/locore.S @@ -77,11 +77,10 @@ ENTRY(_start) msr contextidr_el1, xzr /* Get the virt -> phys offset */ - bl get_virt_delta + bl get_load_phys_addr /* * At this point: - * x29 = PA - VA * x28 = Our physical load address */ @@ -136,10 +135,8 @@ virtdone: mov x0, sp /* Negate the delta so it is VA -> PA */ - neg x29, x29 str x1, [x0, #BP_MODULEP] - str x29, [x0, #BP_KERN_DELTA] adrp x25, initstack add x25, x25, :lo12:initstack str x25, [x0, #BP_KERN_STACK] @@ -359,11 +356,9 @@ LENTRY(drop_to_el1) LEND(drop_to_el1) /* - * Get the delta between the physical address we were loaded to and the - * virtual address we expect to run from. This is used when building the - * initial page table. + * Get the physical address the kernel was loaded at. */ -LENTRY(get_virt_delta) +LENTRY(get_load_phys_addr) /* Load the physical address of virt_map */ adrp x29, virt_map add x29, x29, :lo12:virt_map @@ -379,7 +374,7 @@ LENTRY(get_virt_delta) .align 3 virt_map: .quad virt_map -LEND(get_virt_delta) +LEND(get_load_phys_addr) /* * This builds the page tables containing the identity map, and the kernel diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index 7aa20357acf4..01896c15e650 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -957,7 +957,7 @@ initarm(struct arm64_bootparams *abp) pan_setup(); /* Bootstrap enough of pmap to enter the kernel proper */ - pmap_bootstrap(KERNBASE - abp->kern_delta, lastaddr - KERNBASE); + pmap_bootstrap(lastaddr - KERNBASE); /* Exclude entries needed in the DMAP region, but not phys_avail */ if (efihdr != NULL) exclude_efi_map_entries(efihdr); diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index 3dc74626f01b..adb5e3312e50 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -1258,22 +1258,16 @@ pmap_bootstrap_allocate_kasan_l2(vm_paddr_t start_pa, vm_paddr_t end_pa, * Bootstrap the system enough to run with virtual memory. */ void -pmap_bootstrap(vm_paddr_t kernstart, vm_size_t kernlen) +pmap_bootstrap(vm_size_t kernlen) { vm_offset_t dpcpu, msgbufpv; vm_paddr_t start_pa, pa, min_pa; - uint64_t kern_delta; int i; /* Verify that the ASID is set through TTBR0. */ KASSERT((READ_SPECIALREG(tcr_el1) & TCR_A1) == 0, ("pmap_bootstrap: TCR_EL1.A1 != 0")); - kern_delta = KERNBASE - kernstart; - - printf("pmap_bootstrap %lx %lx\n", kernstart, kernlen); - printf("%lx\n", (KERNBASE >> L1_SHIFT) & Ln_ADDR_MASK); - /* Set this early so we can use the pagetable walking functions */ kernel_pmap_store.pm_l0 = pagetable_l0_ttbr1; PMAP_LOCK_INIT(kernel_pmap); @@ -1288,7 +1282,7 @@ pmap_bootstrap(vm_paddr_t kernstart, vm_size_t kernlen) kernel_pmap->pm_asid_set = &asids; /* Assume the address we were loaded to is a valid physical address */ - min_pa = KERNBASE - kern_delta; + min_pa = pmap_early_vtophys(KERNBASE); physmap_idx = physmem_avail(physmap, nitems(physmap)); physmap_idx /= 2; @@ -1316,7 +1310,7 @@ pmap_bootstrap(vm_paddr_t kernstart, vm_size_t kernlen) */ bs_state.table_attrs &= ~TATTR_PXN_TABLE; - start_pa = pa = KERNBASE - kern_delta; + start_pa = pa = pmap_early_vtophys(KERNBASE); /* * Create the l2 tables up to VM_MAX_KERNEL_ADDRESS. We assume that the @@ -7848,7 +7842,7 @@ void __nosanitizeaddress pmap_san_bootstrap(struct arm64_bootparams *abp) { - pmap_san_early_kernstart = KERNBASE - abp->kern_delta; + pmap_san_early_kernstart = pmap_early_vtophys(KERNBASE); kasan_init_early(abp->kern_stack, KSTACK_PAGES * PAGE_SIZE); } diff --git a/sys/arm64/include/machdep.h b/sys/arm64/include/machdep.h index 026a64e0a350..80cb28bcfbeb 100644 --- a/sys/arm64/include/machdep.h +++ b/sys/arm64/include/machdep.h @@ -31,7 +31,6 @@ struct arm64_bootparams { vm_offset_t modulep; - uint64_t kern_delta; vm_offset_t kern_stack; vm_paddr_t kern_ttbr0; uint64_t hcr_el2; diff --git a/sys/arm64/include/pmap.h b/sys/arm64/include/pmap.h index ad9aa409815a..efbf7eaaae91 100644 --- a/sys/arm64/include/pmap.h +++ b/sys/arm64/include/pmap.h @@ -144,7 +144,7 @@ extern vm_offset_t virtual_end; #define pmap_vm_page_alloc_check(m) void pmap_activate_vm(pmap_t); -void pmap_bootstrap(vm_paddr_t, vm_size_t); +void pmap_bootstrap(vm_size_t); int pmap_change_attr(vm_offset_t va, vm_size_t size, int mode); int pmap_change_prot(vm_offset_t va, vm_size_t size, vm_prot_t prot); void pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode);