[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALCETrU1i4_N8M0o=8hxxPFYisLsxpmDqM-GTsymORp9UeZYSg@mail.gmail.com>
Date: Tue, 12 Nov 2019 08:16:19 -0800
From: Andy Lutomirski <luto@...nel.org>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>, X86 ML <x86@...nel.org>,
Linus Torvalds <torvalds@...uxfoundation.org>,
Andy Lutomirski <luto@...nel.org>,
Stephen Hemminger <stephen@...workplumber.org>,
Willy Tarreau <w@....eu>, Juergen Gross <jgross@...e.com>,
Sean Christopherson <sean.j.christopherson@...el.com>,
"H. Peter Anvin" <hpa@...or.com>
Subject: Re: [patch V2 09/16] x86/ioperm: Move TSS bitmap update to exit to
user work
On Mon, Nov 11, 2019 at 2:35 PM Thomas Gleixner <tglx@...utronix.de> wrote:
>
> There is no point to update the TSS bitmap for tasks which use I/O bitmaps
> on every context switch. It's enough to update it right before exiting to
> user space.
>
+
> +static inline void switch_to_bitmap(unsigned long tifp)
> +{
> + /*
> + * Invalidate I/O bitmap if the previous task used it. If the next
> + * task has an I/O bitmap it will handle it on exit to user mode.
> + */
> + if (tifp & _TIF_IO_BITMAP)
> + tss_invalidate_io_bitmap(this_cpu_ptr(&cpu_tss_rw));
> +}
Shouldn't you be invalidating the io bitmap if the *next* task doesn't
use? Or is the rule that, when a non-io-bitmap-using task is running,
even in kernel mode, the io bitmap is always invalid.
As it stands, you need exit_thread() to invalidate the bitmap. I
assume it does, but I can't easily see it in the middle of the series
like this.
IOW your code might be fine, but it could at least use some comments
in appropriate places (exit_to_usermode_loop()?) that we guarantee
that, if the bit is *clear*, then the TSS has the io bitmap marked
invalid. And add an assertion under CONFIG_DEBUG_ENTRY.
Also, do you need to update EXIT_TO_USERMODE_LOOP_FLAGS?
Powered by blists - more mailing lists