From nobody Thu Oct 06 22:05:39 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 4Mk59J0hLvz4VBWX; Thu, 6 Oct 2022 22:05:40 +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 4Mk59J07Gyz3tXH; Thu, 6 Oct 2022 22:05:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665093940; 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=a3x5i5jXKkp4lkuZIBiW/bmobknHiliougQsxgnNJ9I=; b=bnVMou1XftG4+bqHMVL5Bg6RQXQ2aZxspNQ8h75JikJIX1s9Fnb+QdX49nUJegdh3MdkJZ wD6iXKFivKO0axplr6QKm+5ViNrhnK5vwwCnNwdDV9jq+DYaIkoAhHD9XqYc35TRICPKUh 7VtH0wroyyQ1WByHlKnw77mSR1qXPmn0wa0SkHwz/82l6XdSSV4c8BhbjBrh/3nhvyVZTF aqBlifCL6r9b6TAxLPNqsD6ysAb2/q1dn95nbSP+k/+zqtG6Up1v3d0rvp+tL1zwtZDo+Z LmtlvKndhG/bIHzqoFjc1/TkoTym2d17eZqU37WRx42I7kcStZ0FhBNBIVND4w== 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 4Mk59H6JYLzNmm; Thu, 6 Oct 2022 22:05:39 +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 296M5did056139; Thu, 6 Oct 2022 22:05:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 296M5dsP056138; Thu, 6 Oct 2022 22:05:39 GMT (envelope-from git) Date: Thu, 6 Oct 2022 22:05:39 GMT Message-Id: <202210062205.296M5dsP056138@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: 9d1aef84021f - main - riscv: handle superpage in pmap_enter_quick_locked() 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: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9d1aef84021f4e99d37f4e9149a8799c3d9e5e03 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665093940; 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=a3x5i5jXKkp4lkuZIBiW/bmobknHiliougQsxgnNJ9I=; b=PolsMt3PgDh36dLw+HFc/4PCyf+ojJfWRa/9y0WSbSijMCOZ8y80w20a1UAiZZOdZ4wM5s X1kqHdnpd/A3R+dkCYhZRhwzGIrJRW/HSTYvRcMfVIplS6AINf0BRlDcfnww5c+d3YcaU6 PtSJqQvE4FyZJ3BPMyCIIoUSw94gFilYtVYCL/YHE8J5r7C+s4h9nBUMSdPs358LSPRMwv kX2pS4uJvcAZT0LHe60dlVXlmc4iv3Cc7UfquZXo5aSU3bGozretdriz9Cs3Go2DPxbHdh O68axRB8JZPRNoiqQJR6L9OA0hRxkwin9Wq2y9n30nHjMVUeb/4ISPAS8EDg3A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665093940; a=rsa-sha256; cv=none; b=t0MBi3jx8dZrYJduMyedmgmxQv/SNfA5fXxTvO4HwAjYALMaYhublythNGWYI6dfwlk/1/ HKgQkT9lb4WqkvSunO6+D7StFd8/8f1ZkKbKYEWiRT/LRzfJmkkNlVnAW1GER4Y2xWrckA W/Itr89/TXnkypr+6D9pA+3k4MGZKZuwjzYErdAB863p7TSSbCGa8ZInxKR4GCC80b7Q3A 6Oz5FLqwNKgoDdddNgjVGIt3UIP17bTl8zscNcJuQeKB3pTGvmLE9a9no/xALYjcqxilzM mRVZP2J90nLXRL3jErmE2CXHnuCalA721GAVIPTVMm0lPpIQiqmpWcI3YPs+CQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=9d1aef84021f4e99d37f4e9149a8799c3d9e5e03 commit 9d1aef84021f4e99d37f4e9149a8799c3d9e5e03 Author: Mitchell Horne AuthorDate: 2022-10-05 17:11:02 +0000 Commit: Mitchell Horne CommitDate: 2022-10-06 22:02:38 +0000 riscv: handle superpage in pmap_enter_quick_locked() Previously, if pmap_enter_l2() was asked to re-map an existing superpage (the result of madvise(MADV_WILLNEED) on a mapped range), it could 'fail' to do so, falling back to trying pmap_enter_quick_locked() for each 4K virtual page. Because this function does not check if the l2 entry it finds is a superpage, it would proceed, sometimes resulting in the creation of false PV entries. If the relevant range was later munmap'ed, the system would panic during the process' exit in pmap_remove_pages(), while attempting to clean up the PV entries for mappings which no longer exist. Instead, we should return early in the presence of an existing superpage, as is done in other pmaps. PR: 266108 Reviewed by: markj, alc MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D36563 --- sys/riscv/riscv/pmap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index 69f2a9ab1522..9f73a020d0f4 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -3383,6 +3383,8 @@ pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m, * attempt fails, we don't retry. Instead, we give up. */ if (l2 != NULL && pmap_load(l2) != 0) { + if ((pmap_load(l2) & PTE_RWX) != 0) + return (NULL); phys = PTE_TO_PHYS(pmap_load(l2)); mpte = PHYS_TO_VM_PAGE(phys); mpte->ref_count++;