From nobody Tue Mar 01 14:40:05 2022 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 0C7CD19DB6BA; Tue, 1 Mar 2022 14:40:07 +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 4K7KfG4hrxz3G1L; Tue, 1 Mar 2022 14:40:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646145606; 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=OPPT2270205G3NN8YbYpkxADAsGsDGodOURbX3uSUJg=; b=x+AbWkgA+aRV0HWHBIKxgnHoAsqgTGJhIoeJKcXatUOhdRomJ66Fuxofyl9dRN655XuMwl 8BWg6gBeZ14kjFEwhW00Dc9UyFwW4VQOdmePH4rMHaZoGP568lhejaO7SXjyoBmd0mjRBB imDdoOIyAkIlfEdgaOZ+5A6tklBtpWpfnLBWmY9w5YSzte9sTDeaU9A8dWKTL4gdPiTzhI 5vVeO6MXITo9a54j0cGy8ba05wt8z0f6qGqUtBZEfHm2QPgJ2FwSeYYmnHCQbKRQYJ7rHe Z/gPxXw+jZeUGC/OODJ5mWtV8AwFekCxNzZ7yZH0rsIx1OfwtqOWsuDQ25SZ8w== 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 E91F7115B2; Tue, 1 Mar 2022 14:40:05 +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 221Ee5Vu041159; Tue, 1 Mar 2022 14:40:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 221Ee5hU041157; Tue, 1 Mar 2022 14:40:05 GMT (envelope-from git) Date: Tue, 1 Mar 2022 14:40:05 GMT Message-Id: <202203011440.221Ee5hU041157@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: ceed61483ca9 - main - riscv: Maintain the allpmaps list only in SV39 mode 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ceed61483ca9c3c0bf44e37118ae9c8377e6b9ff Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646145606; 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=OPPT2270205G3NN8YbYpkxADAsGsDGodOURbX3uSUJg=; b=egoECB2Gzgt+WT644y6xRPtglrFN2TSD36XMi8DF8uqY5oEBD565ESglPxtu0W87+6p1Ia UM1irCNUmeuaxuw3LnCbcsgTrET4qEySwmbyQc+SRUYc0KGq/9uYO7t9sEGPO99ke42mWG Vs/ZSXZYF7lWOnIZ6vgACA1Mp1wkrzC7B9TkD9jRt81bKSu+9mnTTHV9SRfyZ04KowzDSK asVK9bTtu65hdQpxgjGdU2CyzRB/FJI7wYatrKOQCjyOfMoWwUEkH14Q1QtQHjPAWZ5TiS l4UT6M/V2rhVI0/zs/FQPlvMIWCRJsw5E3ewnvluVMQ+l2zOLK3ozyZHcydJ9Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646145606; a=rsa-sha256; cv=none; b=ZVjmKqldIBTh4btLkqGPmCgOXyKtr39dhaivM6BmfG126z+Gd+rKmKlb+IgmwliYEddfSJ ldLL9QPPAf7VYgBKMvlfXnAL4t/pXKdc9MHlJNpO6NbC1jvT1wNjqzOa5GzQh45vm/sYjV Qq2MrKTLQ3C7AVcCnhU6+NhWEuj2pEX0luGzV9icYzMKISAOUEAazLF90xU+xU4mhHPOyz fjI2Fe4YwNj39esC72da1eIdOZ6y11ec/0IrTA9UlQge7shbutItgowmCaFIbnrB6t+hA3 +03R9siX+mVgK4UU4Nti9x07Vxub2/0fLHPAe6BHsvrsT3ibOYreMEwpe5qakg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ceed61483ca9c3c0bf44e37118ae9c8377e6b9ff commit ceed61483ca9c3c0bf44e37118ae9c8377e6b9ff Author: Mark Johnston AuthorDate: 2022-03-01 14:06:31 +0000 Commit: Mark Johnston CommitDate: 2022-03-01 14:39:44 +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 MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34277 --- 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 2bd8f8843a57..aaaccfec4fe9 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);