From nobody Thu Oct 13 14:09:55 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 4MpBH76qjSz4g2vh; Thu, 13 Oct 2022 14:09:55 +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 4MpBH76LyBz3KNb; Thu, 13 Oct 2022 14:09:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665670195; 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=Pihg6ugJKrjrQP/Ml8BDppk3DoUTAKBIhZHhjom8fV0=; b=cpWWpBSZ1QJ144D/O/54Gfr2VNAYJAA0qigdzQtAoh575s95AGdnsVSq05whaK4GpfNJxQ XqvHyngALL81u8CeDvHdgr8vDF4Ko0Dy3wPOIWMBkvbcNz7JCoJaAWtyr4KWwmlOV7poW6 y34/a4T2HbOUHry2+Kjkb3nc9MXwR/qq5eUN9LJtS0uiA0GQHQfaH10OCtRbFUIv4ajpSP c/oRY8hQ/XvMM7k6jnfcB5F3EwwHJMxrrlGkTwkhTkU881hbZoC4LqbK/FGPpLTL1wJ4Ls NSdyw9lnp1Ldrr4Awji7YqKOZyvt475g5FU5gnnzpAppbCGbkIxroInkrsdDdw== 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 4MpBH7584bzRYf; Thu, 13 Oct 2022 14:09:55 +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 29DE9tj2099332; Thu, 13 Oct 2022 14:09:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29DE9tRN099331; Thu, 13 Oct 2022 14:09:55 GMT (envelope-from git) Date: Thu, 13 Oct 2022 14:09:55 GMT Message-Id: <202210131409.29DE9tRN099331@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 472294b86549 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 472294b86549d6cb7562cff4f702010a34565c87 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665670195; 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=Pihg6ugJKrjrQP/Ml8BDppk3DoUTAKBIhZHhjom8fV0=; b=E/4X6xgcxmUeDXvHofOX25snHHZkjFEU2PXaxVVBW1EGqiThk2BSfCUP+kvU2r0RjO9ojX mXEYscDRLn4gUZyUWF4ILj1K7EtlB5uD1780xYQbowf+l7+/fo9OsDWC8N6fHGUy9UQn/N MUnCKDMswbI/v1ZR6UcZpkQc0pGEwQ2rJMKSnfEHAyI7y1M7TQpKiGq1qtTax+zFhDGhEG tTrjvC7mgCDd2NHBl3AZIF7dOMOSFgBSgwJQ2RAmja23kat3+Q4A6lwOGUWfRm7/tp1p7i BHyP7d1WugJl+LnidovpB6xHEwq2Ncknr+QbYG9VgwBcYOHhye0hXK34PSsE0A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665670195; a=rsa-sha256; cv=none; b=uLjkhovRSV95tVWJc1R2XVdyxQ0v0puAEEwlksneAEnusg635sJDQy6G76ZYnZGmu/1yKO mvdedPzrRL98GX5YT0VVdJeePK4zSBbuM63TY0iTHrwTY+w9tbDk2Iw2NU5uouCuTDBGOf 6q5hObDzW59fefKHaaYQnsSNcKor5pdQaUAdXWrD414JOIv4GvVTlY8a+E6o/u97dGN2jK zw6HTW+nY679vCbZc7V55XPSuP7rJPBE/fr+COFKDRGwcfe9q9jAFmf89VC0p4bJZM+mjd F84e343wQtdmgYafrm1/uFm8XPcbpJzvhsaxbNhk8zJ6r+IQu2ZvsWZ27slgMQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=472294b86549d6cb7562cff4f702010a34565c87 commit 472294b86549d6cb7562cff4f702010a34565c87 Author: Mitchell Horne AuthorDate: 2022-10-05 17:11:02 +0000 Commit: Mitchell Horne CommitDate: 2022-10-13 14:05:20 +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 (cherry picked from commit 9d1aef84021f4e99d37f4e9149a8799c3d9e5e03) --- 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 9ca06968b1d6..d72b989f8f38 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++;