]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/subpage_prot.2
mmap.2: srcfix: note kernel commit that caused MAP_POPULATE | MAP_NONBLOCK to be...
[thirdparty/man-pages.git] / man2 / subpage_prot.2
CommitLineData
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 32subpage_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 :
40There is no glibc wrapper for this system call; see NOTES.
8a686975
MK
41.SH DESCRIPTION
42The PowerPC-specific
43.BR subpage_prot ()
44system call provides the facility to control the access
ee8655b5
MK
45permissions on individual 4\ kB subpages on systems configured with
46a page size of 64\ kB.
efeece04 47.PP
8a686975
MK
48The protection map is applied to the memory pages in the region starting at
49.I addr
50and continuing for
51.I len
52bytes.
53Both of these arguments must be aligned to a 64-kB boundary.
efeece04 54.PP
8a686975
MK
55The protection map is specified in the buffer pointed to by
56.IR map .
ee8655b5
MK
57The map has 2 bits per 4\ kB subpage;
58thus each 32-bit word specifies the protections of 16 4\ kB subpages
59inside a 64\ kB page
8a686975
MK
60(so, the number of 32-bit words pointed to by
61.I map
62should equate to the number of 64-kB pages specified by
63.IR len ).
64Each 2-bit field in the protection map is either 0 to allow any access,
651 to prevent writes, or 2 or 3 to prevent all accesses.
66.SH RETURN VALUE
67On success,
68.BR subpage_prot ()
69returns 0.
c079ed64 70Otherwise, one of the error codes specified below is returned.
8a686975
MK
71.SH ERRORS
72.TP
27807c32
MK
73.B EFAULT
74The buffer referred to by
75.I map
76is not accessible.
77.TP
8a686975
MK
78.B EINVAL
79The
80.I addr
81or
82.I len
83arguments are incorrect.
84Both of these arguments must be aligned to a multiple of the system page size,
85and they must not refer to a region outside of the
86address space of the process or to a region that consists of huge pages.
87.TP
8a686975
MK
88.B ENOMEM
89Out of memory.
90.SH VERSIONS
91This system call is provided on the PowerPC architecture
92since Linux 2.6.25.
93The system call is provided only if the kernel is configured with
94.BR CONFIG_PPC_64K_PAGES .
95No library support is provided.
96.SH CONFORMING TO
97This system call is Linux-specific.
98.SH NOTES
45c99e3e
MK
99Glibc does not provide a wrapper for this system call; call it using
100.BR syscall (2).
efeece04 101.PP
8a686975
MK
102Normal page protections (at the 64-kB page level) also apply;
103the subpage protection mechanism is an additional constraint,
104so putting 0 in a 2-bit field won't allow writes to a page that is otherwise
105write-protected.
106.SS Rationale
107This system call is provided to assist writing emulators that
108operate using 64-kB pages on PowerPC systems.
109When emulating systems such as x86, which uses a smaller page size,
110the emulator can no longer use the memory-management unit (MMU)
111and normal system calls for controlling page protections.
112(The emulator could emulate the MMU by checking and possibly remapping
113the address for each memory access in software, but that is slow.)
114The idea is that the emulator supplies an array of protection masks
115to apply to a specified range of virtual addresses.
116These masks are applied at the level where hardware page-table entries (PTEs)
117are inserted into the hardware page table based on the Linux PTEs,
118so the Linux PTEs are not affected.
c079ed64
MK
119Implicit in this is that the regions of the address space that are
120protected are switched to use 4-kB hardware pages rather than 64-kB
121hardware 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 133in the Linux kernel source tree