1SUBPAGE_PROT(2) Linux Programmer's Manual SUBPAGE_PROT(2)
2
3
4
6 subpage_prot - define a subpage protection for an address range
7
9 #include <sys/syscall.h> /* Definition of SYS_* constants */
10 #include <unistd.h>
11
12 int syscall(SYS_subpage_prot, unsigned long addr, unsigned long len,
13 uint32_t *map);
14
15 Note: glibc provides no wrapper for subpage_prot(), necessitating the
16 use of syscall(2).
17
19 The PowerPC-specific subpage_prot() system call provides the facility
20 to control the access permissions on individual 4 kB subpages on sys‐
21 tems configured with a page size of 64 kB.
22
23 The protection map is applied to the memory pages in the region start‐
24 ing at addr and continuing for len bytes. Both of these arguments must
25 be aligned to a 64-kB boundary.
26
27 The protection map is specified in the buffer pointed to by map. The
28 map has 2 bits per 4 kB subpage; thus each 32-bit word specifies the
29 protections of 16 4 kB subpages inside a 64 kB page (so, the number of
30 32-bit words pointed to by map should equate to the number of 64-kB
31 pages specified by len). Each 2-bit field in the protection map is ei‐
32 ther 0 to allow any access, 1 to prevent writes, or 2 or 3 to prevent
33 all accesses.
34
36 On success, subpage_prot() returns 0. Otherwise, one of the error
37 codes specified below is returned.
38
40 EFAULT The buffer referred to by map is not accessible.
41
42 EINVAL The addr or len arguments are incorrect. Both of these argu‐
43 ments must be aligned to a multiple of the system page size, and
44 they must not refer to a region outside of the address space of
45 the process or to a region that consists of huge pages.
46
47 ENOMEM Out of memory.
48
50 This system call is provided on the PowerPC architecture since Linux
51 2.6.25. The system call is provided only if the kernel is configured
52 with CONFIG_PPC_64K_PAGES. No library support is provided.
53
55 This system call is Linux-specific.
56
58 Normal page protections (at the 64-kB page level) also apply; the sub‐
59 page protection mechanism is an additional constraint, so putting 0 in
60 a 2-bit field won't allow writes to a page that is otherwise write-pro‐
61 tected.
62
63 Rationale
64 This system call is provided to assist writing emulators that operate
65 using 64-kB pages on PowerPC systems. When emulating systems such as
66 x86, which uses a smaller page size, the emulator can no longer use the
67 memory-management unit (MMU) and normal system calls for controlling
68 page protections. (The emulator could emulate the MMU by checking and
69 possibly remapping the address for each memory access in software, but
70 that is slow.) The idea is that the emulator supplies an array of pro‐
71 tection masks to apply to a specified range of virtual addresses.
72 These masks are applied at the level where hardware page-table entries
73 (PTEs) are inserted into the hardware page table based on the Linux
74 PTEs, so the Linux PTEs are not affected. Implicit in this is that the
75 regions of the address space that are protected are switched to use
76 4-kB hardware pages rather than 64-kB hardware pages (on machines with
77 hardware 64-kB page support).
78
80 mprotect(2), syscall(2)
81
82 Documentation/admin-guide/mm/hugetlbpage.rst in the Linux kernel source
83 tree
84
86 This page is part of release 5.13 of the Linux man-pages project. A
87 description of the project, information about reporting bugs, and the
88 latest version of this page, can be found at
89 https://www.kernel.org/doc/man-pages/.
90
91
92
93Linux 2021-03-22 SUBPAGE_PROT(2)