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