1 .\" Copyright (c) 2010 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\" based on a proposal from Stephan Mueller <smueller@atsec.com>
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
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>
10 .TH subpage_prot 2 (date) "Linux man-pages (unreleased)"
12 subpage_prot \- define a subpage protection for an address range
15 .RI ( libc ", " \-lc )
18 .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
19 .B #include <unistd.h>
21 .BI "int syscall(SYS_subpage_prot, unsigned long " addr ", unsigned long " len ,
22 .BI " uint32_t *" map );
26 glibc provides no wrapper for
28 necessitating the use of
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.
37 The protection map is applied to the memory pages in the region starting at
42 Both of these arguments must be aligned to a 64-kB boundary.
44 The protection map is specified in the buffer pointed to by
46 The map has 2 bits per 4\ kB subpage;
47 thus each 32-bit word specifies the protections of 16 4\ kB subpages
49 (so, the number of 32-bit words pointed to by
51 should equate to the number of 64-kB pages specified by
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.
59 Otherwise, one of the error codes specified below is returned.
63 The buffer referred to by
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.
80 This system call is provided on the PowerPC architecture
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.
86 This system call is Linux-specific.
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
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.
118 .I Documentation/admin\-guide/mm/hugetlbpage.rst
119 in the Linux kernel source tree