Lines Matching +full:user +full:- +full:level
1 // SPDX-License-Identifier: GPL-2.0
3 * This contains the io-permission bitmap code - written by obz, with changes
24 /* Can be NULL when current->thread.iopl_emul == 3 */ in io_bitmap_share()
25 if (current->thread.io_bitmap) { in io_bitmap_share()
30 refcount_inc(¤t->thread.io_bitmap->refcnt); in io_bitmap_share()
31 tsk->thread.io_bitmap = current->thread.io_bitmap; in io_bitmap_share()
38 struct thread_struct *t = &tsk->thread; in task_update_io_bitmap()
40 if (t->iopl_emul == 3 || t->io_bitmap) { in task_update_io_bitmap()
41 /* TSS update is handled on exit to user space */ in task_update_io_bitmap()
54 struct io_bitmap *iobm = tsk->thread.io_bitmap; in io_bitmap_exit()
56 tsk->thread.io_bitmap = NULL; in io_bitmap_exit()
58 if (iobm && refcount_dec_and_test(&iobm->refcnt)) in io_bitmap_exit()
67 struct thread_struct *t = ¤t->thread; in ksys_ioperm()
72 return -EINVAL; in ksys_ioperm()
75 return -EPERM; in ksys_ioperm()
82 iobm = t->io_bitmap; in ksys_ioperm()
89 return -ENOMEM; in ksys_ioperm()
91 memset(iobm->bitmap, 0xff, sizeof(iobm->bitmap)); in ksys_ioperm()
92 refcount_set(&iobm->refcnt, 1); in ksys_ioperm()
100 if (refcount_read(&iobm->refcnt) > 1) { in ksys_ioperm()
103 return -ENOMEM; in ksys_ioperm()
104 refcount_set(&iobm->refcnt, 1); in ksys_ioperm()
113 t->io_bitmap = iobm; in ksys_ioperm()
114 /* Mark it active for context switching and exit to user mode */ in ksys_ioperm()
119 * exit to user mode. So this needs no protection. in ksys_ioperm()
122 bitmap_clear(iobm->bitmap, from, num); in ksys_ioperm()
124 bitmap_set(iobm->bitmap, from, num); in ksys_ioperm()
132 if (iobm->bitmap[i] != ~0UL) in ksys_ioperm()
141 iobm->max = (max_long + 1) * sizeof(unsigned long); in ksys_ioperm()
145 * user mode. in ksys_ioperm()
147 iobm->sequence = atomic64_add_return(1, &io_bitmap_sequence); in ksys_ioperm()
158 * The sys_iopl functionality depends on the level argument, which if
162 * also allow the user space task to use the CLI/STI instructions.
164 * Disabling interrupts in a user space task is dangerous as it might lock
168 * Setting IOPL to level 0-2 is disabling I/O permissions. Level 3
173 SYSCALL_DEFINE1(iopl, unsigned int, level) in SYSCALL_DEFINE1() argument
175 struct thread_struct *t = ¤t->thread; in SYSCALL_DEFINE1()
178 if (level > 3) in SYSCALL_DEFINE1()
179 return -EINVAL; in SYSCALL_DEFINE1()
181 old = t->iopl_emul; in SYSCALL_DEFINE1()
184 if (level == old) in SYSCALL_DEFINE1()
188 if (level > old) { in SYSCALL_DEFINE1()
191 return -EPERM; in SYSCALL_DEFINE1()
194 t->iopl_emul = level; in SYSCALL_DEFINE1()
204 return -ENOSYS; in ksys_ioperm()
208 return -ENOSYS; in SYSCALL_DEFINE3()
211 SYSCALL_DEFINE1(iopl, unsigned int, level) in SYSCALL_DEFINE1() argument
213 return -ENOSYS; in SYSCALL_DEFINE1()