From: "Jan Beulich" Subject: Re: [PATCH 6/7] Nested VMX: Update APIC-v(RVI/SVI) when vmexit to L1 Date: Fri, 09 Aug 2013 13:31:39 +0100 Message-ID: <5204FD4B02000078000EAB62@nat28.tlf.novell.com> References: <1376038175-18571-1-git-send-email-yang.z.zhang@intel.com> <1376038175-18571-7-git-send-email-yang.z.zhang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1V7lr3-0000dU-80 for xen-devel@lists.xenproject.org; Fri, 09 Aug 2013 12:31:41 +0000 In-Reply-To: <1376038175-18571-7-git-send-email-yang.z.zhang@intel.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Yang Zhang Cc: xen-devel , keir.xen@gmail.com List-Id: xen-devel@lists.xenproject.org >>> On 09.08.13 at 10:49, Yang Zhang wrote: > From: Yang Zhang > > If enabling APIC-v, all interrupts to L1 is delivered through APIC-v. > But when L2 is running, external interrupt will casue L1 vmexit with > reason external interrupt. Then L1 will pick up the interrupt through > vmcs. So we need to update APIC-v related structure accordingly; This doesn't sound logical to me: If L1 picks up the interrupt from VMCS, how can the be a reason/explanation for the need to update the APIC-v related data? > +static void nvmx_update_apicv(struct vcpu *v) > +{ > + struct nestedvmx *nvmx = &vcpu_2_nvmx(v); > + struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v); > + unsigned long reason = __get_vvmcs(nvcpu->nv_vvmcx, VM_EXIT_REASON); > + uint32_t intr_info = __get_vvmcs(nvcpu->nv_vvmcx, VM_EXIT_INTR_INFO); > + > + if ( !cpu_has_vmx_virtual_intr_delivery ) > + return; > + > + if ( reason == EXIT_REASON_EXTERNAL_INTERRUPT && > + nvmx->intr.source == hvm_intsrc_lapic && > + (intr_info & INTR_INFO_VALID_MASK) ) > + { > + unsigned long status; > + uint32_t rvi, ppr; > + uint32_t vector = intr_info & 0xff; > + struct vlapic *vlapic = vcpu_vlapic(v); > + > + WARN_ON(vector <= 0); For both this ... > + > + vlapic_ack_pending_irq(v, vector, 1); > + > + ppr = vlapic_set_ppr(vlapic); > + BUG_ON( (ppr & 0xf0) != (vector & 0xf0) ); ... and this: Is it guaranteed that the guest have no influence on the participating values? Because otherwise either or both are security issues. It also looks inconsistent to me that the former is a WARN_ON() while the latter is a BUG_ON(). Besides that I agree with all of Andrew's comments. Jan