From nobody Mon Jul 08 14:54:46 2024 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 4WHnGH3HDTz5QN7G; Mon, 08 Jul 2024 14:54:47 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WHnGH1nDjz3xrs; Mon, 8 Jul 2024 14:54:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720450487; 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=SiWRugpBs51SUoAwWOuIm/4kF33nweON15RhAvFgmng=; b=uTNr4vva+7juUauL2eYRYXzdPR5Q/nF3kkqU+NW8Oct/0ZPccf8VZxiVzOrX0xnkp0At17 e5PqO1Rc032jy6MArfP6Kcd+80bZf45nxSBbpUeCX22wpesr/sTRK9jDqXV+5LhXo9Hp6q 7eXglgN/xXUMo2fCgipmXMxESXsK92rIbUKdbMrCQzQmoWcWXNrmAGM/EkBKrB5mqYO6LK +3D4Jc6UuJsTTcN8lgm6O8JAUiJdmgnLplLhdScGXu0n6DKLvdaU3lpULuFHXy0IPTkI8A 1VEE+SXJIiIodxWWtaTOUY2IBN8Lk/LiRCaZ9cZuk42JgsCkwO+cj214gn4tLQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1720450487; a=rsa-sha256; cv=none; b=B262sUiYwzqMRiN1yTctkGWBQPelIGH1r3l4IU6qeyNcEH0rtn1b5PTyTDVPpxUFD9TcXO 9ig30FKxmQlA2Gc88wB3pkOHG6Xet/el+iX0Ex+o+tkPEaNO2nx12BZKDpYUnYZXEDIhwQ rv0b9BWVXczGjeZpj+xryR+uy3egatiqDFcz5pEBaBlzQXVHglcrsvqbw76SRFO47mZBhk NgmndL1zS0niMFaGGf3hxBohtv7hzdpPA/u/jFwK3YXAiM+AxtndMEey3HM3w6K8L8WwAT tthAxr+omnslZGiAwRRNfM4E5PaV0XXOnYLlnZCEMpziOa3JfpEtYlojd4AtGg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720450487; 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=SiWRugpBs51SUoAwWOuIm/4kF33nweON15RhAvFgmng=; b=yGW20VH9L1VQDm46n2Q6GhiOatg/gmGTi2fyp6H7C6mEgzPb7uCJeIC/k2i6UA2L+Fdtkd xUc1jDLl9kxdX4QiSSs8SZ95NeCl3BZoVTadfMTyudFMHkFhO1DywW2TH/1M5U2Svhq7y8 ueMHwy759W+yIQRaAuLpkQkduL0umG5SiwHYvoUHYK135uC2xl9k+rG+AhWLh7+TJ3Jj/l HZi4pmuxDsaObxCM8PRUsd+k/NfaPxoN3YL+L58X/vo1OwsSmTPeQ8HSoz5BpmAMCW/0mM oxoLYpXPJ2/RP01qtiQ+TftYQ9sdNFLdG7fONUmlv9vNeI+QqORzEwMwelsrJA== 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 4WHnGG6BtXzwKG; Mon, 8 Jul 2024 14:54:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 468EskLc047173; Mon, 8 Jul 2024 14:54:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 468EskAe047170; Mon, 8 Jul 2024 14:54:46 GMT (envelope-from git) Date: Mon, 8 Jul 2024 14:54:46 GMT Message-Id: <202407081454.468EskAe047170@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: b426b8b3b000 - main - arm64: simplify physmap usage in pmap_bootstrap() 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b426b8b3b000080d9c582c2de32f0fa73e7c2649 Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=b426b8b3b000080d9c582c2de32f0fa73e7c2649 commit b426b8b3b000080d9c582c2de32f0fa73e7c2649 Author: Mitchell Horne AuthorDate: 2024-07-08 14:54:00 +0000 Commit: Mitchell Horne CommitDate: 2024-07-08 14:54:00 +0000 arm64: simplify physmap usage in pmap_bootstrap() The subr_physmem.c facility provides guarantees about non-empty ranges. Push this into pmap_bootstrap_dmap() and simplify; the lowest physical memory range is always in the first item. No functional change intended. Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45759 --- sys/arm64/arm64/pmap.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index 29552f722aa4..c3357900e1be 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -1207,11 +1207,14 @@ pmap_bootstrap_l3_page(struct pmap_bootstrap_state *state, int i) } static void -pmap_bootstrap_dmap(vm_paddr_t min_pa) +pmap_bootstrap_dmap(void) { int i; - dmap_phys_base = min_pa & ~L1_OFFSET; + /* Fill in physmap array. */ + physmap_idx = physmem_avail(physmap, nitems(physmap)); + + dmap_phys_base = physmap[0] & ~L1_OFFSET; dmap_phys_max = 0; dmap_max_addr = 0; @@ -1299,8 +1302,7 @@ void pmap_bootstrap(vm_size_t kernlen) { vm_offset_t dpcpu, msgbufpv; - vm_paddr_t start_pa, pa, min_pa; - int i; + vm_paddr_t start_pa, pa; /* Verify that the ASID is set through TTBR0. */ KASSERT((READ_SPECIALREG(tcr_el1) & TCR_A1) == 0, @@ -1319,28 +1321,13 @@ pmap_bootstrap(vm_size_t kernlen) kernel_pmap->pm_ttbr = kernel_pmap->pm_l0_paddr; kernel_pmap->pm_asid_set = &asids; - /* Assume the address we were loaded to is a valid physical address */ - min_pa = pmap_early_vtophys(KERNBASE); - - physmap_idx = physmem_avail(physmap, nitems(physmap)); - - /* - * Find the minimum physical address. physmap is sorted, - * but may contain empty ranges. - */ - for (i = 0; i < physmap_idx; i += 2) { - if (physmap[i] == physmap[i + 1]) - continue; - if (physmap[i] <= min_pa) - min_pa = physmap[i]; - } - bs_state.freemempos = KERNBASE + kernlen; bs_state.freemempos = roundup2(bs_state.freemempos, PAGE_SIZE); /* Create a direct map region early so we can use it for pa -> va */ - pmap_bootstrap_dmap(min_pa); + pmap_bootstrap_dmap(); bs_state.dmap_valid = true; + /* * We only use PXN when we know nothing will be executed from it, e.g. * the DMAP region.