Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934033AbdCJL2u (ORCPT ); Fri, 10 Mar 2017 06:28:50 -0500 Received: from mga02.intel.com ([134.134.136.20]:62637 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933703AbdCJL2q (ORCPT ); Fri, 10 Mar 2017 06:28:46 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,140,1486454400"; d="scan'208";a="75082118" Subject: Re: [RFC PATCH 0/4] KVM: Emulate UMIP (or almost do so) To: Paolo Bonzini References: <1468351223-3250-1-git-send-email-pbonzini@redhat.com> <0543af50-8961-38a7-1acc-aaefd4915dda@redhat.com> <58B68E91.4010400@linux.intel.com> <58C25D7A.7070605@linux.intel.com> <46eca436-0d57-a514-39e4-7c45e25e493e@redhat.com> <58C2728B.3060903@linux.intel.com> Cc: qian.ouyang@intel.com, "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" From: Yu Zhang Message-ID: <58C28DDA.4050001@linux.intel.com> Date: Fri, 10 Mar 2017 19:28:26 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <58C2728B.3060903@linux.intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2168 Lines: 67 On 3/10/2017 5:31 PM, Yu Zhang wrote: > > > On 3/10/2017 4:36 PM, Paolo Bonzini wrote: >> >> On 10/03/2017 09:02, Yu Zhang wrote: >>>> Besides, is this all the test for UMIP unit test? I.e. do we >>>> need to >>>> construct a scenario in the test to trigger vm exit and let hypervisor >>>> inject a GP fault? - I did not see this scenario in this patch. Or any >>>> other suggestions? :-) >>> Hi Paolo, any suggestions? >>> Sorry for the disturb. :) >> Hi, you get the scenario where a vmexit is triggered by the hypervisor >> if you run the unit test on a machine that lacks UMIP support. >> >> We can also add a module parameter to force emulation, so that it will >> be possible to test UMIP emulation on newer processors too. > > Thanks for your reply, Paolo. :-) > > Well, my previous understanding is that there might be a situation on > a machine with UMIP > feature: > 1> when an APP in VM runs instructions such as sgdt addrA, > 2> and the addrA may cause anVM exit(e.g. ept violation), > 3> next, the emulator in hypervisor need to inject a GP fault to the VM. > Is this situation possible? > This is the case I'd like to test, yet do not know to construct the > scenario. > Sorry, Paolo. I may have misunderstanding on this. In intel SDM chapt 25, it says "Certain exceptions have priority over VM exits. These include invalid-opcode exceptions, faults based on privilege level...". So in above case, it is GP fault in VM that should happen, instead of VM exit, right? > But as to the scenario you described, I do not quit understand. > I mean, on a host which do not support UMIP, although hypervisor may > intercept cpuid and > provide an emulated cr4 to guest, how does it guarantee those > instructions in VM will cause > a VM exit? For this scenario, vm exit should be caused if "descriptor-table exiting? VM-execution control is 1, then hypervisor should have opportunity to do the force emulation. Is my new understanding correct? Another question is, what if host do have the UMIP feature, and the "descriptor-table exiting? VM-execution control is 1? Will a GP fault in VM happen, or a VM exit? Thanks Yu > Yu >> Paolo >> > >