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