]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/subpage_prot.2
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man2 / subpage_prot.2
1 .\" Copyright (c) 2010 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\" based on a proposal from Stephan Mueller <smueller@atsec.com>
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
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 .\"
10 .TH subpage_prot 2 (date) "Linux man-pages (unreleased)"
11 .SH NAME
12 subpage_prot \- define a subpage protection for an address range
13 .SH LIBRARY
14 Standard C library
15 .RI ( libc ", " \-lc )
16 .SH SYNOPSIS
17 .nf
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 );
23 .fi
24 .PP
25 .IR Note :
26 glibc provides no wrapper for
27 .BR subpage_prot (),
28 necessitating the use of
29 .BR syscall (2).
30 .SH DESCRIPTION
31 The PowerPC-specific
32 .BR subpage_prot ()
33 system call provides the facility to control the access
34 permissions on individual 4\ kB subpages on systems configured with
35 a page size of 64\ kB.
36 .PP
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.
43 .PP
44 The protection map is specified in the buffer pointed to by
45 .IR map .
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
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.
59 Otherwise, one of the error codes specified below is returned.
60 .SH ERRORS
61 .TP
62 .B EFAULT
63 The buffer referred to by
64 .I map
65 is not accessible.
66 .TP
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
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.
85 .SH STANDARDS
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.
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:
109 .\" In fact the whole process is switched to use 4 kB hardware pages when the
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.
114 .SH SEE ALSO
115 .BR mprotect (2),
116 .BR syscall (2)
117 .PP
118 .I Documentation/admin\-guide/mm/hugetlbpage.rst
119 in the Linux kernel source tree