From nobody Sat Aug 12 06:29:08 2023 X-Original-To: dev-commits-src-main@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 4RN9jd2Hlhz4TvV7; Sat, 12 Aug 2023 06:29:09 +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 4RN9jc5LNkz3Y4t; Sat, 12 Aug 2023 06:29:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691821748; 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=uYGoDYysZGhMB2qpp+VeFuKOmMWYfcIs4mc9yntHHv8=; b=O+B1RRU7P7GWOr/zhX2oRP2Gq3GvAFCPdffEjdnjspd+CjOy+0sN5ctAETZypdtRoSN+n4 XvZB3H7TERPXIrrHLR4K6Ui3usSOFKPKGxcbYJm1XzUaXp4WizIQhsJNIQnIplDbNIzISt Gy6usm9GVSwC/48KLjmB7pt1th8OL9HTdGJBa5I4sQnCqivbL0fk+8ymipJhleJ6w+HBEX 4i4zCLMCf0GJz2pk7R3lwjdWY5GN1eMMLTTgrXWqSNWCC+e22RceGhVj6EI+lWKBY5i3b+ Syt+Wu4lUBGENrajVkBn0UzPKiCpZq0LirX70KDUjvJRJQJqp5lNUWntKhBmDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691821748; 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=uYGoDYysZGhMB2qpp+VeFuKOmMWYfcIs4mc9yntHHv8=; b=cnqqqoOkmskiPtF2dO1R2KpmUp9V/9idFuDlkpVVbzAaEnSHUE+m4sJcPCqPTOixv9mebU AowMlx3v4K+PCLBLDSfOwLvtyQ5xtiFN+TP8wlGdteNdpeCZSoISejDuwOf5x2k4Pw5poO EaMiHL4q4Jp3Zny30R/PI5ke7+WBYIOfRcxjMBIPhzj5exYJUth+/HzBOUz+ZKXGG6WgSU vpZ4qcam3qQ9B0wMdXyw7vk6u5FkdrN2F+KHXLiqIcXp1sJ8wYJcOx3rxfe4EBrGBjZ4R5 8VGQ4CR7uc2k58QkZYtLbMZzG4Pt4paC01HkaoExKdz5WuXBqqhPzIMsEJO+gQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1691821748; a=rsa-sha256; cv=none; b=XEMymThIKz4LlKWtOqRq5cfl5GEj2XCR+wtnC4cvB6jAI++FMrfpxkP9jlSE6eZkxKFZKg qSbiuXGG0ePDKiBwPfNX1YErHPSA6PTFuZfGSVs/fbAx/BCB6AMXkcD3gXxpeGJfxRyaY9 q1HlRISM2ScHmCso8ASsOWsfFoKXX2Nr0+xShs5Z6T+xNJcYrpa3GFwkmPV0H8KooykwWN aDuceUqDhAtpBTCEnXPckEFpcAS3YJO49VcqkjcUoiD6QS6yAVZz10k/m/NIIIn7CMNqli FSR9tdj8arPW8PxsCf/wwuCJQUnTyjyzLg4htZj6qB+0I7r8F6Za4ufUDtvkyA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4RN9jc4S38z18jV; Sat, 12 Aug 2023 06:29:08 +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 37C6T8Mv024848; Sat, 12 Aug 2023 06:29:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37C6T8OO024845; Sat, 12 Aug 2023 06:29:08 GMT (envelope-from git) Date: Sat, 12 Aug 2023 06:29:08 GMT Message-Id: <202308120629.37C6T8OO024845@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 79169929f04d - main - vm_map_protect(): move guard handling at the last phase into an empty dedicated helper List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 79169929f04d00e51a901d1e4cb377d2475bf660 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=79169929f04d00e51a901d1e4cb377d2475bf660 commit 79169929f04d00e51a901d1e4cb377d2475bf660 Author: Konstantin Belousov AuthorDate: 2023-07-28 00:14:07 +0000 Commit: Konstantin Belousov CommitDate: 2023-08-12 06:28:13 +0000 vm_map_protect(): move guard handling at the last phase into an empty dedicated helper Restructure the first phase slightly, to facilitate further changes. Reviewed by: alc, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D41099 --- sys/vm/vm_map.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 28c44544c660..dd342752bf6c 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -2722,6 +2722,13 @@ vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot, VM_OBJECT_RUNLOCK(object); } +static void +vm_map_protect_guard(vm_map_entry_t entry, vm_prot_t new_prot, + vm_prot_t new_maxprot, int flags) +{ + MPASS((entry->eflags & MAP_ENTRY_GUARD) != 0); +} + /* * vm_map_protect: * @@ -2780,12 +2787,13 @@ again: check_prot |= new_maxprot; for (entry = first_entry; entry->start < end; entry = vm_map_entry_succ(entry)) { - if ((entry->eflags & MAP_ENTRY_GUARD) != 0) - continue; if ((entry->eflags & MAP_ENTRY_IS_SUB_MAP) != 0) { vm_map_unlock(map); return (KERN_INVALID_ARGUMENT); } + if ((entry->eflags & MAP_ENTRY_GUARD) != 0) { + continue; + } if (!CONTAINS_BITS(entry->max_protection, check_prot)) { vm_map_unlock(map); return (KERN_PROTECTION_FAILURE); @@ -2884,10 +2892,15 @@ again: entry->start < end; vm_map_try_merge_entries(map, prev_entry, entry), prev_entry = entry, entry = vm_map_entry_succ(entry)) { - if (rv != KERN_SUCCESS || - (entry->eflags & MAP_ENTRY_GUARD) != 0) + if (rv != KERN_SUCCESS) continue; + if ((entry->eflags & MAP_ENTRY_GUARD) != 0) { + vm_map_protect_guard(entry, new_prot, new_maxprot, + flags); + continue; + } + old_prot = entry->protection; if ((flags & VM_MAP_PROTECT_SET_MAXPROT) != 0) {