From owner-dev-commits-src-main@freebsd.org Tue Jan 26 17:15:25 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0C2364F6B83; Tue, 26 Jan 2021 17:15:25 +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 4DQCzc702nz4jmr; Tue, 26 Jan 2021 17:15:24 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 E2E235445; Tue, 26 Jan 2021 17:15:24 +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 10QHFOVt074970; Tue, 26 Jan 2021 17:15:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10QHFOYf074969; Tue, 26 Jan 2021 17:15:24 GMT (envelope-from git) Date: Tue, 26 Jan 2021 17:15:24 GMT Message-Id: <202101261715.10QHFOYf074969@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: ee55e19a7942 - main - vm_map_protect.9: update after code changes 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: ee55e19a79429fe8505ae37d561eccb38d5fa6b8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2021 17:15:25 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ee55e19a79429fe8505ae37d561eccb38d5fa6b8 commit ee55e19a79429fe8505ae37d561eccb38d5fa6b8 Author: Konstantin Belousov AuthorDate: 2021-01-23 20:19:06 +0000 Commit: Konstantin Belousov CommitDate: 2021-01-26 17:15:05 +0000 vm_map_protect.9: update after code changes Reviewed by: brooks, markj Discussed with: emaste Sponsored by: The FreeBSD Foundation MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D28311 --- share/man/man9/vm_map_protect.9 | 118 +++++++++++++++++++++++++--------------- 1 file changed, 74 insertions(+), 44 deletions(-) diff --git a/share/man/man9/vm_map_protect.9 b/share/man/man9/vm_map_protect.9 index 5e58074ebda7..048f574aef2b 100644 --- a/share/man/man9/vm_map_protect.9 +++ b/share/man/man9/vm_map_protect.9 @@ -1,7 +1,12 @@ .\" .\" Copyright (c) 2003 Bruce M Simpson +.\" Copyright (c) 2021 The FreeBSD Foundation, Inc. .\" All rights reserved. .\" +.\" Parts of this documentation were written by +.\" Konstantin Belousov under sponsorship +.\" from the FreeBSD Foundation. +.\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -25,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 20, 2019 +.Dd January 23, 2021 .Dt VM_MAP_PROTECT 9 .Os .Sh NAME @@ -37,70 +42,95 @@ .In vm/vm_map.h .Ft int .Fo vm_map_protect -.Fa "vm_map_t map" "vm_offset_t start" "vm_offset_t end" "vm_prot_t new_prot" -.Fa "boolean_t set_max" +.Fa "vm_map_t map" +.Fa "vm_offset_t start" +.Fa "vm_offset_t end" +.Fa "vm_prot_t new_prot" +.Fa "vm_prot_t new_maxprot" +.Fa "int flags" .Fc .Sh DESCRIPTION The .Fn vm_map_protect -function sets the protection bits of the address region bounded by +function sets the protection bits and maximum protection bits of the address +region bounded by .Fa start and .Fa end within the map -.Fa map -to +.Fa map . +.Pp +If the +.Fa flags +argument has the +.Dv VM_MAP_PROTECT_SET_PROT +bit set, then the effective protection is set to .Fa new_prot . -The value specified by -.Fa new_prot -may not include any protection bits that are not set in -.Va max_protection -on every entry within the range. .Pp -If -.Fa set_max -is TRUE, +If the +.Fa flags +argument has the +.Dv VM_MAP_PROTECT_SET_MAXPROT +bit set, then the maximum protection is set to +.Fa new_maxprot . +Protection bits not included into +.Fa new_maxprot +will be cleared from existing entries. +.Pp +The values specified by .Fa new_prot -is treated as the new +and +.Fa new_maxprot +are not allowed to include any protection bits that are not set in existing .Va max_protection -setting for each underlying entry. -Protection bits not included -.Fa new_prot -will be cleared from existing entries. -If -.Fa set_max -is FALSE only the -.Va protection -field is affected. +on every entry within the range. +The operation will fail if this condition is violated. +For instance, this prevents upgrading a shared mapping of a read-only file +from read-only to read-write. .Pp -The range MUST be contiguous, and MUST NOT contain sub-maps. +The specified range must not contain sub-maps. .Sh IMPLEMENTATION NOTES The function acquires a lock on the .Fa map for the duration, by calling .Xr vm_map_lock 9 . +Also, any in-progress wiring operation on the map affecting the specified +range will cause +.Nm +to sleep, waiting for completion. .Sh RETURN VALUES -The -.Fn vm_map_protect -function returns -.Dv KERN_SUCCESS -if the protection bits could be set successfully. -.Pp -If a sub-map entry was encountered in the range, -.Dv KERN_INVALID_ARGUMENT -is returned. -If the value of +.Bl -tag -width "Dv KERN_PROTECTION_FAILURE" +.It Dv KERN_SUCCESS +The specified protection bits were set successfully. +.It Dv KERN_INVALID_ARGUMENT +A sub-map entry was encountered in the range, +.It Dv KERN_PROTECTION_FAILURE +The value of .Fa new_prot -would exceed +or +.Fa new_maxprot +exceed .Va max_protection -for an entry within the range, -.Dv KERN_PROTECTION_FAILURE -is returned. -If a copy-on-write mapping is transitioned from read-only to -read-write, and too little swap space is available for backing the -copied pages, -.Dv KERN_RESOURCE_SHORTAGE -is returned. +for an entry within the range. +.It Dv KERN_PROTECTION_FAILURE +The map does not allow simultaneous setting of write and execute permissions, +but +.Fa new_prot +has both +.Dv VM_PROT_WRITE +and +.Dv VM_PROT_EXECUTE +set. +.It Dv KERN_RESOURCE_SHORTAGE +A copy-on-write mapping is transitioned from read-only to +read-write, and not enough swap space is available to back the +copied pages. +.It Dv KERN_OUT_OF_BOUNDS +Both new protection and new maximum protection updates were requested, +but the specified +.Fa new_prot +is not a subset of +.Fa new_maxprot . .Sh SEE ALSO .Xr vm_map 9 .Sh AUTHORS