]>
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 | .\" | |
5fbde956 | 4 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
8a686975 MK |
5 | .\" |
6 | .\" Various pieces of text taken from the kernel source and the commentary | |
7 | .\" in kernel commit fa28237cfcc5827553044cbd6ee52e33692b0faa | |
8 | .\" both written by Paul Mackerras <paulus@samba.org> | |
9 | .\" | |
45186a5d | 10 | .TH SUBPAGE_PROT 2 2021-03-22 "Linux man-pages (unreleased)" |
8a686975 | 11 | .SH NAME |
8af78666 | 12 | subpage_prot \- define a subpage protection for an address range |
2b761b8f AC |
13 | .SH LIBRARY |
14 | Standard C library | |
8fc3b2cf | 15 | .RI ( libc ", " \-lc ) |
8a686975 MK |
16 | .SH SYNOPSIS |
17 | .nf | |
c2370727 AC |
18 | .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" |
19 | .B #include <unistd.h> | |
20 | .PP | |
21 | .BI "int syscall(SYS_subpage_prot, unsigned long " addr ", unsigned long " len , | |
22 | .BI " uint32_t *" map ); | |
8a686975 | 23 | .fi |
dbfe9c70 | 24 | .PP |
45c99e3e | 25 | .IR Note : |
c2370727 AC |
26 | glibc provides no wrapper for |
27 | .BR subpage_prot (), | |
28 | necessitating the use of | |
29 | .BR syscall (2). | |
8a686975 MK |
30 | .SH DESCRIPTION |
31 | The PowerPC-specific | |
32 | .BR subpage_prot () | |
33 | system call provides the facility to control the access | |
ee8655b5 MK |
34 | permissions on individual 4\ kB subpages on systems configured with |
35 | a page size of 64\ kB. | |
efeece04 | 36 | .PP |
8a686975 MK |
37 | The protection map is applied to the memory pages in the region starting at |
38 | .I addr | |
39 | and continuing for | |
40 | .I len | |
41 | bytes. | |
42 | Both of these arguments must be aligned to a 64-kB boundary. | |
efeece04 | 43 | .PP |
8a686975 MK |
44 | The protection map is specified in the buffer pointed to by |
45 | .IR map . | |
ee8655b5 MK |
46 | The map has 2 bits per 4\ kB subpage; |
47 | thus each 32-bit word specifies the protections of 16 4\ kB subpages | |
48 | inside a 64\ kB page | |
8a686975 MK |
49 | (so, the number of 32-bit words pointed to by |
50 | .I map | |
51 | should equate to the number of 64-kB pages specified by | |
52 | .IR len ). | |
53 | Each 2-bit field in the protection map is either 0 to allow any access, | |
54 | 1 to prevent writes, or 2 or 3 to prevent all accesses. | |
55 | .SH RETURN VALUE | |
56 | On success, | |
57 | .BR subpage_prot () | |
58 | returns 0. | |
c079ed64 | 59 | Otherwise, one of the error codes specified below is returned. |
8a686975 MK |
60 | .SH ERRORS |
61 | .TP | |
27807c32 MK |
62 | .B EFAULT |
63 | The buffer referred to by | |
64 | .I map | |
65 | is not accessible. | |
66 | .TP | |
8a686975 MK |
67 | .B EINVAL |
68 | The | |
69 | .I addr | |
70 | or | |
71 | .I len | |
72 | arguments are incorrect. | |
73 | Both of these arguments must be aligned to a multiple of the system page size, | |
74 | and they must not refer to a region outside of the | |
75 | address space of the process or to a region that consists of huge pages. | |
76 | .TP | |
8a686975 MK |
77 | .B ENOMEM |
78 | Out of memory. | |
79 | .SH VERSIONS | |
80 | This system call is provided on the PowerPC architecture | |
81 | since Linux 2.6.25. | |
82 | The system call is provided only if the kernel is configured with | |
83 | .BR CONFIG_PPC_64K_PAGES . | |
84 | No library support is provided. | |
3113c7f3 | 85 | .SH STANDARDS |
8a686975 MK |
86 | This system call is Linux-specific. |
87 | .SH NOTES | |
88 | Normal page protections (at the 64-kB page level) also apply; | |
89 | the subpage protection mechanism is an additional constraint, | |
90 | so putting 0 in a 2-bit field won't allow writes to a page that is otherwise | |
91 | write-protected. | |
92 | .SS Rationale | |
93 | This system call is provided to assist writing emulators that | |
94 | operate using 64-kB pages on PowerPC systems. | |
95 | When emulating systems such as x86, which uses a smaller page size, | |
96 | the emulator can no longer use the memory-management unit (MMU) | |
97 | and normal system calls for controlling page protections. | |
98 | (The emulator could emulate the MMU by checking and possibly remapping | |
99 | the address for each memory access in software, but that is slow.) | |
100 | The idea is that the emulator supplies an array of protection masks | |
101 | to apply to a specified range of virtual addresses. | |
102 | These masks are applied at the level where hardware page-table entries (PTEs) | |
103 | are inserted into the hardware page table based on the Linux PTEs, | |
104 | so the Linux PTEs are not affected. | |
c079ed64 MK |
105 | Implicit in this is that the regions of the address space that are |
106 | protected are switched to use 4-kB hardware pages rather than 64-kB | |
107 | hardware pages (on machines with hardware 64-kB page support). | |
108 | .\" In the initial implementation, it was the case that: | |
ee8655b5 | 109 | .\" In fact the whole process is switched to use 4 kB hardware pages when the |
c079ed64 MK |
110 | .\" subpage_prot system call is used, but this could be improved in future |
111 | .\" to switch only the affected segments. | |
112 | .\" But Paul Mackerass says (Oct 2010): I'm pretty sure we now only switch | |
113 | .\" the affected segment, not the whole process. | |
8a686975 MK |
114 | .SH SEE ALSO |
115 | .BR mprotect (2), | |
173fe7e7 | 116 | .BR syscall (2) |
efeece04 | 117 | .PP |
1ae6b2c7 | 118 | .I Documentation/admin\-guide/mm/hugetlbpage.rst |
173fe7e7 | 119 | in the Linux kernel source tree |