From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Neri Subject: Re: [v6 PATCH 21/21] selftests/x86: Add tests for User-Mode Instruction Prevention Date: Fri, 10 Mar 2017 15:38:18 -0800 Message-ID: <1489189098.131264.36.camel@ranerica-desktop> References: <20170308003254.27833-1-ricardo.neri-calderon@linux.intel.com> <20170308003254.27833-22-ricardo.neri-calderon@linux.intel.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: linux-msdos-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Andy Lutomirski Cc: Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Andy Lutomirski , Borislav Petkov , Peter Zijlstra , Andrew Morton , Brian Gerst , Chris Metcalf , Dave Hansen , Paolo Bonzini , Liang Z Li , Masami Hiramatsu , Huang Rui , Jiri Slaby , Jonathan Corbet , "Michael S. Tsirkin" , Paul Gortmaker , Vlastimil Babka , Chen Yucong , Alexandre Julliard <> On Wed, 2017-03-08 at 07:56 -0800, Andy Lutomirski wrote: > On Tue, Mar 7, 2017 at 4:32 PM, Ricardo Neri > wrote: > > Certain user space programs that run on virtual-8086 mode may utilize > > instructions protected by the User-Mode Instruction Prevention (UMIP) > > security feature present in new Intel processors: SGDT, SIDT and SMSW. In > > such a case, a general protection fault is issued if UMIP is enabled. When > > such a fault happens, the kernel catches it and emulates the results of > > these instructions with dummy values. The purpose of this new > > test is to verify whether the impacted instructions can be executed without > > causing such #GP. If no #GP exceptions occur, we expect to exit virtual- > > 8086 mode from INT 0x80. > > > > The instructions protected by UMIP are executed in representative use > > cases: > > a) the memory address of the result is given in the form of a displacement > > from the base of the data segment > > b) the memory address of the result is given in a general purpose register > > c) the result is stored directly in a general purpose register. > > > > Unfortunately, it is not possible to check the results against a set of > > expected values because no emulation will occur in systems that do not have > > the UMIP feature. Instead, results are printed for verification. > > You could pre-initialize the result buffer to a bunch of non-matching > values (1, 2, 3, ...) and then check that all the invocations of the > same instruction gave the same value. Yes, I can do this. Alternatively, I can check in the test program if the CPU has UMIP and only run the tests in that case. > > If you do this, maybe make it a follow-up patch -- see other email. Great! Thank you! Thanks and BR, Ricardo