Re: [PATCH 2/4] x86: Prepare vm86 tasks to handle User-Mode Instruction Prevention

From: Peter Zijlstra
Date: Tue Nov 08 2016 - 12:00:47 EST


On Tue, Nov 08, 2016 at 08:01:39AM -0800, Andy Lutomirski wrote:
> > diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
> > index 0888a87..32b7301 100644
> > --- a/arch/x86/kernel/process.c
> > +++ b/arch/x86/kernel/process.c
> > @@ -233,6 +233,16 @@ void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p,
> > */
> > memset(tss->io_bitmap, 0xff, prev->io_bitmap_max);
> > }
> > +
> > +#if defined(CONFIG_VM86) && defined(CONFIG_X86_INTEL_UMIP)
> > + if (next->vm86 && next->vm86->saved_sp0 && next->vm86->disable_x86_umip)
> > + cr4_clear_bits(X86_CR4_UMIP);
> > + else {
> > + if (static_cpu_has(X86_FEATURE_UMIP))
> > + cr4_set_bits(X86_CR4_UMIP);
> > + }
> > +#endif
> > +
>
> NAK. If this code is going to exist, it needs to be deeply buried in
> some unlikely if statement that already exists. There's no good
> reason to penalize all context switches to support some nonsensical
> vm86 use case.

Agreed, now if instead vm86 get to emulate these instructions, this all
magically goes away..