summaryrefslogtreecommitdiff
path: root/arch/x86/kernel/process.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2019-11-11 23:03:24 +0100
committerThomas Gleixner <tglx@linutronix.de>2019-11-16 11:24:03 +0100
commitea5f1cd7ab494f65f50f338299eabb40ad6a1767 (patch)
tree4e9addcdf5873dbac21bbe70aadb312760b55a87 /arch/x86/kernel/process.c
parent22fe5b0439dd53643fd6f4c582c46c6dba0fde53 (diff)
x86/ioperm: Remove bitmap if all permissions dropped
If ioperm() results in a bitmap with all bits set (no permissions to any I/O port), then handling that bitmap on context switch and exit to user mode is pointless. Drop it. Move the bitmap exit handling to the ioport code and reuse it for both the thread exit path and dropping it. This allows to reuse this code for the upcoming iopl() emulation. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Andy Lutomirski <luto@kernel.org>
Diffstat (limited to 'arch/x86/kernel/process.c')
-rw-r--r--arch/x86/kernel/process.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 108af913ab3c..7ba4d54aec17 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -102,21 +102,10 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
void exit_thread(struct task_struct *tsk)
{
struct thread_struct *t = &tsk->thread;
- struct io_bitmap *iobm = t->io_bitmap;
struct fpu *fpu = &t->fpu;
- struct tss_struct *tss;
-
- if (iobm) {
- preempt_disable();
- tss = this_cpu_ptr(&cpu_tss_rw);
-
- t->io_bitmap = NULL;
- clear_thread_flag(TIF_IO_BITMAP);
- /* Invalidate the io bitmap base in the TSS */
- tss->x86_tss.io_bitmap_base = IO_BITMAP_OFFSET_INVALID;
- preempt_enable();
- kfree(iobm);
- }
+
+ if (test_thread_flag(TIF_IO_BITMAP))
+ io_bitmap_exit();
free_vm86(t);