From nobody Fri Jun 14 18:02:27 2024 X-Original-To: dev-commits-src-all@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 4W16Yv5cyCz5PGSm; Fri, 14 Jun 2024 18:02:27 +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 4W16Yv3C1gz46yn; Fri, 14 Jun 2024 18:02:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718388147; 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=rw7tVkfk0/GTWH3CkLygPEU8DLJVQxEMB2gL7j3zApo=; b=MICO96gLLz3eEE73Ymaggp1J2agqPPWbgZuD0sqHX2Uez+wShoY1O1CeoVBsMycTi1fPms xFsD7Fo2vRDrZE5tjC6ov2oBP3BIWDjFJ0Dz5+nmU2otBYPdEslG8axuKNSZoGKhQelqlY nffu+SFFhNlfg0NDY+IizoSJ7Pb0WUB3CXEg1xcuqCHYGQi2fH1w3mMBJhTnG8gdmzKwR9 n2F7lh6YeidkP4dVyyOwOY4wzfrSdW9AKMpN6x+G/fGY/E9zue+PF7rPbIiHgRCjigM9lm Vcf4nC7cLk7oSpKv3UNhWUO4Jd/QXryOvKWCR9djpVi7V43ZrDbI35YsDO8vUA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718388147; a=rsa-sha256; cv=none; b=ahFZoAADF8ahsFK1PIq2BRZjXd90loaaWMK2gHMUGecMe5qcIbw1M7CWuTp6y94laMhT6k GsH7TYm45YkjCm9mtNdz4jbyb4OgLRrNggaqdbdKPDDNrnJVxWJ9S3PhHKRqeeBzBqj29h sFxXcWElA8QRe3j7SL9PYuw/w5XD6Dic+EEK6SAA7RxJCmGtIhw2H/0vnT0Ev5a1ddkrb+ Rrh+uHbcE65crWnk6EDxhpi+hJ5lTgCXJy9EuZa5gD2RZ5uqkiIMrOH4EkACuY1Lf3BxCk QTD1KdL7EowV2jeZ+84spuICYuwMxwk5FHhxxl0tmG0yRrPmtb3zm88bZjQY4g== 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=1718388147; 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=rw7tVkfk0/GTWH3CkLygPEU8DLJVQxEMB2gL7j3zApo=; b=eLln1n9rqc6JfKIfooeHsNO+S9KG+tI4qEZlhaHScjfq6MuZKQBUJpiIvRN9oe8MYt/B0i YsvkStovwT53lmfbLjzsLHHGDtg+9RXXDMdG+LJ9+QdC2ehRaGZ4f35AtNP5UdLeHwQY30 PV427knAt7JJoURr38eCFz6NZ9+IP/xLPCWmIsckS5HDZuvAArDuPC22QJF8iBL2MQ/q87 /fonNqM0l7vOWg7rHpfIQ9ujk6X5BKIw/lk6ljxi5kmswoI0XjVt+/2WgS9ZOjYX7pKXHQ GcfSXO/7tycaZdv33EFgFSdAXhrlNz+gbR9W6S2I2WhQ1gqtIeX8TlvhrTf23g== 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 4W16Yv2phlzW74; Fri, 14 Jun 2024 18:02:27 +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 45EI2Rix053047; Fri, 14 Jun 2024 18:02:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45EI2RSO053044; Fri, 14 Jun 2024 18:02:27 GMT (envelope-from git) Date: Fri, 14 Jun 2024 18:02:27 GMT Message-Id: <202406141802.45EI2RSO053044@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: 134f7b5fa91f - main - riscv: improve commentary around initial stvec List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: 134f7b5fa91fa41e3c3c7caeaf1dff72018684e5 Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=134f7b5fa91fa41e3c3c7caeaf1dff72018684e5 commit 134f7b5fa91fa41e3c3c7caeaf1dff72018684e5 Author: Mitchell Horne AuthorDate: 2024-06-03 17:24:12 +0000 Commit: Mitchell Horne CommitDate: 2024-06-14 18:02:05 +0000 riscv: improve commentary around initial stvec Make it explicit why we must set the trap vector before enabling virtual memory. Reviewed by: br, jhb, markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45474 --- sys/riscv/riscv/locore.S | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sys/riscv/riscv/locore.S b/sys/riscv/riscv/locore.S index 5a7e15ba443b..7e885ab8ca89 100644 --- a/sys/riscv/riscv/locore.S +++ b/sys/riscv/riscv/locore.S @@ -197,7 +197,11 @@ pagetables: /* Page tables END */ - /* Setup supervisor trap vector */ + /* + * Set the supervisor trap vector temporarily. Enabling virtual memory + * may generate a page fault. We simply wish to continue onwards, so + * have the trap deliver us to 'va'. + */ 2: lla t0, va sub t0, t0, s9 @@ -221,7 +225,7 @@ va: lla gp, __global_pointer$ .option pop - /* Setup supervisor trap vector */ + /* Set the trap vector to the real handler. */ la t0, cpu_exception_handler csrw stvec, t0 @@ -342,7 +346,11 @@ ENTRY(mpentry) /* Get the kernel's load address */ jal get_physmem - /* Setup supervisor trap vector */ + /* + * Set the supervisor trap vector temporarily. Enabling virtual memory + * may generate a page fault. We simply wish to continue onwards, so + * have the trap deliver us to 'mpva'. + */ lla t0, mpva sub t0, t0, s9 li t1, KERNBASE @@ -365,7 +373,7 @@ mpva: lla gp, __global_pointer$ .option pop - /* Setup supervisor trap vector */ + /* Set the trap vector to the real handler. */ la t0, cpu_exception_handler csrw stvec, t0