From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH] KVM: APIC: avoid instruction emulation for EOI writes Date: Mon, 29 Aug 2011 13:03:34 +0200 Message-ID: <4E5B7206.5070603@siemens.com> References: <625BA99ED14B2D499DC4E29D8138F15063045B0C0C@shsmsx502.ccr.corp.intel.com> <4E5B68DA.1090208@siemens.com> <4E5B70F8.30307@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "Tian, Kevin" , "kvm@vger.kernel.org" , "Nakajima, Jun" , "Dong, Eddie" , Marcelo Tosatti To: Avi Kivity Return-path: Received: from thoth.sbs.de ([192.35.17.2]:24295 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750998Ab1H2LDn (ORCPT ); Mon, 29 Aug 2011 07:03:43 -0400 In-Reply-To: <4E5B70F8.30307@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 2011-08-29 12:59, Avi Kivity wrote: > On 08/29/2011 01:24 PM, Jan Kiszka 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. >>> + */ >> >> Is there no cheap way to validate this assumption and fall back to the >> slow path in case it doesn't apply? E.g. reading the first instruction >> byte and matching it against a whitelist? Even if the ignored scenarios >> are highly unlikely, I think we so far tried hard to provide both fast >> and accurate results to the guest in all cases. >> > > Just reading the first byte requires a guest page table walk. This is > probably the highest cost in emulation (which also requires a walk for > the data access). And what about caching the result of the first walk? Usually, a "sane guest" won't have many code pages that issue the EIO. Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux