From nobody Mon Mar 14 14:46:13 2022 X-Original-To: dev-commits-src-branches@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 F144B1A272C8; Mon, 14 Mar 2022 14:46:15 +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 4KHK9L4Br6z3hBp; Mon, 14 Mar 2022 14:46:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647269175; 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=2f83Qqm2+PgCwUGbrH0xHO8o4oC2cIjNsIcgjUm7Fgc=; b=WjsQ3COZB7+gdwNExLgLXY10JNSWONhMy+89vd3kTowsocQ9Hzg9mU3MaeKBdwAa72ZhuH YgOj+Zz9fGSO06qyXbsTPR8PfokbeHNh9lFT2qqSwYuUoUHxPOOglqmIJ2nUPPmMNflaqL GzvFc2Rq1TXHkJTIOETPNMZDelkfmR0KoGxsg0qIDryn6cNH5f2+GbM66n5Uz+tBk9PXMY /tL0ujegzRXseyPtWSea2EgID8/z0Rl+k1O+90TDisNAIkSN77RxkLmv7oUsu/IXaD7bJL ZLurpman7TNgAdStsbM+T5l67+sQhqpDCFlPBisD/HtMYxQV7aIuEyiMESq7HA== 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 0B6A57709; Mon, 14 Mar 2022 14:46:14 +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 22EEkDXR052048; Mon, 14 Mar 2022 14:46:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22EEkDD8052047; Mon, 14 Mar 2022 14:46:13 GMT (envelope-from git) Date: Mon, 14 Mar 2022 14:46:13 GMT Message-Id: <202203141446.22EEkDD8052047@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 79e0f742da9b - stable/13 - riscv: Maintain the allpmaps list only in SV39 mode List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 79e0f742da9b7fab40de4f1309e864340451c0a3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647269175; 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=2f83Qqm2+PgCwUGbrH0xHO8o4oC2cIjNsIcgjUm7Fgc=; b=o9qxLO1fcwCoRy+4ZJ4UKKuAGwk+zpVUbf9bi3d3N7DNhoeSKJue6+69DpJUxmsYyAGEjx VE6Xvw7YNXmxEl3SEDYNzhduyb8j/JJYjgjZMcPByCbhkbbghtm9F1rPUrh7JkLnWPiyCu wgLTwP0nUgWPRlmlOM7q6b9e0Tgocrehoh+Bv/oSU7T1PGAxpJrLetz1d50d42GQy1n9us SZoQpdpN+7QObvlHps/8pHies1EI89aAwyImrF5/j8Gj7w95YBWxYOgQgtmpBCwi2QC1IT MJ2fvYUdSZRwevtThh+mhzXNPhd1F9YeWJyRIegdD1k9x6uqXopbAK8yQma6tA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647269175; a=rsa-sha256; cv=none; b=fegkQuie7rxK4qe+yxJ1kboqShM3Nw8UjXs4AULd3V9VOwx+xS/dlJTp2KvF4zrtinrzLd j7N/Dlg1uyDbG2EhP0oC/HnBnNO/CTeLjPdGSDHeLXIwsIpxa8s0SX93q3YGKIzGSbxjge NW9o2RftVV7+WW4ccDSiOSlMoY0KFeXkt2dYTcMgi1SwvV0NJlo0xCgHk5J9X6uGtUoUTs u35urf90VPfUbB3tMFXqAU/hDzpNqFZ5fZ+rT7C/s2jR/7S+esnjTpn5wNr8yfBqJvQBrC LAFBVpfYmHv9KS5SR1yuUo7LpqhGxPVmtrw4TujwGA1sIZthun0FsmXBwpbvaA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=79e0f742da9b7fab40de4f1309e864340451c0a3 commit 79e0f742da9b7fab40de4f1309e864340451c0a3 Author: Mark Johnston AuthorDate: 2022-03-01 14:06:31 +0000 Commit: Mark Johnston CommitDate: 2022-03-14 14:45:43 +0000 riscv: Maintain the allpmaps list only in SV39 mode When four-level page tables are used, there is no need to distribute updates to the top-level page to all pmaps. Reviewed by: jhb Sponsored by: The FreeBSD Foundation (cherry picked from commit ceed61483ca9c3c0bf44e37118ae9c8377e6b9ff) --- sys/riscv/riscv/pmap.c | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index 74192a16341c..71957b235e70 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -486,8 +486,13 @@ pmap_distribute_l1(struct pmap *pmap, vm_pindex_t l1index, struct pmap *user_pmap; pd_entry_t *l1; - /* Distribute new kernel L1 entry to all the user pmaps */ - if (pmap != kernel_pmap) + /* + * Distribute new kernel L1 entry to all the user pmaps. This is only + * necessary with three-level paging configured: with four-level paging + * the kernel's half of the top-level page table page is static and can + * simply be copied at pmap initialization time. + */ + if (pmap != kernel_pmap || pmap_mode != PMAP_MODE_SV39) return; mtx_lock(&allpmaps_lock); @@ -1266,6 +1271,7 @@ pmap_pinit(pmap_t pmap) { vm_paddr_t topphys; vm_page_t mtop; + size_t i; mtop = vm_page_alloc_noobj(VM_ALLOC_WIRED | VM_ALLOC_ZERO | VM_ALLOC_WAITOK); @@ -1278,19 +1284,25 @@ pmap_pinit(pmap_t pmap) CPU_ZERO(&pmap->pm_active); - /* - * Copy L1 entries from the kernel pmap. This must be done with the - * allpmaps lock held to avoid races with pmap_distribute_l1(). - */ - mtx_lock(&allpmaps_lock); - LIST_INSERT_HEAD(&allpmaps, pmap, pm_list); - for (size_t i = pmap_l1_index(VM_MIN_KERNEL_ADDRESS); - i < pmap_l1_index(VM_MAX_KERNEL_ADDRESS); i++) - pmap->pm_top[i] = kernel_pmap->pm_top[i]; - for (size_t i = pmap_l1_index(DMAP_MIN_ADDRESS); - i < pmap_l1_index(DMAP_MAX_ADDRESS); i++) + if (pmap_mode == PMAP_MODE_SV39) { + /* + * Copy L1 entries from the kernel pmap. This must be done with + * the allpmaps lock held to avoid races with + * pmap_distribute_l1(). + */ + mtx_lock(&allpmaps_lock); + LIST_INSERT_HEAD(&allpmaps, pmap, pm_list); + for (i = pmap_l1_index(VM_MIN_KERNEL_ADDRESS); + i < pmap_l1_index(VM_MAX_KERNEL_ADDRESS); i++) + pmap->pm_top[i] = kernel_pmap->pm_top[i]; + for (i = pmap_l1_index(DMAP_MIN_ADDRESS); + i < pmap_l1_index(DMAP_MAX_ADDRESS); i++) + pmap->pm_top[i] = kernel_pmap->pm_top[i]; + mtx_unlock(&allpmaps_lock); + } else { + i = pmap_l0_index(VM_MIN_KERNEL_ADDRESS); pmap->pm_top[i] = kernel_pmap->pm_top[i]; - mtx_unlock(&allpmaps_lock); + } vm_radix_init(&pmap->pm_root); @@ -1480,9 +1492,11 @@ pmap_release(pmap_t pmap) KASSERT(CPU_EMPTY(&pmap->pm_active), ("releasing active pmap %p", pmap)); - mtx_lock(&allpmaps_lock); - LIST_REMOVE(pmap, pm_list); - mtx_unlock(&allpmaps_lock); + if (pmap_mode == PMAP_MODE_SV39) { + mtx_lock(&allpmaps_lock); + LIST_REMOVE(pmap, pm_list); + mtx_unlock(&allpmaps_lock); + } m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pmap->pm_top)); vm_page_unwire_noq(m);