From nobody Mon Mar 14 14:46:11 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 8037F1A27181; Mon, 14 Mar 2022 14:46:12 +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 4KHK9J17YRz3hVQ; Mon, 14 Mar 2022 14:46:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647269172; 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=54A0corIDeJQigRhRq6daLiLSJfNBsq7RVFOkuksrXA=; b=KhaPx9Z6KFaTfnfImDaimKc6HyCVGfF5iQ9OlCxT4qAT7Clt9ksZGX94IjcKIfCCvlZ547 lslCY4q3kKNhvh19KsJyKkBI+MnvvaiB21im7iLxGgjcUUdqUvR9+TdzkAhBVk3HHRX0zr eq7Yks6nDlyDr0MOfq19t8MKJ5ccNze70zRILPkjC59Y3UrnEPuXSoiEwvCew5buFPY+7Z 0s1p8JNLwvOaTczERU6u4Jq4EH6po9zZcZjcHQtC3bTclQmvf7068it9f43vFqDPpjQPSO 783YV+MDyuhnuy3e0TaVNWAnsAkNcD5vq82tMWX+QB9BzTGRXPwBnxcAthiBdQ== 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 AFF88761F; Mon, 14 Mar 2022 14:46:11 +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 22EEkBtJ052000; Mon, 14 Mar 2022 14:46:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22EEkB4Z051999; Mon, 14 Mar 2022 14:46:11 GMT (envelope-from git) Date: Mon, 14 Mar 2022 14:46:11 GMT Message-Id: <202203141446.22EEkB4Z051999@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: 7e27397935dc - stable/13 - riscv: Try to improve the comments for locore's page table setup 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: 7e27397935dc467e871e36a266dea06e112f8dfc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647269172; 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=54A0corIDeJQigRhRq6daLiLSJfNBsq7RVFOkuksrXA=; b=FWC4u0BcRyvE38UN1gXQcFFU5uFYIvKyLVURSlfnv6Kp2e893Egu7cleCN7/K4JxVrUENe h0qXwjWB6cVYKn3/rz6MFZ6qgOBMCfpPToQbsg1w1VDlURV0F6W01ePdgac7xpOpqicx/u 0DC99ZQxIgNJrQBUHx6xk2zWuD6t3q6CSlrGoJfiY33FH1JhOVOdW3FzjRjXicg8PfF3ck r6kesPs1y4EpgXUWH8SwMd/YQ7lxEF1RKfETVeKwxrflWRdl3GhI7IIvMR+X4HkJNN1nzo 8uUVs+Fbv8VksTAIiNcv5X1S4y01vobkjSAm9WxADfWDozxd+BNMLb6cKd33qA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647269172; a=rsa-sha256; cv=none; b=cxkQsUz8mYfUP716nJkTSV3ZauMJKLEjsndo/0gheNXFLGheViWMHzodA3EaasY1rW0J6k Ol8kD0JBCuPfsgj3oZoHi6ffTbtY3gRuH+9A4CGz9ebyyOLk4YsI3WXzjPpInfbuJE3mhM 3IiUXIiviXrxjYMEDqIqpFWDlOHHBqXaFy28G25cFd2qVtr7dBQk2b/qymmn/DI48RWfv/ hg/tVUARsB02JBMWXAl7s3gSJCDT8SOpA0M8JG08sDvPNJCsXw3LWKFsvbNDztL341KzgD y8vBx0t0IalIgvfh8rQ6f4wxajUIkYHsLGDUBFVJLA0tXwADkvXl3NWc/zNK1w== 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=7e27397935dc467e871e36a266dea06e112f8dfc commit 7e27397935dc467e871e36a266dea06e112f8dfc Author: Mark Johnston AuthorDate: 2022-03-01 14:06:03 +0000 Commit: Mark Johnston CommitDate: 2022-03-14 14:45:38 +0000 riscv: Try to improve the comments for locore's page table setup No functional change intended. Reviewed by: jhb Sponsored by: The FreeBSD Foundation (cherry picked from commit 43379792365130b1fa338c310f00aa6821493ead) --- sys/riscv/riscv/locore.S | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/sys/riscv/riscv/locore.S b/sys/riscv/riscv/locore.S index 28e68c1d6057..bf0ac8e122be 100644 --- a/sys/riscv/riscv/locore.S +++ b/sys/riscv/riscv/locore.S @@ -107,7 +107,16 @@ _start: mv a1, zero /* - * Page tables setup + * Set up page tables: map a 1GB region starting at KERNBASE using 2MB + * superpages, starting from the first 2MB physical page into which the + * kernel was loaded. Also reserve an L2 page for the early device map + * and map the DTB, if any, using the second-last entry of that L2 + * page. This is hopefully enough to get us to pmap_bootstrap(). + * + * Implementations are required to provide SV39 mode, so we use that + * initially and will optionally enable SV48 mode during kernel pmap + * initialization. + * * a0 - modulep or zero * a1 - zero or dtbp */ @@ -122,7 +131,7 @@ pagetables: li a5, KERNBASE srli a5, a5, L1_SHIFT /* >> L1_SHIFT */ - andi a5, a5, 0x1ff /* & 0x1ff */ + andi a5, a5, Ln_ADDR_MASK /* & Ln_ADDR_MASK */ li t4, PTE_V slli t5, s2, PTE_PPN0_S /* (s2 << PTE_PPN0_S) */ or t6, t4, t5 @@ -148,19 +157,19 @@ pagetables: addi t4, t4, 1 bltu t4, t3, 1b - /* Create an L1 page for early devmap */ + /* Create an L1 table entry for early devmap */ lla s1, pagetable_l1 lla s2, pagetable_l2_devmap /* Link to next level PN */ srli s2, s2, PAGE_SHIFT li a5, (VM_MAX_KERNEL_ADDRESS - L2_SIZE) srli a5, a5, L1_SHIFT /* >> L1_SHIFT */ - andi a5, a5, 0x1ff /* & 0x1ff */ + andi a5, a5, Ln_ADDR_MASK /* & Ln_ADDR_MASK */ li t4, PTE_V slli t5, s2, PTE_PPN0_S /* (s2 << PTE_PPN0_S) */ or t6, t4, t5 - /* Store single level1 PTE entry to position */ + /* Store the L1 table entry */ li a6, PTE_SIZE mulw a5, a5, a6 add t0, s1, a5 @@ -169,7 +178,7 @@ pagetables: /* Check if we have a DTB that needs to be mapped */ beqz a1, 2f - /* Create an L2 page superpage for DTB */ + /* Create an L2 mapping for the DTB */ lla s1, pagetable_l2_devmap mv s2, a1 srli s2, s2, PAGE_SHIFT @@ -180,7 +189,7 @@ pagetables: slli t2, s2, PTE_PPN0_S /* << PTE_PPN0_S */ or t0, t0, t2 - /* Store PTE entry to position */ + /* Store the L2 table entry for the DTB */ li a6, PTE_SIZE li a5, 510 mulw a5, a5, a6