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