1subpage_prot(2)               System Calls Manual              subpage_prot(2)
2
3
4

NAME

6       subpage_prot - define a subpage protection for an address range
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <sys/syscall.h>      /* Definition of SYS_* constants */
13       #include <unistd.h>
14
15       int syscall(SYS_subpage_prot, unsigned long addr, unsigned long len,
16                   uint32_t *map);
17
18       Note:  glibc  provides no wrapper for subpage_prot(), necessitating the
19       use of syscall(2).
20

DESCRIPTION

22       The PowerPC-specific subpage_prot() system call provides  the  facility
23       to  control  the access permissions on individual 4 kB subpages on sys‐
24       tems configured with a page size of 64 kB.
25
26       The protection map is applied to the memory pages in the region  start‐
27       ing at addr and continuing for len bytes.  Both of these arguments must
28       be aligned to a 64-kB boundary.
29
30       The protection map is specified in the buffer pointed to by  map.   The
31       map  has  2  bits per 4 kB subpage; thus each 32-bit word specifies the
32       protections of 16 4 kB subpages inside a 64 kB page (so, the number  of
33       32-bit  words  pointed  to  by map should equate to the number of 64-kB
34       pages specified by len).  Each 2-bit field in the protection map is ei‐
35       ther  0  to allow any access, 1 to prevent writes, or 2 or 3 to prevent
36       all accesses.
37

RETURN VALUE

39       On success, subpage_prot() returns 0.   Otherwise,  one  of  the  error
40       codes specified below is returned.
41

ERRORS

43       EFAULT The buffer referred to by map is not accessible.
44
45       EINVAL The  addr  or  len arguments are incorrect.  Both of these argu‐
46              ments must be aligned to a multiple of the system page size, and
47              they  must not refer to a region outside of the address space of
48              the process or to a region that consists of huge pages.
49
50       ENOMEM Out of memory.
51

STANDARDS

53       Linux.
54

HISTORY

56       Linux 2.6.25 (PowerPC).
57
58       The system call is provided only if the kernel is configured with  CON‐
59       FIG_PPC_64K_PAGES.
60

NOTES

62       Normal  page protections (at the 64-kB page level) also apply; the sub‐
63       page protection mechanism is an additional constraint, so putting 0  in
64       a 2-bit field won't allow writes to a page that is otherwise write-pro‐
65       tected.
66
67   Rationale
68       This system call is provided to assist writing emulators  that  operate
69       using  64-kB  pages on PowerPC systems.  When emulating systems such as
70       x86, which uses a smaller page size, the emulator can no longer use the
71       memory-management  unit  (MMU)  and normal system calls for controlling
72       page protections.  (The emulator could emulate the MMU by checking  and
73       possibly  remapping the address for each memory access in software, but
74       that is slow.)  The idea is that the emulator supplies an array of pro‐
75       tection  masks  to  apply  to  a  specified range of virtual addresses.
76       These masks are applied at the level where hardware page-table  entries
77       (PTEs)  are  inserted  into  the hardware page table based on the Linux
78       PTEs, so the Linux PTEs are not affected.  Implicit in this is that the
79       regions  of  the  address  space that are protected are switched to use
80       4-kB hardware pages rather than 64-kB hardware pages (on machines  with
81       hardware 64-kB page support).
82

SEE ALSO

84       mprotect(2), syscall(2)
85
86       Documentation/admin-guide/mm/hugetlbpage.rst in the Linux kernel source
87       tree
88
89
90
91Linux man-pages 6.04              2023-03-30                   subpage_prot(2)
Impressum