From patchwork Mon Jun 14 22:30:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 106080 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5EMWuQ8014168 for ; Mon, 14 Jun 2010 22:32:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757056Ab0FNWct (ORCPT ); Mon, 14 Jun 2010 18:32:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6452 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751306Ab0FNWct (ORCPT ); Mon, 14 Jun 2010 18:32:49 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5EMWloN019901 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 14 Jun 2010 18:32:48 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5EMWl22030325; Mon, 14 Jun 2010 18:32:47 -0400 Received: from amt.cnet (vpn-9-73.rdu.redhat.com [10.11.9.73]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o5EMWjLH025190; Mon, 14 Jun 2010 18:32:46 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 8593768A900; Mon, 14 Jun 2010 19:30:05 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o5EMU454009670; Mon, 14 Jun 2010 19:30:04 -0300 Date: Mon, 14 Jun 2010 19:30:04 -0300 From: Marcelo Tosatti To: Avi Kivity , Gleb Natapov Cc: kvm Subject: KVM: VMX: optimize APIC EOI Message-ID: <20100614223004.GA9594@amt.cnet> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 14 Jun 2010 22:32:56 +0000 (UTC) Index: kvm/arch/x86/kvm/lapic.c =================================================================== --- kvm.orig/arch/x86/kvm/lapic.c +++ kvm/arch/x86/kvm/lapic.c @@ -1279,3 +1279,9 @@ int kvm_hv_vapic_msr_read(struct kvm_vcp return 0; } + +void kvm_lapic_set_eoi(struct kvm_vcpu *vcpu) +{ + apic_set_eoi(vcpu->arch.apic); +} +EXPORT_SYMBOL_GPL(kvm_lapic_set_eoi); Index: kvm/arch/x86/kvm/lapic.h =================================================================== --- kvm.orig/arch/x86/kvm/lapic.h +++ kvm/arch/x86/kvm/lapic.h @@ -52,6 +52,8 @@ int kvm_x2apic_msr_read(struct kvm_vcpu int kvm_hv_vapic_msr_write(struct kvm_vcpu *vcpu, u32 msr, u64 data); int kvm_hv_vapic_msr_read(struct kvm_vcpu *vcpu, u32 msr, u64 *data); +void kvm_lapic_set_eoi(struct kvm_vcpu *vcpu); + static inline bool kvm_hv_vapic_assist_page_enabled(struct kvm_vcpu *vcpu) { return vcpu->arch.hv_vapic & HV_X64_MSR_APIC_ASSIST_PAGE_ENABLE; Index: kvm/arch/x86/kvm/vmx.c =================================================================== --- kvm.orig/arch/x86/kvm/vmx.c +++ kvm/arch/x86/kvm/vmx.c @@ -3395,6 +3395,17 @@ static int handle_wbinvd(struct kvm_vcpu static int handle_apic_access(struct kvm_vcpu *vcpu) { + unsigned long exit_qualification = vmcs_readl(EXIT_QUALIFICATION); + int access_type, offset; + + access_type = (exit_qualification >> 12) & 0xf; + offset = exit_qualification & 0xfff; + if (access_type == 1 && offset == APIC_EOI) { + kvm_lapic_set_eoi(vcpu); + skip_emulated_instruction(vcpu); + return 1; + } + return emulate_instruction(vcpu, 0, 0, 0) == EMULATE_DONE; }