From patchwork Wed Nov 21 08:09:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yang Z" X-Patchwork-Id: 1778821 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B1F88E013C for ; Wed, 21 Nov 2012 08:14:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753427Ab2KUIOI (ORCPT ); Wed, 21 Nov 2012 03:14:08 -0500 Received: from mga03.intel.com ([143.182.124.21]:64721 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753316Ab2KUINx (ORCPT ); Wed, 21 Nov 2012 03:13:53 -0500 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga101.ch.intel.com with ESMTP; 21 Nov 2012 00:13:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.83,291,1352102400"; d="scan'208";a="170896290" Received: from yang-desktop.sh.intel.com ([10.239.13.107]) by AZSMGA002.ch.intel.com with ESMTP; 21 Nov 2012 00:13:51 -0800 From: Yang Zhang To: kvm@vger.kernel.org Cc: mtosatti@redhat.com, gleb@redhat.com, Yang Zhang Subject: [PATCH v2 5/6] x86: Enable ack interrupt on vmexit Date: Wed, 21 Nov 2012 16:09:38 +0800 Message-Id: <1353485379-6823-6-git-send-email-yang.z.zhang@intel.com> X-Mailer: git-send-email 1.7.1.1 In-Reply-To: <1353485379-6823-1-git-send-email-yang.z.zhang@intel.com> References: <1353485379-6823-1-git-send-email-yang.z.zhang@intel.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Ack interrupt on vmexit is required by Posted Interrupt. With it, when external interrupt caused vmexit, the cpu will acknowledge the interrupt controller and save the interrupt's vector in vmcs. There are several approaches to enable it. This patch uses a simply way: re-generate an interrupt via self ipi. Signed-off-by: Yang Zhang --- arch/x86/kvm/vmx.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 7949d21..f6ef090 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2525,7 +2525,8 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf) #ifdef CONFIG_X86_64 min |= VM_EXIT_HOST_ADDR_SPACE_SIZE; #endif - opt = VM_EXIT_SAVE_IA32_PAT | VM_EXIT_LOAD_IA32_PAT; + opt = VM_EXIT_SAVE_IA32_PAT | VM_EXIT_LOAD_IA32_PAT | + VM_EXIT_ACK_INTR_ON_EXIT; if (adjust_vmx_controls(min, opt, MSR_IA32_VMX_EXIT_CTLS, &_vmexit_control) < 0) return -EIO; @@ -4457,6 +4458,14 @@ static int handle_exception(struct kvm_vcpu *vcpu) static int handle_external_interrupt(struct kvm_vcpu *vcpu) { + unsigned int vector; + + vector = vmcs_read32(VM_EXIT_INTR_INFO); + vector &= INTR_INFO_VECTOR_MASK; + + apic_eoi(); + apic->send_IPI_self(vector); + ++vcpu->stat.irq_exits; return 1; }