16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2607ca46eSDavid Howells #ifndef _UAPI_LINUX_SHM_H_ 3607ca46eSDavid Howells #define _UAPI_LINUX_SHM_H_ 4607ca46eSDavid Howells 5607ca46eSDavid Howells #include <linux/ipc.h> 6607ca46eSDavid Howells #include <linux/errno.h> 74da243acSMike Kravetz #include <asm-generic/hugetlb_encode.h> 8607ca46eSDavid Howells #ifndef __KERNEL__ 9607ca46eSDavid Howells #include <unistd.h> 10607ca46eSDavid Howells #endif 11607ca46eSDavid Howells 12607ca46eSDavid Howells /* 13f57a19a7SDavidlohr Bueso * SHMMNI, SHMMAX and SHMALL are default upper limits which can be 14f57a19a7SDavidlohr Bueso * modified by sysctl. The SHMMAX and SHMALL values have been chosen to 15f57a19a7SDavidlohr Bueso * be as large possible without facilitating scenarios where userspace 16f57a19a7SDavidlohr Bueso * causes overflows when adjusting the limits via operations of the form 17f57a19a7SDavidlohr Bueso * "retrieve current limit; add X; update limit". It is therefore not 18f57a19a7SDavidlohr Bueso * advised to make SHMMAX and SHMALL any larger. These limits are 19f57a19a7SDavidlohr Bueso * suitable for both 32 and 64-bit systems. 20607ca46eSDavid Howells */ 21607ca46eSDavid Howells #define SHMMIN 1 /* min shared seg size (bytes) */ 22607ca46eSDavid Howells #define SHMMNI 4096 /* max num of segs system wide */ 23f57a19a7SDavidlohr Bueso #define SHMMAX (ULONG_MAX - (1UL << 24)) /* max shared seg size (bytes) */ 24f57a19a7SDavidlohr Bueso #define SHMALL (ULONG_MAX - (1UL << 24)) /* max shm system wide (pages) */ 25607ca46eSDavid Howells #define SHMSEG SHMMNI /* max shared segs per process */ 26607ca46eSDavid Howells 27607ca46eSDavid Howells /* Obsolete, used only for backwards compatibility and libc5 compiles */ 28607ca46eSDavid Howells struct shmid_ds { 29607ca46eSDavid Howells struct ipc_perm shm_perm; /* operation perms */ 30607ca46eSDavid Howells int shm_segsz; /* size of segment (bytes) */ 31*2a785996SArnd Bergmann __kernel_old_time_t shm_atime; /* last attach time */ 32*2a785996SArnd Bergmann __kernel_old_time_t shm_dtime; /* last detach time */ 33*2a785996SArnd Bergmann __kernel_old_time_t shm_ctime; /* last change time */ 34607ca46eSDavid Howells __kernel_ipc_pid_t shm_cpid; /* pid of creator */ 35607ca46eSDavid Howells __kernel_ipc_pid_t shm_lpid; /* pid of last operator */ 36607ca46eSDavid Howells unsigned short shm_nattch; /* no. of current attaches */ 37607ca46eSDavid Howells unsigned short shm_unused; /* compatibility */ 38607ca46eSDavid Howells void *shm_unused2; /* ditto - used by DIPC */ 39607ca46eSDavid Howells void *shm_unused3; /* unused */ 40607ca46eSDavid Howells }; 41607ca46eSDavid Howells 42607ca46eSDavid Howells /* Include the definition of shmid64_ds and shminfo64 */ 43607ca46eSDavid Howells #include <asm/shmbuf.h> 44607ca46eSDavid Howells 454da243acSMike Kravetz /* 464da243acSMike Kravetz * shmget() shmflg values. 474da243acSMike Kravetz */ 484da243acSMike Kravetz /* The bottom nine bits are the same as open(2) mode flags */ 49607ca46eSDavid Howells #define SHM_R 0400 /* or S_IRUGO from <linux/stat.h> */ 50607ca46eSDavid Howells #define SHM_W 0200 /* or S_IWUGO from <linux/stat.h> */ 514da243acSMike Kravetz /* Bits 9 & 10 are IPC_CREAT and IPC_EXCL */ 524da243acSMike Kravetz #define SHM_HUGETLB 04000 /* segment will use huge TLB pages */ 534da243acSMike Kravetz #define SHM_NORESERVE 010000 /* don't check for reservations */ 54607ca46eSDavid Howells 554da243acSMike Kravetz /* 564da243acSMike Kravetz * Huge page size encoding when SHM_HUGETLB is specified, and a huge page 574da243acSMike Kravetz * size other than the default is desired. See hugetlb_encode.h 584da243acSMike Kravetz */ 594da243acSMike Kravetz #define SHM_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT 604da243acSMike Kravetz #define SHM_HUGE_MASK HUGETLB_FLAG_ENCODE_MASK 614da243acSMike Kravetz 624da243acSMike Kravetz #define SHM_HUGE_64KB HUGETLB_FLAG_ENCODE_64KB 634da243acSMike Kravetz #define SHM_HUGE_512KB HUGETLB_FLAG_ENCODE_512KB 644da243acSMike Kravetz #define SHM_HUGE_1MB HUGETLB_FLAG_ENCODE_1MB 654da243acSMike Kravetz #define SHM_HUGE_2MB HUGETLB_FLAG_ENCODE_2MB 664da243acSMike Kravetz #define SHM_HUGE_8MB HUGETLB_FLAG_ENCODE_8MB 674da243acSMike Kravetz #define SHM_HUGE_16MB HUGETLB_FLAG_ENCODE_16MB 6820916d46SAnshuman Khandual #define SHM_HUGE_32MB HUGETLB_FLAG_ENCODE_32MB 694da243acSMike Kravetz #define SHM_HUGE_256MB HUGETLB_FLAG_ENCODE_256MB 7020916d46SAnshuman Khandual #define SHM_HUGE_512MB HUGETLB_FLAG_ENCODE_512MB 714da243acSMike Kravetz #define SHM_HUGE_1GB HUGETLB_FLAG_ENCODE_1GB 724da243acSMike Kravetz #define SHM_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB 734da243acSMike Kravetz #define SHM_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB 744da243acSMike Kravetz 754da243acSMike Kravetz /* 764da243acSMike Kravetz * shmat() shmflg values 774da243acSMike Kravetz */ 78607ca46eSDavid Howells #define SHM_RDONLY 010000 /* read-only access */ 79607ca46eSDavid Howells #define SHM_RND 020000 /* round attach address to SHMLBA boundary */ 80607ca46eSDavid Howells #define SHM_REMAP 040000 /* take-over region on attach */ 81607ca46eSDavid Howells #define SHM_EXEC 0100000 /* execution access */ 82607ca46eSDavid Howells 83607ca46eSDavid Howells /* super user shmctl commands */ 84607ca46eSDavid Howells #define SHM_LOCK 11 85607ca46eSDavid Howells #define SHM_UNLOCK 12 86607ca46eSDavid Howells 87607ca46eSDavid Howells /* ipcs ctl commands */ 88607ca46eSDavid Howells #define SHM_STAT 13 89607ca46eSDavid Howells #define SHM_INFO 14 90c21a6970SDavidlohr Bueso #define SHM_STAT_ANY 15 91607ca46eSDavid Howells 92607ca46eSDavid Howells /* Obsolete, used only for backwards compatibility */ 93607ca46eSDavid Howells struct shminfo { 94607ca46eSDavid Howells int shmmax; 95607ca46eSDavid Howells int shmmin; 96607ca46eSDavid Howells int shmmni; 97607ca46eSDavid Howells int shmseg; 98607ca46eSDavid Howells int shmall; 99607ca46eSDavid Howells }; 100607ca46eSDavid Howells 101607ca46eSDavid Howells struct shm_info { 102607ca46eSDavid Howells int used_ids; 103f8dcdf01SH.J. Lu __kernel_ulong_t shm_tot; /* total allocated shm */ 104f8dcdf01SH.J. Lu __kernel_ulong_t shm_rss; /* total resident shm */ 105f8dcdf01SH.J. Lu __kernel_ulong_t shm_swp; /* total swapped shm */ 106f8dcdf01SH.J. Lu __kernel_ulong_t swap_attempts; 107f8dcdf01SH.J. Lu __kernel_ulong_t swap_successes; 108607ca46eSDavid Howells }; 109607ca46eSDavid Howells 110607ca46eSDavid Howells 111607ca46eSDavid Howells #endif /* _UAPI_LINUX_SHM_H_ */ 112