Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #ifndef _LINUX_SHM_H_ |
| 3 | #define _LINUX_SHM_H_ |
| 4 | |
Jack Miller | ab602f7 | 2014-08-08 14:23:19 -0700 | [diff] [blame] | 5 | #include <linux/list.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | #include <asm/page.h> |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 7 | #include <uapi/linux/shm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <asm/shmparam.h> |
Manfred Spraul | 060028b | 2014-06-06 14:37:42 -0700 | [diff] [blame] | 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | struct shmid_kernel /* private to the kernel */ |
| 11 | { |
| 12 | struct kern_ipc_perm shm_perm; |
Manfred Spraul | 239521f | 2014-01-27 17:07:04 -0800 | [diff] [blame] | 13 | struct file *shm_file; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | unsigned long shm_nattch; |
| 15 | unsigned long shm_segsz; |
Deepa Dinamani | 7ff2819 | 2017-08-02 19:51:14 -0700 | [diff] [blame] | 16 | time64_t shm_atim; |
| 17 | time64_t shm_dtim; |
| 18 | time64_t shm_ctim; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | pid_t shm_cprid; |
| 20 | pid_t shm_lprid; |
| 21 | struct user_struct *mlock_user; |
Vasiliy Kulikov | 5774ed0 | 2011-07-29 03:55:31 +0400 | [diff] [blame] | 22 | |
| 23 | /* The task created the shm object. NULL if the task is dead. */ |
| 24 | struct task_struct *shm_creator; |
Jack Miller | ab602f7 | 2014-08-08 14:23:19 -0700 | [diff] [blame] | 25 | struct list_head shm_clist; /* list by creator */ |
Kees Cook | 3859a27 | 2016-10-28 01:22:25 -0700 | [diff] [blame] | 26 | } __randomize_layout; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
| 28 | /* shm_mode upper byte flags */ |
| 29 | #define SHM_DEST 01000 /* segment will be destroyed on last detach */ |
| 30 | #define SHM_LOCKED 02000 /* segment will not be swapped */ |
Andi Kleen | 42d7395 | 2012-12-11 16:01:34 -0800 | [diff] [blame] | 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #ifdef CONFIG_SYSVIPC |
Jack Miller | ab602f7 | 2014-08-08 14:23:19 -0700 | [diff] [blame] | 33 | struct sysv_shm { |
| 34 | struct list_head shm_clist; |
| 35 | }; |
| 36 | |
Will Deacon | 079a96a | 2012-07-30 14:42:38 -0700 | [diff] [blame] | 37 | long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr, |
| 38 | unsigned long shmlba); |
Yaowei Bai | 2954e440 | 2016-01-20 15:01:11 -0800 | [diff] [blame] | 39 | bool is_file_shm_hugepages(struct file *file); |
Jack Miller | ab602f7 | 2014-08-08 14:23:19 -0700 | [diff] [blame] | 40 | void exit_shm(struct task_struct *task); |
| 41 | #define shm_init_task(task) INIT_LIST_HEAD(&(task)->sysvshm.shm_clist) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #else |
Jack Miller | ab602f7 | 2014-08-08 14:23:19 -0700 | [diff] [blame] | 43 | struct sysv_shm { |
| 44 | /* empty */ |
| 45 | }; |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | static inline long do_shmat(int shmid, char __user *shmaddr, |
Will Deacon | 079a96a | 2012-07-30 14:42:38 -0700 | [diff] [blame] | 48 | int shmflg, unsigned long *addr, |
| 49 | unsigned long shmlba) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | { |
| 51 | return -ENOSYS; |
| 52 | } |
Yaowei Bai | 2954e440 | 2016-01-20 15:01:11 -0800 | [diff] [blame] | 53 | static inline bool is_file_shm_hugepages(struct file *file) |
Adam Litke | 516dffd | 2007-03-01 15:46:08 -0800 | [diff] [blame] | 54 | { |
Yaowei Bai | 2954e440 | 2016-01-20 15:01:11 -0800 | [diff] [blame] | 55 | return false; |
Adam Litke | 516dffd | 2007-03-01 15:46:08 -0800 | [diff] [blame] | 56 | } |
Vasiliy Kulikov | b34a6b1 | 2011-07-26 16:08:48 -0700 | [diff] [blame] | 57 | static inline void exit_shm(struct task_struct *task) |
| 58 | { |
| 59 | } |
Jack Miller | ab602f7 | 2014-08-08 14:23:19 -0700 | [diff] [blame] | 60 | static inline void shm_init_task(struct task_struct *task) |
| 61 | { |
| 62 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | #endif |
| 64 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | #endif /* _LINUX_SHM_H_ */ |