From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 24/30] nVMX: Correct handling of idt vectoring info Date: Mon, 09 May 2011 14:04:01 +0300 Message-ID: <4DC7CA21.1040007@redhat.com> References: <1304842511-nyh@il.ibm.com> <201105080827.p488RW9O018328@rice.haifa.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, gleb@redhat.com To: "Nadav Har'El" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:21054 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751746Ab1EILEG (ORCPT ); Mon, 9 May 2011 07:04:06 -0400 In-Reply-To: <201105080827.p488RW9O018328@rice.haifa.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: On 05/08/2011 11:27 AM, Nadav Har'El wrote: > This patch adds correct handling of IDT_VECTORING_INFO_FIELD for the nested > case. > > When a guest exits while handling an interrupt or exception, we get this > information in IDT_VECTORING_INFO_FIELD in the VMCS. When L2 exits to L1, > there's nothing we need to do, because L1 will see this field in vmcs12, and > handle it itself. However, when L2 exits and L0 handles the exit itself and > plans to return to L2, L0 must inject this event to L2. > > In the normal non-nested case, the idt_vectoring_info case is discovered after > the exit, and the decision to inject (though not the injection itself) is made > at that point. However, in the nested case a decision of whether to return > to L2 or L1 also happens during the injection phase (see the previous > patches), so in the nested case we can only decide what to do about the > idt_vectoring_info right after the injection, i.e., in the beginning of > vmx_vcpu_run, which is the first time we know for sure if we're staying in > L2 (i.e., nested_mode is true). > > +static void nested_handle_valid_idt_vectoring_info(struct vcpu_vmx *vmx) > +{ > + int irq = vmx->idt_vectoring_info& VECTORING_INFO_VECTOR_MASK; > + int type = vmx->idt_vectoring_info& VECTORING_INFO_TYPE_MASK; > + int errCodeValid = vmx->idt_vectoring_info& > + VECTORING_INFO_DELIVER_CODE_MASK; Innovative coding style. > + vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, > + irq | type | INTR_INFO_VALID_MASK | errCodeValid); > + Why not do a 1:1 copy? > + vmcs_write32(VM_ENTRY_INSTRUCTION_LEN, > + vmx->nested.vm_exit_instruction_len); > + if (errCodeValid) > + vmcs_write32(VM_ENTRY_EXCEPTION_ERROR_CODE, > + vmx->nested.idt_vectoring_error_code); > +} > + > #ifdef CONFIG_X86_64 > #define R "r" > #define Q "q" -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.