1# zx_vmar_protect
2
3## NAME
4
5<!-- Updated by update-docs-from-abigen, do not edit. -->
6
7vmar_protect - set protection of virtual memory pages
8
9## SYNOPSIS
10
11<!-- Updated by update-docs-from-abigen, do not edit. -->
12
13```
14#include <zircon/syscalls.h>
15
16zx_status_t zx_vmar_protect(zx_handle_t handle,
17                            zx_vm_option_t options,
18                            zx_vaddr_t addr,
19                            uint64_t len);
20```
21
22## DESCRIPTION
23
24`zx_vmar_protect()` alters the access protections for the memory mappings
25in the range of *len* bytes starting from *addr*. The *options* argument should
26be a bitwise-or of one or more of the following:
27- **ZX_VM_PERM_READ**  Map as readable.  It is an error if *handle*
28  does not have **ZX_VM_CAN_MAP_READ** permissions or *handle* does
29  not have the **ZX_RIGHT_READ** right.  It is also an error if the VMO handle
30  used to create the mapping did not have the **ZX_RIGHT_READ** right.
31- **ZX_VM_PERM_WRITE**  Map as writable.  It is an error if *handle*
32  does not have **ZX_VM_CAN_MAP_WRITE** permissions or *handle* does
33  not have the **ZX_RIGHT_WRITE** right.  It is also an error if the VMO handle
34  used to create the mapping did not have the **ZX_RIGHT_WRITE** right.
35- **ZX_VM_PERM_EXECUTE**  Map as executable.  It is an error if *handle*
36  does not have **ZX_VM_CAN_MAP_EXECUTE** permissions or *handle* does
37  not have the **ZX_RIGHT_EXECUTE** right.  It is also an error if the VMO handle
38  used to create the mapping did not have the **ZX_RIGHT_EXECUTE** right.
39
40*len* must be page-aligned.
41
42## RIGHTS
43
44<!-- Updated by update-docs-from-abigen, do not edit. -->
45
46If *options* & **ZX_VM_PERM_READ**, *handle* must be of type **ZX_OBJ_TYPE_VMAR** and have **ZX_RIGHT_READ**.
47
48If *options* & **ZX_VM_PERM_WRITE**, *handle* must be of type **ZX_OBJ_TYPE_VMAR** and have **ZX_RIGHT_WRITE**.
49
50If *options* & **ZX_VM_PERM_EXECUTE**, *handle* must be of type **ZX_OBJ_TYPE_VMAR** and have **ZX_RIGHT_EXECUTE**.
51
52## RETURN VALUE
53
54`zx_vmar_protect()` returns **ZX_OK** on success.
55
56## ERRORS
57
58**ZX_ERR_BAD_HANDLE**  *handle* is not a valid handle.
59
60**ZX_ERR_WRONG_TYPE**  *handle* is not a VMAR handle.
61
62**ZX_ERR_INVALID_ARGS**  *prot_flags* is an unsupported combination of flags
63(e.g., **ZX_VM_PERM_WRITE** but not **ZX_VM_PERM_READ**), *addr* is
64not page-aligned, *len* is 0, or some subrange of the requested range is
65occupied by a subregion.
66
67**ZX_ERR_NOT_FOUND**  Some subrange of the requested range is not mapped.
68
69**ZX_ERR_ACCESS_DENIED**  *handle* does not have the proper rights for the
70requested change, the original VMO handle used to create the mapping did not
71have the rights for the requested change, or the VMAR itself does not allow
72the requested change.
73
74## NOTES
75
76## SEE ALSO
77
78 - [`zx_vmar_allocate()`]
79 - [`zx_vmar_destroy()`]
80 - [`zx_vmar_map()`]
81 - [`zx_vmar_unmap()`]
82
83<!-- References updated by update-docs-from-abigen, do not edit. -->
84
85[`zx_vmar_allocate()`]: vmar_allocate.md
86[`zx_vmar_destroy()`]: vmar_destroy.md
87[`zx_vmar_map()`]: vmar_map.md
88[`zx_vmar_unmap()`]: vmar_unmap.md
89