Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933032AbdCJXih (ORCPT ); Fri, 10 Mar 2017 18:38:37 -0500 Received: from mga02.intel.com ([134.134.136.20]:41871 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755486AbdCJXiV (ORCPT ); Fri, 10 Mar 2017 18:38:21 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,143,1486454400"; d="scan'208";a="75305428" Message-ID: <1489189098.131264.36.camel@ranerica-desktop> Subject: Re: [v6 PATCH 21/21] selftests/x86: Add tests for User-Mode Instruction Prevention From: Ricardo Neri 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 , Stas Sergeev , Fenghua Yu , "Ravi V. Shankar" , Shuah Khan , "linux-kernel@vger.kernel.org" , X86 ML , linux-msdos@vger.kernel.org, wine-devel@winehq.org Date: Fri, 10 Mar 2017 15:38:18 -0800 In-Reply-To: References: <20170308003254.27833-1-ricardo.neri-calderon@linux.intel.com> <20170308003254.27833-22-ricardo.neri-calderon@linux.intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1805 Lines: 39 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