]>
Commit | Line | Data |
---|---|---|
8a686975 MK |
1 | .\" Copyright (c) 2010 Michael Kerrisk <mtk.manpages@gmail.com> |
2 | .\" based on a proposal from Stephan Mueller <smueller@atsec.com> | |
3 | .\" | |
93015253 | 4 | .\" %%%LICENSE_START(VERBATIM) |
8a686975 MK |
5 | .\" Permission is granted to make and distribute verbatim copies of this |
6 | .\" manual provided the copyright notice and this permission notice are | |
7 | .\" preserved on all copies. | |
8 | .\" | |
9 | .\" Permission is granted to copy and distribute modified versions of | |
10 | .\" this manual under the conditions for verbatim copying, provided that | |
11 | .\" the entire resulting derived work is distributed under the terms of | |
12 | .\" a permission notice identical to this one. | |
13 | .\" | |
14 | .\" Since the Linux kernel and libraries are constantly changing, this | |
62290181 SP |
15 | .\" manual page may be incorrect or out-of-date. The author(s) assume |
16 | .\" no responsibility for errors or omissions, or for damages resulting | |
17 | .\" from the use of the information contained herein. The author(s) may | |
18 | .\" not have taken the same level of care in the production of this | |
19 | .\" manual, which is licensed free of charge, as they might when working | |
8a686975 MK |
20 | .\" professionally. |
21 | .\" | |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 24 | .\" %%%LICENSE_END |
8a686975 MK |
25 | .\" |
26 | .\" Various pieces of text taken from the kernel source and the commentary | |
27 | .\" in kernel commit fa28237cfcc5827553044cbd6ee52e33692b0faa | |
28 | .\" both written by Paul Mackerras <paulus@samba.org> | |
29 | .\" | |
9ba01802 | 30 | .TH SUBPAGE_PROT 2 2019-03-06 "Linux" "Linux Programmer's Manual" |
8a686975 | 31 | .SH NAME |
8af78666 | 32 | subpage_prot \- define a subpage protection for an address range |
8a686975 MK |
33 | .SH SYNOPSIS |
34 | .nf | |
35 | .BI "long subpage_prot(unsigned long " addr ", unsigned long " len , | |
36 | .BI " uint32_t *" map "); | |
37 | .fi | |
dbfe9c70 | 38 | .PP |
45c99e3e MK |
39 | .IR Note : |
40 | There is no glibc wrapper for this system call; see NOTES. | |
8a686975 MK |
41 | .SH DESCRIPTION |
42 | The PowerPC-specific | |
43 | .BR subpage_prot () | |
44 | system call provides the facility to control the access | |
ee8655b5 MK |
45 | permissions on individual 4\ kB subpages on systems configured with |
46 | a page size of 64\ kB. | |
efeece04 | 47 | .PP |
8a686975 MK |
48 | The protection map is applied to the memory pages in the region starting at |
49 | .I addr | |
50 | and continuing for | |
51 | .I len | |
52 | bytes. | |
53 | Both of these arguments must be aligned to a 64-kB boundary. | |
efeece04 | 54 | .PP |
8a686975 MK |
55 | The protection map is specified in the buffer pointed to by |
56 | .IR map . | |
ee8655b5 MK |
57 | The map has 2 bits per 4\ kB subpage; |
58 | thus each 32-bit word specifies the protections of 16 4\ kB subpages | |
59 | inside a 64\ kB page | |
8a686975 MK |
60 | (so, the number of 32-bit words pointed to by |
61 | .I map | |
62 | should equate to the number of 64-kB pages specified by | |
63 | .IR len ). | |
64 | Each 2-bit field in the protection map is either 0 to allow any access, | |
65 | 1 to prevent writes, or 2 or 3 to prevent all accesses. | |
66 | .SH RETURN VALUE | |
67 | On success, | |
68 | .BR subpage_prot () | |
69 | returns 0. | |
c079ed64 | 70 | Otherwise, one of the error codes specified below is returned. |
8a686975 MK |
71 | .SH ERRORS |
72 | .TP | |
27807c32 MK |
73 | .B EFAULT |
74 | The buffer referred to by | |
75 | .I map | |
76 | is not accessible. | |
77 | .TP | |
8a686975 MK |
78 | .B EINVAL |
79 | The | |
80 | .I addr | |
81 | or | |
82 | .I len | |
83 | arguments are incorrect. | |
84 | Both of these arguments must be aligned to a multiple of the system page size, | |
85 | and they must not refer to a region outside of the | |
86 | address space of the process or to a region that consists of huge pages. | |
87 | .TP | |
8a686975 MK |
88 | .B ENOMEM |
89 | Out of memory. | |
90 | .SH VERSIONS | |
91 | This system call is provided on the PowerPC architecture | |
92 | since Linux 2.6.25. | |
93 | The system call is provided only if the kernel is configured with | |
94 | .BR CONFIG_PPC_64K_PAGES . | |
95 | No library support is provided. | |
96 | .SH CONFORMING TO | |
97 | This system call is Linux-specific. | |
98 | .SH NOTES | |
45c99e3e MK |
99 | Glibc does not provide a wrapper for this system call; call it using |
100 | .BR syscall (2). | |
efeece04 | 101 | .PP |
8a686975 MK |
102 | Normal page protections (at the 64-kB page level) also apply; |
103 | the subpage protection mechanism is an additional constraint, | |
104 | so putting 0 in a 2-bit field won't allow writes to a page that is otherwise | |
105 | write-protected. | |
106 | .SS Rationale | |
107 | This system call is provided to assist writing emulators that | |
108 | operate using 64-kB pages on PowerPC systems. | |
109 | When emulating systems such as x86, which uses a smaller page size, | |
110 | the emulator can no longer use the memory-management unit (MMU) | |
111 | and normal system calls for controlling page protections. | |
112 | (The emulator could emulate the MMU by checking and possibly remapping | |
113 | the address for each memory access in software, but that is slow.) | |
114 | The idea is that the emulator supplies an array of protection masks | |
115 | to apply to a specified range of virtual addresses. | |
116 | These masks are applied at the level where hardware page-table entries (PTEs) | |
117 | are inserted into the hardware page table based on the Linux PTEs, | |
118 | so the Linux PTEs are not affected. | |
c079ed64 MK |
119 | Implicit in this is that the regions of the address space that are |
120 | protected are switched to use 4-kB hardware pages rather than 64-kB | |
121 | hardware pages (on machines with hardware 64-kB page support). | |
122 | .\" In the initial implementation, it was the case that: | |
ee8655b5 | 123 | .\" In fact the whole process is switched to use 4 kB hardware pages when the |
c079ed64 MK |
124 | .\" subpage_prot system call is used, but this could be improved in future |
125 | .\" to switch only the affected segments. | |
126 | .\" But Paul Mackerass says (Oct 2010): I'm pretty sure we now only switch | |
127 | .\" the affected segment, not the whole process. | |
8a686975 MK |
128 | .SH SEE ALSO |
129 | .BR mprotect (2), | |
173fe7e7 | 130 | .BR syscall (2) |
efeece04 | 131 | .PP |
a2463bae | 132 | .IR Documentation/admin-guide/mm/hugetlbpage.rst |
173fe7e7 | 133 | in the Linux kernel source tree |