From patchwork Wed Jan 8 10:38:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 11323171 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 56AD81398 for ; Wed, 8 Jan 2020 10:40:25 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3286420705 for ; Wed, 8 Jan 2020 10:40:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="N0GfuyaW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3286420705 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ip8kD-0007xG-UO; Wed, 08 Jan 2020 10:39:21 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ip8kC-0007x7-0v for xen-devel@lists.xenproject.org; Wed, 08 Jan 2020 10:39:20 +0000 X-Inumbo-ID: 193036a0-3203-11ea-bf56-bc764e2007e4 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 193036a0-3203-11ea-bf56-bc764e2007e4; Wed, 08 Jan 2020 10:39:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578479948; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ba4ra9nZdllESORCXLcGcHMgte79HZx546Vj9gUeQJk=; b=N0GfuyaWWR5994xiDC1fhU1axbZ7VrIbz8eay0N7CW+COJOBhmEaLPKM wzSs8z3m5/OPo1ccCRO98Dufn80uxu6C5jbnoEsusTPSYGz0+VhN5k1Tu /CX23Lk5hw/sROdEdHVAsk0bNgSV/Wz6ao7YB9q0P8f4fBQLw1xWUqnEm 8=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@citrix.com; spf=Pass smtp.mailfrom=roger.pau@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of roger.pau@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of roger.pau@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 7jiqfmdepobmiVldalbVvA7XJ2NiDBNqSr9cq58kdW8Cdcj57QGOgPZSqS+OxEzuvFdbiOzHtu 7zdCjOkjsbIW78iZl2PqrBNHI+/lfwTp35o2gb/iNBfVK/KGOvGWOzvlo66a1k510/zcpMy2OT KEc4pWHSdqWQIpJkY8FPK99jQGc6ZjTaptTR5piMLG/oIDsp99M3OrafjzdemDygbnmLu+LxPg //Y7MJVfoe8idE39+dvdudlCzEoK8m/i2eeRFqfemNmLyJgBMbegT+JL6zyG4UUl5XOTVpA1Jk KxU= X-SBRS: 2.7 X-MesageID: 10603608 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,409,1571716800"; d="scan'208";a="10603608" From: Roger Pau Monne To: Date: Wed, 8 Jan 2020 11:38:56 +0100 Message-ID: <20200108103857.77236-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200108103857.77236-1-roger.pau@citrix.com> References: <20200108103857.77236-1-roger.pau@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 1/2] nvmx: fix handling of interrupts X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Kevin Tian , Jun Nakajima , Wei Liu , Andrew Cooper , Jan Beulich , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" When doing a virtual vmexit (ie: a vmexit handled by the L1 VMM) interrupts shouldn't be injected using the virtual interrupt delivery mechanism, and instead should be signaled in the vmcs using the exit reason and the interruption-information field if the "Acknowledge interrupt on exit" vmexit control is set. Remove the nvmx_update_apicv helper: it's bogus to attempt to inject interrupts on virtual vmexit using the virtual interrupt delivery assistance, and it's also bogus to ack interrupts without checking if the vmexit "Acknowledge interrupt on exit" vmexit control is set. nvmx_intr_intercept already handles interrupts correctly on virtual vmexit. Note that this fixes the usage of x2APIC by the L1 VMM, at least when the L1 VMM is Xen. Signed-off-by: Roger Pau Monné --- xen/arch/x86/hvm/vmx/vvmx.c | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c index d8ab167d62..af48b0beef 100644 --- a/xen/arch/x86/hvm/vmx/vvmx.c +++ b/xen/arch/x86/hvm/vmx/vvmx.c @@ -1316,35 +1316,6 @@ static void sync_exception_state(struct vcpu *v) } } -static void nvmx_update_apicv(struct vcpu *v) -{ - struct nestedvmx *nvmx = &vcpu_2_nvmx(v); - unsigned long reason = get_vvmcs(v, VM_EXIT_REASON); - uint32_t intr_info = get_vvmcs(v, VM_EXIT_INTR_INFO); - - if ( reason == EXIT_REASON_EXTERNAL_INTERRUPT && - nvmx->intr.source == hvm_intsrc_lapic && - (intr_info & INTR_INFO_VALID_MASK) ) - { - uint16_t status; - uint32_t rvi, ppr; - uint32_t vector = intr_info & 0xff; - struct vlapic *vlapic = vcpu_vlapic(v); - - vlapic_ack_pending_irq(v, vector, 1); - - ppr = vlapic_set_ppr(vlapic); - WARN_ON((ppr & 0xf0) != (vector & 0xf0)); - - status = vector << VMX_GUEST_INTR_STATUS_SVI_OFFSET; - rvi = vlapic_has_pending_irq(v); - if ( rvi != -1 ) - status |= rvi & VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK; - - __vmwrite(GUEST_INTR_STATUS, status); - } -} - static void virtual_vmexit(struct cpu_user_regs *regs) { struct vcpu *v = current; @@ -1393,9 +1364,6 @@ static void virtual_vmexit(struct cpu_user_regs *regs) /* updating host cr0 to sync TS bit */ __vmwrite(HOST_CR0, v->arch.hvm.vmx.host_cr0); - if ( cpu_has_vmx_virtual_intr_delivery ) - nvmx_update_apicv(v); - nvcpu->nv_vmswitch_in_progress = 0; }