From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] KVM: APIC: avoid instruction emulation for EOI writes Date: Mon, 29 Aug 2011 10:23:43 +0300 Message-ID: <4E5B3E7F.9030507@redhat.com> References: <625BA99ED14B2D499DC4E29D8138F15063045B0C0C@shsmsx502.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "kvm@vger.kernel.org" , "Nakajima, Jun" , "Dong, Eddie" , Marcelo Tosatti To: "Tian, Kevin" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:38030 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751080Ab1H2HXr (ORCPT ); Mon, 29 Aug 2011 03:23:47 -0400 In-Reply-To: <625BA99ED14B2D499DC4E29D8138F15063045B0C0C@shsmsx502.ccr.corp.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On 08/29/2011 09:09 AM, Tian, Kevin wrote: > > 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; > + /* > + * Sane guest uses MOV instead of string operations to > + * write EOI, with written value not cared. So make a > + * short-circuit here by avoiding heavy instruction > + * emulation. > + */ > + if ((access_type == 1)&& (offset == APIC_EOI)) { Please replace this 1 with a #define. > + kvm_lapic_set_eoi(vcpu); > + skip_emulated_instruction(vcpu); > + return 1; > + } > return emulate_instruction(vcpu, 0) == EMULATE_DONE; > } > > Looks good otherwise. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.