OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / 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 .\" %%%LICENSE_START(VERBATIM)
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
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
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.
24 .\" %%%LICENSE_END
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 .\"
30 .TH SUBPAGE_PROT 2 2012-07-13 "Linux" "Linux Programmer's Manual"
31 .SH NAME
32 subpage_prot \- define a subpage protection for an address range
33 .SH SYNOPSIS
34 .nf
35 .BI "long subpage_prot(unsigned long " addr ", unsigned long " len ,
36 .BI "                  uint32_t *" map ");
37 .fi
38
39 .IR Note :
40 There is no glibc wrapper for this system call; see NOTES.
41 .SH DESCRIPTION
42 The PowerPC-specific
43 .BR subpage_prot ()
44 system call provides the facility to control the access
45 permissions on individual 4kB subpages on systems configured with
46 a page size of 64kB.
47
48 The protection map is applied to the memory pages in the region starting at
49 .I addr
50 and continuing for
51 .I len
52 bytes.
53 Both of these arguments must be aligned to a 64-kB boundary.
54
55 The protection map is specified in the buffer pointed to by
56 .IR map .
57 The map has 2 bits per 4kB subpage;
58 thus each 32-bit word specifies the protections of 16 4kB subpages
59 inside a 64kB page
60 (so, the number of 32-bit words pointed to by
61 .I map
62 should equate to the number of 64-kB pages specified by
63 .IR len ).
64 Each 2-bit field in the protection map is either 0 to allow any access,
65 1 to prevent writes, or 2 or 3 to prevent all accesses.
66 .SH RETURN VALUE
67 On success,
68 .BR subpage_prot ()
69 returns 0.
70 Otherwise, one of the error codes specified below is returned.
71 .SH ERRORS
72 .TP
73 .B EFAULT
74 The buffer referred to by
75 .I map
76 is not accessible.
77 .TP
78 .B EINVAL
79 The
80 .I addr
81 or
82 .I len
83 arguments are incorrect.
84 Both of these arguments must be aligned to a multiple of the system page size,
85 and they must not refer to a region outside of the
86 address space of the process or to a region that consists of huge pages.
87 .TP
88 .B ENOMEM
89 Out of memory.
90 .SH VERSIONS
91 This system call is provided on the PowerPC architecture
92 since Linux 2.6.25.
93 The system call is provided only if the kernel is configured with
94 .BR CONFIG_PPC_64K_PAGES .
95 No library support is provided.
96 .SH CONFORMING TO
97 This system call is Linux-specific.
98 .SH NOTES
99 Glibc does not provide a wrapper for this system call; call it using
100 .BR syscall (2).
101
102 Normal page protections (at the 64-kB page level) also apply;
103 the subpage protection mechanism is an additional constraint,
104 so putting 0 in a 2-bit field won't allow writes to a page that is otherwise
105 write-protected.
106 .SS Rationale
107 This system call is provided to assist writing emulators that
108 operate using 64-kB pages on PowerPC systems.
109 When emulating systems such as x86, which uses a smaller page size,
110 the emulator can no longer use the memory-management unit (MMU)
111 and normal system calls for controlling page protections.
112 (The emulator could emulate the MMU by checking and possibly remapping
113 the address for each memory access in software, but that is slow.)
114 The idea is that the emulator supplies an array of protection masks
115 to apply to a specified range of virtual addresses.
116 These masks are applied at the level where hardware page-table entries (PTEs)
117 are inserted into the hardware page table based on the Linux PTEs,
118 so the Linux PTEs are not affected.
119 Implicit in this is that the regions of the address space that are
120 protected are switched to use 4-kB hardware pages rather than 64-kB
121 hardware pages (on machines with hardware 64-kB page support).
122 .\" In the initial implementation, it was the case that:
123 .\"     In fact the whole process is switched to use 4k hardware pages when the
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.
128 .SH SEE ALSO
129 .BR mprotect (2),
130 .BR syscall (2)
131
132 .IR Documentation/vm/hugetlbpage.txt
133 in the Linux kernel source tree
134 .SH COLOPHON
135 This page is part of release 3.79 of the Linux
136 .I man-pages
137 project.
138 A description of the project,
139 information about reporting bugs,
140 and the latest version of this page,
141 can be found at
142 \%http://www.kernel.org/doc/man\-pages/.