Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933028AbcKHRAp (ORCPT ); Tue, 8 Nov 2016 12:00:45 -0500 Received: from merlin.infradead.org ([205.233.59.134]:45894 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752944AbcKHRAm (ORCPT ); Tue, 8 Nov 2016 12:00:42 -0500 Date: Tue, 8 Nov 2016 18:00:34 +0100 From: Peter Zijlstra To: Andy Lutomirski Cc: Ricardo Neri , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , "linux-kernel@vger.kernel.org" , X86 ML , "linux-doc@vger.kernel.org" , Andy Lutomirski , Andrew Morton , Borislav Petkov , Brian Gerst , Chen Yucong , Chris Metcalf , Dave Hansen , Fenghua Yu , Huang Rui , Jiri Slaby , Jonathan Corbet , "Michael S . Tsirkin" , Paul Gortmaker , "Ravi V . Shankar" , Shuah Khan , Vlastimil Babka Subject: Re: [PATCH 2/4] x86: Prepare vm86 tasks to handle User-Mode Instruction Prevention Message-ID: <20161108170034.GK3117@twins.programming.kicks-ass.net> References: <1478585533-19406-1-git-send-email-ricardo.neri-calderon@linux.intel.com> <1478585533-19406-3-git-send-email-ricardo.neri-calderon@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1148 Lines: 27 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..