From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH] Calculate correct instruction length for data-fault VM exits on VT-x systems Date: Thu, 27 Apr 2006 21:41:01 -0500 Message-ID: <445180BD.5000007@us.ibm.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Khoa Huynh Cc: xen-devel List-Id: xen-devel@lists.xenproject.org Please don't submit patches with mailers that attach as binary attachments. You'll have to resubmit anyway as your copyright line is wrong (unless you really did write this code a thousand years ago ;-)) Regards, Anthony Liguori Khoa Huynh wrote: > On VT-x systems, according to Intel VMX specifications, > the instruction-length information in VMCS on VM exits > is not always valid. The instruction-length field in > VMCS is ONLY valid in the follwing cases: when the VM > exit is caused by the execution of instructions that > cause the VM exit unconditionally or based on the > execution-control bitmap, a software exception (INT3 > or INT0), or a task switch. > > For VM exits caused by data faults (hardware exceptions), > the instruction-length field in VMCS is actually undefined. > In these cases, the hypervisor can derive the correct > instruction length by fetching bytes based on the guest > instruction pointer and decoding those bytes. There is > already a function to do this in the SVM sub-directory. > This function should be moved up one level to HVM > sub-directory, so both VMX and SVM can use it. > > It should be noted that VMX only uses this instrlen > function when the hypervisor needs the instruction-length > info and that info is undefined in VMCS, e.g., for MMIO > instructions. In other cases where the instruction-length > field is valid in VMCS, the hypervisor continues to get > that info from VMCS (via vmread operation). > > I came across this problem in my effort to get Windows > NT booting on Xen. > > There are TWO patches attached below: > > * instrlen1.patch effectively moves the instrlen.c file > from xen/arch/x86/hvm/svm sub-directory up one level to > xen/arch/x86/hvm sub-directory and makes minor changes > to instrlen.c so that it will work at its new location. > > * instrlen2.patch makes additional changes to VMX code > so the hypervisor can use the instrlen function correctly > in all modes in cases where the instruction-length field is > undefined and read from VMCS in cases where it is defined. > > I must acknowledge that most of the code in the first patch > (instrlen1.patch) does not come from me since the primary > prupose of this patch is to move the instrlen.c file from > one location to another in the tree (it also makes some > minor changes). The second patch (instrlen2.patch) is > more meaty :-) > > These two patches should apply cleanly to the latest > xen-unstable tree (hg tip = 9866). > > I have tested these patches successfully on two systems > using a variety of guest OSes (e.g. WinXP, Win2003 Server). > > Signed-off-by: Khoa Huynh > > (See attached file: instrlen1.patch)(See attached file: instrlen2.patch) > > Regards, > Khoa > _________________________________________ > Khoa Huynh, Ph.D. > IBM Linux Technology Center > (512) 838-4903; T/L 678-4903; khoa@us.ibm.com > ------------------------------------------------------------------------ > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel