blob: 2bbafacfbfc9fc87bb03d207b79915e237a2eb1a [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef _LINUX_SHM_H_
3#define _LINUX_SHM_H_
4
Jack Millerab602f72014-08-08 14:23:19 -07005#include <linux/list.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#include <asm/page.h>
David Howells607ca462012-10-13 10:46:48 +01007#include <uapi/linux/shm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#include <asm/shmparam.h>
Manfred Spraul060028b2014-06-06 14:37:42 -07009
Linus Torvalds1da177e2005-04-16 15:20:36 -070010struct shmid_kernel /* private to the kernel */
11{
12 struct kern_ipc_perm shm_perm;
Manfred Spraul239521f2014-01-27 17:07:04 -080013 struct file *shm_file;
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 unsigned long shm_nattch;
15 unsigned long shm_segsz;
Deepa Dinamani7ff28192017-08-02 19:51:14 -070016 time64_t shm_atim;
17 time64_t shm_dtim;
18 time64_t shm_ctim;
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 pid_t shm_cprid;
20 pid_t shm_lprid;
21 struct user_struct *mlock_user;
Vasiliy Kulikov5774ed02011-07-29 03:55:31 +040022
23 /* The task created the shm object. NULL if the task is dead. */
24 struct task_struct *shm_creator;
Jack Millerab602f72014-08-08 14:23:19 -070025 struct list_head shm_clist; /* list by creator */
Kees Cook3859a272016-10-28 01:22:25 -070026} __randomize_layout;
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
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 Kleen42d73952012-12-11 16:01:34 -080031
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#ifdef CONFIG_SYSVIPC
Jack Millerab602f72014-08-08 14:23:19 -070033struct sysv_shm {
34 struct list_head shm_clist;
35};
36
Will Deacon079a96a2012-07-30 14:42:38 -070037long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr,
38 unsigned long shmlba);
Yaowei Bai2954e4402016-01-20 15:01:11 -080039bool is_file_shm_hugepages(struct file *file);
Jack Millerab602f72014-08-08 14:23:19 -070040void exit_shm(struct task_struct *task);
41#define shm_init_task(task) INIT_LIST_HEAD(&(task)->sysvshm.shm_clist)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#else
Jack Millerab602f72014-08-08 14:23:19 -070043struct sysv_shm {
44 /* empty */
45};
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047static inline long do_shmat(int shmid, char __user *shmaddr,
Will Deacon079a96a2012-07-30 14:42:38 -070048 int shmflg, unsigned long *addr,
49 unsigned long shmlba)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050{
51 return -ENOSYS;
52}
Yaowei Bai2954e4402016-01-20 15:01:11 -080053static inline bool is_file_shm_hugepages(struct file *file)
Adam Litke516dffd2007-03-01 15:46:08 -080054{
Yaowei Bai2954e4402016-01-20 15:01:11 -080055 return false;
Adam Litke516dffd2007-03-01 15:46:08 -080056}
Vasiliy Kulikovb34a6b12011-07-26 16:08:48 -070057static inline void exit_shm(struct task_struct *task)
58{
59}
Jack Millerab602f72014-08-08 14:23:19 -070060static inline void shm_init_task(struct task_struct *task)
61{
62}
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#endif
64
Linus Torvalds1da177e2005-04-16 15:20:36 -070065#endif /* _LINUX_SHM_H_ */