From nobody Thu Sep 29 17:24:32 2022 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 4MdgG91Px9z4dlbx; Thu, 29 Sep 2022 17:24:33 +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 4MdgG90x0Bz4D1x; Thu, 29 Sep 2022 17:24:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664472273; 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=M932GS26879cp4u9IBuSnuEy1HjO4bGu1UCY/FS5WbA=; b=wWDPG/aUCyDJaBCAP5UCyM733yXSrvRuRhfKWLDgu5U00lB3xa3efrATPV4eBwKxjv3R1H FXY3fcRlvxmyviZ6716GO72qihuO1Hp1JKMRqTtuaO+YnKfZ4NfQH0kJae6EZEoBKSZ8Rj sCT6ZgB1lLROD2YCwIa5cVW8Ehn5KTMJPg/Td7AGSsngMOBUHOluJp2qiowPknuGKxfzOQ 0PCOTsRitgLN4luRO9x7jfhJsOYuYi5Tz1dPPzi9Py3gtDtFz3O6C33q6YOWYVyisnK67Q nWLvaGsvmunXfmg8MO4gJJtXo0mWP1tcyxjl2f2WDipu7+AneXb7b9o3dc5MBQ== 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 4MdgG8736XztXN; Thu, 29 Sep 2022 17:24:32 +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 28THOWGc053190; Thu, 29 Sep 2022 17:24:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28THOW6h053189; Thu, 29 Sep 2022 17:24:32 GMT (envelope-from git) Date: Thu, 29 Sep 2022 17:24:32 GMT Message-Id: <202209291724.28THOW6h053189@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: ec21f85ab5f0 - main - riscv: Handle invalid L2 entries in pmap_extract() 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: ec21f85ab5f03a803884cc7bafa88621c613f4ca Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664472273; 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=M932GS26879cp4u9IBuSnuEy1HjO4bGu1UCY/FS5WbA=; b=jjhJSuSiPKmP/rh8sr80t9Vd8jRdepYcXnfKgKP5kBYqRyDJXcer3y9dSp21hB1R4ILEK3 BwagM5E7ndZC/6TqcBDDbNMbpdy0hMKGz+nWTNKEK7OxBgHornzkQvqGLzaJ/hN2VLu1VE x+Zr8DQjvn2ABJKq6ulmSNy7JvhxYE24/bxc07iPvcWBUeGTr/eW4hCg+yQuALm9cJ6nLP cLTsXE6NpcjNClDphxrDBFWllJ96Wx8m5DTKlYnPeNHHf3+NumJxD0eSZgEcICvC6WkVjq ijEoAy7n+bKX1sc+pNKy3I7dWm5L6F23KhEqKciqYY+Tvt08ASZjS86BRjULgw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664472273; a=rsa-sha256; cv=none; b=RxVKGejCuS2mGzi3TcJR/mv3Ta7sraJuA7un+mKSPxIOzdIwk761pKLj1ERKa+tKTYWe6Z yIeAvdp6x41pTQy9WVi5J3hoNBqAvowAHFNw69sSN4yaNs2HbC7sauBHezGqLvvCrgumzc hL5Wa0Q9aE7QbZhMhav4I831i+dPR4H2Qw4r4lY5x6kIhOxdhe+ppm+WkbnowTTDSiJ2m2 0UhlTKXn2WLQXIq3pOFS+1XVLrY25lqtqixtSk9pO5FxzzUkDoGRBgtmLlwG7/gr55EXwc QyDjYtW6maG1ydao0XBt6jOfWlqvo6g1u3kUuxaX6kiXhpdrRpZxl2hAZlNiLw== 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=ec21f85ab5f03a803884cc7bafa88621c613f4ca commit ec21f85ab5f03a803884cc7bafa88621c613f4ca Author: Mark Johnston AuthorDate: 2022-09-29 17:07:26 +0000 Commit: Mark Johnston CommitDate: 2022-09-29 17:11:26 +0000 riscv: Handle invalid L2 entries in pmap_extract() While here, eliminate a single-use local variable. PR: 266103 Reviewed by: mhorne MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D36395 --- sys/riscv/riscv/pmap.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index 6aec89faf860..ddbeb9039c51 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -903,27 +903,25 @@ vm_paddr_t pmap_extract(pmap_t pmap, vm_offset_t va) { pd_entry_t *l2p, l2; - pt_entry_t *l3p, l3; + pt_entry_t *l3p; vm_paddr_t pa; pa = 0; - PMAP_LOCK(pmap); + /* - * Start with the l2 tabel. We are unable to allocate - * pages in the l1 table. + * Start with an L2 lookup, L1 superpages are currently not implemented. */ + PMAP_LOCK(pmap); l2p = pmap_l2(pmap, va); - if (l2p != NULL) { - l2 = pmap_load(l2p); - if ((l2 & PTE_RX) == 0) { + if (l2p != NULL && ((l2 = pmap_load(l2p)) & PTE_V) != 0) { + if ((l2 & PTE_RWX) == 0) { l3p = pmap_l2_to_l3(l2p, va); if (l3p != NULL) { - l3 = pmap_load(l3p); - pa = PTE_TO_PHYS(l3); + pa = PTE_TO_PHYS(pmap_load(l3p)); pa |= (va & L3_OFFSET); } } else { - /* L2 is superpages */ + /* L2 is a superpage mapping. */ pa = L2PTE_TO_PHYS(l2); pa |= (va & L2_OFFSET); }