Commit 7b0b8cfd authored by Borislav Petkov's avatar Borislav Petkov Committed by Ingo Molnar
Browse files

x86/ioperm: Save an indentation level in tss_update_io_bitmap()



... for better readability.

No functional changes.

[ Minor edit. ]

Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 59c4bd85
Loading
Loading
Loading
Loading
+26 −26
Original line number Diff line number Diff line
@@ -377,19 +377,22 @@ static void tss_copy_io_bitmap(struct tss_struct *tss, struct io_bitmap *iobm)
void tss_update_io_bitmap(void)
{
	struct tss_struct *tss = this_cpu_ptr(&cpu_tss_rw);
	struct thread_struct *t = &current->thread;
	u16 *base = &tss->x86_tss.io_bitmap_base;

	if (test_thread_flag(TIF_IO_BITMAP)) {
		struct thread_struct *t = &current->thread;
	if (!test_thread_flag(TIF_IO_BITMAP)) {
		tss_invalidate_io_bitmap(tss);
		return;
	}

	if (IS_ENABLED(CONFIG_X86_IOPL_IOPERM) && t->iopl_emul == 3) {
		*base = IO_BITMAP_OFFSET_VALID_ALL;
	} else {
		struct io_bitmap *iobm = t->io_bitmap;

		/*
			 * Only copy bitmap data when the sequence number
			 * differs. The update time is accounted to the
			 * incoming task.
		 * Only copy bitmap data when the sequence number differs. The
		 * update time is accounted to the incoming task.
		 */
		if (tss->io_bitmap.prev_sequence != iobm->sequence)
			tss_copy_io_bitmap(tss, iobm);
@@ -397,17 +400,14 @@ void tss_update_io_bitmap(void)
		/* Enable the bitmap */
		*base = IO_BITMAP_OFFSET_VALID_MAP;
	}

	/*
		 * Make sure that the TSS limit is covering the io bitmap.
		 * It might have been cut down by a VMEXIT to 0x67 which
		 * would cause a subsequent I/O access from user space to
		 * trigger a #GP because tbe bitmap is outside the TSS
		 * limit.
	 * Make sure that the TSS limit is covering the IO bitmap. It might have
	 * been cut down by a VMEXIT to 0x67 which would cause a subsequent I/O
	 * access from user space to trigger a #GP because tbe bitmap is outside
	 * the TSS limit.
	 */
	refresh_tss_limit();
	} else {
		tss_invalidate_io_bitmap(tss);
	}
}
#else /* CONFIG_X86_IOPL_IOPERM */
static inline void switch_to_bitmap(unsigned long tifp) { }